Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ContextMenuManager/BluePointLilac.Controls/MyListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MyListBox : Panel
public MyListBox()
{
this.AutoScroll = true;
this.BackColor = Color.FromArgb(250, 250, 250);
this.BackColor = ContextMenuManager.Methods.AppTheme.FormBack;
}

protected override void OnMouseWheel(MouseEventArgs e)
Expand Down Expand Up @@ -52,14 +52,14 @@ public MyListItem HoveredItem
if(hoveredItem == value) return;
if(hoveredItem != null)
{
hoveredItem.ForeColor = Color.FromArgb(90, 90, 90);
hoveredItem.ForeColor = ContextMenuManager.Methods.AppTheme.PanelFore;
//hoveredItem.BackColor = Color.FromArgb(250, 250, 250);
//hoveredItem.Font = new Font(hoveredItem.Font, FontStyle.Regular);
}
hoveredItem = value;
if(hoveredItem != null)
{
value.ForeColor = Color.FromArgb(0, 138, 217);
value.ForeColor = ContextMenuManager.Methods.AppTheme.ItemSelected;
//value.BackColor = Color.FromArgb(200, 230, 250);
//value.Font = new Font(hoveredItem.Font, FontStyle.Bold);
value.Focus();
Expand Down Expand Up @@ -154,8 +154,8 @@ public MyListItem()
this.Height = 50.DpiZoom();
this.Margin = new Padding(0);
this.Font = SystemFonts.IconTitleFont;
this.ForeColor = Color.FromArgb(80, 80, 80);
this.BackColor = Color.FromArgb(250, 250, 250);
this.ForeColor = ContextMenuManager.Methods.AppTheme.Text;
this.BackColor = ContextMenuManager.Methods.AppTheme.FormBack;
this.Controls.AddRange(new Control[] { lblSeparator, flpControls, lblText, picImage });
this.Resize += (Sender, e) => pnlScrollbar.Height = this.ClientSize.Height;
flpControls.MouseClick += (sender, e) => this.OnMouseClick(e);
Expand Down Expand Up @@ -224,7 +224,7 @@ public bool HasImage
};
private readonly Label lblSeparator = new Label
{
BackColor = Color.FromArgb(220, 220, 220),
BackColor = ContextMenuManager.Methods.AppTheme.Separator,
Dock = DockStyle.Bottom,
Name = "Separator",
Height = 1
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/BluePointLilac.Controls/MyMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public MyMainForm()
{
this.SuspendLayout();
this.Text = Application.ProductName;
this.ForeColor = Color.FromArgb(80, 80, 80);
this.BackColor = Color.FromArgb(250, 250, 250);
this.ForeColor = ContextMenuManager.Methods.AppTheme.FormFore;
this.BackColor = ContextMenuManager.Methods.AppTheme.FormBack;
this.StartPosition = FormStartPosition.CenterScreen;
this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
this.Controls.AddRange(new Control[] { MainBody, SideBar, StatusBar, ToolBar });
Expand Down
24 changes: 18 additions & 6 deletions ContextMenuManager/BluePointLilac.Controls/MySideBar.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BluePointLilac.Methods;
using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
Expand All @@ -13,8 +13,8 @@ public MySideBar()
this.ItemHeight = 30.DpiZoom();
this.Font = SystemFonts.MenuFont;
this.Font = new Font(this.Font.FontFamily, this.Font.Size + 1F);
this.ForeColor = Color.FromArgb(80, 80, 80);
this.BackColor = Color.FromArgb(245, 245, 245);
this.ForeColor = ContextMenuManager.Methods.AppTheme.PanelFore;
this.BackColor = ContextMenuManager.Methods.AppTheme.PanelBack;
this.BackgroundImageLayout = ImageLayout.None;
this.Controls.AddRange(new Control[] { LblSeparator, PnlSelected, PnlHovered });
PnlHovered.Paint += PaintItem;
Expand Down Expand Up @@ -81,19 +81,19 @@ public Color HoveredForeColor

readonly Panel PnlSelected = new Panel
{
BackColor = Color.FromArgb(40, 140, 210),
BackColor = ContextMenuManager.Methods.AppTheme.ItemSelected,
ForeColor = Color.White,
Enabled = false
};
readonly Panel PnlHovered = new Panel
{
BackColor = Color.FromArgb(80, 180, 250),
BackColor = ContextMenuManager.Methods.AppTheme.ItemHover,
ForeColor = Color.White,
Enabled = false
};
readonly Label LblSeparator = new Label
{
BackColor = Color.FromArgb(220, 220, 220),
BackColor = ContextMenuManager.Methods.AppTheme.Separator,
Dock = DockStyle.Right,
Width = 1,
};
Expand Down Expand Up @@ -212,5 +212,17 @@ public int HoveredIndex
HoverIndexChanged?.Invoke(this, null);
}
}

public void UpdateTheme()
{
this.ForeColor = ContextMenuManager.Methods.AppTheme.PanelFore;
this.BackColor = ContextMenuManager.Methods.AppTheme.PanelBack;
PnlSelected.BackColor = ContextMenuManager.Methods.AppTheme.ItemSelected;
PnlHovered.BackColor = ContextMenuManager.Methods.AppTheme.ItemHover;
LblSeparator.BackColor = ContextMenuManager.Methods.AppTheme.Separator;
PaintItems();
RefreshItem(PnlSelected, SelectedIndex);
RefreshItem(PnlHovered, HoveredIndex);
}
}
}
15 changes: 13 additions & 2 deletions ContextMenuManager/BluePointLilac.Controls/MyToolBar.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BluePointLilac.Methods;
using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
Expand All @@ -12,7 +12,10 @@ public MyToolBar()
this.Height = 80.DpiZoom();
this.Dock = DockStyle.Top;
this.DoubleBuffered = true;
this.BackColor = Color.FromArgb(85, 145, 215);
if (ContextMenuManager.Methods.AppConfig.DarkTheme)
this.BackColor = Color.FromArgb(45, 45, 48); // Darker blue/grey for dark theme
else
this.BackColor = Color.FromArgb(85, 145, 215);
}

private MyToolBarButton selectedButton;
Expand Down Expand Up @@ -79,6 +82,14 @@ public void AddButtons(MyToolBarButton[] buttons)
Array.ForEach(buttons, button => maxWidth = Math.Max(maxWidth, TextRenderer.MeasureText(button.Text, button.Font).Width));
Array.ForEach(buttons, button => { button.Width = maxWidth; AddButton(button); });
}

public void UpdateTheme()
{
if (ContextMenuManager.Methods.AppConfig.DarkTheme)
this.BackColor = Color.FromArgb(45, 45, 48);
else
this.BackColor = Color.FromArgb(85, 145, 215);
}
}

public sealed class MyToolBarButton : Panel
Expand Down
6 changes: 3 additions & 3 deletions ContextMenuManager/BluePointLilac.Methods/EncodingType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -49,8 +49,8 @@ private static bool IsUTF8Bytes(byte[] bytes)
{
if(curByte >= 0x80)
{
//判断当前
while(((curByte <<= 1) & 0x80) != 0) count++;
int tempByte = curByte;
while(((tempByte <<= 1) & 0x80) != 0) count++;
//标记位首位若为非0 则至少以2个1开始 如:110XXXXX...........1111110X
if(count == 1 || count > 6) return false;
}
Expand Down
5 changes: 4 additions & 1 deletion ContextMenuManager/BluePointLilac.Methods/WinOsVersion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace BluePointLilac.Methods
{
Expand All @@ -25,5 +25,8 @@ public static class WinOsVersion
public static readonly Version Win10_1909 = new Version(10, 0, 18363);
public static readonly Version Win10_2004 = new Version(10, 0, 19041);
public static readonly Version Win10_20H2 = new Version(10, 0, 19042);
public static readonly Version Win11 = new Version(10, 0, 22000);

public static bool IsWin11 => Current >= Win11;
}
}
3 changes: 2 additions & 1 deletion ContextMenuManager/ContextMenuManager.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -198,6 +198,7 @@
</Compile>
<Compile Include="Methods\UwpHelper.cs" />
<Compile Include="BluePointLilac.Methods\WinOsVersion.cs" />
<Compile Include="Methods\Win11Helper.cs" />
<Compile Include="BluePointLilac.Methods\ShellLink.cs" />
<Compile Include="Methods\WinXHasher.cs" />
<Compile Include="BluePointLilac.Controls\DownloadDialog.cs">
Expand Down
39 changes: 35 additions & 4 deletions ContextMenuManager/Controls/AppSettingBox.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BluePointLilac.Controls;
using BluePointLilac.Controls;
using BluePointLilac.Methods;
using ContextMenuManager.Methods;
using System.Drawing;
Expand Down Expand Up @@ -28,6 +28,8 @@ public AppSettingBox()
mliOpenMoreExplorer.AddCtr(chkOpenMoreExplorer);
mliHideDisabledItems.AddCtr(chkHideDisabledItems);
mliHideSysStoreItems.AddCtr(chkHideSysStoreItems);
mliAppTheme.AddCtr(cmbAppTheme);
mliWin11ClassicMenu.AddCtr(chkWin11ClassicMenu);

ToolTipBox.SetToolTip(btnUpdate, AppString.Tip.ImmediatelyCheck);
ToolTipBox.SetToolTip(cmbConfigDir, AppString.Tip.ConfigPath);
Expand All @@ -41,13 +43,16 @@ public AppSettingBox()
cmbUpdate.Items.AddRange(new[] { AppString.Other.OnceAWeek, AppString.Other.OnceAMonth,
AppString.Other.OnceASeason, AppString.Other.NeverCheck });

cmbConfigDir.Width = cmbEngine.Width = cmbUpdate.Width = cmbRepo.Width = 120.DpiZoom();
cmbAppTheme.Items.AddRange(new[] { "Light", "Dark", "Auto" });

cmbConfigDir.Width = cmbEngine.Width = cmbUpdate.Width = cmbRepo.Width = cmbAppTheme.Width = 120.DpiZoom();
cmbConfigDir.DropDownStyle = cmbEngine.DropDownStyle = cmbUpdate.DropDownStyle
= cmbRepo.DropDownStyle = ComboBoxStyle.DropDownList;
= cmbRepo.DropDownStyle = cmbAppTheme.DropDownStyle = ComboBoxStyle.DropDownList;
cmbConfigDir.AutosizeDropDownWidth();
cmbEngine.AutosizeDropDownWidth();
cmbUpdate.AutosizeDropDownWidth();
cmbRepo.AutosizeDropDownWidth();
cmbAppTheme.AutosizeDropDownWidth();

btnUpdate.MouseDown += (sender, e) =>
{
Expand All @@ -70,9 +75,33 @@ public AppSettingBox()
cmbUpdate.SelectionChangeCommitted += (sender, e) => ChangeUpdateFrequency();
cmbConfigDir.SelectionChangeCommitted += (sender, e) => ChangeConfigDir();
cmbEngine.SelectionChangeCommitted += (sender, e) => ChangeEngineUrl();
cmbAppTheme.SelectionChangeCommitted += (sender, e) =>
{
if(AppConfig.ThemeMode == cmbAppTheme.SelectedIndex) return;
AppConfig.ThemeMode = cmbAppTheme.SelectedIndex;
AppTheme.OnThemeChanged();
};
chkWin11ClassicMenu.CheckChanged += () =>
{
Win11Helper.IsClassicMenuEnabled = chkWin11ClassicMenu.Checked;
ExplorerRestarter.Show();
};
this.ResumeLayout();
}

readonly MyListItem mliAppTheme = new MyListItem
{
Text = "App Theme"
};
readonly ComboBox cmbAppTheme = new ComboBox();

readonly MyListItem mliWin11ClassicMenu = new MyListItem
{
Text = AppString.Other.Win11ClassicMenu,
Visible = WinOsVersion.IsWin11
};
readonly MyCheckBox chkWin11ClassicMenu = new MyCheckBox();

readonly MyListItem mliConfigDir = new MyListItem
{
Text = AppString.Other.ConfigPath
Expand Down Expand Up @@ -163,7 +192,7 @@ public override void ClearItems()

public void LoadItems()
{
this.AddItems(new[] { mliConfigDir, mliUpdate, mliRepo, mliEngine, mliBackup, mliTopMost, mliProtect, mliShowFilePath,
this.AddItems(new[] { mliConfigDir, mliUpdate, mliRepo, mliEngine, mliBackup, mliAppTheme, mliWin11ClassicMenu, mliTopMost, mliProtect, mliShowFilePath,
mliHideDisabledItems, mliHideSysStoreItems, mliOpenMoreRegedit, mliOpenMoreExplorer, mliWinXSortable });
foreach(MyListItem item in this.Controls) item.HasImage = false;
cmbConfigDir.SelectedIndex = AppConfig.SaveToAppDir ? 1 : 0;
Expand All @@ -179,6 +208,8 @@ public void LoadItems()
chkOpenMoreExplorer.Checked = AppConfig.OpenMoreExplorer;
chkHideDisabledItems.Checked = AppConfig.HideDisabledItems;
chkHideSysStoreItems.Checked = AppConfig.HideSysStoreItems;
cmbAppTheme.SelectedIndex = AppConfig.ThemeMode;
chkWin11ClassicMenu.Checked = Win11Helper.IsClassicMenuEnabled;
}

private void ChangeConfigDir()
Expand Down
25 changes: 16 additions & 9 deletions ContextMenuManager/Controls/ShellList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BluePointLilac.Controls;
using BluePointLilac.Controls;
using BluePointLilac.Methods;
using ContextMenuManager.Methods;
using Microsoft.Win32;
Expand Down Expand Up @@ -230,7 +230,7 @@ public void LoadItems()
case Scenes.CommandStore:
//Vista系统没有这一项
if(WinOsVersion.Current == WinOsVersion.Vista) return;
this.AddNewItem(RegistryEx.GetParentPath(ShellItem.CommandStorePath));
this.AddNewItem(RegistryEx.GetParentPath(ObjectPath.CommandStorePath));
this.LoadStoreItems();
return;
case Scenes.DragDrop:
Expand All @@ -241,6 +241,7 @@ public void LoadItems()
this.LoadShellExItems(GetShellExPath(MENUPATH_DRIVE));
this.LoadShellExItems(GetShellExPath(MENUPATH_ALLOBJECTS));
return;

}
this.AddNewItem(scenePath);
this.LoadItems(scenePath);
Expand Down Expand Up @@ -371,11 +372,12 @@ private void AddNewItem(string scenePath)
PictureButton btnEnhanceMenu = new PictureButton(AppImage.Enhance);
ToolTipBox.SetToolTip(btnAddExisting, AppString.Tip.AddFromPublic);
ToolTipBox.SetToolTip(btnEnhanceMenu, AppString.StatusBar.EnhanceMenu);
if(Scene == Scenes.DragDrop || ShellItem.CommandStorePath.Equals(shellPath,
if(Scene == Scenes.DragDrop || ObjectPath.CommandStorePath.Equals(shellPath,
StringComparison.OrdinalIgnoreCase) || ObjectPath.CommandStorePathCU.Equals(shellPath,
StringComparison.OrdinalIgnoreCase)) btnAddExisting.Visible = false;
else
{
using(RegistryKey key = RegistryEx.GetRegistryKey(ShellItem.CommandStorePath))
using(RegistryKey key = RegistryEx.GetRegistryKey(ObjectPath.CommandStorePath))
{
List<string> subKeyNames = key.GetSubKeyNames().ToList();
if(AppConfig.HideSysStoreItems) subKeyNames.RemoveAll(name => name.StartsWith("Windows.", StringComparison.OrdinalIgnoreCase));
Expand Down Expand Up @@ -410,7 +412,7 @@ private void AddNewItem(string scenePath)
using(ShellStoreDialog dlg = new ShellStoreDialog())
{
dlg.IsReference = false;
dlg.ShellPath = ShellItem.CommandStorePath;
dlg.ShellPath = ObjectPath.CommandStorePath;
dlg.Filter = new Func<string, bool>(itemName => !(AppConfig.HideSysStoreItems
&& itemName.StartsWith("Windows.", StringComparison.OrdinalIgnoreCase)));
if(dlg.ShowDialog() != DialogResult.OK) return;
Expand Down Expand Up @@ -548,16 +550,21 @@ private void AddNewShellExItem(string scenePath)

private void LoadStoreItems()
{
using(RegistryKey shellKey = RegistryEx.GetRegistryKey(ShellItem.CommandStorePath))
foreach(string path in new[] { ObjectPath.CommandStorePath, ObjectPath.CommandStorePathCU })
{
foreach(string itemName in shellKey.GetSubKeyNames())
using(RegistryKey shellKey = RegistryEx.GetRegistryKey(path))
{
if(AppConfig.HideSysStoreItems && itemName.StartsWith("Windows.", StringComparison.OrdinalIgnoreCase)) continue;
this.AddItem(new StoreShellItem($@"{ShellItem.CommandStorePath}\{itemName}", true, false));
if(shellKey == null) continue;
foreach(string itemName in shellKey.GetSubKeyNames())
{
if(AppConfig.HideSysStoreItems && itemName.StartsWith("Windows.", StringComparison.OrdinalIgnoreCase)) continue;
this.AddItem(new StoreShellItem($@"{path}\{itemName}", true, false));
}
}
}
}


private void LoadUwpModeItem()
{
foreach(XmlDocument doc in XmlDicHelper.UwpModeItemsDic)
Expand Down
Loading