Merge pull request #1 from Demo-Liu/1.0-beta

1.0 beta
This commit is contained in:
Demo-Liu
2021-07-14 10:06:42 +08:00
committed by GitHub
88 changed files with 7657 additions and 2147 deletions

View File

@@ -7,8 +7,9 @@
d1p1:Ignorable="d" d1p1:Ignorable="d"
xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"> xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/GeekDesk;component/Resource/Dictionary/Geometry.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/> <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/> <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>

View File

@@ -1,10 +1,4 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace GeekDesk namespace GeekDesk
{ {

View File

@@ -50,7 +50,7 @@ namespace DraggAnimatedPanelExample
/// <param name = "canExecuteMethod">Delegate to execute when CanExecute is called on the command. This can be null.</param> /// <param name = "canExecuteMethod">Delegate to execute when CanExecute is called on the command. This can be null.</param>
/// <exception cref = "ArgumentNullException">When both <paramref name = "executeMethod" /> and <paramref name = "canExecuteMethod" /> ar <see langword = "null" />.</exception> /// <exception cref = "ArgumentNullException">When both <paramref name = "executeMethod" /> and <paramref name = "canExecuteMethod" /> ar <see langword = "null" />.</exception>
public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod) public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
: base((o) => executeMethod((T) o), (o) => canExecuteMethod((T) o)) : base((o) => executeMethod((T)o), (o) => canExecuteMethod((T)o))
{ {
if (executeMethod == null || canExecuteMethod == null) if (executeMethod == null || canExecuteMethod == null)
throw new ArgumentNullException("executeMethod"); throw new ArgumentNullException("executeMethod");

14
Constant/AppHideType.cs Normal file
View File

@@ -0,0 +1,14 @@

/// <summary>
/// 面板隐藏方式
/// </summary>
namespace GeekDesk.Constant
{
public enum AppHideType
{
LOST_FOCUS = 1, // 失去焦点后
START_EXE = 2, //启动程序后
HANDLE = 3 //手动关闭
}
}

32
Constant/Constants.cs Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,18 +1,14 @@
using System; /// <summary>
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// 默认参数 /// 默认参数
/// </summary> /// </summary>
namespace GeekDesk.Constant namespace GeekDesk.Constant
{ {
enum DefaultConstant public enum DefaultConstant
{ {
WINDOW_WIDTH = 650, //默认窗体宽度 WINDOW_WIDTH = 666, //默认窗体宽度
WINDOW_HEIGHT = 700, //默认窗体高度 WINDOW_HEIGHT = 500, //默认窗体高度
MENU_CARD_WIDHT = 150 //默认菜单栏宽度 MENU_CARD_WIDHT = 165, //默认菜单栏宽度
IMAGE_WIDTH = 60, //默认图标宽度
IMAGE_HEIGHT = 60, //默认图标高度
} }
} }

18
Constant/IconStartType.cs Normal file
View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// 图标应用启动方式
/// </summary>
namespace GeekDesk.Constant
{
public enum IconStartType
{
DEFAULT_STARTUP = 1, //默认启动方式
ADMIN_STARTUP = 2, //管理员方式启动
SHOW_IN_EXPLORE = 3 //打开文件所在位置
}
}

View File

@@ -1,12 +1,6 @@
using System; namespace GeekDesk.Constant
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Constant
{ {
enum SortType public enum SortType
{ {
CUSTOM = 1, //自定义排序 CUSTOM = 1, //自定义排序
NAME = 2, //按名称排序 NAME = 2, //按名称排序

View File

@@ -0,0 +1,49 @@
<Border x:Class="GeekDesk.Control.Other.BacklogNotificatin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="AliceBlue"
BorderThickness="1"
BorderBrush="{DynamicResource BorderBrush}"
Width="320"
Height="450">
<Grid>
<Image Source="/Resource/Image/BacklogImg.png" Margin="22,35,22,361" />
<hc:Card MaxWidth="250" Height="200" BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="8">
<!--Card 的内容部分-->
<Border CornerRadius="4,4,0,0" Width="160" Height="160">
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Msg}"/>
</Border>
<!--Card 的尾部部分-->
<hc:Card.Footer>
<StackPanel Margin="10" Width="160">
<!--Card 的一级内容-->
<TextBlock TextWrapping="NoWrap" FontSize="20" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
Text="{Binding Title}"
HorizontalAlignment="Left"/>
<!--Card 的二级内容-->
<TextBlock TextWrapping="NoWrap" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
Text="{Binding ExeTime}" Margin="0,6,0,0"
HorizontalAlignment="Left"/>
</StackPanel>
</hc:Card.Footer>
</hc:Card>
<hc:UniformSpacingPanel Spacing="20" HorizontalAlignment="Center" Margin="0,346,0,0">
<hc:TextBox x:Name="DelayTime" Height="20" Width="60" Text="10" PreviewTextInput="DelayTime_PreviewTextInput" PreviewLostKeyboardFocus="DelayTime_PreviewLostKeyboardFocus" />
<ComboBox x:Name="DelayType" hc:DropDownElement.ConsistentWidth="False" SelectedIndex="0" Height="20" Width="60">
<ComboBox.Items>
<ComboBoxItem Content="分"/>
<ComboBoxItem Content="时"/>
</ComboBox.Items>
</ComboBox>
<Button Content="推迟提醒" Click="DelayButton_Click"/>
</hc:UniformSpacingPanel>
<Button Click="BacklogDone_Click" Content="朕已阅" Margin="10,0,10,20" Width="298" VerticalAlignment="Bottom"/>
</Grid>
</Border>

View File

@@ -0,0 +1,105 @@
using GeekDesk.Task;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Other
{
/// <summary>
/// BacklogNotificatin.xaml 的交互逻辑
/// </summary>
public partial class BacklogNotificatin
{
private AppData appData = MainWindow.appData;
public BacklogNotificatin(BacklogInfo info)
{
InitializeComponent();
this.DataContext = info;
}
private void BacklogDone_Click(object sender, RoutedEventArgs e)
{
BacklogInfo info = this.DataContext as BacklogInfo;
info.DoneTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
appData.ExeBacklogList.Remove(info); //执行任务删除
appData.HiBacklogList.Add(info); //添加历史任务
BacklogTask.activityBacklog[info].Close(); //关闭桌面通知
BacklogTask.activityBacklog.Remove(info);//激活任务删除
CommonCode.SaveAppData(appData);
}
/// <summary>
/// 只允许输入数字
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DelayTime_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
int textBoxInt;
//转化按下的键为数字,如果不是数字则会抓取到报错信息,不键入,反之则键入
try
{
textBoxInt = int.Parse($"{e.Text}");
}
catch (FormatException)
{
e.Handled = true;
}
}
/// <summary>
/// 失去焦点前如果为空
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DelayTime_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
int textBoxInt;
//转化val为数字如果不是数字则会抓取到报错信息
try
{
textBoxInt = int.Parse(DelayTime.Text.Trim());
}
catch (FormatException)
{
DelayTime.Text = "10";
}
}
/// <summary>
/// 推迟提醒
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DelayButton_Click(object sender, RoutedEventArgs e)
{
BacklogInfo info = this.DataContext as BacklogInfo;
int time = int.Parse(DelayTime.Text);
string type = DelayType.Text;
switch(type)
{
case "分":
info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");
break;
case "时":
info.ExeTime = DateTime.Now.AddHours(time).ToString("yyyy-MM-dd HH:mm:ss");
break;
}
BacklogTask.activityBacklog[info].Close(); //关闭桌面通知
BacklogTask.activityBacklog.Remove(info);//激活任务删除
}
}
}

View File

@@ -0,0 +1,51 @@
<Border x:Class="GeekDesk.Control.Other.CustomIconUrlDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="3"
Width="400"
Height="230"
Opacity="0.95">
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="100"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="1"/>
</Border.Background>
<hc:SimplePanel Margin="10">
<Grid Margin="8,20,8,20">
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,-10">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="SVG 图标地址:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="*" Foreground="Red"/>
</WrapPanel>
<TextBox x:Name="IconUrl" Text="{Binding CustomIconUrl, Mode=OneWay}" Width="240" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,58.276,0,-58.276">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="JSON 配置地址:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="*" Foreground="Red"/>
</WrapPanel>
<TextBox x:Name="JsonUrl" Text="{Binding CustomIconJsonUrl, Mode=OneWay}" Width="240" FontSize="14"/>
</hc:UniformSpacingPanel>
<TextBlock Text="注: 需配置正确的url方可加载远程图标!" Foreground="Red" Margin="10,95,-10,-92" />
<hc:UniformSpacingPanel Spacing="10" Margin="246.206,124.551,-246.206,-124.551">
<Button Content="取消" Command="hc:ControlCommands.Close"
/>
<Button Content="保存" Click="Confirm_Click"
Command="hc:ControlCommands.Close"
Background="#5BC0DE"
Foreground="White"/>
</hc:UniformSpacingPanel>
</Grid>
<!--<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>-->
</hc:SimplePanel>
</Border>

View File

@@ -0,0 +1,44 @@
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace GeekDesk.Control.Other
{
/// <summary>
/// TextDialog.xaml 的交互逻辑
/// </summary>
public partial class CustomIconUrlDialog
{
public CustomIconUrlDialog(AppConfig appConfig)
{
InitializeComponent();
this.DataContext = appConfig;
}
public CustomIconUrlDialog()
{
InitializeComponent();
}
private void Confirm_Click(object sender, RoutedEventArgs e)
{
AppConfig appConfig = this.DataContext as AppConfig;
appConfig.CustomIconJsonUrl = JsonUrl.Text.Trim();
appConfig.CustomIconUrl = IconUrl.Text.Trim();
if (!StringUtil.IsEmpty(IconUrl.Text) && !StringUtil.IsEmpty(JsonUrl.Text))
{
IconfontWindow.vm.IsSettingUrl = "true";
} else
{
IconfontWindow.vm.IsSettingUrl = "false";
}
}
}
}

View File

@@ -0,0 +1,50 @@
<Border x:Class="GeekDesk.Control.Other.IconInfoDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="4"
Width="300"
Height="300"
Opacity="0.9">
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="40"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
</Border.Background>
<hc:SimplePanel Margin="10">
<Grid Margin="8,20,8,20">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,50,0,71" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,59,0,-9" Grid.ColumnSpan="4">
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" Width="60" Height="60"/>
<Button Content="修改" Click="EditImage"/>
<Button Content="重置" Click="ReStoreImage"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,128,0,23" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,150,0,10" Grid.ColumnSpan="4">
<CheckBox x:Name="IconIsAdmin" Content="始终以管理员方式启动" IsChecked="{Binding AdminStartUp, Mode=OneWay}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,200,0,-27" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,218,0,-38" Grid.ColumnSpan="4">
<Button Content="保存" Command="hc:ControlCommands.Close" Click="SaveProperty" Margin="208,6,-208,-10"/>
</hc:UniformSpacingPanel>
</Grid>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
</hc:SimplePanel>
</Border>

View File

@@ -0,0 +1,82 @@
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace GeekDesk.Control.Other
{
/// <summary>
/// TextDialog.xaml 的交互逻辑
/// </summary>
public partial class IconInfoDialog
{
public IconInfoDialog()
{
InitializeComponent();
}
public IconInfoDialog(IconInfo info)
{
this.DataContext = info;
InitializeComponent();
}
/// <summary>
/// 保存修改属性
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveProperty(object sender, RoutedEventArgs e)
{
IconInfo info = this.DataContext as IconInfo;
info.BitmapImage = IconImg.Source as BitmapImage;
info.Name = IconName.Text;
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
CommonCode.SaveAppData(MainWindow.appData);
}
/// <summary>
/// 修改图标为默认
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ReStoreImage(object sender, RoutedEventArgs e)
{
IconInfo info = ((Button)sender).Tag as IconInfo;
info.BitmapImage = ImageUtil.ByteArrToImage(info.DefaultImage);
CommonCode.SaveAppData(MainWindow.appData);
}
/// <summary>
/// 修改图标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void EditImage(object sender, RoutedEventArgs e)
{
try
{
OpenFileDialog ofd = new OpenFileDialog
{
Multiselect = false, //只允许选中单个文件
Filter = "所有文件(*.*)|*.*"
};
if (ofd.ShowDialog() == true)
{
IconInfo info = this.DataContext as IconInfo;
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
CommonCode.SaveAppData(MainWindow.appData);
}
} catch (Exception)
{
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
}
}
}
}

View File

@@ -0,0 +1,56 @@
<Border x:Class="GeekDesk.Control.Other.MenuGeometryDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="10"
Width="300"
Height="300"
Opacity="0.9">
<!--<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="40"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
</Border.Background>
<hc:SimplePanel Margin="10">
<Grid Margin="8,20,8,20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="93*"/>
<ColumnDefinition Width="38*"/>
<ColumnDefinition Width="126*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,50,0,71" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,59,0,-9" Grid.ColumnSpan="4">
<TextBlock Text="图标:" Style="{StaticResource LeftTB}"/>
<Image x:Name="IconImg" Source="{Binding BitmapImage, Mode=OneWay}" Width="60" Height="60"/>
<Button Content="修改" Click="EditImage"/>
<Button Content="重置" Click="ReStoreImage"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,128,0,23" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,150,0,10" Grid.ColumnSpan="4">
<CheckBox x:Name="IconIsAdmin" Content="始终以管理员方式启动" IsChecked="{Binding AdminStartUp, Mode=OneWay}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,200,0,-27" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10" Margin="0,218,0,-38" Grid.ColumnSpan="4">
<Button Content="保存" Command="hc:ControlCommands.Close" Click="SaveProperty" Margin="208,6,-208,-10"/>
</hc:UniformSpacingPanel>
</Grid>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
</hc:SimplePanel>-->
</Border>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.Other
{
/// <summary>
/// MenuGeometryDialogxaml.xaml 的交互逻辑
/// </summary>
public partial class MenuGeometryDialog
{
public MenuGeometryDialog()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,57 @@
<UserControl x:Class="GeekDesk.Control.UserControls.Backlog.BacklogControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
>
<hc:SimplePanel Margin="20">
<Grid>
<DataGrid x:Name="BacklogList"
HeadersVisibility="All"
AutoGenerateColumns="False"
ItemsSource="{Binding}"
IsReadOnly="True"
Initialized="DataGridMenu_Initialized"
>
<DataGrid.ContextMenu>
<ContextMenu x:Name="Menu" Width="120">
<MenuItem Header="详情" Click="DetailMenu_Click"/>
<MenuItem Header="删除" Click="DeleteMenu_Click"/>
</ContextMenu>
</DataGrid.ContextMenu>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
<EventSetter Event="MouseRightButtonUp" Handler="DataGridRow_MouseRightButtonUp" />
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource DataGridColumnHeaderStyle}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Background>
<SolidColorBrush Color="AliceBlue"/>
</DataGrid.Background>
<DataGrid.Columns>
<DataGridTextColumn Width="120" Binding="{Binding Title}" Header="待办任务"/>
<DataGridTextColumn Width="210" Binding="{Binding Msg}" Header="待办详情"/>
<DataGridTextColumn Width="147" Binding="{Binding ExeTime}" Header="待办时间"/>
<DataGridTextColumn Width="147" Binding="{Binding DoneTime}" Header="完成时间"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel hc:Growl.GrowlParent="True" hc:Growl.Token="DeleteConfirm" VerticalAlignment="Center" Margin="0,10,10,50"/>
</Grid>
</hc:SimplePanel>
</UserControl>

View File

@@ -0,0 +1,72 @@
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.Backlog
{
/// <summary>
/// BacklogControl.xaml 的交互逻辑
/// </summary>
public partial class BacklogControl : UserControl
{
private AppData appData = MainWindow.appData;
public BacklogControl()
{
InitializeComponent();
}
private void DeleteMenu_Click(object sender, RoutedEventArgs e)
{
BacklogInfo info = BacklogList.SelectedItem as BacklogInfo;
Growl.Ask("确认删除吗?", isConfirmed =>
{
if (isConfirmed)
{
appData.ExeBacklogList.Remove(info);
CommonCode.SaveAppData(MainWindow.appData);
}
return true;
}, "DeleteConfirm");
}
private void DetailMenu_Click(object sender, RoutedEventArgs e)
{
BacklogInfo info = BacklogList.SelectedItem as BacklogInfo;
BacklogInfoWindow.ShowDetail(info);
}
/// <summary>
/// 禁用设置按钮右键菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DataGridMenu_Initialized(object sender, EventArgs e)
{
BacklogList.ContextMenu = null;
}
private void DataGridRow_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
BacklogList.SelectedIndex = ((DataGridRow)sender).GetIndex();
Menu.IsOpen = true;
}
}
}

View File

@@ -0,0 +1,35 @@
<UserControl x:Class="GeekDesk.Control.UserControls.Config.AboutControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
d:DesignHeight="400" d:DesignWidth="500">
<UserControl.Resources>
</UserControl.Resources>
<hc:SimplePanel Margin="20,50,20,20">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
<Image Source="/Resource/Image/About.png" Width="400" Height="100"/>
<TextBlock TextAlignment="Center" Text="Copyright © 2021 GeekDesk 1.0 beta"/>
<WrapPanel Margin="0,10,0,0" VerticalAlignment="Center" HorizontalAlignment="Center">
<hc:Shield Subject=".net" Status=">=4.72" Margin="0,0,10,0" Color="#1182c3"/>
<hc:Shield Subject="IDE" Status="VS2019" Margin="0,0,10,0" Color="#1182c3"/>
<hc:Shield Subject="公众号" Status="抓几个娃" Color="#04913B">
<hc:Poptip.Instance>
<hc:Poptip PlacementType="Top">
<hc:Poptip.Content>
<Image Source="/Resource/Image/公众号.jpg" Width="150" Height="150" />
</hc:Poptip.Content>
</hc:Poptip>
</hc:Poptip.Instance>
</hc:Shield>
</WrapPanel>
<TextBlock Margin="0,20,0,0" FontSize="13" Width="200" TextAlignment="Center" Text="这是个人开发的程序,所有人可任意修改和免费使用(商用请联系作者)" TextWrapping="Wrap"/>
</StackPanel>
</hc:SimplePanel>
</UserControl>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.Config
{
/// <summary>
/// AboutControl.xaml 的交互逻辑
/// </summary>
public partial class AboutControl : UserControl
{
public AboutControl()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,70 @@
<UserControl x:Class="GeekDesk.Control.UserControls.Config.MotionControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
d:DesignHeight="300" d:DesignWidth="450">
<UserControl.Resources>
<cvt:HideTypeConvert x:Key="HideTypeConvert"/>
</UserControl.Resources>
<hc:SimplePanel Margin="20">
<hc:UniformSpacingPanel Spacing="10" Margin="0,0,0,10" Grid.ColumnSpan="4">
<TextBlock Text="面板动作设置" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,26.394,0,-16.394" Grid.ColumnSpan="4">
<CheckBox x:Name="IconIsAdmin" Content="启动时显示主面板" IsChecked="{Binding StartedShowPanel}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,50,0,-102.337" Grid.ColumnSpan="4">
<CheckBox Content="显示时追随鼠标位置" IsChecked="{Binding FollowMouse}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,89.49,-30,-79.49" Grid.ColumnSpan="4">
<TextBlock Text="面板关闭方式" VerticalAlignment="Center" Margin="-26,0,26,0"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,115,20,-102.337" Grid.ColumnSpan="4">
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
Style="{StaticResource RadioButtonIcon}" Content="失去焦点后"
IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=1}"/>
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
Style="{StaticResource RadioButtonIcon}" Content="运行项目后"
IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=2}"/>
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
Style="{StaticResource RadioButtonIcon}" Content="手动关闭"
IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=3}"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,164.49,-30,-154.49" Grid.ColumnSpan="4">
<TextBlock Text="热键设置" VerticalAlignment="Center" Margin="-26,0,26,0"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="30,193,0,-180.337" Grid.ColumnSpan="4">
<TextBlock Text="当前热键:"/>
<hc:TextBox HorizontalAlignment="Left"
VerticalAlignment="Top"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
Width="200"
Text="{Binding HotkeyStr}"
KeyDown="HotKeyDown"
KeyUp="HotKeyUp"
Margin="12.967,-7.38,-12.967,0"/>
</hc:UniformSpacingPanel>
</hc:SimplePanel>
</UserControl>

View File

@@ -0,0 +1,231 @@
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using GlobalHotKey;
using HandyControl.Data;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.Config
{
/// <summary>
/// 动作设置
/// </summary>
public partial class MotionControl : UserControl
{
private static bool hotkeyFinished = true; //热键设置结束
private static KeyEventArgs prevKeyTemp; //上一个按键
private static AppConfig appConfig = MainWindow.appData.AppConfig;
public MotionControl()
{
InitializeComponent();
}
/// <summary>
/// 注册热键按下
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HotKeyDown(object sender, KeyEventArgs e)
{
if (!e.IsRepeat)
{
if (hotkeyFinished)
{
appConfig.Hotkey = 0;
appConfig.HotkeyStr = "";
appConfig.HotkeyModifiers = 0;
hotkeyFinished = false;
}
//首次按下按键
if (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0)
{
if (CheckModifierKeys(e))
{
//辅助键
appConfig.HotkeyStr = GetKeyName(e);
appConfig.HotkeyModifiers = GetModifierKeys(e);
prevKeyTemp = e;
}
}
else
{
//非首次按下 需要判断前一个键值是否为辅助键
if (CheckModifierKeys(prevKeyTemp)
&& ((e.Key >= Key.A && e.Key <= Key.Z)
|| (e.Key >= Key.F1 && e.Key <= Key.F12)
|| (e.Key >= Key.D0 && e.Key <= Key.D9)))
{
appConfig.Hotkey = e.Key;
appConfig.HotkeyStr += e.Key.ToString();
prevKeyTemp = e;
}
else if (CheckModifierKeys(e))
{
appConfig.HotkeyStr += GetKeyName(e);
appConfig.HotkeyModifiers |= GetModifierKeys(e);
prevKeyTemp = e;
}
}
}
}
private string GetKeyName(KeyEventArgs e)
{
Key key = e.Key;
if (key == Key.LeftCtrl || key == Key.RightCtrl)
{
return "Ctrl + ";
} else if (key == Key.LWin || key == Key.RWin)
{
return "Win + ";
}
else if (key == Key.LeftShift || key == Key.RightShift)
{
return "Shift + ";
}
else
{
return "Alt + ";
}
}
private HotkeyModifiers GetModifierKeys(KeyEventArgs e)
{
Key key = e.Key;
if (key == Key.LeftCtrl || key == Key.RightCtrl)
{
return HotkeyModifiers.MOD_CONTROL;
}
else if (key == Key.LWin || key == Key.RWin)
{
return HotkeyModifiers.MOD_WIN;
}
else if (key == Key.LeftShift || key == Key.RightShift)
{
return HotkeyModifiers.MOD_SHIFT;
}
else
{
return HotkeyModifiers.MOD_ALT;
}
}
private bool CheckModifierKeys(KeyEventArgs e)
{
Key key = e.Key;
return key == Key.LeftCtrl || key == Key.RightCtrl
|| key == Key.LWin || key == Key.RWin
|| key == Key.LeftShift || key == Key.RightShift
|| key == Key.LeftAlt || key == Key.RightAlt;
}
private void HotKeyUp(object sender, KeyEventArgs e)
{
hotkeyFinished = true;
ConfigWindow cw = (ConfigWindow)Window.GetWindow(this);
try
{
if (cw.mainWindow.hotKeyId != -1)
{
Hotkey.UnRegist(new WindowInteropHelper(cw.mainWindow).Handle, Hotkey.keymap[cw.mainWindow.hotKeyId]);
}
cw.mainWindow.hotKeyId = Hotkey.Regist(cw.mainWindow, appConfig.HotkeyModifiers, appConfig.Hotkey, () =>
{
if (cw.mainWindow.Visibility == Visibility.Collapsed)
{
cw.mainWindow.ShowApp();
}
else
{
cw.mainWindow.Visibility = Visibility.Collapsed;
}
});
} catch (Exception)
{
HandyControl.Controls.Growl.WarningGlobal("当前快捷键已被其它程序占用(" + appConfig.HotkeyStr + ")!");
}
}
private void ShowApp(MainWindow mainWindow)
{
if (appConfig.FollowMouse)
{
ShowAppAndFollowMouse(mainWindow);
}
else
{
this.Visibility = Visibility.Visible;
}
Keyboard.Focus(this);
}
/// <summary>
/// 随鼠标位置显示面板 (鼠标始终在中间)
/// </summary>
private void ShowAppAndFollowMouse(MainWindow mainWindow)
{
//获取鼠标位置
System.Windows.Point p = MouseUtil.GetMousePosition();
double left = SystemParameters.VirtualScreenLeft;
double top = SystemParameters.VirtualScreenTop;
double width = SystemParameters.VirtualScreenWidth;
double height = SystemParameters.VirtualScreenHeight;
double right = width - Math.Abs(left);
double bottom = height - Math.Abs(top);
if (p.X - mainWindow.Width / 2 < left)
{
//判断是否在最左边缘
mainWindow.Left = left;
}
else if (p.X + mainWindow.Width / 2 > right)
{
//判断是否在最右边缘
mainWindow.Left = right - mainWindow.Width;
}
else
{
mainWindow.Left = p.X - mainWindow.Width / 2;
}
if (p.Y - mainWindow.Height / 2 < top)
{
//判断是否在最上边缘
mainWindow.Top = top;
}
else if (p.Y + mainWindow.Height / 2 > bottom)
{
//判断是否在最下边缘
mainWindow.Top = bottom - mainWindow.Height;
}
else
{
mainWindow.Top = p.Y - mainWindow.Height / 2;
}
mainWindow.Visibility = Visibility.Visible;
}
}
}

View File

@@ -0,0 +1,102 @@
<UserControl x:Class="GeekDesk.Control.UserControls.Config.ThemeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.Config"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Background="AliceBlue"
d:DesignHeight="380" d:DesignWidth="450">
<hc:SimplePanel Margin="20">
<hc:UniformSpacingPanel Spacing="10" Margin="0,0,-40,-12" Grid.ColumnSpan="4">
<TextBlock Text="背景图片" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="19,20,-59,-31.5" Grid.ColumnSpan="4">
<TextBlock Text="图片路径:" VerticalAlignment="Center"/>
<TextBlock Text="{Binding BacImgName}" Width="200"
VerticalAlignment="Center"
hc:Poptip.HitMode="None"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding BacImgName}"
hc:Poptip.Placement="TopLeft"
/>
<Button Content="修改" Click="BGButton_Click"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="19,60,11,-36.433" Grid.ColumnSpan="4">
<CheckBox x:Name="IconIsAdmin" Content="毛玻璃效果" IsChecked="{Binding BlurEffect}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" Margin="0,91.5,0,34.5" LineStroke="Black" Grid.ColumnSpan="4"/>
<StackPanel Margin="0,30,0,0">
<hc:UniformSpacingPanel Spacing="10" Margin="0,80,-40,-89.5" Grid.ColumnSpan="4">
<TextBlock Text="托盘不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,110,-40,-122" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding CardOpacity}"
Maximum="100"
Margin="0,-12,-313.5,19.5"
>
<hc:PreviewSlider.PreviewContent>
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
</hc:PreviewSlider.PreviewContent>
</hc:PreviewSlider>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,135,-40,-161.626" Grid.ColumnSpan="4">
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,155,-40,-183" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding BgOpacity}"
Maximum="100"
Margin="0,0,-313.5,7.5"
>
<hc:PreviewSlider.PreviewContent>
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
</hc:PreviewSlider.PreviewContent>
</hc:PreviewSlider>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,195,-40,-208.813" Grid.ColumnSpan="4">
<TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,215,-40,-241" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding PannelOpacity}"
Minimum="50"
Maximum="100"
Margin="0,0,-313.5,7.5"
>
<hc:PreviewSlider.PreviewContent>
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
</hc:PreviewSlider.PreviewContent>
</hc:PreviewSlider>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,245,-40,-279.313" Grid.ColumnSpan="4">
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,265,-40,-321" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding PannelCornerRadius}"
Maximum="25"
Margin="0,0,-313.5,7.5"
>
<hc:PreviewSlider.PreviewContent>
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
</hc:PreviewSlider.PreviewContent>
</hc:PreviewSlider>
</hc:UniformSpacingPanel>
</StackPanel>
</hc:SimplePanel>
</UserControl>

View File

@@ -0,0 +1,60 @@
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.Config
{
/// <summary>
/// MotionControl.xaml 的交互逻辑
/// </summary>
public partial class ThemeControl : System.Windows.Controls.UserControl
{
public ThemeControl()
{
InitializeComponent();
}
/// <summary>
/// 修改背景图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BGButton_Click(object sender, RoutedEventArgs e)
{
AppConfig appConfig = MainWindow.appData.AppConfig;
try
{
OpenFileDialog ofd = new OpenFileDialog
{
Multiselect = false, //只允许选中单个文件
Filter = "图像文件(*.png, *.jpg)|*.png;*.jpg;*.gif"
};
if (ofd.ShowDialog() == true)
{
appConfig.BitmapImage = ImageUtil.GetBitmapImageByFile(ofd.FileName);
appConfig.BacImgName = ofd.FileName;
}
}
catch (Exception)
{
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
}
}
}
}

View File

@@ -0,0 +1,45 @@
<UserControl x:Class="GeekDesk.Control.UserControls.IconFont.IconPannel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.IconFont"
mc:Ignorable="d"
>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top">
<ListBox x:Name="IconListBox" ItemsSource="{Binding Iconfonts}" BorderThickness="0" Background="AliceBlue">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Background="Transparent"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Width="80" Height="80">
<Button Background="Transparent"
BorderThickness="0"
IsEnabled="False"
Opacity="0.8"
hc:IconElement.Geometry="{Binding Text}"
hc:IconElement.Height="35"
hc:IconElement.Width="35"
Height="60"
Width="60"
/>
<TextBlock TextAlignment="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="100" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</UserControl>

View File

@@ -0,0 +1,30 @@
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.IconFont
{
/// <summary>
/// IconPannel.xaml 的交互逻辑
/// </summary>
public partial class IconPannel : UserControl
{
public IconPannel()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,145 @@
<UserControl x:Class="GeekDesk.Control.UserControls.PannelCard.LeftCardControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<!--左侧栏样式动画-->
<Style x:Key="MenuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
<Setter Property="FontSize" Value="15"/>
<Setter Property="Margin" Value="0,0,0,1"/>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Opacity="0"/>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="False"/>
<Condition Property="IsSelected" Value="False"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="15" Duration="0:0:0.5" Storyboard.TargetProperty="FontSize"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="60">
<DoubleAnimation To="18" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE4DBDB"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="#FFECECEC"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
</UserControl.Resources>
<!--左侧栏-->
<hc:Card x:Name="MyCard"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,0,5"
>
<hc:Card.Background>
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
</SolidColorBrush>
</hc:Card.Background>
<hc:Card.BorderBrush>
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
</hc:Card.BorderBrush>
<hc:Card.ContextMenu>
<ContextMenu Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
</ContextMenu>
</hc:Card.ContextMenu>
<WrapPanel Orientation="Horizontal">
<ListBox x:Name="menus"
ItemsSource="{Binding MenuList}"
Tag="{Binding AppConfig.MenuCardWidth}"
BorderThickness="0" Foreground="{x:Null}"
SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
VirtualizingPanel.VirtualizationMode="Recycling"
>
<ListBox.Resources>
<ContextMenu x:Key="menuDialog" Width="200">
<MenuItem Header="新建菜单" Click="CreateMenu"/>
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
</ContextMenu>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
<Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
</ListBox.Background>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="30" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
HorizontalAlignment="Left"
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"
FontSize="15"
TextAlignment="Left"
LostFocus="LostFocusOrEnterDown"
KeyDown="LostFocusOrEnterDown"
Tag="{Binding}"
IsVisibleChanged="MenuEditWhenVisibilityChanged"
Visibility="{Binding MenuEdit}"/>
<StackPanel Orientation="Horizontal">
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="{Binding MenuGeometry}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
IsEnabled="False"
Opacity="1"
Foreground="{Binding GeometryColor}"
/>
<TextBlock Text="{Binding MenuName}"
HorizontalAlignment="Center"
TextAlignment="Center"
VerticalAlignment="Center"
IsVisibleChanged="MenuWhenVisibilityChanged"
Visibility="{Binding NotMenuEdit}"
/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card>
</UserControl>

View File

@@ -0,0 +1,193 @@
using DraggAnimatedPanelExample;
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace GeekDesk.Control.UserControls.PannelCard
{
/// <summary>
/// LeftCardControl.xaml 的交互逻辑
/// </summary>
public partial class LeftCardControl : UserControl
{
private int menuSelectIndexTemp = -1;
private AppData appData = MainWindow.appData;
public LeftCardControl()
{
InitializeComponent();
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
}
DelegateCommand<int[]> _swap;
public DelegateCommand<int[]> SwapCommand
{
get
{
if (_swap == null)
_swap = new DelegateCommand<int[]>(
(indexes) =>
{
int fromS = indexes[0];
int to = indexes[1];
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
var elementSource = menuList[to];
var dragged = menuList[fromS];
menuList.Remove(dragged);
menuList.Insert(to, dragged);
menus.SelectedIndex = to;
MainWindow.appData.MenuList = menuList;
}
);
return _swap;
}
}
////菜单点击事件
private void MenuClick(object sender, MouseButtonEventArgs e)
{
//设置对应菜单的图标列表
MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
appData.AppConfig.SelectedMenuIcons = mi.IconList;
}
/// <summary>
/// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
/// 修改菜单元素不可见时 原菜单可见 并 选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
{
TextBlock tb = sender as TextBlock;
if (tb.Visibility == Visibility.Collapsed)
{
if (menus.SelectedIndex != -1)
{
menuSelectIndexTemp = menus.SelectedIndex;
menus.SelectedIndex = -1;
}
else
{
menus.SelectedIndex = menuSelectIndexTemp;
}
}
}
/// <summary>
/// 新建菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CreateMenu(object sender, RoutedEventArgs e)
{
MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
appData.MenuList.Add(info);
menus.Items.Refresh();
menus.SelectedIndex = appData.MenuList.Count - 1;
appData.AppConfig.SelectedMenuIndex = menus.SelectedIndex;
appData.AppConfig.SelectedMenuIcons = info.IconList;
}
/// <summary>
/// 重命名菜单 将textbox 设置为可见
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RenameMenu(object sender, RoutedEventArgs e)
{
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
menuInfo.MenuEdit = (int)Visibility.Visible;
}
/// <summary>
/// 删除菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DeleteMenu(object sender, RoutedEventArgs e)
{
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
if (appData.MenuList.Count == 1)
{
//如果删除以后没有菜单的话 先创建一个
CreateMenu(null, null);
}
appData.MenuList.Remove(menuInfo);
if (menus.SelectedIndex == -1)
{
// 选中下一个菜单
menus.SelectedIndex = 0;
appData.AppConfig.SelectedMenuIndex = menus.SelectedIndex;
appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList;
}
}
/// <summary>
/// 编辑菜单失焦或者敲下Enter键时保存修改后的菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LostFocusOrEnterDown(object sender, EventArgs e)
{
TextBox menuBox = null;
if (e.GetType() == typeof(KeyEventArgs))
{
KeyEventArgs eKey = e as KeyEventArgs;
if (eKey.Key == Key.Enter)
{
menuBox = ((TextBox)sender);
}
}
else if (e.GetType() == typeof(RoutedEventArgs))
{
menuBox = ((TextBox)sender);
}
if (menuBox != null)
{
MenuInfo menuInfo = menuBox.Tag as MenuInfo;
string text = menuBox.Text;
menuInfo.MenuName = text;
menuInfo.MenuEdit = Visibility.Collapsed;
}
}
/// <summary>
/// 当修改菜单元素可见时 设置全选并获得焦点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuEditWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
{
TextBox box = sender as TextBox;
if (box.Visibility == Visibility.Visible)
{
Keyboard.Focus(box);
box.SelectAll();
}
}
/// <summary>
/// 修改菜单图标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void EditMenuGeometry(object sender, RoutedEventArgs e)
{
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
IconfontWindow.Show(SvgToGeometry.GetIconfonts(), menuInfo);
}
}
}

View File

@@ -0,0 +1,117 @@
<UserControl x:Class="GeekDesk.Control.UserControls.PannelCard.RightCardControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<!--右侧栏样式动画-->
<Style x:Key="imageStyle" TargetType="Image">
<Setter Property="Width" Value="{Binding ImageWidth}"/>
<Setter Property="Height" Value="{Binding ImageHeight}"/>
<Setter Property="Source" Value="{Binding BitmapImage}"/>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Width"/>
<DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Height"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Width"/>
<DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Height"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
</Style.Triggers>
</Style>
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
<cvt:OpcityConvert x:Key="OpcityConvert"/>
</UserControl.Resources>
<!--右侧栏-->
<hc:Card AllowDrop="True"
Drop="Wrap_Drop"
BorderThickness="1"
Effect="{DynamicResource EffectShadow2}"
Margin="5,0,5,5" Grid.ColumnSpan="2">
<hc:Card.Background>
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
</hc:Card.Background>
<hc:Card.BorderBrush>
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
</hc:Card.BorderBrush>
<WrapPanel Orientation="Horizontal">
<ListBox x:Name="icons" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
BorderThickness="0"
SelectionChanged="IconSelectionChanged "
VirtualizingPanel.VirtualizationMode="Recycling"
>
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100" HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Resources>
<ContextMenu x:Key="iconDialog" Width="200">
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
<MenuItem Header="资源管理器菜单" Click="MenuItem_Click" Tag="{Binding}"/>
<MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/>
<MenuItem Header="从列表移除" Click="RemoveIcon" Tag="{Binding}"/>
</ContextMenu>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="ContextMenu" Value="{StaticResource iconDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Tag="{Binding}"
MouseLeftButtonUp="IconClick"
HorizontalAlignment="Center"
Margin="5,5,5,5"
hc:Poptip.HitMode="None"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding Content}"
hc:Poptip.Placement="BottomLeft"
>
<Image Style="{StaticResource imageStyle}" />
<TextBlock MaxWidth="80"
MaxHeight="40"
TextWrapping="Wrap"
TextTrimming="WordEllipsis"
TextAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card>
</UserControl>

View File

@@ -0,0 +1,217 @@
using DraggAnimatedPanelExample;
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.PannelCard
{
/// <summary>
/// RightCardControl.xaml 的交互逻辑
/// </summary>
public partial class RightCardControl : UserControl
{
private AppData appData = MainWindow.appData;
public RightCardControl()
{
InitializeComponent();
}
#region
DelegateCommand<int[]> _swap;
public DelegateCommand<int[]> SwapCommand
{
get
{
if (_swap == null)
_swap = new DelegateCommand<int[]>(
(indexes) =>
{
int fromS = indexes[0];
int to = indexes[1];
ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
var elementSource = iconList[to];
var dragged = iconList[fromS];
iconList.Remove(dragged);
iconList.Insert(to, dragged);
}
);
return _swap;
}
}
#endregion
/// <summary>
/// 图标点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void IconClick(object sender, MouseButtonEventArgs e)
{
IconInfo icon = (IconInfo)((StackPanel)sender).Tag;
if (icon.AdminStartUp)
{
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
}
else
{
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
}
}
/// <summary>
/// 管理员方式启动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void IconAdminStart(object sender, RoutedEventArgs e)
{
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
}
/// <summary>
/// 打开文件所在位置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShowInExplore(object sender, RoutedEventArgs e)
{
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
}
private void StartIconApp(IconInfo icon, IconStartType type)
{
try
{
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
return;
}
Process p = new Process();
p.StartInfo.FileName = icon.Path;
switch (type)
{
case IconStartType.ADMIN_STARTUP:
p.StartInfo.Arguments = "1";//启动参数
p.StartInfo.Verb = "runas";
p.StartInfo.CreateNoWindow = false; //设置显示窗口
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
p.StartInfo.ErrorDialog = false;
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
{
Window parentWin = Window.GetWindow(this);
parentWin.Visibility = Visibility.Collapsed;
}
break;// c#好像不能case穿透
case IconStartType.DEFAULT_STARTUP:
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
{
Window parentWin = Window.GetWindow(this);
parentWin.Visibility = Visibility.Collapsed;
}
break;
case IconStartType.SHOW_IN_EXPLORE:
p.StartInfo.FileName = "Explorer.exe";
p.StartInfo.Arguments = "/e,/select," + icon.Path;
break;
}
p.Start();
icon.Count++;
}
catch (Exception)
{
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
}
}
/// <summary>
/// data选中事件 设置不可选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void IconSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (icons.SelectedIndex != -1) icons.SelectedIndex = -1;
}
private void Wrap_Drop(object sender, DragEventArgs e)
{
Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
if (dropObject == null) return;
foreach (object obj in dropObject)
{
string path = (string)obj;
//string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
IconInfo iconInfo = new IconInfo
{
Path = path,
BitmapImage = ImageUtil.GetBitmapIconByPath(path)
};
iconInfo.DefaultImage = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(path);
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
}
}
/// <summary>
/// 从列表删除图标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RemoveIcon(object sender, RoutedEventArgs e)
{
appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe");
psi.Arguments = "/e,/select," + icon.Path;
System.Diagnostics.Process.Start(psi);
}
/// <summary>
/// 弹出Icon属性修改面板
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PropertyConfig(object sender, RoutedEventArgs e)
{
HandyControl.Controls.Dialog.Show(new IconInfoDialog((IconInfo)((MenuItem)sender).Tag));
}
}
}

View File

@@ -0,0 +1,73 @@
<Window x:Class="GeekDesk.Control.Windows.BacklogInfoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Height="670"
Width="450"
Title="TaskInfo"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
>
<Window.Resources>
</Window.Resources>
<Border CornerRadius="3" BorderThickness="2" BorderBrush="Black" Margin="0,0,0,313.323" MouseDown="DragMove">
<Border.Background>
<SolidColorBrush Color="AliceBlue"/>
</Border.Background>
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="65"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</Border.Resources>
<Grid Margin="0,0,0,8">
<hc:SimplePanel Margin="20" HorizontalAlignment="Center">
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<WrapPanel>
<TextBlock Text="待办任务:" Style="{StaticResource LeftTB}"/>
<TextBlock Text="*" Foreground="Red" />
</WrapPanel>
<TextBox x:Name="Title" Width="290" FontSize="14" />
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,48.997,0,-48.997">
<TextBlock Text="待办详情:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="Msg" TextWrapping="Wrap"
AcceptsReturn="True"
VerticalScrollBarVisibility="Visible"
Height="100" MaxHeight="150" MinHeight="100" Width="290" MinWidth="290"
VerticalAlignment="Center" HorizontalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,167.622,0,-167.622">
<TextBlock Text="待办时间*:" Style="{StaticResource LeftTB}"/>
<hc:DateTimePicker x:Name="ExeTime" ErrorStr="test" Width="200"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,228,0,-228">
<TextBlock Text="完成时间:" Style="{StaticResource LeftTB}"/>
<TextBlock x:Name="DoneTime" Width="200"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,273.333,0,-93.333" Grid.ColumnSpan="4">
<Button Content="保存" Background="#5BC0DE"
Foreground="White" Margin="320,6,-208,-10"
Click="Save_Button_Click"/>
</hc:UniformSpacingPanel>
</hc:SimplePanel>
<Button Panel.ZIndex="2" 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"/>
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
</Grid>
</Border>
</Window>

View File

@@ -0,0 +1,145 @@
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// BacklogInfoWindow.xaml 的交互逻辑
/// </summary>
public partial class BacklogInfoWindow
{
private static int windowType = -1;
private static readonly int NEW_BACKLOG = 1;
private static readonly int DETAIL_BACKLOG = 2;
private AppData appData = MainWindow.appData;
private BacklogInfo info;
private BacklogInfoWindow()
{
InitializeComponent();
ExeTime.SelectedDateTime = DateTime.Now.AddMinutes(10);
this.Topmost = true;
}
private BacklogInfoWindow(BacklogInfo info)
{
InitializeComponent();
this.Topmost = true;
Title.Text = info.Title;
Msg.Text = info.Msg;
ExeTime.Text = info.ExeTime;
DoneTime.Text = info.DoneTime;
this.info = info;
}
/// <summary>
/// 点击关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Close_Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
/// <summary>
/// 保存待办
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Save_Button_Click(object sender, RoutedEventArgs e)
{
if (Title.Text.Trim() == "" || ExeTime.Text.Trim() == "")
{
Growl.Warning("任务标题 和 待办时间不能为空!");
return;
} else
{
try
{
Convert.ToDateTime(ExeTime.Text);
} catch (Exception)
{
Growl.Warning("请输入正确的时间!");
return;
}
}
if (windowType == NEW_BACKLOG)
{
info = new BacklogInfo
{
Title = Title.Text,
Msg = Msg.Text,
ExeTime = ExeTime.Text
};
appData.ExeBacklogList.Add(info);
} else
{
int index =appData.ExeBacklogList.IndexOf(info);
appData.ExeBacklogList.Remove(info);
info.Title = Title.Text;
info.Msg = Msg.Text;
info.ExeTime = ExeTime.Text;
info.DoneTime = DoneTime.Text;
appData.ExeBacklogList.Insert(index, info);
}
CommonCode.SaveAppData(MainWindow.appData);
this.Close();
}
private static System.Windows.Window window = null;
public static void ShowNone()
{
if (window == null || !window.Activate())
{
window = new BacklogInfoWindow();
}
windowType = NEW_BACKLOG;
window.Show();
}
private static System.Windows.Window window2 = null;
public static void ShowDetail(BacklogInfo info)
{
if (window2 == null || !window2.Activate())
{
window2 = new BacklogInfoWindow(info);
}
windowType = DETAIL_BACKLOG;
window2.Show();
}
}
}

View File

@@ -0,0 +1,104 @@
<Window x:Class="GeekDesk.Control.Windows.BacklogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Height="450"
Width="850"
Title="Task"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
>
<Window.Resources>
<Style x:Key="MenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
<Style.Setters>
<Setter Property="Background" Value="AliceBlue"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE2E2E2"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFDAD7D7"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border CornerRadius="8" BorderThickness="0">
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<hc:Card Grid.Row="0" Grid.Column="0">
<hc:SideMenu BorderThickness="1"
AutoSelect="True"
>
<hc:SideMenu.Background>
<SolidColorBrush Color="AliceBlue"/>
</hc:SideMenu.Background>
<hc:SideMenu.ItemContainerStyle>
<Style TargetType="hc:SideMenuItem" BasedOn="{StaticResource MenuStyle}"/>
</hc:SideMenu.ItemContainerStyle>
<hc:SideMenuItem Header="待办列表"
IsSelected="True"
Selected="MemuClick"
Tag="ExeList"
>
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
hc:IconElement.Geometry="{StaticResource List}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="历史待办"
Tag="History"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
hc:IconElement.Geometry="{StaticResource History}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</hc:Card>
<hc:Card Grid.Row="0" Grid.Column="1" x:Name="RightCard" Height="450" MouseDown="DragMove" />
<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 Content="新建待办"
Panel.ZIndex="1"
Background="#5BC0DE"
Foreground="White"
Grid.Column="1"
Margin="590,29,10,384"
Click="CreateBacklog_BtnClick"/>
</Grid>
</Border>
</Window>

View File

@@ -0,0 +1,97 @@
using GeekDesk.Control.UserControls.Backlog;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// BacklogWindow.xaml 的交互逻辑
/// </summary>
public partial class BacklogWindow
{
private static BacklogControl backlog = new BacklogControl();
private AppData appData = MainWindow.appData;
private BacklogWindow()
{
InitializeComponent();
RightCard.Content = backlog;
backlog.BacklogList.ItemsSource = appData.ExeBacklogList;
this.Topmost = true;
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
/// <summary>
/// 点击关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Close_Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void MemuClick(object sender, RoutedEventArgs e)
{
SideMenuItem smi = sender as SideMenuItem;
switch (smi.Tag.ToString())
{
case "History":
backlog.BacklogList.ItemsSource = appData.HiBacklogList;
break;
default:
backlog.BacklogList.ItemsSource = appData.ExeBacklogList;
break;
}
}
/// <summary>
/// 新建待办
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CreateBacklog_BtnClick(object sender, RoutedEventArgs e)
{
BacklogInfoWindow.ShowNone();
}
private static System.Windows.Window window = null;
public static void Show()
{
if (window == null || !window.Activate())
{
window = new BacklogWindow();
}
window.Show();
}
}
}

View File

@@ -0,0 +1,117 @@
<hc:Window x:Class="GeekDesk.Control.Windows.ConfigWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk"
Title="Setting"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Height="450"
Width="600"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False"
>
<Window.Resources>
<Style x:Key="MenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
<Style.Setters>
<Setter Property="Background" Value="AliceBlue"/>
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE2E2E2"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFDAD7D7"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border CornerRadius="8" BorderThickness="0">
<Border.Background>
<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<hc:Card Grid.Row="0" Grid.Column="0">
<hc:SideMenu BorderThickness="1"
AutoSelect="True"
>
<hc:SideMenu.Background>
<SolidColorBrush Color="AliceBlue"/>
</hc:SideMenu.Background>
<hc:SideMenu.ItemContainerStyle>
<Style TargetType="hc:SideMenuItem" BasedOn="{StaticResource MenuStyle}"/>
</hc:SideMenu.ItemContainerStyle>
<hc:SideMenuItem Header="关于"
IsSelected="True"
Selected="MemuClick"
Tag="About"
>
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
hc:IconElement.Geometry="{StaticResource About}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="显示设置"
Tag="Theme"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
hc:IconElement.Geometry="{StaticResource Pannel}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="动作"
Tag="Motion"
Selected="MemuClick">
<hc:SideMenuItem.Icon>
<Button Background="Transparent"
IsEnabled="False"
Opacity="1"
BorderThickness="0"
hc:IconElement.Geometry="{StaticResource Motion}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
/>
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</hc:Card>
<hc:ScrollViewer Grid.Row="0" Grid.Column="1">
<hc:Card x:Name="RightCard" Height="448" MouseDown="DragMove">
</hc:Card>
</hc:ScrollViewer>
<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"/>
</Grid>
</Border>
</hc:Window>

View File

@@ -0,0 +1,84 @@

using GalaSoft.MvvmLight.Command;
using GeekDesk.Control.UserControls;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Windows;
using System.Windows.Input;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// ConfigDialog.xaml 的交互逻辑
/// </summary>
public partial class ConfigWindow
{
private static AboutControl about = new AboutControl();
private static ThemeControl theme = new ThemeControl();
private static MotionControl motion = new MotionControl();
public MainWindow mainWindow;
private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
{
InitializeComponent();
this.DataContext = appConfig;
RightCard.Content = about;
this.Topmost = true;
this.mainWindow = mainWindow;
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
/// <summary>
/// 点击关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Close_Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void MemuClick(object sender, RoutedEventArgs e)
{
SideMenuItem smi = sender as SideMenuItem;
switch (smi.Tag.ToString())
{
case "Motion":
RightCard.Content = motion;
break;
case "Theme":
RightCard.Content = theme;
break;
default:
RightCard.Content = about;
break;
}
}
private static System.Windows.Window window = null;
public static void Show(AppConfig appConfig, MainWindow mainWindow)
{
if (window == null || !window.Activate())
{
window = new ConfigWindow(appConfig, mainWindow);
}
window.Show();
}
}
}

View File

@@ -0,0 +1,53 @@
<Window x:Class="GeekDesk.Control.Windows.IconfontWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.IconFont"
mc:Ignorable="d"
Title="Svg"
Height="450" Width="600"
WindowStyle="None"
AllowsTransparency="True"
Background="AliceBlue"
MouseDown="DragMove"
>
<Window.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="80"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="11"/>
</Style>
</Window.Resources>
<Border MouseDown="DragMove">
<Grid MouseDown="DragMove">
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
<hc:TabControl x:Name="MyTabControl" IsAnimationEnabled="True" SelectionChanged="TabControl_SelectionChanged" ShowContextMenu="True" IsTabFillEnabled="True" Margin="20,30,20,20" Height="350" VerticalAlignment="Top">
<hc:TabItem Tag="System" IsSelected="True" Header="系统图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}" >
<hc:SimplePanel Background="AliceBlue">
<uc:IconPannel x:Name="SystemIcon"/>
</hc:SimplePanel>
</hc:TabItem>
<hc:TabItem Tag="Custom" Header="自定义图标" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CalendarGeometry}">
<hc:SimplePanel Background="AliceBlue">
<uc:IconPannel x:Name="CustomIcon"/>
<hc:LoadingCircle x:Name="LoadingEle"/>
</hc:SimplePanel>
</hc:TabItem>
</hc:TabControl>
<Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
<Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Background="#5BC0DE" Foreground="White" RenderTransformOrigin="-0.868,0.583" Margin="447,397.5,71,22.5"/>
<Button Content="确定" Click="Confirm_Click" Background="#5BC0DE" Foreground="White" Margin="534,397.5,20,22.5" RenderTransformOrigin="0.696,0.45"/>
</Grid>
</Border>
</Window>

View File

@@ -0,0 +1,215 @@
using GeekDesk.Control.Other;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// IconfontWindow.xaml 的交互逻辑
/// </summary>
public partial class IconfontWindow : Window
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private static MenuInfo menuInfo;
private static List<IconfontInfo> systemIcons;
private static List<IconfontInfo> customIcons;
public static IconfontViewModel vm;
private IconfontWindow(List<IconfontInfo> icons, MenuInfo menuInfo)
{
InitializeComponent();
systemIcons = icons;
this.Topmost = true;
IconfontWindow.menuInfo = menuInfo;
vm = new IconfontViewModel
{
Iconfonts = systemIcons
};
this.DataContext = vm;
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
private void Close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
switch (ti.Tag.ToString())
{
case "Custom":
CustomButton.IsEnabled = true;
if (StringUtil.IsEmpty(appConfig.CustomIconUrl) || StringUtil.IsEmpty(appConfig.CustomIconJsonUrl))
{
LoadingEle.Visibility = Visibility.Visible;
CustomIcon.Visibility = Visibility.Collapsed;
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
} else
{
if (customIcons == null)
{
vm.Iconfonts = null;
LoadingOnlineIcon();
} else
{
vm.Iconfonts = customIcons;
LoadingEle.Visibility = Visibility.Collapsed;
CustomIcon.Visibility = Visibility.Visible;
}
}
break;
default:
if (CustomButton != null)
{
CustomButton.IsEnabled = false;
}
if (vm != null)
{
vm.Iconfonts = systemIcons;
}
break;
}
}
private void Confirm_Click(object sender, RoutedEventArgs e)
{
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
int index;
switch (ti.Tag.ToString())
{
case "Custom":
index = this.CustomIcon.IconListBox.SelectedIndex;
if (index != -1)
{
menuInfo.MenuGeometry = customIcons[index].Text;
}
break;
default:
index = this.SystemIcon.IconListBox.SelectedIndex;
if (index != -1)
{
menuInfo.MenuGeometry = systemIcons[index].Text;
}
break;
}
this.Close();
}
private static System.Windows.Window window = null;
public static void Show(List<IconfontInfo> listInfo, MenuInfo menuInfo)
{
if (window == null || !window.Activate())
{
window = new IconfontWindow(listInfo, menuInfo);
}
window.Show();
}
private void CustomButton_Click(object sender, RoutedEventArgs e)
{
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
}
private void CheckSettingUrl_TextChanged(object sender, TextChangedEventArgs e)
{
if (CheckSettingUrl.Text == "true")
{
LoadingOnlineIcon();
} else
{
LoadingEle.IsRunning = true;
CustomIcon.Visibility = Visibility.Collapsed;
}
}
private void LoadingOnlineIcon()
{
try
{
string svgJsStr = HttpUtil.Get(appConfig.CustomIconUrl);
string jsonStr = HttpUtil.Get(appConfig.CustomIconJsonUrl);
List<IconfontInfo> icons = SvgToGeometry.GetIconfonts(svgJsStr, jsonStr);
customIcons = icons;
vm.Iconfonts = customIcons;
LoadingEle.Visibility = Visibility.Collapsed;
CustomIcon.Visibility = Visibility.Visible;
}
catch (Exception)
{
HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
}
}
public class IconfontViewModel : INotifyPropertyChanged
{
private List<IconfontInfo> iconfonts;
private string isSettingUrl;
public List<IconfontInfo> Iconfonts
{
get
{
return iconfonts;
}
set
{
iconfonts = value;
OnPropertyChanged("Iconfonts");
}
}
public string IsSettingUrl
{
get
{
return isSettingUrl;
}
set
{
isSettingUrl = value;
OnPropertyChanged("IsSettingUrl");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace GeekDesk.Converts
{
class DoubleToGridLength : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double val = double.Parse(value.ToString());
return new GridLength(val);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
GridLength val = (GridLength)value;
return double.Parse(val.ToString());
}
}
}

View File

@@ -0,0 +1,29 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts
{
public class HideTypeConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (AppHideType)value == (AppHideType)int.Parse(parameter.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isChecked = (bool)value;
if (!isChecked)
{
return null;
}
return (AppHideType)int.Parse(parameter.ToString());
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace GeekDesk.Converts
{
class IntToCornerRadius : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int val = int.Parse(value.ToString());
return new CornerRadius(val);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,21 +1,18 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data; using System.Windows.Data;
namespace GeekDesk.Util namespace GeekDesk.Converts
{ {
class MenuWidthConvert : IValueConverter public class MenuWidthConvert : IValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
if (value != null && value.ToString().Length>0) if (value != null && value.ToString().Length > 0)
{ {
return System.Convert.ToDouble(value.ToString()) - 10d; return System.Convert.ToDouble(value.ToString()) - 10d;
} else }
else
{ {
return 0d; return 0d;
} }

24
Converts/OpcityConvert.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts
{
public class OpcityConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double val = double.Parse(value.ToString());
return (double)(Math.Round((decimal)(val / 100.00), 2));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -2,183 +2,181 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
namespace DraggAnimatedPanel namespace DraggAnimatedPanel
{ {
/// <summary> /// <summary>
/// Description of SafariPanel_Drag. /// Description of SafariPanel_Drag.
/// </summary> /// </summary>
public partial class DraggAnimatedPanel public partial class DraggAnimatedPanel
{ {
#region const drag #region const drag
const double mouseDif = 2d; const double mouseDif = 2d;
const int mouseTimeDif = 25; const int mouseTimeDif = 25;
#endregion #endregion
#region private #region private
UIElement __draggedElement; UIElement __draggedElement;
public UIElement _draggedElement { public UIElement _draggedElement
get { return __draggedElement; } {
set get { return __draggedElement; }
{ set
__draggedElement = value; {
} __draggedElement = value;
} }
int _draggedIndex; }
int _draggedIndex;
bool _firstScrollRequest = true; bool _firstScrollRequest = true;
ScrollViewer _scrollContainer; ScrollViewer _scrollContainer;
ScrollViewer scrollViewer ScrollViewer scrollViewer
{ {
get get
{ {
if (_firstScrollRequest && _scrollContainer == null) if (_firstScrollRequest && _scrollContainer == null)
{ {
_firstScrollRequest = false; _firstScrollRequest = false;
_scrollContainer = (ScrollViewer)GetParent(this as DependencyObject, (ve)=>ve is ScrollViewer); _scrollContainer = (ScrollViewer)GetParent(this as DependencyObject, (ve) => ve is ScrollViewer);
} }
return _scrollContainer; return _scrollContainer;
} }
} }
#endregion #endregion
#region private drag #region private drag
double _lastMousePosX; double _lastMousePosX;
double _lastMousePosY; double _lastMousePosY;
int _lastMouseMoveTime; int _lastMouseMoveTime;
double _x; double _x;
double _y; double _y;
Rect _rectOnDrag; Rect _rectOnDrag;
#endregion #endregion
void OnMouseMove(object sender,MouseEventArgs e) void OnMouseMove(object sender, MouseEventArgs e)
{ {
if (e.LeftButton == MouseButtonState.Pressed && _draggedElement == null && !this.IsMouseCaptured) if (e.LeftButton == MouseButtonState.Pressed && _draggedElement == null && !this.IsMouseCaptured)
StartDrag(e); StartDrag(e);
else if (_draggedElement != null) else if (_draggedElement != null)
OnDragOver(e); OnDragOver(e);
} }
void OnDragOver(MouseEventArgs e) void OnDragOver(MouseEventArgs e)
{ {
Point mousePos = Mouse.GetPosition(this); Point mousePos = Mouse.GetPosition(this);
double difX = mousePos.X - _lastMousePosX; double difX = mousePos.X - _lastMousePosX;
double difY = mousePos.Y - _lastMousePosY; double difY = mousePos.Y - _lastMousePosY;
int timeDif = e.Timestamp - _lastMouseMoveTime; int timeDif = e.Timestamp - _lastMouseMoveTime;
if ((Math.Abs(difX) > mouseDif || Math.Abs(difY) > mouseDif) && timeDif > mouseTimeDif) if ((Math.Abs(difX) > mouseDif || Math.Abs(difY) > mouseDif) && timeDif > mouseTimeDif)
{ {
//this lines is for keepn draged item inside control bounds //this lines is for keepn draged item inside control bounds
DoScroll(); DoScroll();
if (_x + difX < _rectOnDrag.Location.X) if (_x + difX < _rectOnDrag.Location.X)
_x = 0; _x = 0;
else if (ItemsWidth + _x + difX > _rectOnDrag.Location.X + _rectOnDrag.Width) else if (ItemsWidth + _x + difX > _rectOnDrag.Location.X + _rectOnDrag.Width)
_x = _rectOnDrag.Location.X + _rectOnDrag.Width - ItemsWidth; _x = _rectOnDrag.Location.X + _rectOnDrag.Width - ItemsWidth;
else if (mousePos.X > _rectOnDrag.Location.X && mousePos.X < _rectOnDrag.Location.X + _rectOnDrag.Width) else if (mousePos.X > _rectOnDrag.Location.X && mousePos.X < _rectOnDrag.Location.X + _rectOnDrag.Width)
_x += difX; _x += difX;
if (_y + difY < _rectOnDrag.Location.Y) if (_y + difY < _rectOnDrag.Location.Y)
_y = 0; _y = 0;
else if (ItemsHeight + _y + difY > _rectOnDrag.Location.Y + _rectOnDrag.Height) else if (ItemsHeight + _y + difY > _rectOnDrag.Location.Y + _rectOnDrag.Height)
_y = _rectOnDrag.Location.Y + _rectOnDrag.Height - ItemsHeight; _y = _rectOnDrag.Location.Y + _rectOnDrag.Height - ItemsHeight;
else if (mousePos.Y > _rectOnDrag.Location.Y && mousePos.Y < _rectOnDrag.Location.Y + _rectOnDrag.Height) else if (mousePos.Y > _rectOnDrag.Location.Y && mousePos.Y < _rectOnDrag.Location.Y + _rectOnDrag.Height)
_y += difY; _y += difY;
//lines ends //lines ends
AnimateTo(_draggedElement,_x,_y, 0); AnimateTo(_draggedElement, _x, _y, 0);
_lastMousePosX = mousePos.X; _lastMousePosX = mousePos.X;
_lastMousePosY = mousePos.Y; _lastMousePosY = mousePos.Y;
_lastMouseMoveTime = e.Timestamp; _lastMouseMoveTime = e.Timestamp;
SwapElement(_x + ItemsWidth/2 , _y + ItemsHeight/2); SwapElement(_x + ItemsWidth / 2, _y + ItemsHeight / 2);
} }
} }
void StartDrag(MouseEventArgs e) void StartDrag(MouseEventArgs e)
{ {
Point mousePos = Mouse.GetPosition(this); Point mousePos = Mouse.GetPosition(this);
_draggedElement = GetChildThatHasMouseOver(); _draggedElement = GetChildThatHasMouseOver();
if (_draggedElement == null) if (_draggedElement == null)
return; return;
_draggedIndex = Children.IndexOf(_draggedElement); _draggedIndex = Children.IndexOf(_draggedElement);
_rectOnDrag = VisualTreeHelper.GetDescendantBounds(this); _rectOnDrag = VisualTreeHelper.GetDescendantBounds(this);
Point p = GetItemVisualPoint(_draggedElement); Point p = GetItemVisualPoint(_draggedElement);
_x = p.X; _x = p.X;
_y = p.Y; _y = p.Y;
SetZIndex(_draggedElement,1000); SetZIndex(_draggedElement, 1000);
_lastMousePosX = mousePos.X; _lastMousePosX = mousePos.X;
_lastMousePosY = mousePos.Y; _lastMousePosY = mousePos.Y;
_lastMouseMoveTime = e.Timestamp; _lastMouseMoveTime = e.Timestamp;
this.InvalidateArrange(); this.InvalidateArrange();
e.Handled = true; e.Handled = true;
this.CaptureMouse(); this.CaptureMouse();
} }
void OnMouseUp(object sender,MouseEventArgs e) void OnMouseUp(object sender, MouseEventArgs e)
{ {
if (this.IsMouseCaptured) if (this.IsMouseCaptured)
ReleaseMouseCapture(); ReleaseMouseCapture();
} }
void SwapElement(double x, double y) void SwapElement(double x, double y)
{ {
int index = GetIndexFromPoint(x,y); int index = GetIndexFromPoint(x, y);
if (index == _draggedIndex || index < 0) if (index == _draggedIndex || index < 0)
return; return;
if (index >= Children.Count) if (index >= Children.Count)
index = Children.Count - 1; index = Children.Count - 1;
int[] parameter = new int[]{_draggedIndex, index}; int[] parameter = new int[] { _draggedIndex, index };
if (SwapCommand != null && SwapCommand.CanExecute(parameter)) if (SwapCommand != null && SwapCommand.CanExecute(parameter))
{ {
SwapCommand.Execute(parameter); SwapCommand.Execute(parameter);
_draggedElement = Children[index]; //this is bcause after changing the collection the element is other _draggedElement = Children[index]; //this is bcause after changing the collection the element is other
FillNewDraggedChild(_draggedElement); FillNewDraggedChild(_draggedElement);
_draggedIndex = index; _draggedIndex = index;
} }
this.InvalidateArrange(); this.InvalidateArrange();
} }
void FillNewDraggedChild(UIElement child) void FillNewDraggedChild(UIElement child)
{ {
if (child.RenderTransform as TransformGroup == null) if (child.RenderTransform as TransformGroup == null)
{ {
child.RenderTransformOrigin = new Point(0.5, 0.5); child.RenderTransformOrigin = new Point(0.5, 0.5);
TransformGroup group = new TransformGroup(); TransformGroup group = new TransformGroup();
child.RenderTransform = group; child.RenderTransform = group;
group.Children.Add(new TranslateTransform()); group.Children.Add(new TranslateTransform());
} }
SetZIndex(child,1000); SetZIndex(child, 1000);
AnimateTo(child,_x,_y, 0); //need relocate the element AnimateTo(child, _x, _y, 0); //need relocate the element
} }
void OnLostMouseCapture(object sender,MouseEventArgs e) void OnLostMouseCapture(object sender, MouseEventArgs e)
{ {
FinishDrag(); FinishDrag();
} }
void FinishDrag() void FinishDrag()
{ {
if (_draggedElement != null) if (_draggedElement != null)
{ {
SetZIndex(_draggedElement,0); SetZIndex(_draggedElement, 0);
_draggedElement = null; _draggedElement = null;
this.InvalidateArrange(); this.InvalidateArrange();
} }
} }
void DoScroll() void DoScroll()
{ {
if (scrollViewer != null) if (scrollViewer != null)
{ {
Point position = Mouse.GetPosition(scrollViewer); Point position = Mouse.GetPosition(scrollViewer);
double scrollMargin = Math.Min(scrollViewer.FontSize * 2, scrollViewer.ActualHeight / 2); double scrollMargin = Math.Min(scrollViewer.FontSize * 2, scrollViewer.ActualHeight / 2);
if (position.X >= scrollViewer.ActualWidth - scrollMargin && if (position.X >= scrollViewer.ActualWidth - scrollMargin &&
@@ -201,5 +199,5 @@ namespace DraggAnimatedPanel
} }
} }
} }
} }
} }

View File

@@ -1,237 +1,234 @@
/*Developed by (doiTTeam)=>doiTTeam.mail = devdoiTTeam@gmail.com*/ /*Developed by (doiTTeam)=>doiTTeam.mail = devdoiTTeam@gmail.com*/
using System; using System;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Navigation;
namespace DraggAnimatedPanel namespace DraggAnimatedPanel
{ {
/// <summary> /// <summary>
/// Description of DraggAnimatedPanel. /// Description of DraggAnimatedPanel.
/// </summary> /// </summary>
public partial class DraggAnimatedPanel : WrapPanel public partial class DraggAnimatedPanel : WrapPanel
{ {
#region private vars #region private vars
Size _calculatedSize; Size _calculatedSize;
bool _isNotFirstArrange = false; bool _isNotFirstArrange = false;
int columns, rows; int columns, rows;
#endregion #endregion
static DraggAnimatedPanel() static DraggAnimatedPanel()
{ {
DefaultStyleKeyProperty.OverrideMetadata(typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(typeof(DraggAnimatedPanel))); DefaultStyleKeyProperty.OverrideMetadata(typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(typeof(DraggAnimatedPanel)));
} }
public DraggAnimatedPanel() : base() public DraggAnimatedPanel() : base()
{ {
this.AddHandler(Mouse.MouseMoveEvent, new MouseEventHandler(OnMouseMove), false); this.AddHandler(Mouse.MouseMoveEvent, new MouseEventHandler(OnMouseMove), false);
this.MouseLeftButtonUp += OnMouseUp; this.MouseLeftButtonUp += OnMouseUp;
this.LostMouseCapture += OnLostMouseCapture; this.LostMouseCapture += OnLostMouseCapture;
} }
UIElement GetChildThatHasMouseOver() UIElement GetChildThatHasMouseOver()
{ {
return GetParent(Mouse.DirectlyOver as DependencyObject, (ve) => Children.Contains(ve as UIElement)) as UIElement; return GetParent(Mouse.DirectlyOver as DependencyObject, (ve) => Children.Contains(ve as UIElement)) as UIElement;
} }
Point GetItemVisualPoint(UIElement element) Point GetItemVisualPoint(UIElement element)
{ {
TransformGroup group = (TransformGroup)element.RenderTransform; TransformGroup group = (TransformGroup)element.RenderTransform;
TranslateTransform trans = (TranslateTransform)group.Children[0]; TranslateTransform trans = (TranslateTransform)group.Children[0];
return new Point(trans.X, trans.Y); return new Point(trans.X, trans.Y);
} }
int GetIndexFromPoint(double x, double y) int GetIndexFromPoint(double x, double y)
{ {
int columnIndex = (int)Math.Truncate(x / itemContainterWidth); int columnIndex = (int)Math.Truncate(x / itemContainterWidth);
int rowIndex = (int)Math.Truncate(y / itemContainterHeight); int rowIndex = (int)Math.Truncate(y / itemContainterHeight);
return columns * rowIndex + columnIndex; return columns * rowIndex + columnIndex;
} }
int GetIndexFromPoint(Point p) int GetIndexFromPoint(Point p)
{ {
return GetIndexFromPoint(p.X, p.Y); return GetIndexFromPoint(p.X, p.Y);
} }
#region dependency properties #region dependency properties
public static readonly DependencyProperty ItemsWidthProperty = public static readonly DependencyProperty ItemsWidthProperty =
DependencyProperty.Register( DependencyProperty.Register(
"ItemsWidth", "ItemsWidth",
typeof(double), typeof(double),
typeof(DraggAnimatedPanel), typeof(DraggAnimatedPanel),
new FrameworkPropertyMetadata(150d)); new FrameworkPropertyMetadata(150d));
public static readonly DependencyProperty ItemsHeightProperty = public static readonly DependencyProperty ItemsHeightProperty =
DependencyProperty.Register( DependencyProperty.Register(
"ItemsHeight", "ItemsHeight",
typeof(double), typeof(double),
typeof(DraggAnimatedPanel), typeof(DraggAnimatedPanel),
new FrameworkPropertyMetadata(60d)); new FrameworkPropertyMetadata(60d));
public static readonly DependencyProperty ItemSeparationProperty = public static readonly DependencyProperty ItemSeparationProperty =
DependencyProperty.Register( DependencyProperty.Register(
"ItemSeparation", "ItemSeparation",
typeof(Thickness), typeof(Thickness),
typeof(DraggAnimatedPanel), typeof(DraggAnimatedPanel),
new FrameworkPropertyMetadata()); new FrameworkPropertyMetadata());
// Using a DependencyProperty as the backing store for AnimationMilliseconds. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for AnimationMilliseconds. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AnimationMillisecondsProperty = public static readonly DependencyProperty AnimationMillisecondsProperty =
DependencyProperty.Register("AnimationMilliseconds", typeof(int), typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(200)); DependencyProperty.Register("AnimationMilliseconds", typeof(int), typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(200));
public static readonly DependencyProperty SwapCommandProperty = public static readonly DependencyProperty SwapCommandProperty =
DependencyProperty.Register( DependencyProperty.Register(
"SwapCommand", "SwapCommand",
typeof(ICommand), typeof(ICommand),
typeof(DraggAnimatedPanel), typeof(DraggAnimatedPanel),
new FrameworkPropertyMetadata(null)); new FrameworkPropertyMetadata(null));
#endregion #endregion
#region properties #region properties
public double ItemsWidth public double ItemsWidth
{ {
get { return (double)GetValue(ItemsWidthProperty); } get { return (double)GetValue(ItemsWidthProperty); }
set { SetValue(ItemsWidthProperty, value); } set { SetValue(ItemsWidthProperty, value); }
} }
public double ItemsHeight public double ItemsHeight
{ {
get { return (double)GetValue(ItemsHeightProperty); } get { return (double)GetValue(ItemsHeightProperty); }
set { SetValue(ItemsHeightProperty, value); } set { SetValue(ItemsHeightProperty, value); }
} }
public Thickness ItemSeparation public Thickness ItemSeparation
{ {
get { return (Thickness)this.GetValue(ItemSeparationProperty); } get { return (Thickness)this.GetValue(ItemSeparationProperty); }
set { this.SetValue(ItemSeparationProperty, value); } set { this.SetValue(ItemSeparationProperty, value); }
} }
public int AnimationMilliseconds public int AnimationMilliseconds
{ {
get { return (int)GetValue(AnimationMillisecondsProperty); } get { return (int)GetValue(AnimationMillisecondsProperty); }
set { SetValue(AnimationMillisecondsProperty, value); } set { SetValue(AnimationMillisecondsProperty, value); }
} }
private double itemContainterHeight private double itemContainterHeight
{ {
get { return ItemSeparation.Top + ItemsHeight + ItemSeparation.Bottom; } get { return ItemSeparation.Top + ItemsHeight + ItemSeparation.Bottom; }
} }
private double itemContainterWidth private double itemContainterWidth
{ {
get { return ItemSeparation.Left + ItemsWidth + ItemSeparation.Right; } get { return ItemSeparation.Left + ItemsWidth + ItemSeparation.Right; }
} }
public ICommand SwapCommand public ICommand SwapCommand
{ {
get { return (ICommand)GetValue(SwapCommandProperty); } get { return (ICommand)GetValue(SwapCommandProperty); }
set { SetValue(SwapCommandProperty, value); } set { SetValue(SwapCommandProperty, value); }
} }
#endregion #endregion
#region transformation things #region transformation things
private void AnimateAll() private void AnimateAll()
{ {
//Apply exactly the same algorithm, but instide of Arrange a call AnimateTo method //Apply exactly the same algorithm, but instide of Arrange a call AnimateTo method
double colPosition = 0; double colPosition = 0;
double rowPosition = 0; double rowPosition = 0;
foreach (UIElement child in Children) foreach (UIElement child in Children)
{ {
if (child != _draggedElement) if (child != _draggedElement)
AnimateTo(child, colPosition + ItemSeparation.Left, rowPosition + ItemSeparation.Top, _isNotFirstArrange ? AnimationMilliseconds : 0); AnimateTo(child, colPosition + ItemSeparation.Left, rowPosition + ItemSeparation.Top, _isNotFirstArrange ? AnimationMilliseconds : 0);
//drag will locate dragged element //drag will locate dragged element
colPosition += itemContainterWidth; colPosition += itemContainterWidth;
if (colPosition + 1 > _calculatedSize.Width) if (colPosition + 1 > _calculatedSize.Width)
{ {
colPosition = 0; colPosition = 0;
rowPosition += itemContainterHeight; rowPosition += itemContainterHeight;
} }
} }
} }
private void AnimateTo(UIElement child, double x, double y, int duration) private void AnimateTo(UIElement child, double x, double y, int duration)
{ {
TransformGroup group = (TransformGroup)child.RenderTransform; TransformGroup group = (TransformGroup)child.RenderTransform;
TranslateTransform trans = (TranslateTransform)group.Children.First((groupElement) => groupElement is TranslateTransform); TranslateTransform trans = (TranslateTransform)group.Children.First((groupElement) => groupElement is TranslateTransform);
trans.BeginAnimation(TranslateTransform.XProperty, MakeAnimation(x, duration)); trans.BeginAnimation(TranslateTransform.XProperty, MakeAnimation(x, duration));
trans.BeginAnimation(TranslateTransform.YProperty, MakeAnimation(y, duration)); trans.BeginAnimation(TranslateTransform.YProperty, MakeAnimation(y, duration));
} }
private DoubleAnimation MakeAnimation(double to, int duration) private DoubleAnimation MakeAnimation(double to, int duration)
{ {
DoubleAnimation anim = new DoubleAnimation(to, TimeSpan.FromMilliseconds(duration)); DoubleAnimation anim = new DoubleAnimation(to, TimeSpan.FromMilliseconds(duration));
anim.AccelerationRatio = 0.2; anim.AccelerationRatio = 0.2;
anim.DecelerationRatio = 0.7; anim.DecelerationRatio = 0.7;
return anim; return anim;
} }
#endregion #endregion
#region measure #region measure
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
Size itemContainerSize = new Size(itemContainterWidth, itemContainterHeight); Size itemContainerSize = new Size(itemContainterWidth, itemContainterHeight);
int count = 0; //for not call it again int count = 0; //for not call it again
foreach (UIElement child in Children) foreach (UIElement child in Children)
{ {
child.Measure(itemContainerSize); child.Measure(itemContainerSize);
count++; count++;
} }
if (availableSize.Width < itemContainterWidth) if (availableSize.Width < itemContainterWidth)
_calculatedSize = new Size(itemContainterWidth, count * itemContainterHeight); //the size of nX1 _calculatedSize = new Size(itemContainterWidth, count * itemContainterHeight); //the size of nX1
else else
{ {
columns = (int)Math.Truncate(availableSize.Width / itemContainterWidth); columns = (int)Math.Truncate(availableSize.Width / itemContainterWidth);
rows = count / columns; rows = count / columns;
if (count % columns != 0) if (count % columns != 0)
rows++; rows++;
_calculatedSize = new Size(columns * itemContainterWidth, rows * itemContainterHeight); _calculatedSize = new Size(columns * itemContainterWidth, rows * itemContainterHeight);
} }
return _calculatedSize; return _calculatedSize;
} }
#endregion #endregion
#region arrange #region arrange
protected override Size ArrangeOverride(Size finalSize) protected override Size ArrangeOverride(Size finalSize)
{ {
Size _finalItemSize = new Size(ItemsWidth, ItemsHeight); Size _finalItemSize = new Size(ItemsWidth, ItemsHeight);
//if is animated then arrange elements to 0,0, and then put them on its location using the transform //if is animated then arrange elements to 0,0, and then put them on its location using the transform
foreach (UIElement child in InternalChildren) foreach (UIElement child in InternalChildren)
{ {
// If this is the first time we've seen this child, add our transforms // If this is the first time we've seen this child, add our transforms
if (child.RenderTransform as TransformGroup == null) if (child.RenderTransform as TransformGroup == null)
{ {
child.RenderTransformOrigin = new Point(0.5, 0.5); child.RenderTransformOrigin = new Point(0.5, 0.5);
TransformGroup group = new TransformGroup(); TransformGroup group = new TransformGroup();
child.RenderTransform = group; child.RenderTransform = group;
group.Children.Add(new TranslateTransform()); group.Children.Add(new TranslateTransform());
} }
//locate all children in 0,0 point//TODO: use infinity and then scale each element to items size //locate all children in 0,0 point//TODO: use infinity and then scale each element to items size
child.Arrange(new Rect(new Point(0, 0), _finalItemSize)); //when use transformations change to childs.DesireSize child.Arrange(new Rect(new Point(0, 0), _finalItemSize)); //when use transformations change to childs.DesireSize
} }
AnimateAll(); AnimateAll();
if (!_isNotFirstArrange) if (!_isNotFirstArrange)
_isNotFirstArrange = true; _isNotFirstArrange = true;
return _calculatedSize; return _calculatedSize;
} }
#endregion #endregion
#region Static #region Static
//this can be an extension method //this can be an extension method
public static DependencyObject GetParent(DependencyObject o, Func<DependencyObject, bool> matchFunction) public static DependencyObject GetParent(DependencyObject o, Func<DependencyObject, bool> matchFunction)
{ {
DependencyObject t = o; DependencyObject t = o;
do do
{ {
t = VisualTreeHelper.GetParent(t); t = VisualTreeHelper.GetParent(t);
} while (t != null && !matchFunction.Invoke(t)); } while (t != null && !matchFunction.Invoke(t));
return t; return t;
} }
#endregion #endregion
//TODO: Add IsEditing property //TODO: Add IsEditing property
//TODO: Add Scale transform to items for fill items area //TODO: Add Scale transform to items for fill items area
} }
} }

View File

@@ -37,7 +37,19 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject>GeekDesk.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Taskbar.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Apex.WinForms, Version=1.6.0.0, Culture=neutral, PublicKeyToken=98d06957926c086d, processorArchitecture=MSIL">
<HintPath>packages\SharpShellTools.2.2.0.0\lib\Apex.WinForms.dll</HintPath>
</Reference>
<Reference Include="CommonServiceLocator, Version=2.0.6.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL"> <Reference Include="CommonServiceLocator, Version=2.0.6.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>packages\CommonServiceLocator.2.0.6\lib\net45\CommonServiceLocator.dll</HintPath> <HintPath>packages\CommonServiceLocator.2.0.6\lib\net45\CommonServiceLocator.dll</HintPath>
</Reference> </Reference>
@@ -50,18 +62,32 @@
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL"> <Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath> <HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference> </Reference>
<Reference Include="GlobalHotKey, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\GlobalHotKey.1.1.0\lib\GlobalHotKey.dll</HintPath>
</Reference>
<Reference Include="HandyControl, Version=3.1.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL"> <Reference Include="HandyControl, Version=3.1.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
<HintPath>packages\HandyControl.3.1.0\lib\net452\HandyControl.dll</HintPath> <HintPath>packages\HandyControl.3.1.0\lib\net472\HandyControl.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="ServerManager, Version=2.2.0.0, Culture=neutral, processorArchitecture=x86">
<HintPath>packages\SharpShellTools.2.2.0.0\lib\ServerManager.exe</HintPath>
</Reference>
<Reference Include="SharpShell, Version=2.2.0.0, Culture=neutral, PublicKeyToken=f14dc899472fe6fb, processorArchitecture=MSIL">
<HintPath>packages\SharpShellTools.2.2.0.0\lib\SharpShell.dll</HintPath>
</Reference>
<Reference Include="srm, Version=2.2.0.0, Culture=neutral, PublicKeyToken=68bd4561cc3495fc, processorArchitecture=MSIL">
<HintPath>packages\SharpShellTools.2.2.0.0\lib\srm.exe</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=4.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Drawing.Common, Version=4.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Drawing.Common.5.0.2\lib\net461\System.Drawing.Common.dll</HintPath> <HintPath>packages\System.Drawing.Common.6.0.0-preview.3.21201.4\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath> <HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference> </Reference>
@@ -85,23 +111,145 @@
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Command\DelegateCommand.cs" /> <Compile Include="Command\DelegateCommand.cs" />
<Compile Include="Command\DelegateCommandBase.cs" /> <Compile Include="Command\DelegateCommandBase.cs" />
<Compile Include="Constant\AppHideType.cs" />
<Compile Include="Constant\Constants.cs" />
<Compile Include="Constant\DefaultConstant.cs" /> <Compile Include="Constant\DefaultConstant.cs" />
<Compile Include="Constant\IconStartType.cs" />
<Compile Include="Constant\SortType.cs" /> <Compile Include="Constant\SortType.cs" />
<Compile Include="Control\Other\BacklogNotificatin.xaml.cs">
<DependentUpon>BacklogNotificatin.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\CustomIconUrlDialog.xaml.cs">
<DependentUpon>CustomIconUrlDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\Backlog\BacklogControl.xaml.cs">
<DependentUpon>BacklogControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\IconFont\IconPannel.xaml.cs">
<DependentUpon>IconPannel.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\BacklogInfoWindow.xaml.cs">
<DependentUpon>BacklogInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\BacklogWindow.xaml.cs">
<DependentUpon>BacklogWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\ConfigWindow.xaml.cs">
<DependentUpon>ConfigWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\IconInfoDialog.xaml.cs">
<DependentUpon>IconInfoDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\MenuGeometryDialog.xaml.cs">
<DependentUpon>MenuGeometryDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\Config\AboutControl.xaml.cs">
<DependentUpon>AboutControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\PannelCard\LeftCardControl.xaml.cs">
<DependentUpon>LeftCardControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\Config\ThemeControl.xaml.cs">
<DependentUpon>ThemeControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\PannelCard\RightCardControl.xaml.cs">
<DependentUpon>RightCardControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\Config\MotionControl.xaml.cs">
<DependentUpon>MotionControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\IconfontWindow.xaml.cs">
<DependentUpon>IconfontWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converts\DoubleToGridLength.cs" />
<Compile Include="Converts\IntToCornerRadius.cs" />
<Compile Include="Converts\OpcityConvert.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" /> <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" /> <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
<Compile Include="Converts\HideTypeConvert.cs" />
<Compile Include="Task\BacklogTask.cs" />
<Compile Include="Util\AeroGlassHelper.cs" />
<Compile Include="Util\CommonCode.cs" /> <Compile Include="Util\CommonCode.cs" />
<Compile Include="Util\ConsoleManager.cs" /> <Compile Include="Util\ConsoleManager.cs" />
<Compile Include="Util\DragAdorner.cs" /> <Compile Include="Util\DragAdorner.cs" />
<Compile Include="Util\FileIcon.cs" /> <Compile Include="Util\FileIcon.cs" />
<Compile Include="Util\HotKey.cs" />
<Compile Include="Util\HttpUtil.cs" />
<Compile Include="Util\ImageUtil.cs" />
<Compile Include="Util\ListViewDragDropManager.cs" /> <Compile Include="Util\ListViewDragDropManager.cs" />
<Compile Include="Util\MenuWidthConvert.cs" /> <Compile Include="Converts\MenuWidthConvert.cs" />
<Compile Include="Util\MouseUtil.cs" />
<Compile Include="Util\MouseUtilities.cs" /> <Compile Include="Util\MouseUtilities.cs" />
<Compile Include="Util\ShellContextMenu.cs" />
<Compile Include="Util\StringUtil.cs" />
<Compile Include="Util\SvgToGeometry.cs" />
<Compile Include="Util\SystemIcon.cs" /> <Compile Include="Util\SystemIcon.cs" />
<Compile Include="ViewModel\AppConfig.cs" /> <Compile Include="ViewModel\AppConfig.cs" />
<Compile Include="ViewModel\DataInfos.cs" /> <Compile Include="ViewModel\AppData.cs" />
<Compile Include="ViewModel\MainModel.cs" /> <Compile Include="ViewModel\BacklogInfo.cs" />
<Compile Include="ViewModel\MainViewModel.cs" /> <Compile Include="ViewModel\IconfontInfo.cs" />
<Compile Include="ViewModel\MenuViewModel.cs" /> <Compile Include="ViewModel\IconInfo.cs" />
<Compile Include="ViewModel\MenuInfo.cs" />
<Page Include="Control\Other\BacklogNotificatin.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Other\CustomIconUrlDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\UserControls\Backlog\BacklogControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\IconFont\IconPannel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\BacklogInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\BacklogWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\ConfigWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Other\IconInfoDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Other\MenuGeometryDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\Config\AboutControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\PannelCard\LeftCardControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\Config\ThemeControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\PannelCard\RightCardControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\Config\MotionControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\IconfontWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@@ -114,6 +262,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Resource\Dictionary\Geometry.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
@@ -133,6 +285,7 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<Resource Include="Resource\Iconfont\iconfont.json" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@@ -142,5 +295,30 @@
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\图片.png" />
<Resource Include="Resource\Image\文件夹.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Iconfont\iconfont.js" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\公众号.jpg" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\BacklogImg.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\Taskbar.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\TitleLogo.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\About.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Taskbar.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -4,216 +4,127 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk" xmlns:local="clr-namespace:GeekDesk"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
mc:Ignorable="d" mc:Ignorable="d"
xmlns:util="clr-namespace:GeekDesk.Util" xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel" x:Name="window" xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
x:Name="window"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:hc="https://handyorg.github.io/handycontrol"
Title="MainWindow" Height="450" Width="800"> Title="GeekDesk"
d:DesignHeight="500" d:DesignWidth="700"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
OpacityMask ="White"
Deactivated="window_Deactivated"
SizeChanged="window_SizeChanged"
>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" ResizeBorderThickness="10"/>
</WindowChrome.WindowChrome>
<Window.Resources> <Window.Resources>
<Style x:Key="ListBoxStyle" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox"/> <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
<Style TargetType="{x:Type ListBoxItem}" x:Key="memuStory" BasedOn="{StaticResource ListBoxStyle}"> <cvt:OpcityConvert x:Key="OpcityConvert"/>
<Style.Triggers> <cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
<!--鼠标移入--> <cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
<EventTrigger RoutedEvent="MouseMove">
<BeginStoryboard>
<Storyboard>
<!--鼠标移入放大-->
<DoubleAnimation To="20" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<!--鼠标移出-->
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<!--鼠标移出恢复正常大小-->
<DoubleAnimation To="15" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
<!--左侧栏样式动画-->
<Style x:Key="menuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
<Setter Property="FontSize" Value="15"/>
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform/>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="20" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="15" Duration="0:0:0.5" Storyboard.TargetProperty="FontSize"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
</Style.Triggers>
</Style>
<!--右侧栏样式动画-->
<Style x:Key="imageStyle" TargetType="Image">
<Setter Property="Width" Value="60"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Source" Value="{Binding BitmapImage}"/>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="80" Duration="0:0:0.1" Storyboard.TargetProperty="Width"/>
<DoubleAnimation To="80" Duration="0:0:0.1" Storyboard.TargetProperty="Height"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Width"/>
<DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Height"/>
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
</Style.Triggers>
</Style>
<util:MenuWidthConvert x:Key="MenuWidthConvert"/>
</Window.Resources> </Window.Resources>
<Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
Background="AliceBlue" LostFocus="App_LostFocus"
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0">
<!--背景图片-->
<Border.Background>
<VisualBrush>
<VisualBrush.Visual>
<Grid ClipToBounds="True">
<Image Source="{Binding AppConfig.BitmapImage}" Margin="-30" Opacity="{Binding AppConfig.BgOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
<Image.Effect>
<BlurEffect Radius="{Binding AppConfig.BlurValue}"/>
</Image.Effect>
</Image>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
<!--<ImageBrush ImageSource="{Binding AppConfig.BitmapImage}" Opacity="{Binding AppConfig.BgOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"></ImageBrush>-->
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="{Binding AppConfig.MenuCardWidth, Mode=TwoWay, Converter={StaticResource DoubleToGridLength}}" MaxWidth="200"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid>
<!--背景图片-->
<Grid.Background>
<ImageBrush ImageSource="D:\壁纸\18078.jpg"></ImageBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="leftColumn" MinWidth="80" Width="150" MaxWidth="200"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<DockPanel Grid.Row="0" Grid.Column="0">
<Label>Text</Label>
</DockPanel>
<!--左侧栏--> <DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
<hc:Card Opacity="1" x:Name="leftCard" Grid.Row="1" Grid.Column="0" <DockPanel.Background>
BorderThickness="1" <SolidColorBrush Opacity="0.01"/>
Effect="{DynamicResource EffectShadow2}" </DockPanel.Background>
Margin="5,5,0,5" <Image Source="/Resource/Image/TitleLogo.png" Margin="10,0,0,0" Width="94" Height="30" HorizontalAlignment="Left"/>
> </DockPanel>
<!--<hc:Card.ContextMenu>
<ContextMenu Width="200">
<TextBlock Text="新建菜单"/>
</ContextMenu>
</hc:Card.ContextMenu>-->
<!--<ListBox x:Name="menu" BorderThickness="0" ItemsSource="{Binding}" Margin="10,8,10,8"
>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding menu}" FontSize="15" Style="{StaticResource memuStory}" PreviewMouseLeftButtonDown="menuClick" RenderTransformOrigin="0.5,0.5">
</TextBlock> <DockPanel Grid.Row="0" Grid.Column="2" MouseMove="DragMove">
</DataTemplate> <DockPanel.Background>
</ListBox.ItemTemplate> <SolidColorBrush Opacity="0.01"/>
</ListBox>--> </DockPanel.Background>
<hc:UniformSpacingPanel Spacing="0" Grid.ColumnSpan="4" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="M917.930667 512c0-57.6 36.181333-106.496 86.869333-125.952a505.429333 505.429333 0 0 0-55.210667-133.461333A134.826667 134.826667 0 0 1 771.413333 74.410667 507.733333 507.733333 0 0 0 637.952 19.2 135.168 135.168 0 0 1 512 106.069333 134.912 134.912 0 0 1 386.048 19.2 505.429333 505.429333 0 0 0 252.586667 74.410667c22.186667 49.749333 13.141333 109.824-27.562667 150.528a135.168 135.168 0 0 1-150.528 27.648 502.016 502.016 0 0 0-55.296 133.461333c50.688 19.626667 86.869333 68.437333 86.869333 125.952 0 57.6-36.181333 106.496-86.869333 125.952 12.117333 47.530667 30.72 92.330667 55.210667 133.461333a134.826667 134.826667 0 0 1 178.090666 178.176 507.733333 507.733333 0 0 0 133.546667 55.210667A135.168 135.168 0 0 1 512 917.930667c57.6 0 106.496 36.181333 125.952 86.869333a505.429333 505.429333 0 0 0 133.461333-55.210667 134.912 134.912 0 0 1 27.562667-150.528 135.168 135.168 0 0 1 150.528-27.648 502.016 502.016 0 0 0 55.296-133.461333A134.912 134.912 0 0 1 917.930667 512zM512 647.338667a135.338667 135.338667 0 1 1 0.085333-270.762667A135.338667 135.338667 0 0 1 512 647.338667z"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
Click="ConfigButtonClick"
Initialized="SettingButton_Initialized"
x:Name="SettingButton"
>
<Button.ContextMenu>
<ContextMenu x:Name="SettingMenus" Width="130">
<MenuItem Header="设置" Click="ConfigMenuClick"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="M828.770654 148.714771C641.293737-20.89959 354.184117-19.590868 168.245698 152.630946c-212.062907 196.418185-212.062907 522.329912 0 718.748098 185.93842 172.221815 473.048039 173.520546 660.524956 3.916176 219.435707-198.536117 219.435707-528.054322 0-726.580449z m-121.880976 569.643707c-11.708566 11.708566-30.680039 11.708566-42.388605 0L502.729054 556.586459c-0.659356-0.659356-1.728312-0.659356-2.397659 0L338.609327 718.318517c-11.708566 11.708566-30.680039 11.708566-42.388605 0l-0.039961-0.039961c-11.708566-11.708566-11.708566-30.680039 0-42.388605l161.732059-161.732058c0.659356-0.659356 0.659356-1.728312 0-2.397659L296.1408 350.008195c-11.708566-11.708566-11.708566-30.680039 0-42.388605l0.039961-0.039961c11.708566-11.708566 30.680039-11.708566 42.388605 0l161.772019 161.77202c0.659356 0.659356 1.728312 0.659356 2.397659 0L664.551024 307.539668c11.708566-11.708566 30.680039-11.708566 42.388605 0l0.039961 0.039961c11.708566 11.708566 11.708566 30.680039 0 42.388605L545.15762 511.770224c-0.659356 0.659356-0.659356 1.728312 0 2.397659L706.919649 675.939902c11.708566 11.708566 11.708566 30.680039 0 42.388605l-0.029971 0.029971z"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
HorizontalAlignment="Right"
Click="CloseButtonClick"
/>
</hc:UniformSpacingPanel>
<ListBox x:Name="menu" ItemsSource="{Binding}"> </DockPanel>
<ListBox.Resources>
<ContextMenu x:Key="menuDialog" Width="200">
<MenuItem Header="新建菜单"/>
<MenuItem Header="重命名"/>
<MenuItem Header="删除" Click="deleteMenu"/>
</ContextMenu>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource menuStyle}">
<Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="30" ItemsWidth="{Binding ElementName=leftColumn, Path=Width, Converter={StaticResource MenuWidthConvert}}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand2, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate> <uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
<DataTemplate> <!--分割线-->
<TextBlock Text="{Binding menu}" PreviewMouseLeftButtonDown="menuClick" /> <GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</hc:Card>
<!--分割线-->
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
<!--右侧栏--> <uc:RightCardControl Grid.Row="1" Grid.Column="1"/>
<hc:Card AllowDrop="True" Drop="Wrap_Drop" Opacity="1" x:Name="rightCard" Grid.Row="1" Grid.Column="1" BorderThickness="1" Effect="{DynamicResource EffectShadow2}" Margin="5,5,5,5">
<WrapPanel Orientation="Horizontal">
<ListBox x:Name="data" ItemsSource="{Binding}"
BorderThickness="0"
SelectionChanged="data_SelectionChanged"
>
<!--<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource dataStyle}"/>
</ListBox.ItemContainerStyle>-->
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100" HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate> <hc:NotifyIcon Icon="/Resource/Image/Taskbar.png" Text="GeekDesk" Click="NotifyIcon_Click">
<DataTemplate> <hc:NotifyIcon.ContextMenu>
<Border Margin="5,5,5,5" CornerRadius="10"> <ContextMenu Width="130">
<StackPanel Tag="{Binding Path}" <MenuItem Header="打开面板" Click="ShowApp"/>
MouseLeftButtonDown="dataClick" <MenuItem Header="待办" Click="BacklogMenuClick"/>
HorizontalAlignment="Center" <MenuItem Header="设置" Click="ConfigApp"/>
hc:Poptip.HitMode="None" <MenuItem Header="退出" Click="ExitApp"/>
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" </ContextMenu>
hc:Poptip.Content="{Binding Path}" </hc:NotifyIcon.ContextMenu>
hc:Poptip.Placement="BottomLeft"
Margin="5,5,5,5"
Height="115"
>
<Image Style="{StaticResource imageStyle}"></Image>
<TextBlock Width="80" TextWrapping="Wrap" TextAlignment="Center" Height="35" LineHeight="15" FontSize="12" Text="{Binding Name}"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</hc:Card> </hc:NotifyIcon>
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
</Grid>
</Border>
</Border>
</Grid>
</Window> </Window>

View File

@@ -1,21 +1,23 @@
using System; using DraggAnimatedPanelExample;
using System.Collections.Generic; using GeekDesk.Constant;
using GeekDesk.Control;
using System.Windows; using GeekDesk.Control.Windows;
using GeekDesk.Task;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using GeekDesk.ViewModel;
using System.IO;
using GeekDesk.Util; using GeekDesk.Util;
using GalaSoft.MvvmLight; using GeekDesk.ViewModel;
using System.Windows.Controls; using GlobalHotKey;
using System.Windows.Media; using HandyControl.Data;
using SharpShell.SharpContextMenu;
using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using WPF.JoshSmith.ServiceProviders.UI; using System.Diagnostics;
using DraggAnimatedPanelExample; using System.Drawing;
using System.ComponentModel; using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
namespace GeekDesk namespace GeekDesk
{ {
@@ -25,300 +27,337 @@ namespace GeekDesk
/// ///
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private static MainModel mainModel;
ListViewDragDropManager<ViewModel.Menu> dragMgr; public static AppData appData = CommonCode.GetAppDataByFile();
ListViewDragDropManager<ViewModel.DataInfos> dragMgr2; public int hotKeyId = -1;
public HotKeyManager hkm = new HotKeyManager();
public MainWindow() public MainWindow()
{ {
LoadData();
InitializeComponent(); InitializeComponent();
this.Topmost = true;
mainModel = new MainModel();
//this.DataContext = mainModel;
//menu.Items = mainModel;
//System.Diagnostics.Process.Start(@"D:\SoftWare\WeGame\wegame.exe");
this.Loaded += Window_Loaded; this.Loaded += Window_Loaded;
this.SizeChanged += MainWindow_Resize; this.SizeChanged += MainWindow_Resize;
BacklogTask.BackLogCheck();
} }
DelegateCommand<int[]> _swap; private void LoadData()
public DelegateCommand<int[]> SwapCommand
{ {
get this.DataContext = appData;
if (appData.MenuList.Count == 0)
{ {
if (_swap == null) appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed});
_swap = new DelegateCommand<int[]>(
(indexes) =>
{
int fromS = indexes[0];
int to = indexes[1];
var elementSource = data.Items[to];
var dragged = data.Items[fromS];
if (fromS > to)
{
data.Items.Remove(dragged);
data.Items.Insert(to, dragged);
}
else
{
data.Items.Remove(dragged);
data.Items.Insert(to, dragged);
}
}
);
return _swap;
}
}
DelegateCommand<int[]> _swap2;
public DelegateCommand<int[]> SwapCommand2
{
get
{
if (_swap2 == null)
_swap2 = new DelegateCommand<int[]>(
(indexes) =>
{
int fromS = indexes[0];
int to = indexes[1];
var elementSource = menu.Items[to];
var dragged = menu.Items[fromS];
if (fromS > to)
{
menu.Items.Remove(dragged);
menu.Items.Insert(to, dragged);
}
else
{
menu.Items.Remove(dragged);
menu.Items.Insert(to, dragged);
}
}
);
return _swap2;
}
}
private void Wrap_Drop(object sender, DragEventArgs e)
{
Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
if (dropObject == null) return;
string path = (string)dropObject.GetValue(0);
if (File.Exists(path))
{
// 文件
BitmapImage bi = FileIcon.GetBitmapImage(path);
DataInfos infos = new DataInfos();
infos.Path = path;
infos.BitmapImage = bi;
infos.Name = Path.GetFileNameWithoutExtension(path);
data.Items.Add(infos);
data.Items.Refresh();
}
else if (Directory.Exists(path))
{
//文件夹
} }
this.Width = appData.AppConfig.WindowWidth;
this.Height = appData.AppConfig.WindowHeight;
} }
//菜单点击事件
private void menuClick(object sender, MouseButtonEventArgs e)
{
}
/// <summary>
/// 图标点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataClick(object sender, MouseButtonEventArgs e)
{
//string path = ((StackPanel)sender).Tag.ToString();
//System.Diagnostics.Process.Start(path);
}
/// <summary>
/// data选中事件 设置不可选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void data_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (data.SelectedIndex != -1) data.SelectedIndex = -1;
}
#region Window_Loaded
void Window_Loaded(object sender, RoutedEventArgs e) void Window_Loaded(object sender, RoutedEventArgs e)
{ {
AppConfig config = CommonCode.GetAppConfig(); if (!appData.AppConfig.StartedShowPanel)
this.Width = config.WindowWidth; {
this.Height = config.WindowHeight; this.Visibility = Visibility.Collapsed;
this.DataContext = config; }
try
{
HotKey hk = hkm.Register(Key.Y, ModifierKeys.Control);
hkm.KeyPressed += DisplayWindowHotKeyPress;
////加载完毕注册热键
//hotKeyId = Hotkey.Regist(this, appData.AppConfig.HotkeyModifiers, appData.AppConfig.Hotkey, () =>
//{
// if (this.Visibility == Visibility.Collapsed)
// {
// ShowApp();
// }
// else
// {
// this.Visibility = Visibility.Collapsed;
// }
//});
} catch (Exception)
{
HandyControl.Controls.Growl.WarningGlobal("启动快捷键已被其它程序占用(" + appData.AppConfig.HotkeyStr + ")!");
}
this.menu.Items.Add(new ViewModel.Menu() { menu = "test1" });
this.menu.Items.Add(new ViewModel.Menu() { menu = "test2" });
this.menu.Items.Add(new ViewModel.Menu() { menu = "test3" });
} }
#endregion // Window_Loaded
#region Window_Closing private void DisplayWindowHotKeyPress(object sender, KeyPressedEventArgs e)
void Window_Closing(object sender, CancelEventArgs e)
{ {
Rect rect = this.RestoreBounds; if (e.HotKey.Key == Key.Y)
AppConfig config = this.DataContext as AppConfig; {
config.WindowWidth = rect.Width; if (this.Visibility == Visibility.Collapsed)
config.WindowHeight = rect.Height; {
CommonCode.SaveAppConfig(config); ShowApp();
}
else
{
this.Visibility = Visibility.Collapsed;
}
}
} }
#endregion // Window_Closing
void MainWindow_Resize(object sender, System.EventArgs e) void MainWindow_Resize(object sender, System.EventArgs e)
{ {
if (this.DataContext != null) if (this.DataContext != null)
{ {
AppConfig config = this.DataContext as AppConfig; AppData appData = this.DataContext as AppData;
config.WindowWidth = this.Width; appData.AppConfig.WindowWidth = this.Width;
config.WindowHeight = this.Height; appData.AppConfig.WindowHeight = this.Height;
CommonCode.SaveAppConfig(config);
}
}
#region dragMgr_ProcessDrop
// Performs custom drop logic for the top ListView.
void dragMgr_ProcessDrop(object sender, ProcessDropEventArgs<object> e)
{
// This shows how to customize the behavior of a drop.
// Here we perform a swap, instead of just moving the dropped item.
int higherIdx = Math.Max(e.OldIndex, e.NewIndex);
int lowerIdx = Math.Min(e.OldIndex, e.NewIndex);
if (lowerIdx < 0)
{
// The item came from the lower ListView
// so just insert it.
e.ItemsSource.Insert(higherIdx, e.DataItem);
}
else
{
// null values will cause an error when calling Move.
// It looks like a bug in ObservableCollection to me.
if (e.ItemsSource[lowerIdx] == null ||
e.ItemsSource[higherIdx] == null)
return;
// The item came from the ListView into which
// it was dropped, so swap it with the item
// at the target index.
e.ItemsSource.Move(lowerIdx, higherIdx);
e.ItemsSource.Move(higherIdx - 1, lowerIdx);
}
// Set this to 'Move' so that the OnListViewDrop knows to
// remove the item from the other ListView.
e.Effects = DragDropEffects.Move;
}
#endregion // dragMgr_ProcessDrop
#region OnListViewDragEnter
// Handles the DragEnter event for both ListViews.
void OnListViewDragEnter(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.Move;
}
#endregion // OnListViewDragEnter
#region OnListViewDrop
// Handles the Drop event for both ListViews.
void OnListViewDrop(object sender, DragEventArgs e)
{
if (e.Effects == DragDropEffects.None)
return;
ViewModel.Menu menuV = e.Data.GetData(typeof(ViewModel.Menu)) as ViewModel.Menu;
DataInfos data = e.Data.GetData(typeof(DataInfos)) as DataInfos;
if (sender == this.menu)
{
if (this.dragMgr.IsDragInProgress)
return;
// An item was dragged from the bottom ListView into the top ListView
// so remove that item from the bottom ListView.
(this.data.ItemsSource as ObservableCollection<DataInfos>).Remove(data);
}
else
{
if (this.dragMgr2.IsDragInProgress)
return;
// An item was dragged from the top ListView into the bottom ListView
// so remove that item from the top ListView.
(this.menu.ItemsSource as ObservableCollection<ViewModel.Menu>).Remove(menuV);
} }
} }
#endregion // OnListViewDrop
private void leftCard_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
private void DragMove(object sender, MouseEventArgs e)
{ {
//if (e.LeftButton == MouseButtonState.Pressed)
}
private void deleteMenu(object sender, RoutedEventArgs e)
{
//if (data.SelectedIndex == -1)
//{ //{
// return; // this.DragMove();
//} //}
ViewModel.Menu pojo = (ViewModel.Menu)((ContextMenu)((MenuItem)sender).Parent).DataContext;
string menuTitle = pojo.menu; if (e.LeftButton == MouseButtonState.Pressed)
int index = 0;
foreach (object obj in menu.Items)
{ {
string test = ((ViewModel.Menu)obj).menu; var windowMode = this.ResizeMode;
if (test == menuTitle) if (this.ResizeMode != ResizeMode.NoResize)
{ {
menu.Items.RemoveAt(index); this.ResizeMode = ResizeMode.NoResize;
menu.Items.Refresh();
return;
} }
index++;
this.UpdateLayout();
/* 当点击拖拽区域的时候,让窗口跟着移动
(When clicking the drag area, make the window follow) */
DragMove();
if (this.ResizeMode != windowMode)
{
this.ResizeMode = windowMode;
}
this.UpdateLayout();
}
}
/// <summary>
/// 关闭按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CloseButtonClick(object sender, RoutedEventArgs e)
{
this.Visibility = Visibility.Collapsed;
}
///// <summary>
///// 左侧栏宽度改变 持久化
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void LeftCardResize(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
//{
// appData.AppConfig.MenuCardWidth = LeftColumn.Width.Value;
//}
/// <summary>
/// 右键任务栏图标 显示主面板
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShowApp(object sender, RoutedEventArgs e)
{
ShowApp();
}
public void ShowApp()
{
if (appData.AppConfig.FollowMouse)
{
ShowAppAndFollowMouse();
} else
{
this.Visibility = Visibility.Visible;
}
Keyboard.Focus(this);
}
/// <summary>
/// 随鼠标位置显示面板 (鼠标始终在中间)
/// </summary>
private void ShowAppAndFollowMouse()
{
//获取鼠标位置
System.Windows.Point p = MouseUtil.GetMousePosition();
double left = SystemParameters.VirtualScreenLeft;
double top = SystemParameters.VirtualScreenTop;
double width = SystemParameters.VirtualScreenWidth;
double height = SystemParameters.VirtualScreenHeight;
double right = width - Math.Abs(left);
double bottom = height - Math.Abs(top);
if (p.X - this.Width / 2 < left)
{
//判断是否在最左边缘
this.Left = left;
}
else if (p.X + this.Width / 2 > right)
{
//判断是否在最右边缘
this.Left = right - this.Width;
}
else
{
this.Left = p.X - this.Width / 2;
} }
if (p.Y - this.Height / 2 < top)
{
//判断是否在最上边缘
this.Top = top;
}
else if (p.Y + this.Height / 2 > bottom)
{
//判断是否在最下边缘
this.Top = bottom - this.Height;
}
else
{
this.Top = p.Y - this.Height / 2;
}
this.Visibility = Visibility.Visible;
} }
public Double ConvertString(string val)
/// <summary>
/// 图片图标单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void NotifyIcon_Click(object sender, RoutedEventArgs e)
{ {
return Convert.ToDouble(val); if (this.Visibility == Visibility.Collapsed)
{
ShowApp();
}
else
{
this.Visibility = Visibility.Collapsed;
}
} }
/// <summary>
/// 右键任务栏图标 设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ConfigApp(object sender, RoutedEventArgs e)
{
ConfigWindow.Show(appData.AppConfig, this);
}
/// <summary>
/// 右键任务栏图标退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ExitApp(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
//public static void ShowContextMenu(IntPtr hAppWnd, Window taskBar, System.Windows.Point pt)
//{
// WindowInteropHelper helper = new WindowInteropHelper(taskBar);
// IntPtr callingTaskBarWindow = helper.Handle;
// IntPtr wMenu = GetSystemMenu(hAppWnd, false);
// // Display the menu
// uint command = TrackPopupMenuEx(wMenu, TPM.LEFTBUTTON | TPM.RETURNCMD, (int) pt.X, (int) pt.Y, callingTaskBarWindow, IntPtr.Zero);
// if (command == 0) return;
// PostMessage(hAppWnd, WM.SYSCOMMAND, new IntPtr(command), IntPtr.Zero);
//}
/// <summary>
/// 设置图标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ConfigButtonClick(object sender, RoutedEventArgs e)
{
SettingMenus.IsOpen = true;
}
/// <summary>
/// 设置菜单点击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ConfigMenuClick(object sender, RoutedEventArgs e)
{
ConfigWindow.Show(appData.AppConfig, this);
}
/// <summary>
/// 待办任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BacklogMenuClick(object sender, RoutedEventArgs e)
{
BacklogWindow.Show();
}
/// <summary>
/// 禁用设置按钮右键菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SettingButton_Initialized(object sender, EventArgs e)
{
SettingButton.ContextMenu = null;
}
private void App_LostFocus(object sender, RoutedEventArgs e)
{
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
{
this.Visibility = Visibility.Collapsed;
}
}
private void window_Deactivated(object sender, EventArgs e)
{
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
{
this.Visibility = Visibility.Collapsed;
}
}
private void window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.DataContext != null)
{
AppData appData = this.DataContext as AppData;
appData.AppConfig.WindowWidth = this.Width;
appData.AppConfig.WindowHeight = this.Height;
}
}
} }
public class MainModel : ViewModelBase
{
public List<ViewModel.Menu> MenuList { get; set; }
public List<ViewModel.DataInfos> DataList { get; set; }
}
} }

View File

@@ -1,6 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;

View File

@@ -0,0 +1,28 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Geometry x:Key="About">
M512 992C246.912 992 32 777.088 32 512 32 246.912 246.912 32 512 32c265.088 0 480 214.912 480 480 0 265.088-214.912 480-480 480z m-59.072-512v236.32a54.144 54.144 0 1 0 108.288 0V480a54.144 54.144 0 1 0-108.288 0z m53.76-226.464c-14.72 0-27.232 4.544-37.568 15.136-11.04 9.856-16.192 22.72-16.192 38.656 0 15.136 5.152 28 16.192 38.624 10.336 10.592 22.848 15.904 37.6 15.904a57.6 57.6 0 0 0 39.04-15.168c10.304-10.592 15.456-23.456 15.456-39.36s-5.12-28.8-15.456-38.656c-10.304-10.56-23.584-15.136-39.04-15.136z
</Geometry>
<Geometry x:Key="Pannel">
M106.666667 106.666667m21.333333 0l128 0q21.333333 0 21.333333 21.333333l0 768q0 21.333333-21.333333 21.333333l-128 0q-21.333333 0-21.333333-21.333333l0-768q0-21.333333 21.333333-21.333333Z
M341.333333 106.666667m21.333334 0l533.333333 0q21.333333 0 21.333333 21.333333l0 170.666667q0 21.333333-21.333333 21.333333l-533.333333 0q-21.333333 0-21.333334-21.333333l0-170.666667q0-21.333333 21.333334-21.333333Z
M341.333333 384m21.333334 0l533.333333 0q21.333333 0 21.333333 21.333333l0 490.666667q0 21.333333-21.333333 21.333333l-533.333333 0q-21.333333 0-21.333334-21.333333l0-490.666667q0-21.333333 21.333334-21.333333Z
</Geometry>
<Geometry x:Key="Motion">
M604.337231 269.666462a33.595077 33.595077 0 0 1-33.634462-33.595077 140.366769 140.366769 0 0 0-140.169846-140.209231 140.366769 140.366769 0 0 0-140.209231 140.209231 33.595077 33.595077 0 0 1-67.150769 0A207.596308 207.596308 0 0 1 430.532923 28.711385a207.596308 207.596308 0 0 1 207.399385 207.36 33.713231 33.713231 0 0 1-33.595077 33.595077z m-287.586462 259.150769V283.608615A114.569846 114.569846 0 0 1 431.241846 169.117538 114.609231 114.609231 0 0 1 545.693538 283.569231v46.158769a34.067692 34.067692 0 0 1 5.435077-0.393846c37.336615 0 70.380308 18.668308 90.19077 47.261538a109.764923 109.764923 0 0 1 119.414153 41.314462c7.758769-1.654154 15.675077-2.520615 23.709539-2.520616h7.207385a113.821538 113.821538 0 0 1 113.703384 113.664v131.15077a29.577846 29.577846 0 0 1 0.196923 3.820307v67.741539c0 153.521231-67.702154 250.052923-190.621538 271.753846-38.4 6.616615-74.161231 10.003692-107.52 10.003692-101.454769 0-181.011692-31.507692-245.681231-96.17723L154.249846 710.025846a122.052923 122.052923 0 0 1 0-172.347077 122.092308 122.092308 0 0 1 162.500923-8.861538z m386.520616 408.457846c89.6-15.753846 135.089231-84.873846 135.08923-205.508923v-19.337846a34.067692 34.067692 0 0 1-0.078769-2.756923v-180.657231c0-25.718154-20.873846-46.473846-46.473846-46.473846h-7.246769c-1.102769 0-2.166154 0-3.308308 0.118154v110.788923a33.634462 33.634462 0 1 1-67.268923-0.118154v-111.773539a42.023385 42.023385 0 0 0-53.169231-40.487384v115.672615a33.595077 33.595077 0 0 1-67.190154 0v-117.76c0-23.433846-19.062154-42.456615-42.496-42.456615a33.792 33.792 0 0 1-5.435077-0.472616v126.267077a33.595077 33.595077 0 1 1-67.229538 0V283.608615a47.379692 47.379692 0 0 0-94.759385 0v321.457231a33.555692 33.555692 0 0 1-57.107692 27.569231l-47.497846-47.458462a54.744615 54.744615 0 0 0-77.390769 77.351385l207.478154 207.399385c69.080615 69.001846 162.500923 90.348308 294.084923 67.347692z
</Geometry>
<Geometry x:Key="List">
M187.392 70.656q28.672 0 48.64 19.456T256 138.24v52.224q0 28.672-19.968 48.64t-48.64 19.968H133.12q-27.648 0-47.616-19.968t-19.968-48.64V138.24q0-28.672 19.968-48.128t47.616-19.456h54.272z m702.464 0q27.648 0 47.616 19.456t19.968 48.128v52.224q0 28.672-19.968 48.64t-47.616 19.968H452.608q-28.672 0-48.64-19.968T384 190.464V138.24q0-28.672 19.968-48.128t48.64-19.456h437.248zM187.392 389.12q28.672 0 48.64 19.968T256 457.728v52.224q0 27.648-19.968 47.616t-48.64 19.968H133.12q-27.648 0-47.616-19.968t-19.968-47.616v-52.224q0-28.672 19.968-48.64t47.616-19.968h54.272z m702.464 0q27.648 0 47.616 19.968t19.968 48.64v52.224q0 27.648-19.968 47.616t-47.616 19.968H452.608q-28.672 0-48.64-19.968T384 509.952v-52.224q0-28.672 19.968-48.64t48.64-19.968h437.248zM187.392 708.608q28.672 0 48.64 19.968T256 776.192v52.224q0 28.672-19.968 48.64t-48.64 19.968H133.12q-27.648 0-47.616-19.968t-19.968-48.64v-52.224q0-27.648 19.968-47.616t47.616-19.968h54.272z m702.464 0q27.648 0 47.616 19.968t19.968 47.616v52.224q0 28.672-19.968 48.64t-47.616 19.968H452.608q-28.672 0-48.64-19.968T384 828.416v-52.224q0-27.648 19.968-47.616t48.64-19.968h437.248z
</Geometry>
<Geometry x:Key="History">
M512 64C262.4 64 64 262.4 64 512s198.4 448 448 448 448-198.4 448-448S761.6 64 512 64z m256 544h-256c-19.2 0-32-12.8-32-32V256c0-19.2 12.8-32 32-32s32 12.8 32 32v288h224c19.2 0 32 12.8 32 32s-12.8 32-32 32z
</Geometry>
</ResourceDictionary>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,604 @@
{
"id": "2642707",
"name": "GeekDesk",
"font_family": "iconfont",
"css_prefix_text": "icon-",
"description": "图标",
"glyphs": [
{
"icon_id": "60399",
"name": "微信",
"font_class": "weixin",
"unicode": "e643",
"unicode_decimal": 58947
},
{
"icon_id": "442756",
"name": "活动",
"font_class": "huodong",
"unicode": "e63e",
"unicode_decimal": 58942
},
{
"icon_id": "1036569",
"name": "搜索",
"font_class": "sousuo",
"unicode": "e644",
"unicode_decimal": 58948
},
{
"icon_id": "1193697",
"name": "钉钉",
"font_class": "dingding",
"unicode": "e622",
"unicode_decimal": 58914
},
{
"icon_id": "3214599",
"name": "百度",
"font_class": "baidu",
"unicode": "e626",
"unicode_decimal": 58918
},
{
"icon_id": "3273215",
"name": "梯子",
"font_class": "tizi",
"unicode": "e707",
"unicode_decimal": 59143
},
{
"icon_id": "3299053",
"name": "衣服",
"font_class": "yifu",
"unicode": "e64e",
"unicode_decimal": 58958
},
{
"icon_id": "3299058",
"name": "衣服 copy",
"font_class": "yifucopy",
"unicode": "e64f",
"unicode_decimal": 58959
},
{
"icon_id": "3563332",
"name": "其它",
"font_class": "qita2",
"unicode": "e601",
"unicode_decimal": 58881
},
{
"icon_id": "3629444",
"name": "鞋子",
"font_class": "xiezi",
"unicode": "e660",
"unicode_decimal": 58976
},
{
"icon_id": "4468481",
"name": "其它",
"font_class": "qita3",
"unicode": "e634",
"unicode_decimal": 58932
},
{
"icon_id": "4859057",
"name": "梯子",
"font_class": "tizi1",
"unicode": "e617",
"unicode_decimal": 58903
},
{
"icon_id": "7603899",
"name": "鞋子",
"font_class": "xiezi1",
"unicode": "e63f",
"unicode_decimal": 58943
},
{
"icon_id": "8099091",
"name": "衣服",
"font_class": "yifu1",
"unicode": "e608",
"unicode_decimal": 58888
},
{
"icon_id": "9295722",
"name": "QQ",
"font_class": "QQ",
"unicode": "e68c",
"unicode_decimal": 59020
},
{
"icon_id": "10094246",
"name": "其它",
"font_class": "qita4",
"unicode": "e779",
"unicode_decimal": 59257
},
{
"icon_id": "13541930",
"name": "检验",
"font_class": "menu_checkout_icon",
"unicode": "e670",
"unicode_decimal": 58992
},
{
"icon_id": "16351299",
"name": "活动",
"font_class": "huodong1",
"unicode": "e616",
"unicode_decimal": 58902
},
{
"icon_id": "18532512",
"name": "百度 -01",
"font_class": "baidu-01",
"unicode": "e702",
"unicode_decimal": 59138
},
{
"icon_id": "19923915",
"name": "检验",
"font_class": "jianyan",
"unicode": "e78d",
"unicode_decimal": 59277
},
{
"icon_id": "20224885",
"name": "搜索",
"font_class": "sousuo1",
"unicode": "e610",
"unicode_decimal": 58896
},
{
"icon_id": "21898770",
"name": "检验",
"font_class": "jianyan1",
"unicode": "e70c",
"unicode_decimal": 59148
},
{
"icon_id": "176160",
"name": "下载",
"font_class": "xiazai",
"unicode": "e6a2",
"unicode_decimal": 59042
},
{
"icon_id": "791886",
"name": "会话",
"font_class": "huihua-copy",
"unicode": "e647",
"unicode_decimal": 58951
},
{
"icon_id": "880997",
"name": "游戏 遥控 玩具",
"font_class": "youxiyaokongwanju",
"unicode": "e899",
"unicode_decimal": 59545
},
{
"icon_id": "1054324",
"name": "文件夹",
"font_class": "folder",
"unicode": "e98f",
"unicode_decimal": 59791
},
{
"icon_id": "1108054",
"name": "游戏",
"font_class": "youxi",
"unicode": "e632",
"unicode_decimal": 58930
},
{
"icon_id": "1599042",
"name": "下载",
"font_class": "xiazai1",
"unicode": "e678",
"unicode_decimal": 59000
},
{
"icon_id": "1816323",
"name": "文档",
"font_class": "wendang",
"unicode": "e614",
"unicode_decimal": 58900
},
{
"icon_id": "1879004",
"name": "搞笑",
"font_class": "gaoxiao",
"unicode": "e607",
"unicode_decimal": 58887
},
{
"icon_id": "1912401",
"name": "浏览器",
"font_class": "xinxinicon",
"unicode": "e60c",
"unicode_decimal": 58892
},
{
"icon_id": "2148348",
"name": "笔记",
"font_class": "biji",
"unicode": "e61f",
"unicode_decimal": 58911
},
{
"icon_id": "2773508",
"name": "税",
"font_class": "shui",
"unicode": "e60d",
"unicode_decimal": 58893
},
{
"icon_id": "2877314",
"name": "网络",
"font_class": "wangluo",
"unicode": "e618",
"unicode_decimal": 58904
},
{
"icon_id": "3643365",
"name": "游戏",
"font_class": "youxi1",
"unicode": "e600",
"unicode_decimal": 58880
},
{
"icon_id": "3700479",
"name": "下载",
"font_class": "xiazai2",
"unicode": "e641",
"unicode_decimal": 58945
},
{
"icon_id": "3768311",
"name": "游戏",
"font_class": "youxi2",
"unicode": "e60e",
"unicode_decimal": 58894
},
{
"icon_id": "5032457",
"name": "图片",
"font_class": "tupian",
"unicode": "e61d",
"unicode_decimal": 58909
},
{
"icon_id": "5100415",
"name": "工具",
"font_class": "gongju",
"unicode": "eb01",
"unicode_decimal": 60161
},
{
"icon_id": "7175008",
"name": "搞笑",
"font_class": "gaoxiaoquwei",
"unicode": "e65c",
"unicode_decimal": 58972
},
{
"icon_id": "7321402",
"name": "使用翻墙软件",
"font_class": "shiyongfanqiangruanjian",
"unicode": "e98d",
"unicode_decimal": 59789
},
{
"icon_id": "7603848",
"name": "审核 笔记 记事本 写字",
"font_class": "shenhebijijishibenxiezi",
"unicode": "e63c",
"unicode_decimal": 58940
},
{
"icon_id": "7699636",
"name": "网络",
"font_class": "wangluo1",
"unicode": "e62c",
"unicode_decimal": 58924
},
{
"icon_id": "7842457",
"name": "文件夹",
"font_class": "wenjianjia",
"unicode": "e615",
"unicode_decimal": 58901
},
{
"icon_id": "8462080",
"name": "工具",
"font_class": "gongju1",
"unicode": "e6a9",
"unicode_decimal": 59049
},
{
"icon_id": "9202140",
"name": "搞笑",
"font_class": "gaoxiao1",
"unicode": "e621",
"unicode_decimal": 58913
},
{
"icon_id": "9319292",
"name": "税",
"font_class": "shui1",
"unicode": "e620",
"unicode_decimal": 58912
},
{
"icon_id": "9521743",
"name": "系统",
"font_class": "xitong",
"unicode": "e68b",
"unicode_decimal": 59019
},
{
"icon_id": "10211567",
"name": "浏览器",
"font_class": "liulanqi",
"unicode": "e6e2",
"unicode_decimal": 59106
},
{
"icon_id": "10250868",
"name": "税",
"font_class": "shui2",
"unicode": "e67d",
"unicode_decimal": 59005
},
{
"icon_id": "10271432",
"name": "工具",
"font_class": "gongju2",
"unicode": "e602",
"unicode_decimal": 58882
},
{
"icon_id": "10646986",
"name": "音乐",
"font_class": "yinle",
"unicode": "e603",
"unicode_decimal": 58883
},
{
"icon_id": "11268672",
"name": "其它",
"font_class": "qita",
"unicode": "e619",
"unicode_decimal": 58905
},
{
"icon_id": "11334214",
"name": "网络",
"font_class": "wangluo2",
"unicode": "e62b",
"unicode_decimal": 58923
},
{
"icon_id": "11682456",
"name": "影音",
"font_class": "yingyin",
"unicode": "e689",
"unicode_decimal": 59017
},
{
"icon_id": "11746216",
"name": "其它",
"font_class": "qita1",
"unicode": "e85f",
"unicode_decimal": 59487
},
{
"icon_id": "12321385",
"name": "文档",
"font_class": "wendang1",
"unicode": "e624",
"unicode_decimal": 58916
},
{
"icon_id": "13119454",
"name": "文档",
"font_class": "wendang2",
"unicode": "e662",
"unicode_decimal": 58978
},
{
"icon_id": "13312750",
"name": "数据库",
"font_class": "shujuku",
"unicode": "e6bc",
"unicode_decimal": 59068
},
{
"icon_id": "13732611",
"name": "影音",
"font_class": "yingyin1",
"unicode": "e74e",
"unicode_decimal": 59214
},
{
"icon_id": "13749574",
"name": "开发",
"font_class": "kaifa",
"unicode": "e990",
"unicode_decimal": 59792
},
{
"icon_id": "13775486",
"name": "会话",
"font_class": "huihua",
"unicode": "e604",
"unicode_decimal": 58884
},
{
"icon_id": "14367558",
"name": "影音",
"font_class": "yingyin2",
"unicode": "e6c7",
"unicode_decimal": 59079
},
{
"icon_id": "14440333",
"name": "浏览器",
"font_class": "liulanqi1",
"unicode": "e638",
"unicode_decimal": 58936
},
{
"icon_id": "14852588",
"name": "网络",
"font_class": "wangluo3",
"unicode": "e640",
"unicode_decimal": 58944
},
{
"icon_id": "15322445",
"name": "笔记",
"font_class": "biji1",
"unicode": "e60f",
"unicode_decimal": 58895
},
{
"icon_id": "15562668",
"name": "会话",
"font_class": "huihua1",
"unicode": "e633",
"unicode_decimal": 58931
},
{
"icon_id": "15826306",
"name": "音乐",
"font_class": "yinle1",
"unicode": "e6af",
"unicode_decimal": 59055
},
{
"icon_id": "15883683",
"name": "税",
"font_class": "shui3",
"unicode": "e6e6",
"unicode_decimal": 59110
},
{
"icon_id": "16677119",
"name": "系统",
"font_class": "xitong1",
"unicode": "e88c",
"unicode_decimal": 59532
},
{
"icon_id": "17267539",
"name": "文件夹",
"font_class": "wenjianjia1",
"unicode": "e629",
"unicode_decimal": 58921
},
{
"icon_id": "17373793",
"name": "开发",
"font_class": "kaifa1",
"unicode": "e65a",
"unicode_decimal": 58970
},
{
"icon_id": "17667583",
"name": "文件_夹",
"font_class": "jia",
"unicode": "e841",
"unicode_decimal": 59457
},
{
"icon_id": "19329201",
"name": "音乐",
"font_class": "yinle2",
"unicode": "e666",
"unicode_decimal": 58982
},
{
"icon_id": "19542090",
"name": "系统",
"font_class": "xitong2",
"unicode": "e605",
"unicode_decimal": 58885
},
{
"icon_id": "20017778",
"name": "人-翻墙",
"font_class": "ren-fanqiang",
"unicode": "e88d",
"unicode_decimal": 59533
},
{
"icon_id": "20030744",
"name": "下载",
"font_class": "lib-download-fill",
"unicode": "e736",
"unicode_decimal": 59190
},
{
"icon_id": "20170023",
"name": "文档",
"font_class": "wendang3",
"unicode": "e612",
"unicode_decimal": 58898
},
{
"icon_id": "20179496",
"name": "系统",
"font_class": "xitong3",
"unicode": "e676",
"unicode_decimal": 58998
},
{
"icon_id": "20295184",
"name": "浏览器",
"font_class": "liulanqi2",
"unicode": "e700",
"unicode_decimal": 59136
},
{
"icon_id": "20537189",
"name": "图片",
"font_class": "tupian1",
"unicode": "e681",
"unicode_decimal": 59009
},
{
"icon_id": "20634659",
"name": "工具",
"font_class": "gongju3",
"unicode": "e613",
"unicode_decimal": 58899
},
{
"icon_id": "20881217",
"name": "数据库",
"font_class": "shujuku1",
"unicode": "e749",
"unicode_decimal": 59209
},
{
"icon_id": "21163108",
"name": "开发",
"font_class": "kaifa2",
"unicode": "e75f",
"unicode_decimal": 59231
},
{
"icon_id": "22091292",
"name": "图 片",
"font_class": "tupian2",
"unicode": "e606",
"unicode_decimal": 58886
}
]
}

BIN
Resource/Image/About.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
Resource/Image/Taskbar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
Resource/Image/图片.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

57
Task/BacklogTask.cs Normal file
View File

@@ -0,0 +1,57 @@
using GeekDesk.Control;
using GeekDesk.Control.Other;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
namespace GeekDesk.Task
{
public class BacklogTask
{
///public static ObservableCollection<BacklogInfo> activityBacklog = new ObservableCollection<BacklogInfo>();
public static Dictionary<BacklogInfo, Notification> activityBacklog = new Dictionary<BacklogInfo, Notification>();
public static void BackLogCheck()
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Enabled = true;
timer.Interval = 5000;
timer.Start();
timer.Elapsed += new System.Timers.ElapsedEventHandler(Check);
}
private static void Check(object source, ElapsedEventArgs e)
{
App.Current.Dispatcher.Invoke((Action)(() =>
{
if (MainWindow.appData.ExeBacklogList.Count > 0)
{
string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
ObservableCollection<BacklogInfo> exeBacklogList = MainWindow.appData.ExeBacklogList;
foreach (BacklogInfo info in exeBacklogList)
{
if (info.ExeTime.CompareTo(nowTime) == -1 && !activityBacklog.ContainsKey(info))
{
activityBacklog.Add(info, Notification.Show(new BacklogNotificatin(info), ShowAnimation.Fade, true));
}
}
}
}));
}
}
}

BIN
Taskbar.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

175
Util/AeroGlassHelper.cs Normal file
View File

@@ -0,0 +1,175 @@
/*
* Virtual Router v1.0 - http://virtualrouter.codeplex.com
* Wifi Hot Spot for Windows 8, 7 and 2008 R2
* Copyright (c) 2013 Chris Pietschmann (http://pietschsoft.com)
* Licensed under the Microsoft Public License (Ms-PL)
* http://virtualrouter.codeplex.com/license
*/
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
namespace GeekDesk.Util
{
public static class AeroGlassHelper
{
#region "Generic Static Methods"
public static void ExtendGlass(IntPtr windowHandle)
{
ExtendGlass(windowHandle, -1, -1, -1, -1);
}
public static void ExtendGlass(IntPtr windowHandle, int left, int right, int top, int bottom)
{
internalExtendGlass(windowHandle, left, right, top, bottom);
}
private static int internalExtendGlass(IntPtr windowHandle, int left, int right, int top, int bottom)
{
var retVal = -1; // Returning less than zero will indicate that Aero Glass could not be extended
// Calculate the Aero Glass Margins
Win32.Margins margins = Win32.GetDpiAdjustedMargins(windowHandle, left, right, top, bottom);
try
{
// Actually Enable Aero Glass
retVal = Win32.DwmExtendFrameIntoClientArea(windowHandle, ref margins);
}
catch (Exception)
{
retVal = -1;
}
return retVal;
}
#endregion
#region "WPF Static Methods"
public static void ExtendGlass(Window win)
{
ExtendGlass(win, -1, -1, -1, -1);
}
public static void ExtendGlass(Window win, int left, int right, int top, int bottom)
{
Brush originalBackgroundBrush = win.Background;
try
{
int retVal = -1;
if (Win32.DwmIsCompositionEnabled())
{
win.Background = Brushes.Transparent;
// Obtain the window handle for WPF application
WindowInteropHelper windowInterop = new WindowInteropHelper(win);
IntPtr windowHandle = windowInterop.Handle;
// Set the Window background to be Transparent so the Aero Glass will show through
HwndSource mainWindowSrc = HwndSource.FromHwnd(windowHandle);
mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent;
retVal = internalExtendGlass(windowHandle, left, right, top, bottom);
}
if (retVal < 0)
{
throw new NotSupportedException("Operation Failed: Aero Glass Not Supported");
}
}
catch
{
// If an error occurred then change the Window.Background back to what it was
win.Background = originalBackgroundBrush;
}
}
#endregion
//#region "Windows.Forms Static Methods"
//public static void ExtendGlass(Form form)
//{
// ExtendGlass(form, -1, -1, -1, -1);
//}
//public static void ExtendGlass(Form form, int left, int right, int top, int bottom)
//{
// System.Drawing.Color oldBackColor = form.BackColor;
// System.Drawing.Color oldTransparencyKey = form.TransparencyKey;
// int retVal = -1;
// try
// {
// form.TransparencyKey = System.Drawing.Color.Beige;
// form.BackColor = form.TransparencyKey;
// retVal = internalExtendGlass(form.Handle, left, right, top, bottom);
// }
// catch (Exception)
// {
// retVal = -1;
// }
// if (retVal < 0)
// {
// form.BackColor = oldBackColor;
// form.TransparencyKey = oldTransparencyKey;
// }
//}
//#endregion
#region "Win32 / pinvoke"
private static class Win32
{
[DllImport("DwmApi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref Margins margins);
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();
[StructLayout(LayoutKind.Sequential)]
public struct Margins
{
public int Left; // width of left border that retains its size
public int Right; // width of right border that retains its size
public int Top; // height of top border that retains its size
public int Bottom; // height of bottom border that retains its size
}
public static Win32.Margins GetDpiAdjustedMargins(IntPtr windowHandle, int left, int right, int top, int bottom)
{
float DesktopDpiX;
float DesktopDpiY;
// Get System Dpi
using (System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(windowHandle))
{
DesktopDpiX = desktop.DpiX;
DesktopDpiY = desktop.DpiY;
}
// Set Margins
Win32.Margins margins = new Win32.Margins();
// Note that the default desktop Dpi is 96dpi. The margins are
// adjusted for the system Dpi.
margins.Left = Convert.ToInt32(left * (DesktopDpiX / 96));
margins.Right = Convert.ToInt32(right * (DesktopDpiX / 96));
margins.Top = Convert.ToInt32(top * (DesktopDpiX / 96));
margins.Bottom = Convert.ToInt32(bottom * (DesktopDpiX / 96));
return margins;
}
}
#endregion
}
}

View File

@@ -1,12 +1,7 @@
using Newtonsoft.Json; using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using GeekDesk.ViewModel; using GeekDesk.ViewModel;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
/// <summary> /// <summary>
/// 提取一些代码 /// 提取一些代码
@@ -15,45 +10,49 @@ namespace GeekDesk.Util
{ {
class CommonCode class CommonCode
{ {
private static string appConfigFilePath = AppDomain.CurrentDomain.BaseDirectory.Trim() + "\\config";
/// <summary> /// <summary>
/// 获取app配置 /// 获取app 数据
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static AppConfig GetAppConfig() public static AppData GetAppDataByFile()
{ {
AppConfig config; AppData appData;
if (!File.Exists(appConfigFilePath)) if (!File.Exists(Constants.DATA_FILE_PATH))
{ {
using (FileStream fs = File.Create(appConfigFilePath)) { } using (FileStream fs = File.Create(Constants.DATA_FILE_PATH)) { }
config = new AppConfig(); appData = new AppData();
SaveAppConfig(config); SaveAppData(appData);
} }
else else
{ {
using (FileStream fs = new FileStream(appConfigFilePath, FileMode.Open)) using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Open))
{ {
BinaryFormatter bf = new BinaryFormatter(); BinaryFormatter bf = new BinaryFormatter();
string json = bf.Deserialize(fs) as string; appData = bf.Deserialize(fs) as AppData;
config = JsonConvert.DeserializeObject<AppConfig>(json);
} }
} }
return config; return appData;
} }
/// <summary> /// <summary>
/// 保存app配置 /// 保存app 数据
/// </summary> /// </summary>
/// <param name="config"></param> /// <param name="appData"></param>
public static void SaveAppConfig(AppConfig config) public static void SaveAppData(AppData appData)
{ {
using (FileStream fs = new FileStream(appConfigFilePath, FileMode.Create))
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Create))
{ {
BinaryFormatter bf = new BinaryFormatter(); BinaryFormatter bf = new BinaryFormatter();
string json = JsonConvert.SerializeObject(config); bf.Serialize(fs, appData);
bf.Serialize(fs, json);
} }
} }
} }
} }

View File

@@ -1,12 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util namespace GeekDesk.Util
{ {

View File

@@ -1,175 +1,170 @@
// Copyright (C) Josh Smith - January 2007 // Copyright (C) Josh Smith - January 2007
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Documents;
using System.Windows; using System.Windows;
using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Controls;
namespace WPF.JoshSmith.Adorners namespace WPF.JoshSmith.Adorners
{ {
/// <summary> /// <summary>
/// Renders a visual which can follow the mouse cursor, /// Renders a visual which can follow the mouse cursor,
/// such as during a drag-and-drop operation. /// such as during a drag-and-drop operation.
/// </summary> /// </summary>
public class DragAdorner : Adorner public class DragAdorner : Adorner
{ {
#region Data #region Data
private Rectangle child = null; private Rectangle child = null;
private double offsetLeft = 0; private double offsetLeft = 0;
private double offsetTop = 0; private double offsetTop = 0;
#endregion // Data #endregion // Data
#region Constructor #region Constructor
/// <summary> /// <summary>
/// Initializes a new instance of DragVisualAdorner. /// Initializes a new instance of DragVisualAdorner.
/// </summary> /// </summary>
/// <param name="adornedElement">The element being adorned.</param> /// <param name="adornedElement">The element being adorned.</param>
/// <param name="size">The size of the adorner.</param> /// <param name="size">The size of the adorner.</param>
/// <param name="brush">A brush to with which to paint the adorner.</param> /// <param name="brush">A brush to with which to paint the adorner.</param>
public DragAdorner( UIElement adornedElement, Size size, Brush brush ) public DragAdorner(UIElement adornedElement, Size size, Brush brush)
: base( adornedElement ) : base(adornedElement)
{ {
Rectangle rect = new Rectangle(); Rectangle rect = new Rectangle();
rect.Fill = brush; rect.Fill = brush;
rect.Width = size.Width; rect.Width = size.Width;
rect.Height = size.Height; rect.Height = size.Height;
rect.IsHitTestVisible = false; rect.IsHitTestVisible = false;
this.child = rect; this.child = rect;
} }
#endregion // Constructor #endregion // Constructor
#region Public Interface #region Public Interface
#region GetDesiredTransform #region GetDesiredTransform
/// <summary> /// <summary>
/// Override. /// Override.
/// </summary> /// </summary>
/// <param name="transform"></param> /// <param name="transform"></param>
/// <returns></returns> /// <returns></returns>
public override GeneralTransform GetDesiredTransform( GeneralTransform transform ) public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
{ {
GeneralTransformGroup result = new GeneralTransformGroup(); GeneralTransformGroup result = new GeneralTransformGroup();
result.Children.Add( base.GetDesiredTransform( transform ) ); result.Children.Add(base.GetDesiredTransform(transform));
result.Children.Add( new TranslateTransform( this.offsetLeft, this.offsetTop ) ); result.Children.Add(new TranslateTransform(this.offsetLeft, this.offsetTop));
return result; return result;
} }
#endregion // GetDesiredTransform #endregion // GetDesiredTransform
#region OffsetLeft #region OffsetLeft
/// <summary> /// <summary>
/// Gets/sets the horizontal offset of the adorner. /// Gets/sets the horizontal offset of the adorner.
/// </summary> /// </summary>
public double OffsetLeft public double OffsetLeft
{ {
get { return this.offsetLeft; } get { return this.offsetLeft; }
set set
{ {
this.offsetLeft = value; this.offsetLeft = value;
UpdateLocation(); UpdateLocation();
} }
} }
#endregion // OffsetLeft #endregion // OffsetLeft
#region SetOffsets #region SetOffsets
/// <summary> /// <summary>
/// Updates the location of the adorner in one atomic operation. /// Updates the location of the adorner in one atomic operation.
/// </summary> /// </summary>
/// <param name="left"></param> /// <param name="left"></param>
/// <param name="top"></param> /// <param name="top"></param>
public void SetOffsets( double left, double top ) public void SetOffsets(double left, double top)
{ {
this.offsetLeft = left; this.offsetLeft = left;
this.offsetTop = top; this.offsetTop = top;
this.UpdateLocation(); this.UpdateLocation();
} }
#endregion // SetOffsets #endregion // SetOffsets
#region OffsetTop #region OffsetTop
/// <summary> /// <summary>
/// Gets/sets the vertical offset of the adorner. /// Gets/sets the vertical offset of the adorner.
/// </summary> /// </summary>
public double OffsetTop public double OffsetTop
{ {
get { return this.offsetTop; } get { return this.offsetTop; }
set set
{ {
this.offsetTop = value; this.offsetTop = value;
UpdateLocation(); UpdateLocation();
} }
} }
#endregion // OffsetTop #endregion // OffsetTop
#endregion // Public Interface #endregion // Public Interface
#region Protected Overrides #region Protected Overrides
/// <summary> /// <summary>
/// Override. /// Override.
/// </summary> /// </summary>
/// <param name="constraint"></param> /// <param name="constraint"></param>
/// <returns></returns> /// <returns></returns>
protected override Size MeasureOverride( Size constraint ) protected override Size MeasureOverride(Size constraint)
{ {
this.child.Measure( constraint ); this.child.Measure(constraint);
return this.child.DesiredSize; return this.child.DesiredSize;
} }
/// <summary> /// <summary>
/// Override. /// Override.
/// </summary> /// </summary>
/// <param name="finalSize"></param> /// <param name="finalSize"></param>
/// <returns></returns> /// <returns></returns>
protected override Size ArrangeOverride( Size finalSize ) protected override Size ArrangeOverride(Size finalSize)
{ {
this.child.Arrange( new Rect( finalSize ) ); this.child.Arrange(new Rect(finalSize));
return finalSize; return finalSize;
} }
/// <summary> /// <summary>
/// Override. /// Override.
/// </summary> /// </summary>
/// <param name="index"></param> /// <param name="index"></param>
/// <returns></returns> /// <returns></returns>
protected override Visual GetVisualChild( int index ) protected override Visual GetVisualChild(int index)
{ {
return this.child; return this.child;
} }
/// <summary> /// <summary>
/// Override. Always returns 1. /// Override. Always returns 1.
/// </summary> /// </summary>
protected override int VisualChildrenCount protected override int VisualChildrenCount
{ {
get { return 1; } get { return 1; }
} }
#endregion // Protected Overrides #endregion // Protected Overrides
#region Private Helpers #region Private Helpers
private void UpdateLocation() private void UpdateLocation()
{ {
AdornerLayer adornerLayer = this.Parent as AdornerLayer; AdornerLayer adornerLayer = this.Parent as AdornerLayer;
if( adornerLayer != null ) if (adornerLayer != null)
adornerLayer.Update( this.AdornedElement ); adornerLayer.Update(this.AdornedElement);
} }
#endregion // Private Helpers #endregion // Private Helpers
} }
} }

View File

@@ -1,13 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
namespace GeekDesk.Util namespace GeekDesk.Util
@@ -25,28 +19,11 @@ namespace GeekDesk.Util
public static BitmapImage GetBitmapImage(string filePath) public static BitmapImage GetBitmapImage(string filePath)
{ {
//Icon ico;
//BitmapImage bmpImage = null;
//MemoryStream strm;
//using (ico = GetIcon(filePath))
//{
// Bitmap bmp = ico.ToBitmap();
// using (strm = new MemoryStream())
// {
// bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
// bmpImage = new BitmapImage();
// bmpImage.BeginInit();
// strm.Seek(0, SeekOrigin.Begin);
// bmpImage.StreamSource = strm;
// bmpImage.EndInit();
// }
//}
//return bmpImage;
Icon ico = GetIcon(filePath); Icon ico = GetIcon(filePath);
Bitmap bmp = ico.ToBitmap(); Bitmap bmp = ico.ToBitmap();
MemoryStream strm = new MemoryStream(); MemoryStream strm = new MemoryStream();
bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png); bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
BitmapImage bmpImage = new BitmapImage(); BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit(); bmpImage.BeginInit();
strm.Seek(0, SeekOrigin.Begin); strm.Seek(0, SeekOrigin.Begin);
bmpImage.StreamSource = strm; bmpImage.StreamSource = strm;

93
Util/HotKey.cs Normal file
View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
/// <summary>
/// 热键注册
/// </summary>
namespace GeekDesk.Util
{
class Hotkey
{
#region api
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool RegisterHotKey(IntPtr hWnd, int id, HotkeyModifiers fsModifiers, uint vk);
[DllImport("user32.dll")]
static extern bool UnregisterHotKey(IntPtr hWnd, int id);
#endregion
/// <summary>
/// 注册快捷键
/// </summary>
/// <param name="window">持有快捷键窗口</param>
/// <param name="fsModifiers">组合键</param>
/// <param name="key">快捷键</param>
/// <param name="callBack">回调函数</param>
public static int Regist(Window window, HotkeyModifiers fsModifiers, Key key, HotKeyCallBackHanlder callBack)
{
var hwnd = new WindowInteropHelper(window).Handle;
var _hwndSource = HwndSource.FromHwnd(hwnd);
_hwndSource.AddHook(WndProc);
int id = keyid++;
var vk = KeyInterop.VirtualKeyFromKey(key);
keymap[id] = callBack;
if (!RegisterHotKey(hwnd, id, fsModifiers, (uint)vk)) throw new Exception("RegisterHotKey Failed");
return id;
}
/// <summary>
/// 快捷键消息处理
/// </summary>
static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_HOTKEY)
{
int id = wParam.ToInt32();
if (keymap.TryGetValue(id, out var callback))
{
callback();
}
}
return IntPtr.Zero;
}
/// <summary>
/// 注销快捷键
/// </summary>
/// <param name="hWnd">持有快捷键窗口的句柄</param>
/// <param name="callBack">回调函数</param>
public static void UnRegist(IntPtr hWnd, HotKeyCallBackHanlder callBack)
{
foreach (KeyValuePair<int, HotKeyCallBackHanlder> var in keymap)
{
if (var.Value == callBack)
UnregisterHotKey(hWnd, var.Key);
}
}
const int WM_HOTKEY = 0x312;
static int keyid = 10;
public static Dictionary<int, HotKeyCallBackHanlder> keymap = new Dictionary<int, HotKeyCallBackHanlder>();
public delegate void HotKeyCallBackHanlder();
}
public enum HotkeyModifiers
{
MOD_ALT = 0x1,
MOD_CONTROL = 0x2,
MOD_SHIFT = 0x4,
MOD_WIN = 0x8
}
}

29
Util/HttpUtil.cs Normal file
View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace GeekDesk.Util
{
public class HttpUtil
{
#region Get请求
public static string Get(string url)
{
//创建Web访问对 象
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
//通过Web访问对象获取响应内容
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
//通过响应内容流创建StreamReader对象因为StreamReader更高级更快
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string returnStr = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾
reader.Close();
myResponse.Close();
return returnStr;
}
#endregion
}
}

343
Util/ImageUtil.cs Normal file
View File

@@ -0,0 +1,343 @@
using GeekDesk.Constant;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
namespace GeekDesk.Util
{
class ImageUtil
{
/// <summary>
/// 图片数组转 BitmapImage
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static BitmapImage ByteArrToImage(byte[] array)
{
using (var ms = new System.IO.MemoryStream(array))
{
var image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad; // here
image.StreamSource = ms;
image.EndInit();
return image;
}
}
/// <summary>
/// BitmapImage 转数组
/// </summary>
/// <param name="bi"></param>
/// <returns></returns>
public static byte[] BitmapImageToByte(BitmapImage bi)
{
using (MemoryStream memStream = new MemoryStream())
{
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bi));
encoder.Save(memStream);
return memStream.GetBuffer();
}
}
/// <summary>
/// byte[]转换成Image
/// </summary>
/// <param name="byteArrayIn">二进制图片流</param>
/// <returns>Image</returns>
public static Image ByteArrayToImage(byte[] byteArrayIn)
{
if (byteArrayIn == null)
return null;
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(byteArrayIn))
{
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
ms.Flush();
return returnImage;
}
}
/// <summary>
/// 图片base64 转 BitmapImage
/// </summary>
/// <param name="base64"></param>
/// <returns></returns>
public static BitmapImage Base64ToBitmapImage(string base64)
{
byte[] byteBuffer = Convert.FromBase64String(base64);
return ByteArrToImage(byteBuffer);
}
/// <summary>
/// 获取文件 icon
/// </summary>
/// <param name="filePath">文件路径</param>
/// <returns></returns>
public static BitmapImage GetBitmapIconByPath(string filePath)
{
if (File.Exists(filePath))
{
if (IsImage(filePath)) {
//图片
return GetThumbnailByFile(filePath, 256, 256);
} else
{ //其它文件
return FileIcon.GetBitmapImage(filePath);
}
} else if(Directory.Exists(filePath)) {
//文件夹
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DIR_IMAGE_BASE64);
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="lcFilename">需要改变大小的图片位置</param>
/// <param name="lnWidth">缩略图的宽度</param>
/// <param name="lnHeight">缩略图的高度</param>
/// <returns></returns>
//public static BitmapImage GetThumbnail(string lcFilename, int lnWidth, int lnHeight)
//{
// Bitmap bmpOut = null;
// try
// {
// Bitmap loBMP = new Bitmap(lcFilename);
// ImageFormat loFormat = loBMP.RawFormat;
// decimal lnRatio;
// int lnNewWidth = 0;
// int lnNewHeight = 0;
// //如果图像小于缩略图直接返回原图因为upfront
// if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
// return BitmapToBitmapImage(loBMP);
// if (loBMP.Width > loBMP.Height)
// {
// lnRatio = (decimal)lnWidth / loBMP.Width;
// lnNewWidth = lnWidth;
// decimal lnTemp = loBMP.Height * lnRatio;
// lnNewHeight = (int)lnTemp;
// }
// else
// {
// lnRatio = (decimal)lnHeight / loBMP.Height;
// lnNewHeight = lnHeight;
// decimal lnTemp = loBMP.Width * lnRatio;
// lnNewWidth = (int)lnTemp;
// }
// bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
// Graphics g = Graphics.FromImage(bmpOut);
// g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
// g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
// g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
// loBMP.Dispose();
// }
// catch (Exception e)
// {
// return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
// }
// return BitmapToBitmapImage(bmpOut);
//}
public static BitmapImage GetThumbnailByFile(string filePath, int tWidth, int tHeight)
{
try
{
Image img = Image.FromFile(filePath);
if (img.Width <= tWidth && img.Height <= tHeight)
{
return GetBitmapImageByFile(filePath);
}
else
{
Bitmap loBMP = new Bitmap(filePath);
ImageFormat loFormat = loBMP.RawFormat;
decimal lnRatio;
int lnNewWidth;
int lnNewHeight;
if (loBMP.Width > loBMP.Height)
{
lnRatio = (decimal)tWidth / loBMP.Width;
lnNewWidth = tWidth;
decimal lnTemp = loBMP.Height * lnRatio;
lnNewHeight = (int)lnTemp;
}
else
{
lnRatio = (decimal)tHeight / loBMP.Height;
lnNewHeight = tHeight;
decimal lnTemp = loBMP.Width * lnRatio;
lnNewWidth = (int)lnTemp;
}
Bitmap bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
loBMP.Dispose();
string tempPath = Constants.APP_DIR + "\\temp";
if (File.Exists(tempPath))
{
File.Delete(tempPath);
}
bmpOut.Save(tempPath, loFormat);
BitmapImage bm = GetBitmapImageByFile(tempPath);
File.Delete(tempPath);
return bm;
}
}
catch (Exception)
{
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
}
}
public static BitmapImage GetBitmapImageByFile(string filePath)
{
BitmapImage bmImg = new BitmapImage();
bmImg.BeginInit();
bmImg.CacheOption = BitmapCacheOption.OnLoad;
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
bmImg.StreamSource = fs;
bmImg.EndInit();
}
return bmImg;
}
public static BitmapImage MemoryStremToBitMapImage(MemoryStream ms)
{
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.EndInit();
bi.Freeze();
return bi;
}
/// <summary>
/// Bitmap to BitmapImage
/// </summary>
/// <param name="bitmap"></param>
/// <returns></returns>
public static BitmapImage BitmapToBitmapImage(Bitmap bitmap)
{
return BitmapToBitmapImage(bitmap, null);
}
public static BitmapImage BitmapToBitmapImage(Image bitmap, ImageFormat format)
{
BitmapImage bitmapImage = new BitmapImage();
using (MemoryStream ms = new MemoryStream())
{
if (format == null)
{
bitmap.Save(ms, bitmap.RawFormat);
}
else
{
bitmap.Save(ms, format);
}
bitmapImage.BeginInit();
bitmapImage.StreamSource = ms;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
bitmapImage.Freeze();
}
return bitmapImage;
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
public static BitmapImage Bitmap2BitmapImage(Bitmap bitmap)
{
IntPtr hBitmap = bitmap.GetHbitmap();
BitmapImage retval;
try
{
retval = (BitmapImage)Imaging.CreateBitmapSourceFromHBitmap(
hBitmap,
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
}
finally
{
DeleteObject(hBitmap);
}
return retval;
}
/// <summary>
/// 图片文件转base64
/// </summary>
/// <param name="Imagefilename"></param>
/// <returns></returns>
public static string FileImageToBase64(string Imagefilename, ImageFormat format)
{
try
{
Bitmap bmp = new Bitmap(Imagefilename);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, format);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 判断文件是否为图片
/// </summary>
/// <param name="path">文件路径</param>
/// <returns></returns>
public static bool IsImage(string path)
{
try
{
string strExt = Path.GetExtension(path).Substring(1);
string suffixs = "bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp,avif";
string[] suffixArr = suffixs.Split(',');
foreach (string suffix in suffixArr)
{
if (suffix.Equals(strExt, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
return false;
}
catch (Exception)
{
return false;
}
}
}
}

File diff suppressed because it is too large Load Diff

35
Util/MouseUtil.cs Normal file
View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace GeekDesk.Util
{
class MouseUtil
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetCursorPos(ref Win32Point pt);
[StructLayout(LayoutKind.Sequential)]
internal struct Win32Point
{
public Int32 X;
public Int32 Y;
};
/// <summary>
/// 获取鼠标坐标
/// </summary>
/// <returns></returns>
public static Point GetMousePosition()
{
var w32Mouse = new Win32Point();
GetCursorPos(ref w32Mouse);
return new Point(w32Mouse.X, w32Mouse.Y);
}
}
}

View File

@@ -1,58 +1,56 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
namespace WPF.JoshSmith.Controls.Utilities namespace WPF.JoshSmith.Controls.Utilities
{ {
/// <summary> /// <summary>
/// Provides access to the mouse location by calling unmanaged code. /// Provides access to the mouse location by calling unmanaged code.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This class was written by Dan Crevier (Microsoft). /// This class was written by Dan Crevier (Microsoft).
/// http://blogs.msdn.com/llobo/archive/2006/09/06/Scrolling-Scrollviewer-on-Mouse-Drag-at-the-boundaries.aspx /// http://blogs.msdn.com/llobo/archive/2006/09/06/Scrolling-Scrollviewer-on-Mouse-Drag-at-the-boundaries.aspx
/// </remarks> /// </remarks>
public class MouseUtilities public class MouseUtilities
{ {
[StructLayout( LayoutKind.Sequential )] [StructLayout(LayoutKind.Sequential)]
private struct Win32Point private struct Win32Point
{ {
public Int32 X; public Int32 X;
public Int32 Y; public Int32 Y;
}; };
[DllImport( "user32.dll" )] [DllImport("user32.dll")]
private static extern bool GetCursorPos( ref Win32Point pt ); private static extern bool GetCursorPos(ref Win32Point pt);
[DllImport( "user32.dll" )] [DllImport("user32.dll")]
private static extern bool ScreenToClient( IntPtr hwnd, ref Win32Point pt ); private static extern bool ScreenToClient(IntPtr hwnd, ref Win32Point pt);
/// <summary> /// <summary>
/// Returns the mouse cursor location. This method is necessary during /// Returns the mouse cursor location. This method is necessary during
/// a drag-drop operation because the WPF mechanisms for retrieving the /// a drag-drop operation because the WPF mechanisms for retrieving the
/// cursor coordinates are unreliable. /// cursor coordinates are unreliable.
/// </summary> /// </summary>
/// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param> /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
public static Point GetMousePosition( Visual relativeTo ) public static Point GetMousePosition(Visual relativeTo)
{ {
Win32Point mouse = new Win32Point(); Win32Point mouse = new Win32Point();
GetCursorPos( ref mouse ); GetCursorPos(ref mouse);
// Using PointFromScreen instead of Dan Crevier's code (commented out below) // Using PointFromScreen instead of Dan Crevier's code (commented out below)
// is a bug fix created by William J. Roberts. Read his comments about the fix // is a bug fix created by William J. Roberts. Read his comments about the fix
// here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx // here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
return relativeTo.PointFromScreen( new Point( (double)mouse.X, (double)mouse.Y ) ); return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
#region Commented Out #region Commented Out
//System.Windows.Interop.HwndSource presentationSource = //System.Windows.Interop.HwndSource presentationSource =
// (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo ); // (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo );
//ScreenToClient( presentationSource.Handle, ref mouse ); //ScreenToClient( presentationSource.Handle, ref mouse );
//GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual ); //GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual );
//Point offset = transform.Transform( new Point( 0, 0 ) ); //Point offset = transform.Transform( new Point( 0, 0 ) );
//return new Point( mouse.X - offset.X, mouse.Y - offset.Y ); //return new Point( mouse.X - offset.X, mouse.Y - offset.Y );
#endregion // Commented Out #endregion // Commented Out
} }
} }
} }

23
Util/ShellContextMenu.cs Normal file
View File

@@ -0,0 +1,23 @@
using SharpShell.SharpContextMenu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GeekDesk.Util
{
class ShellContextMenu : SharpContextMenu
{
protected override bool CanShowMenu()
{
throw new NotImplementedException();
}
protected override ContextMenuStrip CreateMenu()
{
throw new NotImplementedException();
}
}
}

22
Util/StringUtil.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{
public class StringUtil
{
public static bool IsEmpty(string str)
{
if (str == null || str.Length == 0 || str.Trim().Length == 0)
{
return true;
}
return false;
}
}
}

94
Util/SvgToGeometry.cs Normal file
View File

@@ -0,0 +1,94 @@
using GeekDesk.ViewModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Xml;
namespace GeekDesk.Util
{
class SvgToGeometry
{
public static List<IconfontInfo> GetIconfonts()
{
string svgPath = "/GeekDesk;component/Resource/Iconfont/iconfont.js";
string jsonPath = "/GeekDesk;component/Resource/Iconfont/iconfont.json";
Stream svgStream = Application.GetResourceStream(new Uri(svgPath, UriKind.Relative)).Stream;
Stream jsonStream = Application.GetResourceStream(new Uri(jsonPath, UriKind.Relative)).Stream;
StreamReader streamReader = new StreamReader(svgStream);
string svgJsStr = streamReader.ReadToEnd();
JObject jo = ReadJson(jsonStream);
return GetIconfonts(svgJsStr, jo);
}
public static List<IconfontInfo> GetIconfonts(string svgJsStr, string jsonStr)
{
return GetIconfonts(svgJsStr, JObject.Parse(jsonStr));
}
public static List<IconfontInfo> GetIconfonts(string svgJsStr, JObject json)
{
svgJsStr = svgJsStr.Substring(svgJsStr.IndexOf("<svg>"),
svgJsStr.Length - (svgJsStr.Length - (svgJsStr.IndexOf("</svg>") + "</svg>".Length)) - svgJsStr.IndexOf("<svg>"));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(svgJsStr);
XmlNodeList nodeList = xmlDoc.SelectNodes("/svg/symbol");
JArray ja = JArray.Parse(json["glyphs"].ToString());
List<IconfontInfo> listInfo = new List<IconfontInfo>();
for (int i = 0; i < nodeList.Count; i++)
{
XmlNodeList pathNodes = nodeList[i].SelectNodes("path");
string text = "";
foreach (XmlNode pathNode in pathNodes)
{
text += pathNode.Attributes["d"].Value;
}
string name = JObject.Parse(ja[i].ToString())["name"].ToString();
listInfo.Add(new IconfontInfo
{
Text = text,
Name = name
});
}
return listInfo;
}
public static JObject ReadJson(Stream stream)
{
using (StreamReader file = new StreamReader(stream))
{
using (JsonTextReader reader = new JsonTextReader(file))
{
JObject o = (JObject)JToken.ReadFrom(reader);
return o;
}
}
}
public static string GetMd5Str(string ConvertString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(ConvertString)), 4, 8);
t2 = t2.Replace("-", "");
t2 = t2.ToLower();
return t2;
}
}
}

View File

@@ -1,13 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing; using System.Drawing;
using Microsoft.Win32;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using GeekDesk.Util;
namespace GeekDesk.Util namespace GeekDesk.Util
{ {

View File

@@ -1,25 +1,329 @@
using GalaSoft.MvvmLight; 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GeekDesk.Constant; using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
/// <summary>
/// 程序设置
/// </summary>
namespace GeekDesk.ViewModel namespace GeekDesk.ViewModel
{ {
[Serializable] [Serializable]
public class AppConfig : ViewModelBase public class AppConfig : INotifyPropertyChanged
{ {
private int menuSortType = (int)SortType.CUSTOM; //菜单排序类型 private SortType menuSortType = SortType.CUSTOM; //菜单排序类型
private int iconSortType = (int)SortType.CUSTOM; //图表排序类型 private SortType iconSortType = SortType.CUSTOM; //图表排序类型
private double windowWidth = (double)DefaultConstant.WINDOW_WIDTH; //窗口宽度 private double windowWidth = (double)DefaultConstant.WINDOW_WIDTH; //窗口宽度
private double windowHeight = (double)DefaultConstant.WINDOW_HEIGHT; //窗口高度 private double windowHeight = (double)DefaultConstant.WINDOW_HEIGHT; //窗口高度
private double menuCardWidth = (double)DefaultConstant.MENU_CARD_WIDHT;//菜单栏宽度 private double menuCardWidth = (double)DefaultConstant.MENU_CARD_WIDHT;//菜单栏宽度
private int selectedMenuIndex = 0; //上次选中菜单索引
private bool followMouse = true; //面板跟随鼠标 默认是
private Visibility configIconVisible = Visibility.Visible; // 设置按钮是否显示
private AppHideType appHideType = AppHideType.START_EXE; //面板关闭方式 (默认启动程序后)
private bool startedShowPanel = true; //启动时是否显示主面板 默认显示
[field: NonSerialized]
private BitmapImage bitmapImage; //位图
private byte[] imageByteArr; //背景图片 byte数组
private string bacImgName = "系统默认";
private int cardOpacity = 10; //默认0.1的不透明度 此处显示数值 * 100
private int bgOpacity = 100; // 背景图片不透明度 此处显示数值 * 100
private int pannelOpacity = 100; //主面板不透明度 此处显示数值 * 100
private int pannelCornerRadius = 4; //面板圆角 默认4
[field: NonSerialized]
private ObservableCollection<IconInfo> selectedMenuIcons;
private string hotkeyStr = "Ctrl + Q"; //默认启动面板快捷键
private HotkeyModifiers hotkeyModifiers = HotkeyModifiers.MOD_CONTROL; //默认启动面板快捷键
private Key hotkey = Key.Q; //默认启动面板快捷键
private string customIconUrl; //自定义图标url
private string customIconJsonUrl; //自定义图标json信息url
private bool blurEffect = false; //毛玻璃效果 默认否
private double blurValue;
#region GetSet #region GetSet
public int MenuSortType {
public double BlurValue
{
get
{
return blurValue;
}
set
{
blurValue = value;
OnPropertyChanged("BlurValue");
}
}
public bool BlurEffect
{
get
{
return blurEffect;
}
set
{
blurEffect = value;
if (blurEffect)
{
BlurValue = 100;
} else
{
BlurValue = 0;
}
OnPropertyChanged("BlurEffect");
}
}
public string CustomIconUrl
{
get
{
return customIconUrl;
}
set
{
customIconUrl = value;
OnPropertyChanged("CustomIconUrl");
}
}
public string CustomIconJsonUrl
{
get
{
return customIconJsonUrl;
}
set
{
customIconJsonUrl = value;
OnPropertyChanged("CustomIconJsonUrl");
}
}
public Key Hotkey
{
get
{
return hotkey;
}
set
{
hotkey = value;
OnPropertyChanged("Hotkey");
}
}
public string HotkeyStr
{
get
{
return hotkeyStr;
}
set
{
hotkeyStr = value;
OnPropertyChanged("HotkeyStr");
}
}
public HotkeyModifiers HotkeyModifiers
{
get
{
return hotkeyModifiers;
}
set
{
hotkeyModifiers = value;
OnPropertyChanged("HotkeyModifiers");
}
}
public ObservableCollection<IconInfo> SelectedMenuIcons
{
get
{
return selectedMenuIcons;
}
set
{
selectedMenuIcons = value;
OnPropertyChanged("SelectedMenuIcons");
}
}
public int PannelCornerRadius
{
get
{
return pannelCornerRadius;
}
set
{
pannelCornerRadius = value;
OnPropertyChanged("pannelCornerRadius");
}
}
public int PannelOpacity
{
get
{
return pannelOpacity;
}
set
{
pannelOpacity = value;
OnPropertyChanged("PannelOpacity");
}
}
public int BgOpacity
{
get
{
return bgOpacity;
}
set
{
bgOpacity = value;
OnPropertyChanged("BgOpacity");
}
}
public int CardOpacity
{
get
{
return cardOpacity;
}
set
{
cardOpacity = value;
OnPropertyChanged("CardOpacity");
}
}
public string BacImgName
{
get
{
return bacImgName;
}
set
{
bacImgName = value;
OnPropertyChanged("BacImgName");
}
}
public byte[] ImageByteArr
{
get
{
return imageByteArr;
}
set
{
imageByteArr = value;
OnPropertyChanged("ImageByteArr");
}
}
public BitmapImage BitmapImage
{
get
{
if (imageByteArr == null || imageByteArr.Length == 0)
{
bacImgName = "系统默认";
//Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
} else
{
return ImageUtil.ByteArrToImage(ImageByteArr);
}
}
set
{
bitmapImage = value;
imageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
OnPropertyChanged("BitmapImage");
}
}
public bool StartedShowPanel
{
get
{
return startedShowPanel;
}
set
{
startedShowPanel = value;
OnPropertyChanged("StartedShowPanel");
}
}
public AppHideType AppHideType
{
get
{
return appHideType;
}
set
{
appHideType = value;
OnPropertyChanged("AppHideType");
}
}
public Visibility ConfigIconVisible
{
get
{
return configIconVisible;
}
set
{
configIconVisible = value;
OnPropertyChanged("ConfigIconVisible");
}
}
public bool FollowMouse
{
get
{
return followMouse;
}
set
{
followMouse = value;
OnPropertyChanged("FollowMouse");
}
}
public int SelectedMenuIndex
{
get
{
return selectedMenuIndex;
}
set
{
selectedMenuIndex = value;
OnPropertyChanged("SelectedMenuIndex");
}
}
public SortType MenuSortType
{
get get
{ {
return menuSortType; return menuSortType;
@@ -27,11 +331,11 @@ namespace GeekDesk.ViewModel
set set
{ {
menuSortType = value; menuSortType = value;
RaisePropertyChanged(); OnPropertyChanged("MenuSortType");
} }
} }
public int IconSortType public SortType IconSortType
{ {
get get
{ {
@@ -40,7 +344,7 @@ namespace GeekDesk.ViewModel
set set
{ {
iconSortType = value; iconSortType = value;
RaisePropertyChanged(); OnPropertyChanged("IconSortType");
} }
} }
@@ -53,7 +357,7 @@ namespace GeekDesk.ViewModel
set set
{ {
windowWidth = value; windowWidth = value;
RaisePropertyChanged(); OnPropertyChanged("WindowWidth");
} }
} }
@@ -66,7 +370,7 @@ namespace GeekDesk.ViewModel
set set
{ {
windowHeight = value; windowHeight = value;
RaisePropertyChanged(); OnPropertyChanged("WindowHeight");
} }
} }
@@ -79,9 +383,18 @@ namespace GeekDesk.ViewModel
set set
{ {
menuCardWidth = value; menuCardWidth = value;
RaisePropertyChanged(); OnPropertyChanged("MenuCardWidth");
} }
} }
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
}
#endregion #endregion
} }

96
ViewModel/AppData.cs Normal file
View File

@@ -0,0 +1,96 @@
using GeekDesk.Util;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
/// <summary>
/// 程序数据
/// </summary>
namespace GeekDesk.ViewModel
{
[Serializable]
public class AppData : INotifyPropertyChanged
{
private ObservableCollection<MenuInfo> menuList; //菜单信息及菜单对应icon信息
private AppConfig appConfig = new AppConfig(); //程序设置信息
private ObservableCollection<BacklogInfo> hiBacklogList; //历史待办
private ObservableCollection<BacklogInfo> exeBacklogList; //未处理待办 为了提高任务效率 分开处理
public ObservableCollection<BacklogInfo> HiBacklogList
{
get
{
if (hiBacklogList == null)
{
hiBacklogList = new ObservableCollection<BacklogInfo>();
}
return hiBacklogList;
}
set
{
hiBacklogList = value;
OnPropertyChanged("HiBacklogList");
}
}
public ObservableCollection<BacklogInfo> ExeBacklogList
{
get
{
if (exeBacklogList == null)
{
exeBacklogList = new ObservableCollection<BacklogInfo>();
}
return exeBacklogList;
}
set
{
exeBacklogList = value;
OnPropertyChanged("ExeBacklogList");
}
}
public ObservableCollection<MenuInfo> MenuList
{
get
{
if (menuList == null)
{
menuList = new ObservableCollection<MenuInfo>();
}
return menuList;
}
set
{
menuList = value;
OnPropertyChanged("MenuList");
}
}
public AppConfig AppConfig
{
get
{
return appConfig;
}
set
{
appConfig = value;
OnPropertyChanged("AppConfig");
}
}
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
}
}
}

112
ViewModel/BacklogInfo.cs Normal file
View File

@@ -0,0 +1,112 @@
using GeekDesk.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
{
[Serializable]
public class BacklogInfo : INotifyPropertyChanged
{
//private string id; //任务唯一id
private string title; //待办事项
private string msg; //事项详情
private string exeTime; //待办时间
private string doneTime; //完成时间
//private int status; //状态 0 未处理 1 已处理
public string DoneTime
{
get
{
return doneTime;
}
set
{
doneTime = value;
OnPropertyChanged("DoneTime");
}
}
//public string Id
//{
// get
// {
// return id;
// }
// set
// {
// id = value;
// OnPropertyChanged("Id");
// }
//}
public string Title
{
get
{
return title;
}
set
{
title = value;
OnPropertyChanged("Title");
}
}
public string Msg
{
get
{
return msg;
}
set
{
msg = value;
OnPropertyChanged("Msg");
}
}
public string ExeTime
{
get
{
return exeTime;
}
set
{
exeTime = value;
OnPropertyChanged("ExeTime");
}
}
//public int Status
//{
// get
// {
// return status;
// }
// set
// {
// status = value;
// OnPropertyChanged("status");
// }
//}
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
}
}
}

View File

@@ -1,70 +0,0 @@
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace GeekDesk.ViewModel
{
public class DataInfos : ViewModelBase
{
private string path; //路径
private string name; //文件名
private int count = 0; //打开次数
private BitmapImage bitmapImage; //位图
public int Count
{
get
{
return count;
}
set
{
count = value;
RaisePropertyChanged();
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
RaisePropertyChanged();
}
}
public string Path
{
get
{
return path;
}
set
{
path = value;
RaisePropertyChanged();
}
}
public BitmapImage BitmapImage
{
get
{
return bitmapImage;
}
set
{
bitmapImage = value;
RaisePropertyChanged();
}
}
}
}

180
ViewModel/IconInfo.cs Normal file
View File

@@ -0,0 +1,180 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Media.Imaging;
/// <summary>
/// 图标信息
/// </summary>
namespace GeekDesk.ViewModel
{
[Serializable]
public class IconInfo : INotifyPropertyChanged
{
private string path; //路径
private string name; //文件名
private int count = 0; //打开次数
[field: NonSerialized]
private BitmapImage bitmapImage; //位图
private byte[] imageByteArr; //图片 byte数组
private string content; //显示信息
private int imageWidth = (int)DefaultConstant.IMAGE_WIDTH; //图片宽度
private int imageHeight = (int)DefaultConstant.IMAGE_HEIGHT; //图片高度
private bool adminStartUp = false; //始终管理员方式启动 默认否
private byte[] defaultImage; //默认图标
public byte[] DefaultImage
{
get
{
return defaultImage;
}
set
{
defaultImage = value;
OnPropertyChanged("DefaultImage");
}
}
public bool AdminStartUp
{
get
{
return adminStartUp;
}
set
{
adminStartUp = value;
OnPropertyChanged("AdminStartUp");
}
}
public int Count
{
get
{
return count;
}
set
{
count = value;
Content = Path + "\n" + Name + "\n使用次数: " + Count;
OnPropertyChanged("Count");
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
Content = Path + "\n" + Name + "\n使用次数: " + Count;
OnPropertyChanged("Name");
}
}
public string Path
{
get
{
return path;
}
set
{
path = value;
Content = Path + "\n" + Name + "\n使用次数: " + Count;
OnPropertyChanged("Path");
}
}
public BitmapImage BitmapImage
{
get
{
return ImageUtil.ByteArrToImage(ImageByteArr);
}
set
{
bitmapImage = value;
ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
OnPropertyChanged("BitmapImage");
}
}
public byte[] ImageByteArr
{
get
{
return imageByteArr;
}
set
{
imageByteArr = value;
OnPropertyChanged("ImageByteArr");
}
}
public string Content
{
get
{
return content;
}
set
{
content = value;
OnPropertyChanged("Content");
}
}
public int ImageWidth
{
get
{
return imageWidth;
}
set
{
imageWidth = value;
OnPropertyChanged("ImageWidth");
}
}
public int ImageHeight
{
get
{
return imageHeight;
}
set
{
imageHeight = value;
OnPropertyChanged("ImageHeight");
}
}
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
}
}
}

40
ViewModel/IconfontInfo.cs Normal file
View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
{
public class IconfontInfo
{
private string text;
private string name;
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}
}

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
{
class MainModel
{
}
}

View File

@@ -1,34 +0,0 @@
using GalaSoft.MvvmLight;
namespace GeekDesk.ViewModel
{
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm
/// </para>
/// </summary>
public class MainViewModel : ViewModelBase
{
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
////if (IsInDesignMode)
////{
//// // Code runs in Blend --> create design time data.
////}
////else
////{
//// // Code runs "for real"
////}
}
}
}

139
ViewModel/MenuInfo.cs Normal file
View File

@@ -0,0 +1,139 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
namespace GeekDesk.ViewModel
{
[Serializable]
public class MenuInfo : INotifyPropertyChanged
{
private string menuName;
private string menuId;
private Visibility menuEdit = Visibility.Collapsed;
private Visibility notMenuEdit = Visibility.Visible;
private string menuGeometry; //菜单几何图标
private string geometryColor; //几何图标颜色
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
public string MenuGeometry
{
get
{
if (menuGeometry == null)
{
return Constants.DEFAULT_MENU_GEOMETRY;
}
return menuGeometry;
}
set
{
menuGeometry = value;
OnPropertyChanged("MenuGeometry");
}
}
public string GeometryColor
{
get
{
if (geometryColor == null)
{
return Constants.DEFAULT_MENU_GEOMETRY_COLOR;
}
return geometryColor;
}
set
{
geometryColor = value;
OnPropertyChanged("GeometryColor");
}
}
public string MenuName
{
get
{
return menuName;
}
set
{
menuName = value;
OnPropertyChanged("MenuName");
}
}
public string MenuId
{
get
{
return menuId;
}
set
{
menuId = value;
OnPropertyChanged("MenuId");
}
}
public Visibility MenuEdit
{
get
{
return menuEdit;
}
set
{
menuEdit = value;
if (menuEdit == Visibility.Visible)
{
NotMenuEdit = Visibility.Collapsed;
} else
{
NotMenuEdit = Visibility.Visible;
}
OnPropertyChanged("MenuEdit");
}
}
public Visibility NotMenuEdit
{
get
{
return notMenuEdit;
}
set
{
notMenuEdit = value;
OnPropertyChanged("NotMenuEdit");
}
}
public ObservableCollection<IconInfo> IconList
{
get
{
return iconList;
}
set
{
iconList = value;
OnPropertyChanged("IconList");
}
}
[field: NonSerializedAttribute()]
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
CommonCode.SaveAppData(MainWindow.appData);
}
}
}

View File

@@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
{
class MenuViewModel
{
public MenuViewModel()
{
}
public ObservableCollection<Menu> GetMenus()
{
ObservableCollection<Menu> menus = new ObservableCollection<Menu>();
menus.Add(new Menu() { menu = "test1" });
menus.Add(new Menu() { menu = "test2" });
menus.Add(new Menu() { menu = "test3" });
return menus;
}
}
public class Menu
{
public string menu { get; set; }
}
}

View File

@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" /> <package id="CommonServiceLocator" version="2.0.6" targetFramework="net452" requireReinstallation="true" />
<package id="HandyControl" version="3.1.0" targetFramework="net452" requireReinstallation="true" /> <package id="GlobalHotKey" version="1.1.0" targetFramework="net472" />
<package id="MvvmLight" version="5.4.1.1" targetFramework="net452" /> <package id="HandyControl" version="3.1.0" targetFramework="net472" />
<package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net452" /> <package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net452" /> <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="System.Drawing.Common" version="5.0.2" targetFramework="net472" /> <package id="SharpShell" version="2.7.2" targetFramework="net472" />
<package id="SharpShellTools" version="2.2.0.0" targetFramework="net472" />
<package id="System.Drawing.Common" version="6.0.0-preview.3.21201.4" targetFramework="net472" />
</packages> </packages>