优化程序 增加功能
This commit is contained in:
17
Constant/Constants.cs
Normal file
17
Constant/Constants.cs
Normal file
File diff suppressed because one or more lines are too long
@@ -5,9 +5,9 @@ namespace GeekDesk.Constant
|
|||||||
{
|
{
|
||||||
enum DefaultConstant
|
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_WIDTH = 60, //默认图标宽度
|
||||||
IMAGE_HEIGHT = 60, //默认图标高度
|
IMAGE_HEIGHT = 60, //默认图标高度
|
||||||
}
|
}
|
||||||
|
|||||||
18
Constant/IconStartType.cs
Normal file
18
Constant/IconStartType.cs
Normal 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
|
||||||
|
{
|
||||||
|
enum IconStartType
|
||||||
|
{
|
||||||
|
DEFAULT_STARTUP = 1, //默认启动方式
|
||||||
|
ADMIN_STARTUP = 2, //管理员方式启动
|
||||||
|
SHOW_IN_EXPLORE = 3 //打开文件所在位置
|
||||||
|
}
|
||||||
|
}
|
||||||
56
Control/IconInfoDialog.xaml
Normal file
56
Control/IconInfoDialog.xaml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<Border x:Class="GeekDesk.Control.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="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="EditImageToDefault"/>
|
||||||
|
</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>
|
||||||
74
Control/IconInfoDialog.xaml.cs
Normal file
74
Control/IconInfoDialog.xaml.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using GeekDesk.Util;
|
||||||
|
using GeekDesk.ViewModel;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
|
||||||
|
namespace GeekDesk.Control
|
||||||
|
{
|
||||||
|
/// <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 EditImageToDefault(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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,8 +71,13 @@
|
|||||||
<Compile Include="Command\DelegateCommand.cs" />
|
<Compile Include="Command\DelegateCommand.cs" />
|
||||||
<Compile Include="Command\DelegateCommandBase.cs" />
|
<Compile Include="Command\DelegateCommandBase.cs" />
|
||||||
<Compile Include="Constant\AppConstant.cs" />
|
<Compile Include="Constant\AppConstant.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\IconInfoDialog.xaml.cs">
|
||||||
|
<DependentUpon>IconInfoDialog.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
||||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
||||||
<Compile Include="EditTextBlock\EditableTextBlock.cs" />
|
<Compile Include="EditTextBlock\EditableTextBlock.cs" />
|
||||||
@@ -82,6 +87,7 @@
|
|||||||
<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\HotKey.cs" />
|
||||||
|
<Compile Include="Util\ImageUtil.cs" />
|
||||||
<Compile Include="Util\ListViewDragDropManager.cs" />
|
<Compile Include="Util\ListViewDragDropManager.cs" />
|
||||||
<Compile Include="Util\MenuWidthConvert.cs" />
|
<Compile Include="Util\MenuWidthConvert.cs" />
|
||||||
<Compile Include="Util\MouseUtilities.cs" />
|
<Compile Include="Util\MouseUtilities.cs" />
|
||||||
@@ -91,6 +97,10 @@
|
|||||||
<Compile Include="ViewModel\AppData.cs" />
|
<Compile Include="ViewModel\AppData.cs" />
|
||||||
<Compile Include="ViewModel\IconInfo.cs" />
|
<Compile Include="ViewModel\IconInfo.cs" />
|
||||||
<Compile Include="ViewModel\MenuInfo.cs" />
|
<Compile Include="ViewModel\MenuInfo.cs" />
|
||||||
|
<Page Include="Control\IconInfoDialog.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>
|
||||||
@@ -139,6 +149,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Resource\DefaultIconfont\iconfont.svg" />
|
<Content Include="Resource\DefaultIconfont\iconfont.svg" />
|
||||||
|
<Resource Include="Resource\Image\图片.png" />
|
||||||
|
<Resource Include="Resource\Image\文件夹.png" />
|
||||||
<Resource Include="Resource\Image\Ico.png" />
|
<Resource Include="Resource\Image\Ico.png" />
|
||||||
<Resource Include="Resource\Image\Ico.ico" />
|
<Resource Include="Resource\Image\Ico.ico" />
|
||||||
<Resource Include="Resource\Image\WindowLogo.png" />
|
<Resource Include="Resource\Image\WindowLogo.png" />
|
||||||
|
|||||||
260
MainWindow.xaml
260
MainWindow.xaml
@@ -10,6 +10,10 @@
|
|||||||
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="500" Width="600"
|
Title="MainWindow" Height="500" Width="600"
|
||||||
|
WindowStyle="None"
|
||||||
|
AllowsTransparency="True"
|
||||||
|
Background="Transparent"
|
||||||
|
OpacityMask ="White"
|
||||||
>
|
>
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
|
||||||
@@ -17,11 +21,12 @@
|
|||||||
<Style x:Key="menuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
|
<Style x:Key="menuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
|
||||||
<Setter Property="FontSize" Value="15"/>
|
<Setter Property="FontSize" Value="15"/>
|
||||||
<Setter Property="Margin" Value="0,0,0,1"/>
|
<Setter Property="Margin" Value="0,0,0,1"/>
|
||||||
<Setter Property="RenderTransform">
|
<Setter Property="Background">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<TranslateTransform/>
|
<SolidColorBrush Opacity="0"/>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<MultiTrigger>
|
<MultiTrigger>
|
||||||
<MultiTrigger.Conditions>
|
<MultiTrigger.Conditions>
|
||||||
@@ -38,16 +43,16 @@
|
|||||||
<MultiTrigger.ExitActions>
|
<MultiTrigger.ExitActions>
|
||||||
<BeginStoryboard>
|
<BeginStoryboard>
|
||||||
<Storyboard Timeline.DesiredFrameRate="30">
|
<Storyboard Timeline.DesiredFrameRate="30">
|
||||||
<DoubleAnimation To="20" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
|
<DoubleAnimation To="18" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
|
||||||
</Storyboard>
|
</Storyboard>
|
||||||
</BeginStoryboard>
|
</BeginStoryboard>
|
||||||
</MultiTrigger.ExitActions>
|
</MultiTrigger.ExitActions>
|
||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
<Trigger Property="IsMouseOver" Value="True">
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
<Setter Property="Background" Value="#C3C3C3"/>
|
<Setter Property="Background" Value="#FFE4DBDB"/>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
<Trigger Property="IsFocused" Value="true">
|
<Trigger Property="IsSelected" Value="true">
|
||||||
<Setter Property="Background" Value="#B9B9B9"/>
|
<Setter Property="Background" Value="#FFECECEC"/>
|
||||||
<Setter Property="Foreground" Value="Black"/>
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
@@ -90,38 +95,48 @@
|
|||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
|
|
||||||
|
<Border CornerRadius="5" BorderThickness="0" Background="White">
|
||||||
|
<Border CornerRadius="5" BorderThickness="0">
|
||||||
|
<!--背景图片-->
|
||||||
|
<Border.Background>
|
||||||
|
<ImageBrush ImageSource="D:\壁纸\18086.jpg" Opacity="0.9"></ImageBrush>
|
||||||
|
</Border.Background>
|
||||||
|
<Grid>
|
||||||
|
|
||||||
<Grid>
|
<!--<Grid.Background>
|
||||||
<!--背景图片-->
|
|
||||||
<Grid.Background>
|
|
||||||
<ImageBrush ImageSource="D:\壁纸\18039.jpg" Opacity="0.618"></ImageBrush>
|
|
||||||
</Grid.Background>
|
|
||||||
<!--<Grid.Background>
|
|
||||||
<SolidColorBrush Color="Black" Opacity="0.5"/>
|
<SolidColorBrush Color="Black" Opacity="0.5"/>
|
||||||
</Grid.Background>-->
|
</Grid.Background>-->
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
|
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
|
||||||
<RowDefinition Height="*"></RowDefinition>
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition x:Name="leftColumn" MinWidth="80" Width="150" MaxWidth="200"></ColumnDefinition>
|
<ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="165" MaxWidth="200"></ColumnDefinition>
|
||||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
<ColumnDefinition Width="45*"></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
<ColumnDefinition Width="382*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
|
||||||
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
|
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
|
||||||
<Image Source="/Resource/Image/WindowLogo.png" Margin="10,0,0,0" Width="94" Height="30" HorizontalAlignment="Left"/>
|
<DockPanel.Background>
|
||||||
</DockPanel>
|
<SolidColorBrush Opacity="0.01"/>
|
||||||
|
</DockPanel.Background>
|
||||||
|
<Image Source="/Resource/Image/WindowLogo.png" Margin="10,0,0,0" Width="94" Height="30" HorizontalAlignment="Left"/>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" MouseMove="DragMove" HorizontalAlignment="Right" Orientation="Horizontal">
|
<DockPanel Grid.Row="0" Grid.Column="2" MouseMove="DragMove">
|
||||||
<Button Background="Transparent"
|
<DockPanel.Background>
|
||||||
|
<SolidColorBrush Opacity="0.01"/>
|
||||||
|
</DockPanel.Background>
|
||||||
|
<hc:UniformSpacingPanel Spacing="0" Grid.ColumnSpan="4" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||||
|
<Button Background="Transparent"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
hc:IconElement.Geometry="{StaticResource ODDataGeometry}"
|
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.Height="18"
|
||||||
hc:IconElement.Width="18"
|
hc:IconElement.Width="18"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
/>
|
/>
|
||||||
<Button Background="Transparent"
|
<Button Background="Transparent"
|
||||||
BorderThickness="0"
|
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.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.Height="18"
|
||||||
@@ -129,107 +144,142 @@
|
|||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Click="CloseButtonClick"
|
Click="CloseButtonClick"
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
</hc:UniformSpacingPanel>
|
||||||
|
|
||||||
<!--左侧栏-->
|
</DockPanel>
|
||||||
<hc:Card x:Name="leftCard" Grid.Row="1" Grid.Column="0"
|
|
||||||
|
<!--左侧栏-->
|
||||||
|
<hc:Card x:Name="leftCard" Grid.Row="1" Grid.Column="0"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Effect="{DynamicResource EffectShadow2}"
|
Effect="{DynamicResource EffectShadow2}"
|
||||||
Opacity="0.5"
|
|
||||||
Margin="5,0,0,5"
|
Margin="5,0,0,5"
|
||||||
>
|
>
|
||||||
<hc:Card.ContextMenu>
|
<hc:Card.Background>
|
||||||
<ContextMenu Width="200">
|
<SolidColorBrush Color="#FFFFFFFF" Opacity="0.5"/>
|
||||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
</hc:Card.Background>
|
||||||
</ContextMenu>
|
<hc:Card.BorderBrush>
|
||||||
</hc:Card.ContextMenu>
|
<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}"
|
||||||
|
BorderThickness="0" Foreground="{x:Null}"
|
||||||
|
>
|
||||||
|
|
||||||
<ListBox x:Name="menus"
|
|
||||||
ItemsSource="{Binding MenuList}"
|
|
||||||
SelectionChanged="MenuClick">
|
|
||||||
<ListBox.Resources>
|
|
||||||
<ContextMenu x:Key="menuDialog" Width="200">
|
|
||||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
|
||||||
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
|
|
||||||
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
|
|
||||||
</ContextMenu>
|
|
||||||
</ListBox.Resources>
|
|
||||||
|
|
||||||
<ListBox.ItemContainerStyle>
|
<ListBox.Resources>
|
||||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource menuStyle}">
|
<ContextMenu x:Key="menuDialog" Width="200">
|
||||||
<Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
|
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
||||||
</Style>
|
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
|
||||||
</ListBox.ItemContainerStyle>
|
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
|
||||||
<ListBox.ItemsPanel>
|
</ContextMenu>
|
||||||
<ItemsPanelTemplate>
|
</ListBox.Resources>
|
||||||
<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>
|
<ListBox.ItemContainerStyle>
|
||||||
<DataTemplate>
|
<Style TargetType="ListBoxItem" BasedOn="{StaticResource menuStyle}">
|
||||||
<StackPanel>
|
<Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
|
||||||
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
|
<ListBox.Background>
|
||||||
|
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
|
||||||
|
</ListBox.Background>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel MouseLeftButtonDown="MenuClick" Tag="{Binding}">
|
||||||
|
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Width="{Binding ElementName=leftColumn, Path=Width, Converter={StaticResource MenuWidthConvert}}"
|
Width="{Binding ElementName=LeftColumn, Path=Width, Converter={StaticResource MenuWidthConvert}}"
|
||||||
FontSize="15"
|
FontSize="15"
|
||||||
TextAlignment="Left"
|
TextAlignment="Left"
|
||||||
BorderBrush="{x:Null}"
|
|
||||||
BorderThickness="0"
|
|
||||||
LostFocus="LostFocusOrEnterDown"
|
LostFocus="LostFocusOrEnterDown"
|
||||||
KeyDown="LostFocusOrEnterDown"
|
KeyDown="LostFocusOrEnterDown"
|
||||||
Tag="{Binding}"
|
Tag="{Binding}"
|
||||||
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
||||||
Visibility="{Binding Path=MenuEdit, Converter={StaticResource VisibilityConvert}}"/>
|
Visibility="{Binding Path=MenuEdit, Converter={StaticResource VisibilityConvert}}"/>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Button Background="Transparent"
|
<Button Background="Transparent"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
hc:IconElement.Geometry="M805.677 218h100.323v540.3c0 0.072-0.972-0.3-1.696-0.3h-779.304v-561h401.869l3.867-1.982s230.651-131.583 285.375-162.778l-18.832 185.76h8.398zM246.395 562.149c0 45.515 37.029 82.543 82.543 82.543s82.543-37.029 82.543-82.543-37.029-82.543-82.543-82.543-82.543 37.028-82.543 82.543zM607.846 333.696c-25.872-10.699-59.908-16.494-95.837-16.494s-69.965 5.746-95.837 16.445c-41.257 17.061-47.416 40.353-47.416 52.353h33.591c0-5 8.343-13.687 26.661-21.263 21.579-8.924 51.832-13.945 83.001-13.945s61.421 4.971 83.001 13.896c18.317 7.576 26.661 16.312 26.661 21.312h33.591c-0.001-12-6.16-35.243-47.416-52.304zM695.078 479.606c-45.515 0-82.543 37.029-82.543 82.543s37.029 82.543 82.543 82.543c45.515 0 82.543-37.029 82.543-82.543s-37.028-82.543-82.543-82.543zM904.304 792h-784.765c-30.073 0-54.539-24.863-54.539-55.425v-517.298c0-30.561 24.466-55.277 54.539-55.277h398.429c34.254-20 284.848-162.442 292.86-167.011 5.582-3.184 10.775-4.768 15.874-4.767 7.977 0.001 14.871 3.852 19.076 10.598 2.903 4.656 4.221 10.346 4.221 17.432v143.748h54.304c30.356 0 54.697 24.716 54.697 55.277v517.298c0 30.562-24.341 55.425-54.696 55.425zM927 217.598c0-20.155-20.551-20.598-20.551-20.598h-89.449v-169.19l-0.685 4.759c-54.724 31.195-285.477 162.449-285.477 162.449l-3.969 1.982h-408.963c-11.132 0-19.906 9.466-19.906 20.598v521.497c0 11.131 8.774 19.905 19.905 19.905h7.095v-1h779.304c0.724 0 1.696 0.371 1.696 0.3v0.949c11 0 21-9.023 21-20.154v-521.497zM377.891 562.149c0 26.993-21.96 48.953-48.953 48.953-26.993 0-48.953-21.96-48.953-48.953 0-26.992 21.96-48.953 48.953-48.953 26.993 0 48.953 21.961 48.953 48.953zM411.482 562.149c0 45.515-37.029 82.543-82.543 82.543s-82.543-37.029-82.543-82.543 37.029-82.543 82.543-82.543 82.543 37.028 82.543 82.543zM279.986 562.149c0 26.993 21.96 48.953 48.953 48.953 26.992 0 48.953-21.96 48.953-48.953 0-26.992-21.96-48.953-48.953-48.953-26.993 0-48.953 21.961-48.953 48.953zM744.031 562.149c0 26.993-21.96 48.953-48.953 48.953s-48.953-21.96-48.953-48.953c0-26.992 21.96-48.953 48.953-48.953s48.953 21.961 48.953 48.953zM695.078 644.693c-45.515 0-82.543-37.029-82.543-82.543s37.029-82.543 82.543-82.543c45.515 0 82.543 37.029 82.543 82.543s-37.028 82.543-82.543 82.543zM646.126 562.149c0 26.993 21.96 48.953 48.953 48.953s48.953-21.96 48.953-48.953c0-26.992-21.96-48.953-48.953-48.953s-48.953 21.961-48.953 48.953zM595.009 364.737c-21.579-8.924-51.832-13.945-83.001-13.945s-61.421 4.971-83.001 13.896c-18.318 7.576-26.661 16.312-26.661 21.312h-33.591c0-12 6.16-35.243 47.415-52.304 25.873-10.699 59.908-16.494 95.837-16.494s69.965 5.746 95.837 16.445c41.258 17.061 47.417 40.353 47.417 52.353h-33.591c0.001-5-8.343-13.687-26.661-21.263zM125 759h-7.095c-11.131 0-19.905-8.774-19.905-19.905v-521.497c0-11.132 8.774-20.598 19.905-20.598h7.095v562zM906 759.249v-541.249h-108.721l19.036-185.65 0.685-4.54v169.19h89.449s20.551 0.443 20.551 20.598v521.497c0 11.131-10 20.154-21 20.154z"
|
hc:IconElement.Geometry="M438.857143 548.571429a36.571429 36.571429 0 0 1 36.571428 36.571428v256a36.571429 36.571429 0 0 1-36.571428 36.571429H182.857143a36.571429 36.571429 0 0 1-36.571429-36.571429v-256a36.571429 36.571429 0 0 1 36.571429-36.571428h256z m402.285714 0a36.571429 36.571429 0 0 1 36.571429 36.571428v256a36.571429 36.571429 0 0 1-36.571429 36.571429h-256a36.571429 36.571429 0 0 1-36.571428-36.571429v-256a36.571429 36.571429 0 0 1 36.571428-36.571428h256z m-438.857143 73.142857H219.428571v182.857143h182.857143v-182.857143z m402.285715 0h-182.857143v182.857143h182.857143v-182.857143zM438.857143 146.285714a36.571429 36.571429 0 0 1 36.571428 36.571429v256a36.571429 36.571429 0 0 1-36.571428 36.571428H182.857143a36.571429 36.571429 0 0 1-36.571429-36.571428V182.857143a36.571429 36.571429 0 0 1 36.571429-36.571429h256z m402.285714 0a36.571429 36.571429 0 0 1 36.571429 36.571429v256a36.571429 36.571429 0 0 1-36.571429 36.571428h-256a36.571429 36.571429 0 0 1-36.571428-36.571428V182.857143a36.571429 36.571429 0 0 1 36.571428-36.571429h256zM402.285714 219.428571H219.428571v182.857143h182.857143V219.428571z m402.285715 0h-182.857143v182.857143h182.857143V219.428571z"
|
||||||
hc:IconElement.Height="18"
|
hc:IconElement.Height="18"
|
||||||
hc:IconElement.Width="18"
|
hc:IconElement.Width="18"
|
||||||
/>
|
/>
|
||||||
<TextBlock Text="{Binding MenuName}"
|
<TextBlock Text="{Binding MenuName}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
IsVisibleChanged="MenuWhenVisibilityChanged"
|
IsVisibleChanged="MenuWhenVisibilityChanged"
|
||||||
Visibility="{Binding Path=NotMenuEdit, Converter={StaticResource VisibilityConvert}}"
|
Visibility="{Binding Path=NotMenuEdit, Converter={StaticResource VisibilityConvert}}"
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
</hc:Card>
|
|
||||||
|
|
||||||
<!--分割线-->
|
|
||||||
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
|
|
||||||
|
|
||||||
<!--右侧栏-->
|
</StackPanel>
|
||||||
<hc:Card AllowDrop="True"
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</WrapPanel>
|
||||||
|
</hc:Card>
|
||||||
|
|
||||||
|
<!--分割线-->
|
||||||
|
<GridSplitter DragCompleted="LeftCardResize" Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
|
||||||
|
|
||||||
|
<!--右侧栏-->
|
||||||
|
<hc:Card AllowDrop="True"
|
||||||
Drop="Wrap_Drop"
|
Drop="Wrap_Drop"
|
||||||
Opacity="0.5"
|
|
||||||
x:Name="rightCard"
|
x:Name="rightCard"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Effect="{DynamicResource EffectShadow2}"
|
Effect="{DynamicResource EffectShadow2}"
|
||||||
Margin="5,0,5,5">
|
Margin="5,0,5,5" Grid.ColumnSpan="2">
|
||||||
<WrapPanel Orientation="Horizontal">
|
<hc:Card.Background>
|
||||||
<ListBox x:Name="icons" ItemsSource="{Binding}"
|
<SolidColorBrush Color="#FFFFFFFF" Opacity="0.5"/>
|
||||||
|
</hc:Card.Background>
|
||||||
|
<hc:Card.BorderBrush>
|
||||||
|
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||||
|
</hc:Card.BorderBrush>
|
||||||
|
<WrapPanel Orientation="Horizontal">
|
||||||
|
<ListBox x:Name="icons" ItemsSource="{Binding}"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
SelectionChanged="IconSelectionChanged"
|
SelectionChanged="IconSelectionChanged"
|
||||||
>
|
>
|
||||||
<ListBox.ItemsPanel>
|
<ListBox.Background>
|
||||||
<ItemsPanelTemplate>
|
<SolidColorBrush Opacity="0"/>
|
||||||
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100" HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
|
</ListBox.Background>
|
||||||
</ItemsPanelTemplate>
|
<ListBox.ItemsPanel>
|
||||||
</ListBox.ItemsPanel>
|
<ItemsPanelTemplate>
|
||||||
|
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100" HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
|
||||||
|
</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="PropertyConfig" Tag="{Binding}"/>
|
||||||
|
<MenuItem Header="从列表移除" Click="RemoveIcon" Tag="{Binding}"/>
|
||||||
|
</ContextMenu>
|
||||||
|
</ListBox.Resources>
|
||||||
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemContainerStyle>
|
||||||
<DataTemplate>
|
<Style TargetType="ListBoxItem">
|
||||||
<StackPanel
|
<Setter Property="ContextMenu" Value="{StaticResource iconDialog}"/>
|
||||||
MouseLeftButtonDown="IconClick"
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
|
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Tag="{Binding}"
|
||||||
|
MouseLeftButtonUp="IconClick"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Margin="5,5,5,5"
|
Margin="5,5,5,5"
|
||||||
hc:Poptip.HitMode="None"
|
hc:Poptip.HitMode="None"
|
||||||
@@ -237,21 +287,27 @@
|
|||||||
hc:Poptip.Content="{Binding Content}"
|
hc:Poptip.Content="{Binding Content}"
|
||||||
hc:Poptip.Placement="BottomLeft"
|
hc:Poptip.Placement="BottomLeft"
|
||||||
>
|
>
|
||||||
<Image Style="{StaticResource imageStyle}"></Image>
|
<Image Style="{StaticResource imageStyle}" />
|
||||||
<TextBlock MaxWidth="80"
|
<TextBlock MaxWidth="80"
|
||||||
MaxHeight="40"
|
MaxHeight="40"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
TextTrimming="WordEllipsis"
|
TextTrimming="WordEllipsis"
|
||||||
TextAlignment="Center"
|
TextAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{Binding Name}"/>
|
Text="{Binding Name}"/>
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
</StackPanel>
|
||||||
</ListBox.ItemTemplate>
|
</DataTemplate>
|
||||||
</ListBox>
|
</ListBox.ItemTemplate>
|
||||||
</WrapPanel>
|
</ListBox>
|
||||||
</hc:Card>
|
</WrapPanel>
|
||||||
<hc:NotifyIcon Icon="/Resource/Image/Ico.png" Text="GeekDesk" Click="NotifyIcon_Click"/>
|
</hc:Card>
|
||||||
</Grid>
|
<hc:NotifyIcon Icon="/Resource/Image/Ico.png" Text="GeekDesk" Click="NotifyIcon_Click"/>
|
||||||
|
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using DraggAnimatedPanelExample;
|
using DraggAnimatedPanelExample;
|
||||||
|
using GeekDesk.Constant;
|
||||||
|
using GeekDesk.Control;
|
||||||
using GeekDesk.Util;
|
using GeekDesk.Util;
|
||||||
using GeekDesk.ViewModel;
|
using GeekDesk.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -21,7 +21,7 @@ namespace GeekDesk
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
|
||||||
private AppData appData = CommonCode.GetAppDataByFile();
|
public static AppData appData = CommonCode.GetAppDataByFile();
|
||||||
private int menuSelectIndexTemp = -1;
|
private int menuSelectIndexTemp = -1;
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@@ -40,9 +40,10 @@ namespace GeekDesk
|
|||||||
this.DataContext = appData;
|
this.DataContext = appData;
|
||||||
if (appData.MenuList.Count == 0)
|
if (appData.MenuList.Count == 0)
|
||||||
{
|
{
|
||||||
appData.MenuList.Add(new MenuInfo() { MenuName = "NewGouop", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = (int)Visibility.Collapsed});
|
appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = (int)Visibility.Collapsed});
|
||||||
}
|
}
|
||||||
//窗体大小
|
//窗体大小
|
||||||
|
LeftColumn.Width = new GridLength(appData.AppConfig.MenuCardWidth);
|
||||||
this.Width = appData.AppConfig.WindowWidth;
|
this.Width = appData.AppConfig.WindowWidth;
|
||||||
this.Height = appData.AppConfig.WindowHeight;
|
this.Height = appData.AppConfig.WindowHeight;
|
||||||
//选中 菜单
|
//选中 菜单
|
||||||
@@ -64,18 +65,13 @@ namespace GeekDesk
|
|||||||
{
|
{
|
||||||
int fromS = indexes[0];
|
int fromS = indexes[0];
|
||||||
int to = indexes[1];
|
int to = indexes[1];
|
||||||
var elementSource = icons.Items[to];
|
ObservableCollection<IconInfo> iconList = appData.MenuList[menus.SelectedIndex].IconList;
|
||||||
var dragged = icons.Items[fromS];
|
var elementSource = iconList[to];
|
||||||
if (fromS > to)
|
var dragged = iconList[fromS];
|
||||||
{
|
|
||||||
icons.Items.Remove(dragged);
|
iconList.Remove(dragged);
|
||||||
icons.Items.Insert(to, dragged);
|
iconList.Insert(to, dragged);
|
||||||
}
|
CommonCode.SaveAppData(appData);
|
||||||
else
|
|
||||||
{
|
|
||||||
icons.Items.Remove(dragged);
|
|
||||||
icons.Items.Insert(to, dragged);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return _swap;
|
return _swap;
|
||||||
@@ -96,19 +92,11 @@ namespace GeekDesk
|
|||||||
ObservableCollection<MenuInfo> menuList = appData.MenuList;
|
ObservableCollection<MenuInfo> menuList = appData.MenuList;
|
||||||
var elementSource = menuList[to];
|
var elementSource = menuList[to];
|
||||||
var dragged = menuList[fromS];
|
var dragged = menuList[fromS];
|
||||||
if (fromS > to)
|
menuList.Remove(dragged);
|
||||||
{
|
menuList.Insert(to, dragged);
|
||||||
menuList.Remove(dragged);
|
menus.SelectedIndex = to;
|
||||||
menuList.Insert(to, dragged);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
menuList.Remove(dragged);
|
|
||||||
menuList.Insert(to, dragged);
|
|
||||||
}
|
|
||||||
appData.MenuList = menuList;
|
appData.MenuList = menuList;
|
||||||
//menus.Items.Refresh();
|
CommonCode.SaveAppData(appData);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return _swap2;
|
return _swap2;
|
||||||
@@ -124,33 +112,27 @@ namespace GeekDesk
|
|||||||
foreach (object obj in dropObject)
|
foreach (object obj in dropObject)
|
||||||
{
|
{
|
||||||
string path = (string)obj;
|
string path = (string)obj;
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
// 文件
|
|
||||||
BitmapImage bi = FileIcon.GetBitmapImage(path);
|
|
||||||
IconInfo iconInfo = new IconInfo();
|
|
||||||
iconInfo.Path = path;
|
|
||||||
iconInfo.BitmapImage = bi;
|
|
||||||
iconInfo.Name = Path.GetFileNameWithoutExtension(path);
|
|
||||||
appData.MenuList[menus.SelectedIndex].IconList.Add(iconInfo);
|
|
||||||
CommonCode.SaveAppData(appData);
|
|
||||||
|
|
||||||
}
|
IconInfo iconInfo = new IconInfo
|
||||||
else if (Directory.Exists(path))
|
|
||||||
{
|
{
|
||||||
//文件夹
|
Path = path,
|
||||||
|
BitmapImage = ImageUtil.GetBitmapIconByPath(path)
|
||||||
}
|
};
|
||||||
|
iconInfo.DefaultImage = iconInfo.ImageByteArr;
|
||||||
|
iconInfo.Name = Path.GetFileNameWithoutExtension(path);
|
||||||
|
appData.MenuList[menus.SelectedIndex].IconList.Add(iconInfo);
|
||||||
}
|
}
|
||||||
icons.Items.Refresh();
|
CommonCode.SaveAppData(appData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//菜单点击事件
|
|
||||||
private void MenuClick(object sender, SelectionChangedEventArgs e)
|
////菜单点击事件
|
||||||
|
private void MenuClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
//设置对应菜单的图标列表
|
//设置对应菜单的图标列表
|
||||||
icons.ItemsSource = appData.MenuList[menus.SelectedIndex].IconList;
|
MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
|
||||||
appData.AppConfig.SelectedMenuIndex = menus.SelectedIndex;
|
icons.ItemsSource = mi.IconList;
|
||||||
|
appData.AppConfig.SelectedMenuIndex = menus.Items.IndexOf(mi);
|
||||||
CommonCode.SaveAppData(appData);
|
CommonCode.SaveAppData(appData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +146,81 @@ namespace GeekDesk
|
|||||||
private void IconClick(object sender, MouseButtonEventArgs e)
|
private void IconClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
IconInfo icon = (IconInfo)((StackPanel)sender).Tag;
|
IconInfo icon = (IconInfo)((StackPanel)sender).Tag;
|
||||||
System.Diagnostics.Process.Start(icon.Path);
|
if (icon.AdminStartUp)
|
||||||
icon.Count++;
|
{
|
||||||
CommonCode.SaveAppData(appData);
|
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;
|
||||||
|
this.Visibility = Visibility.Collapsed;
|
||||||
|
break;// c#好像不能case穿透
|
||||||
|
case IconStartType.DEFAULT_STARTUP:
|
||||||
|
this.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++;
|
||||||
|
CommonCode.SaveAppData(appData);
|
||||||
|
} catch (Exception)
|
||||||
|
{
|
||||||
|
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// data选中事件 设置不可选中
|
/// data选中事件 设置不可选中
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -313,7 +365,7 @@ namespace GeekDesk
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void CreateMenu(object sender, RoutedEventArgs e)
|
private void CreateMenu(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
appData.MenuList.Add(new MenuInfo() { MenuEdit = (int)Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewGouop" });
|
appData.MenuList.Add(new MenuInfo() { MenuEdit = (int)Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" });
|
||||||
menus.SelectedIndex = appData.MenuList.Count - 1;
|
menus.SelectedIndex = appData.MenuList.Count - 1;
|
||||||
//appData.MenuList[appData.MenuList.Count - 1].MenuEdit = (int)Visibility.Visible;
|
//appData.MenuList[appData.MenuList.Count - 1].MenuEdit = (int)Visibility.Visible;
|
||||||
CommonCode.SaveAppData(appData);
|
CommonCode.SaveAppData(appData);
|
||||||
@@ -345,6 +397,37 @@ namespace GeekDesk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从列表删除图标
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void RemoveIcon(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
appData.MenuList[menus.SelectedIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
|
||||||
|
CommonCode.SaveAppData(appData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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;
|
||||||
|
CommonCode.SaveAppData(appData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
Resource/Image/图片.png
Normal file
BIN
Resource/Image/图片.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
BIN
Resource/Image/文件夹.png
Normal file
BIN
Resource/Image/文件夹.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -19,23 +19,6 @@ 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();
|
||||||
|
|||||||
207
Util/ImageUtil.cs
Normal file
207
Util/ImageUtil.cs
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
using GeekDesk.Constant;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
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>
|
||||||
|
/// 图片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 GetThumbnail(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(bmpOut);
|
||||||
|
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
|
||||||
|
{
|
||||||
|
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
|
||||||
|
}
|
||||||
|
return BitmapToBitmapImage(bmpOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bitmap to BitmapImage
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bitmap"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static BitmapImage BitmapToBitmapImage(Bitmap bitmap)
|
||||||
|
{
|
||||||
|
BitmapImage bitmapImage = new BitmapImage();
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
bitmap.Save(ms, bitmap.RawFormat);
|
||||||
|
bitmapImage.BeginInit();
|
||||||
|
bitmapImage.StreamSource = ms;
|
||||||
|
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
bitmapImage.EndInit();
|
||||||
|
bitmapImage.Freeze();
|
||||||
|
}
|
||||||
|
return bitmapImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace GeekDesk.ViewModel
|
|||||||
{
|
{
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class AppConfig : System.ComponentModel.INotifyPropertyChanged
|
public class AppConfig : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private int menuSortType = (int)SortType.CUSTOM; //菜单排序类型
|
private int menuSortType = (int)SortType.CUSTOM; //菜单排序类型
|
||||||
private int iconSortType = (int)SortType.CUSTOM; //图表排序类型
|
private int iconSortType = (int)SortType.CUSTOM; //图表排序类型
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.ComponentModel;
|
|||||||
namespace GeekDesk.ViewModel
|
namespace GeekDesk.ViewModel
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
class AppData : INotifyPropertyChanged
|
public class AppData : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private ObservableCollection<MenuInfo> menuList = new ObservableCollection<MenuInfo>();
|
private ObservableCollection<MenuInfo> menuList = new ObservableCollection<MenuInfo>();
|
||||||
private AppConfig appConfig = new AppConfig();
|
private AppConfig appConfig = new AppConfig();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using GeekDesk.Constant;
|
using GeekDesk.Constant;
|
||||||
|
using GeekDesk.Util;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -16,8 +17,38 @@ namespace GeekDesk.ViewModel
|
|||||||
private BitmapImage bitmapImage; //位图
|
private BitmapImage bitmapImage; //位图
|
||||||
private byte[] imageByteArr; //图片 base64
|
private byte[] imageByteArr; //图片 base64
|
||||||
private string content; //显示信息
|
private string content; //显示信息
|
||||||
private int imageWidth = (int)DefaultConstant.IMAGE_WIDTH;
|
private int imageWidth = (int)DefaultConstant.IMAGE_WIDTH; //图片宽度
|
||||||
private int imageHeight = (int)DefaultConstant.IMAGE_HEIGHT;
|
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
|
public int Count
|
||||||
{
|
{
|
||||||
@@ -66,12 +97,12 @@ namespace GeekDesk.ViewModel
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
||||||
return ToImage(ImageByteArr);
|
return ImageUtil.ByteArrToImage(ImageByteArr);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
bitmapImage = value;
|
bitmapImage = value;
|
||||||
ImageByteArr = getJPGFromImageControl(bitmapImage);
|
ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
|
||||||
OnPropertyChanged("BitmapImage");
|
OnPropertyChanged("BitmapImage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,29 +171,6 @@ namespace GeekDesk.ViewModel
|
|||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitmapImage ToImage(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getJPGFromImageControl(BitmapImage bi)
|
|
||||||
{
|
|
||||||
using (MemoryStream memStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
PngBitmapEncoder encoder = new PngBitmapEncoder();
|
|
||||||
encoder.Frames.Add(BitmapFrame.Create(bi));
|
|
||||||
encoder.Save(memStream);
|
|
||||||
return memStream.GetBuffer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ namespace GeekDesk.ViewModel
|
|||||||
{
|
{
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
class MenuInfo : INotifyPropertyChanged
|
public class MenuInfo : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user