💩 优化一部分代码

This commit is contained in:
liufei
2022-06-07 11:16:14 +08:00
parent 444697b457
commit 9d174ed2fc
12 changed files with 54 additions and 44 deletions

View File

@@ -149,7 +149,7 @@
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
<TextBlock Text="背景不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<hc:PreviewSlider Value="{Binding BgOpacity}"
@@ -164,7 +164,7 @@
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<!--<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
@@ -177,7 +177,7 @@
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
</hc:PreviewSlider.PreviewContent>
</hc:PreviewSlider>
</hc:UniformSpacingPanel>
</hc:UniformSpacingPanel>-->
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>

View File

@@ -10,12 +10,21 @@ namespace GeekDesk.Converts
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int val = int.Parse(value.ToString());
var param = 0;
if (parameter != null)
{
param = int.Parse(parameter.ToString());
}
if (val + param > 0)
{
val += param;
}
return new CornerRadius(val);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
return null;
}
}
}

View File

@@ -21,6 +21,7 @@ namespace DraggAnimatedPanel
#endregion
static DraggAnimatedPanel()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DraggAnimatedPanel), new FrameworkPropertyMetadata(typeof(DraggAnimatedPanel)));
}

View File

@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
# Visual Studio Version 17
VisualStudioVersion = 17.1.32319.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeekDesk", "GeekDesk.csproj", "{B4983CEC-2281-413C-8ECF-92EE0E40A713}"

View File

@@ -1,2 +1,2 @@
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 这是个人开发的程序,任何人可任意修改和免费使用(未做较大功能性改动不允许修改赞赏码,重新修改发布需注明出处)
- 商用需联系作者

View File

@@ -29,9 +29,7 @@
GotFocus="Window_GotFocus"
Loaded="Window_Loaded"
>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
</WindowChrome.WindowChrome>
<Window.Resources>
<RoutedUICommand x:Key="SearchHotKeyDown" Text="SearchHotKeyDown"/>
@@ -39,37 +37,31 @@
<cvt:OpcityConvert x:Key="OpcityConvert"/>
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
<Style x:Key="BorderBacStyle" TargetType="Border">
</Style>
</Window.Resources>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" CornerRadius="30" ResizeBorderThickness="15"/>
</WindowChrome.WindowChrome>
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+F" Key="F" Command="{StaticResource SearchHotKeyDown}"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource SearchHotKeyDown}" CanExecute="SearchHotKeyDown"/>
<!--<CommandBinding Command="ChangeImgBG" Executed="ChangeImgBG_Executed" CanExecute="ChangeImgBG_CanExecute" />-->
</Window.CommandBindings>
<Window.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Window.Effect>
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
Background="#EBF7E3"
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"
hc:Dialog.Token="IconInfoDialog"
<!--Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"-->
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
BorderThickness="0"
Focusable="True"
x:Name="BGBorder"
hc:Dialog.Token="IconInfoDialog"
>
<hc:DialogContainer Focusable="True">
<!-- -1是为了解决圆角白线的问题-->
<Border x:Name="BGBorder"
CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
BorderThickness="0"
Margin="-1"
>
<Border.Effect>
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Border.Effect>
<hc:DialogContainer Focusable="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
@@ -167,8 +159,7 @@
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
</Grid>
</Border>
</hc:DialogContainer>
</hc:DialogContainer>
</Border>
</Window>

View File

@@ -230,6 +230,10 @@ namespace GeekDesk
//自动备份一次数据
appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
CommonCode.SaveAppData(appData, Constants.DATA_FILE_BAK_PATH);
//毛玻璃 暂时未解决阴影问题
//BlurGlassUtil.EnableBlur(this);
AeroGlassUtil.GlassWindow(this);
}
/// <summary>

View File

@@ -1,3 +1,4 @@
# BookerLiu
diff a/MainWindow.xaml b/MainWindow.xaml (rejected hunks)
@@ -20,6 +20,7 @@
SizeChanged="Window_SizeChanged"

View File

@@ -4,7 +4,7 @@ using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
// 与程序集关联的信息。
[assembly: AssemblyTitle("GeekDesk")]
[assembly: AssemblyDescription("小巧、美观的桌面快速启动工具")]
[assembly: AssemblyConfiguration("")]

View File

@@ -60,7 +60,7 @@ namespace GeekDesk.Task
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
}
#region

View File

@@ -45,7 +45,7 @@ namespace GeekDesk.Util
else
{
LinearGradientBrush lgb = new LinearGradientBrush();
lgb.Opacity = (double)(Math.Round((decimal)(appConfig.BgOpacity / 100.00), 2));
GradientStop gs = new GradientStop
{
Color = (Color)ColorConverter.ConvertFromString(appConfig.GradientBGParam.Color1),

View File

@@ -50,20 +50,24 @@ namespace GeekDesk.Util
public static void EnableBlur(Window window)
{
var windowHelper = new WindowInteropHelper(window);
WindowInteropHelper windowHelper = new WindowInteropHelper(window);
var accent = new AccentPolicy();
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
AccentPolicy accent = new AccentPolicy
{
AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND
};
var accentStructSize = Marshal.SizeOf(accent);
int accentStructSize = Marshal.SizeOf(accent);
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
IntPtr accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
var data = new WindowCompositionAttributeData();
data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
data.SizeOfData = accentStructSize;
data.Data = accentPtr;
WindowCompositionAttributeData data = new WindowCompositionAttributeData
{
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
SizeOfData = accentStructSize,
Data = accentPtr
};
SetWindowCompositionAttribute(windowHelper.Handle, ref data);