fix #41 优化待办任务
This commit is contained in:
15
App.xaml.cs
15
App.xaml.cs
@@ -2,6 +2,8 @@
|
|||||||
using GeekDesk.Util;
|
using GeekDesk.Util;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace GeekDesk
|
namespace GeekDesk
|
||||||
{
|
{
|
||||||
@@ -38,6 +40,7 @@ namespace GeekDesk
|
|||||||
void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
|
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
|
||||||
|
Mouse.OverrideCursor = null;
|
||||||
LogUtil.WriteErrorLog(e, "未捕获异常!");
|
LogUtil.WriteErrorLog(e, "未捕获异常!");
|
||||||
if (Constants.DEV)
|
if (Constants.DEV)
|
||||||
{
|
{
|
||||||
@@ -50,6 +53,18 @@ namespace GeekDesk
|
|||||||
LogUtil.WriteErrorLog(e, "严重异常!");
|
LogUtil.WriteErrorLog(e, "严重异常!");
|
||||||
MessageBox.Show("GeekDesk遇到未知问题崩溃!");
|
MessageBox.Show("GeekDesk遇到未知问题崩溃!");
|
||||||
}
|
}
|
||||||
|
public static void DoEvents()
|
||||||
|
{
|
||||||
|
var frame = new DispatcherFrame();
|
||||||
|
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
|
||||||
|
new DispatcherOperationCallback(
|
||||||
|
delegate (object f)
|
||||||
|
{
|
||||||
|
((DispatcherFrame)f).Continue = false;
|
||||||
|
return null;
|
||||||
|
}), frame);
|
||||||
|
Dispatcher.PushFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,44 @@
|
|||||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:ToDoInfo}"
|
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:ToDoInfo}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
xmlns:cst="clr-namespace:GeekDesk.Converts"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<!--<cst:Count2VisibleConvert x:Key="Count2VisibleConvert"/>
|
||||||
|
<cst:CountGreZero2BoolConvert x:Key="CountGreZero2BoolConvert"/>
|
||||||
|
<Style x:Key="NoDataStyle" TargetType="TextBlock">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=BacklogList, Path=Items.Count, Converter={StaticResource CountGreZero2BoolConvert}}" Value="False">
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=BacklogList, Path=Items.Count, Converter={StaticResource CountGreZero2BoolConvert}}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="ToDoStyle" TargetType="DataGrid">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=BacklogList, Path=Items.Count, Converter={StaticResource CountGreZero2BoolConvert}}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=BacklogList, Path=Items.Count, Converter={StaticResource CountGreZero2BoolConvert}}" Value="False">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>-->
|
||||||
|
</UserControl.Resources>
|
||||||
<hc:SimplePanel Margin="20" Background="Transparent">
|
<hc:SimplePanel Margin="20" Background="Transparent">
|
||||||
<Grid Background="Transparent">
|
<Grid Background="Transparent">
|
||||||
|
<TextBlock x:Name="IsNewToDo" Visibility="Collapsed" />
|
||||||
|
<TextBlock x:Name="NoData"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
TextAlignment="Center"
|
||||||
|
Text="暂无数据!"
|
||||||
|
/>
|
||||||
|
|
||||||
<DataGrid x:Name="BacklogList"
|
<DataGrid x:Name="BacklogList"
|
||||||
HeadersVisibility="All"
|
HeadersVisibility="All"
|
||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
@@ -24,7 +57,7 @@
|
|||||||
<MenuItem Header="删除" Click="DeleteMenu_Click"/>
|
<MenuItem Header="删除" Click="DeleteMenu_Click"/>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</DataGrid.ContextMenu>
|
</DataGrid.ContextMenu>
|
||||||
<DataGrid.RowStyle>
|
<!--<DataGrid.RowStyle>
|
||||||
<Style TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
|
<Style TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
|
||||||
<EventSetter Event="MouseRightButtonDown" Handler="DataGridRow_MouseRightButtonDown" />
|
<EventSetter Event="MouseRightButtonDown" Handler="DataGridRow_MouseRightButtonDown" />
|
||||||
<Setter Property="Background" Value="White"/>
|
<Setter Property="Background" Value="White"/>
|
||||||
@@ -37,8 +70,59 @@
|
|||||||
</Trigger>
|
</Trigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
</DataGrid.RowStyle>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<DataGrid.RowStyle>
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Style.Setters>
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="true"/>
|
||||||
|
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type DataGridRow}">
|
||||||
|
<Border CornerRadius="8" MouseRightButtonDown="DataGridRow_MouseRightButtonDown" Margin="0,0,0,5" BorderBrush="Black" BorderThickness="0" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||||
|
<Border.Style>
|
||||||
|
<Style TargetType="Border">
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||||
|
</Style>
|
||||||
|
</Border.Style>
|
||||||
|
<SelectiveScrollingGrid>
|
||||||
|
<SelectiveScrollingGrid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</SelectiveScrollingGrid.ColumnDefinitions>
|
||||||
|
<SelectiveScrollingGrid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</SelectiveScrollingGrid.RowDefinitions>
|
||||||
|
<DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
<Path Name="Cross" Grid.ColumnSpan="2" Visibility="Collapsed" Margin="10,0,10,0" Data="M0,0.5 L1,0.5" Stretch="Fill" Stroke="Gray" StrokeThickness="1" Opacity="0.5" />
|
||||||
|
</SelectiveScrollingGrid>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=IsNewToDo, Path=Text}" Value="N">
|
||||||
|
<Setter TargetName="Cross" Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=IsNewToDo, Path=Text}" Value="Y">
|
||||||
|
<Setter TargetName="Cross" Property="Visibility" Value="Collapsed"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style.Setters>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="#E5E5E2" />
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
</DataGrid.RowStyle>
|
</DataGrid.RowStyle>
|
||||||
|
|
||||||
|
|
||||||
<DataGrid.CellStyle>
|
<DataGrid.CellStyle>
|
||||||
<Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
|
<Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||||
|
|||||||
@@ -71,7 +71,17 @@ namespace GeekDesk.Control.UserControls.Backlog
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void DataGridRow_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
private void DataGridRow_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
BacklogList.SelectedIndex = ((DataGridRow)sender).GetIndex();
|
int index;
|
||||||
|
ToDoInfo info = ((Border)sender).DataContext as ToDoInfo;
|
||||||
|
if (type == ToDoType.NEW)
|
||||||
|
{
|
||||||
|
index = MainWindow.appData.ToDoList.IndexOf(info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = MainWindow.appData.HiToDoList.IndexOf(info);
|
||||||
|
}
|
||||||
|
BacklogList.SelectedIndex = index;
|
||||||
Menu.IsOpen = true;
|
Menu.IsOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,12 @@
|
|||||||
</hc:SideMenuItem>
|
</hc:SideMenuItem>
|
||||||
</hc:SideMenu>
|
</hc:SideMenu>
|
||||||
</hc:Card>
|
</hc:Card>
|
||||||
<hc:Card Grid.Row="0" MouseDown="DragMove" Background="Transparent" BorderThickness="0" Grid.Column="1" x:Name="RightCard" Height="450">
|
<UniformGrid x:Name="UFG" Grid.Column="1" Grid.Row="0">
|
||||||
</hc:Card>
|
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
|
||||||
|
<hc:Card x:Name="RightCard" VerticalAlignment="Top" MouseDown="DragMove" Background="Transparent" BorderThickness="0" Height="410"/>
|
||||||
|
</hc:TransitioningContentControl>
|
||||||
|
</UniformGrid>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Button Width="22" Height="22" Click="Close_Button_Click" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Grid.Column="1"/>
|
<Button Width="22" Height="22" Click="Close_Button_Click" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Grid.Column="1"/>
|
||||||
@@ -87,8 +91,8 @@
|
|||||||
Panel.ZIndex="1"
|
Panel.ZIndex="1"
|
||||||
Style="{StaticResource Btn1}"
|
Style="{StaticResource Btn1}"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="590.01,29,10,384"
|
Margin="669,400,0,0"
|
||||||
Click="CreateBacklog_BtnClick"/>
|
Click="CreateBacklog_BtnClick" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -20,6 +20,16 @@ namespace GeekDesk.Control.Windows
|
|||||||
RightCard.Content = backlog;
|
RightCard.Content = backlog;
|
||||||
backlog.BacklogList.ItemsSource = appData.ToDoList;
|
backlog.BacklogList.ItemsSource = appData.ToDoList;
|
||||||
this.Topmost = true;
|
this.Topmost = true;
|
||||||
|
if (backlog.BacklogList.Items.Count > 0)
|
||||||
|
{
|
||||||
|
backlog.NoData.Visibility = Visibility.Collapsed;
|
||||||
|
backlog.BacklogList.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backlog.NoData.Visibility = Visibility.Visible;
|
||||||
|
backlog.BacklogList.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,12 +62,37 @@ namespace GeekDesk.Control.Windows
|
|||||||
switch (smi.Tag.ToString())
|
switch (smi.Tag.ToString())
|
||||||
{
|
{
|
||||||
case "History":
|
case "History":
|
||||||
|
UFG.Visibility = Visibility.Collapsed;
|
||||||
backlog.BacklogList.ItemsSource = appData.HiToDoList;
|
backlog.BacklogList.ItemsSource = appData.HiToDoList;
|
||||||
|
if (backlog.BacklogList.Items.Count > 0)
|
||||||
|
{
|
||||||
|
backlog.NoData.Visibility = Visibility.Collapsed;
|
||||||
|
backlog.BacklogList.Visibility = Visibility.Visible;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
backlog.NoData.Visibility = Visibility.Visible;
|
||||||
|
backlog.BacklogList.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
backlog.type = ToDoType.HISTORY;
|
backlog.type = ToDoType.HISTORY;
|
||||||
|
backlog.IsNewToDo.Text = "N";
|
||||||
|
UFG.Visibility = Visibility.Visible;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
UFG.Visibility = Visibility.Collapsed;
|
||||||
backlog.BacklogList.ItemsSource = appData.ToDoList;
|
backlog.BacklogList.ItemsSource = appData.ToDoList;
|
||||||
|
if (backlog.BacklogList.Items.Count > 0)
|
||||||
|
{
|
||||||
|
backlog.NoData.Visibility = Visibility.Collapsed;
|
||||||
|
backlog.BacklogList.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backlog.NoData.Visibility = Visibility.Visible;
|
||||||
|
backlog.BacklogList.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
backlog.type = ToDoType.NEW;
|
backlog.type = ToDoType.NEW;
|
||||||
|
backlog.IsNewToDo.Text = "Y";
|
||||||
|
UFG.Visibility = Visibility.Visible;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,6 +121,21 @@ namespace GeekDesk.Control.Windows
|
|||||||
Keyboard.Focus(window);
|
Keyboard.Focus(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ShowOrHide()
|
||||||
|
{
|
||||||
|
if (window == null || !window.Activate())
|
||||||
|
{
|
||||||
|
window = new ToDoWindow();
|
||||||
|
window.Show();
|
||||||
|
Keyboard.Focus(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Escape)
|
if (e.Key == Key.Escape)
|
||||||
|
|||||||
43
Converts/Count2VisibleConvert.cs
Normal file
43
Converts/Count2VisibleConvert.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace GeekDesk.Converts
|
||||||
|
{
|
||||||
|
public class Count2VisibleConvert : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value == null) return Visibility.Collapsed;
|
||||||
|
int count = (int)value;
|
||||||
|
|
||||||
|
if (parameter == null || "Y".Equals(parameter.ToString()))
|
||||||
|
{
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
return Visibility.Visible;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
return Visibility.Visible;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Converts/CountGreZero2BoolConvert.cs
Normal file
28
Converts/CountGreZero2BoolConvert.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace GeekDesk.Converts
|
||||||
|
{
|
||||||
|
public class CountGreZero2BoolConvert : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value == null) return false;
|
||||||
|
int count = (int)value;
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -220,6 +220,8 @@
|
|||||||
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
|
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
|
||||||
<DependentUpon>UpdateWindow.xaml</DependentUpon>
|
<DependentUpon>UpdateWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Converts\CountGreZero2BoolConvert.cs" />
|
||||||
|
<Compile Include="Converts\Count2VisibleConvert.cs" />
|
||||||
<Compile Include="Converts\StringAppendConvert.cs" />
|
<Compile Include="Converts\StringAppendConvert.cs" />
|
||||||
<Compile Include="Converts\DoubleToGridLength.cs" />
|
<Compile Include="Converts\DoubleToGridLength.cs" />
|
||||||
<Compile Include="Converts\MenuInfoConvert.cs" />
|
<Compile Include="Converts\MenuInfoConvert.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user