Major UI rework!
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
5.4.9.3 Beta (2021-??-??)
|
5.4.9.3 Beta (2021-??-??)
|
||||||
|
|
||||||
- Leaving fullscreen using keepaspect-window=no restores the correct size.
|
- Leaving fullscreen using keepaspect-window=no restores the correct size.
|
||||||
|
- Major UI rework!
|
||||||
- libmpv shinchiro 2021-08-15
|
- libmpv shinchiro 2021-08-15
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
src/.editorconfig
Normal file
7
src/.editorconfig
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[*.cs]
|
||||||
|
|
||||||
|
# IDE0058: Expression value is never used
|
||||||
|
dotnet_diagnostic.IDE0058.severity = none
|
||||||
|
|
||||||
|
# IDE0055: Fix formatting
|
||||||
|
dotnet_diagnostic.IDE0055.severity = none
|
||||||
@@ -97,12 +97,26 @@ namespace mpvnet
|
|||||||
themeContent,
|
themeContent,
|
||||||
Properties.Resources.theme,
|
Properties.Resources.theme,
|
||||||
IsDarkMode ? DarkTheme : LightTheme);
|
IsDarkMode ? DarkTheme : LightTheme);
|
||||||
|
}
|
||||||
|
|
||||||
ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
|
public static void UpdateWpfColors()
|
||||||
ToolStripRendererEx.BackgroundColor = Theme.Current.GetWinFormsColor("menu-background");
|
{
|
||||||
ToolStripRendererEx.SelectionColor = Theme.Current.GetWinFormsColor("menu-highlight");
|
var dic = System.Windows.Application.Current.Resources;
|
||||||
ToolStripRendererEx.BorderColor = Theme.Current.GetWinFormsColor("menu-border");
|
|
||||||
ToolStripRendererEx.CheckedColor = Theme.Current.GetWinFormsColor("menu-checked");
|
dic.Remove("BorderColor");
|
||||||
|
dic.Add("BorderColor", Theme.Current.GetColor("menu-highlight"));
|
||||||
|
|
||||||
|
dic.Remove("RegionColor");
|
||||||
|
dic.Add("RegionColor", Theme.Current.GetColor("menu-background"));
|
||||||
|
|
||||||
|
dic.Remove("SecondaryRegionColor");
|
||||||
|
dic.Add("SecondaryRegionColor", Theme.Current.GetColor("menu-highlight"));
|
||||||
|
|
||||||
|
dic.Remove("PrimaryTextColor");
|
||||||
|
dic.Add("PrimaryTextColor", Theme.Current.GetColor("menu-foreground"));
|
||||||
|
|
||||||
|
dic.Remove("HighlightColor");
|
||||||
|
dic.Add("HighlightColor", Theme.Current.GetColor("highlight"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RunTask(Action action)
|
public static void RunTask(Action action)
|
||||||
@@ -110,19 +124,16 @@ namespace mpvnet
|
|||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
try {
|
try {
|
||||||
action.Invoke();
|
action.Invoke();
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
ShowException(e);
|
ShowException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Version {
|
public static string Version => "Copyright (C) 2000-2021 mpv.net/mpv/mplayer\n" +
|
||||||
get {
|
|
||||||
return "Copyright (C) 2000-2021 mpv.net/mpv/mplayer\n" +
|
|
||||||
$"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" +
|
$"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" +
|
||||||
$"{Core.GetPropertyString("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {Core.GetPropertyString("ffmpeg-version")}\nGPL v2 License";
|
$"{Core.GetPropertyString("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {Core.GetPropertyString("ffmpeg-version")}\nGPL v2 License";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ShowException(object obj)
|
public static void ShowException(object obj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -385,7 +385,12 @@ namespace mpvnet
|
|||||||
|
|
||||||
CommandPaletteItem item = new CommandPaletteItem() {
|
CommandPaletteItem item = new CommandPaletteItem() {
|
||||||
Text = file.FileName(),
|
Text = file.FileName(),
|
||||||
Action = () => Core.SetPropertyInt("playlist-pos", index)
|
Action = () => {
|
||||||
|
Core.SetPropertyInt("playlist-pos", index);
|
||||||
|
|
||||||
|
if (Core.Paused)
|
||||||
|
Core.SetPropertyBool("pause", false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
items.Add(item);
|
items.Add(item);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -10,6 +9,8 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Forms.Integration;
|
using System.Windows.Forms.Integration;
|
||||||
|
|
||||||
|
using WpfControls = System.Windows.Controls;
|
||||||
|
|
||||||
using static mpvnet.Native;
|
using static mpvnet.Native;
|
||||||
using static mpvnet.Global;
|
using static mpvnet.Global;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ namespace mpvnet
|
|||||||
public ElementHost CommandPaletteHost { get; set; }
|
public ElementHost CommandPaletteHost { get; set; }
|
||||||
public static MainForm Instance { get; set; }
|
public static MainForm Instance { get; set; }
|
||||||
public static IntPtr Hwnd { get; set; }
|
public static IntPtr Hwnd { get; set; }
|
||||||
public new ContextMenuStripEx ContextMenu { get; set; }
|
public new WpfControls.ContextMenu ContextMenu { get; set; }
|
||||||
Point LastCursorPosition;
|
Point LastCursorPosition;
|
||||||
Taskbar Taskbar;
|
Taskbar Taskbar;
|
||||||
|
|
||||||
@@ -74,10 +75,6 @@ namespace mpvnet
|
|||||||
|
|
||||||
TaskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated");
|
TaskbarButtonCreatedMessage = RegisterWindowMessage("TaskbarButtonCreated");
|
||||||
|
|
||||||
ContextMenu = new ContextMenuStripEx(components);
|
|
||||||
ContextMenu.Opened += ContextMenu_Opened;
|
|
||||||
ContextMenu.Opening += ContextMenu_Opening;
|
|
||||||
|
|
||||||
if (Core.Screen > -1)
|
if (Core.Screen > -1)
|
||||||
{
|
{
|
||||||
int targetIndex = Core.Screen;
|
int targetIndex = Core.Screen;
|
||||||
@@ -150,8 +147,6 @@ namespace mpvnet
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
|
||||||
|
|
||||||
void Core_Shutdown() => BeginInvoke(new Action(() => Close()));
|
void Core_Shutdown() => BeginInvoke(new Action(() => Close()));
|
||||||
|
|
||||||
void Core_Idle() => SetTitle();
|
void Core_Idle() => SetTitle();
|
||||||
@@ -162,8 +157,6 @@ namespace mpvnet
|
|||||||
|
|
||||||
void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value)));
|
void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value)));
|
||||||
|
|
||||||
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
|
||||||
|
|
||||||
bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None;
|
bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None;
|
||||||
|
|
||||||
bool IsCommandPaletteVissible() => CommandPaletteHost != null && CommandPaletteHost.Visible;
|
bool IsCommandPaletteVissible() => CommandPaletteHost != null && CommandPaletteHost.Visible;
|
||||||
@@ -179,15 +172,15 @@ namespace mpvnet
|
|||||||
return pos.Y > ClientSize.Height * 0.85 || pos.Y < top;
|
return pos.Y > ClientSize.Height * 0.85 || pos.Y < top;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu_Opening(object sender, CancelEventArgs e)
|
void UpdateMenu()
|
||||||
{
|
{
|
||||||
lock (Core.MediaTracks)
|
lock (Core.MediaTracks)
|
||||||
{
|
{
|
||||||
MenuItem trackMenuItem = FindMenuItem("Track");
|
var trackMenuItem = FindMenuItem("Track");
|
||||||
|
|
||||||
if (trackMenuItem != null)
|
if (trackMenuItem != null)
|
||||||
{
|
{
|
||||||
trackMenuItem.DropDownItems.Clear();
|
trackMenuItem.Items.Clear();
|
||||||
|
|
||||||
MediaTrack[] audTracks = Core.MediaTracks.Where(track => track.Type == "a").ToArray();
|
MediaTrack[] audTracks = Core.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||||
MediaTrack[] subTracks = Core.MediaTracks.Where(track => track.Type == "s").ToArray();
|
MediaTrack[] subTracks = Core.MediaTracks.Where(track => track.Type == "s").ToArray();
|
||||||
@@ -196,93 +189,99 @@ namespace mpvnet
|
|||||||
|
|
||||||
foreach (MediaTrack track in vidTracks)
|
foreach (MediaTrack track in vidTracks)
|
||||||
{
|
{
|
||||||
MenuItem mi = new MenuItem(track.Text);
|
var mi = new WpfControls.MenuItem() { Header = track.Text };
|
||||||
mi.Action = () => Core.CommandV("set", "vid", track.ID.ToString());
|
mi.Click += (sender, args) => Core.CommandV("set", "vid", track.ID.ToString());
|
||||||
mi.Checked = Core.VID == track.ID.ToString();
|
mi.IsChecked = Core.VID == track.ID.ToString();
|
||||||
trackMenuItem.DropDownItems.Add(mi);
|
trackMenuItem.Items.Add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vidTracks.Length > 0)
|
if (vidTracks.Length > 0)
|
||||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
trackMenuItem.Items.Add(new WpfControls.Separator());
|
||||||
|
|
||||||
foreach (MediaTrack track in audTracks)
|
foreach (MediaTrack track in audTracks)
|
||||||
{
|
{
|
||||||
MenuItem mi = new MenuItem(track.Text);
|
var mi = new WpfControls.MenuItem() { Header = track.Text };
|
||||||
mi.Action = () => Core.CommandV("set", "aid", track.ID.ToString());
|
mi.Click += (sender, args) => Core.CommandV("set", "aid", track.ID.ToString());
|
||||||
mi.Checked = Core.AID == track.ID.ToString();
|
mi.IsChecked = Core.AID == track.ID.ToString();
|
||||||
trackMenuItem.DropDownItems.Add(mi);
|
trackMenuItem.Items.Add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subTracks.Length > 0)
|
if (subTracks.Length > 0)
|
||||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
trackMenuItem.Items.Add(new WpfControls.Separator());
|
||||||
|
|
||||||
foreach (MediaTrack track in subTracks)
|
foreach (MediaTrack track in subTracks)
|
||||||
{
|
{
|
||||||
MenuItem mi = new MenuItem(track.Text);
|
var mi = new WpfControls.MenuItem() { Header = track.Text };
|
||||||
mi.Action = () => Core.CommandV("set", "sid", track.ID.ToString());
|
mi.Click += (sender, args) => Core.CommandV("set", "sid", track.ID.ToString());
|
||||||
mi.Checked = Core.SID == track.ID.ToString();
|
mi.IsChecked = Core.SID == track.ID.ToString();
|
||||||
trackMenuItem.DropDownItems.Add(mi);
|
trackMenuItem.Items.Add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subTracks.Length > 0)
|
if (subTracks.Length > 0)
|
||||||
{
|
{
|
||||||
MenuItem mi = new MenuItem("S: No subtitles");
|
var mi = new WpfControls.MenuItem() { Header = "S: No subtitles" };
|
||||||
mi.Action = () => Core.CommandV("set", "sid", "no");
|
mi.Click += (sender, args) => Core.CommandV("set", "sid", "no");
|
||||||
mi.Checked = Core.SID == "no";
|
mi.IsChecked = Core.SID == "no";
|
||||||
trackMenuItem.DropDownItems.Add(mi);
|
trackMenuItem.Items.Add(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ediTracks.Length > 0)
|
if (ediTracks.Length > 0)
|
||||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
trackMenuItem.Items.Add(new WpfControls.Separator());
|
||||||
|
|
||||||
foreach (MediaTrack track in ediTracks)
|
foreach (MediaTrack track in ediTracks)
|
||||||
{
|
{
|
||||||
MenuItem mi = new MenuItem(track.Text);
|
var mi = new WpfControls.MenuItem() { Header = track.Text };
|
||||||
mi.Action = () => Core.CommandV("set", "edition", track.ID.ToString());
|
mi.Click += (sender, args) => Core.CommandV("set", "edition", track.ID.ToString());
|
||||||
mi.Checked = Core.Edition == track.ID;
|
mi.IsChecked = Core.Edition == track.ID;
|
||||||
trackMenuItem.DropDownItems.Add(mi);
|
trackMenuItem.Items.Add(mi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (Core.Chapters)
|
lock (Core.Chapters)
|
||||||
{
|
{
|
||||||
MenuItem chaptersMenuItem = FindMenuItem("Chapters");
|
var chaptersMenuItem = FindMenuItem("Chapters");
|
||||||
|
|
||||||
if (chaptersMenuItem != null)
|
if (chaptersMenuItem != null)
|
||||||
{
|
{
|
||||||
chaptersMenuItem.DropDownItems.Clear();
|
chaptersMenuItem.Items.Clear();
|
||||||
|
|
||||||
foreach (var pair in Core.Chapters)
|
foreach (var pair in Core.Chapters)
|
||||||
{
|
{
|
||||||
MenuItem mi = new MenuItem(pair.Key);
|
var chapterMenuItem = new WpfControls.MenuItem() { Header = pair.Key };
|
||||||
mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(pair.Value).ToString().Substring(0, 8) + " ";
|
chapterMenuItem.InputGestureText = TimeSpan.FromSeconds(pair.Value).ToString().Substring(0, 8);
|
||||||
mi.Action = () => Core.CommandV("seek", pair.Value.ToString(CultureInfo.InvariantCulture), "absolute");
|
chapterMenuItem.Click += (sender, args) => Core.CommandV("seek", pair.Value.ToString(CultureInfo.InvariantCulture), "absolute");
|
||||||
chaptersMenuItem.DropDownItems.Add(mi);
|
chaptersMenuItem.Items.Add(chapterMenuItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem recent = FindMenuItem("Recent");
|
var recentMenuItem = FindMenuItem("Recent");
|
||||||
|
|
||||||
if (recent != null)
|
if (recentMenuItem != null)
|
||||||
{
|
{
|
||||||
recent.DropDownItems.Clear();
|
recentMenuItem.Items.Clear();
|
||||||
|
|
||||||
foreach (string path in App.Settings.RecentFiles)
|
foreach (string path in App.Settings.RecentFiles)
|
||||||
MenuItem.Add(recent.DropDownItems, path.ShortPath(100), () => Core.LoadFiles(new[] { path }, true, ModifierKeys.HasFlag(Keys.Control)));
|
{
|
||||||
|
var mi = MenuHelp.Add(recentMenuItem.Items, path.ShortPath(100));
|
||||||
|
|
||||||
recent.DropDownItems.Add(new ToolStripSeparator());
|
if (mi != null)
|
||||||
MenuItem mi = new MenuItem("Clear List");
|
mi.Click += (sender, args) =>
|
||||||
mi.Action = () => App.Settings.RecentFiles.Clear();
|
Core.LoadFiles(new[] { path }, true, ModifierKeys.HasFlag(Keys.Control));
|
||||||
recent.DropDownItems.Add(mi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem titles = FindMenuItem("Titles");
|
recentMenuItem.Items.Add(new WpfControls.Separator());
|
||||||
|
var clearMenuItem = new WpfControls.MenuItem() { Header = "Clear List" };
|
||||||
|
clearMenuItem.Click += (sender, args) => App.Settings.RecentFiles.Clear();
|
||||||
|
recentMenuItem.Items.Add(clearMenuItem);
|
||||||
|
}
|
||||||
|
|
||||||
if (titles != null)
|
var titlesMenuItem = FindMenuItem("Titles");
|
||||||
|
|
||||||
|
if (titlesMenuItem != null)
|
||||||
{
|
{
|
||||||
titles.DropDownItems.Clear();
|
titlesMenuItem.Items.Clear();
|
||||||
|
|
||||||
lock (Core.BluRayTitles)
|
lock (Core.BluRayTitles)
|
||||||
{
|
{
|
||||||
@@ -295,25 +294,39 @@ namespace mpvnet
|
|||||||
.Take(20).OrderBy(item => item.Index);
|
.Take(20).OrderBy(item => item.Index);
|
||||||
|
|
||||||
foreach (var item in titleItems)
|
foreach (var item in titleItems)
|
||||||
if (item.Len != TimeSpan.Zero)
|
|
||||||
MenuItem.Add(titles.DropDownItems, $"{item.Len} ({item.Index})",
|
|
||||||
() => Core.SetBluRayTitle(item.Index));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem profiles = FindMenuItem("Profile");
|
|
||||||
|
|
||||||
if (profiles != null)
|
|
||||||
{
|
{
|
||||||
profiles.DropDownItems.Clear();
|
if (item.Len != TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
var mi = MenuHelp.Add(titlesMenuItem.Items, $"{item.Len} ({item.Index})");
|
||||||
|
|
||||||
|
if (mi != null)
|
||||||
|
mi.Click += (sender, args) => Core.SetBluRayTitle(item.Index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var profilesMenuItem = FindMenuItem("Profile");
|
||||||
|
|
||||||
|
if (profilesMenuItem != null)
|
||||||
|
{
|
||||||
|
profilesMenuItem.Items.Clear();
|
||||||
|
|
||||||
foreach (string profile in ProfileNames)
|
foreach (string profile in ProfileNames)
|
||||||
|
{
|
||||||
if (!profile.StartsWith("extension."))
|
if (!profile.StartsWith("extension."))
|
||||||
MenuItem.Add(profiles.DropDownItems, profile,
|
{
|
||||||
() => {
|
var mi = MenuHelp.Add(profilesMenuItem.Items, profile);
|
||||||
|
|
||||||
|
if (mi != null)
|
||||||
|
{
|
||||||
|
mi.Click += (sender, args) => {
|
||||||
Core.CommandV("show-text", profile);
|
Core.CommandV("show-text", profile);
|
||||||
Core.CommandV("apply-profile", profile);
|
Core.CommandV("apply-profile", profile);
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,18 +347,20 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem FindMenuItem(string text, ToolStripItemCollection items)
|
public WpfControls.MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||||
|
|
||||||
|
WpfControls.MenuItem FindMenuItem(string text, WpfControls.ItemCollection items)
|
||||||
{
|
{
|
||||||
foreach (var item in items)
|
foreach (object item in items)
|
||||||
{
|
{
|
||||||
if (item is MenuItem mi)
|
if (item is WpfControls.MenuItem mi)
|
||||||
{
|
{
|
||||||
if (mi.Text.StartsWith(text) && mi.Text.Trim() == text)
|
if (mi.Header.ToString().StartsWithEx(text) && mi.Header.ToString().TrimEx() == text)
|
||||||
return mi;
|
return mi;
|
||||||
|
|
||||||
if (mi.DropDownItems.Count > 0)
|
if (mi.Items.Count > 0)
|
||||||
{
|
{
|
||||||
MenuItem val = FindMenuItem(text, mi.DropDownItems);
|
WpfControls.MenuItem val = FindMenuItem(text, mi.Items);
|
||||||
|
|
||||||
if (val != null)
|
if (val != null)
|
||||||
return val;
|
return val;
|
||||||
@@ -593,6 +608,8 @@ namespace mpvnet
|
|||||||
|
|
||||||
public void BuildMenu()
|
public void BuildMenu()
|
||||||
{
|
{
|
||||||
|
ContextMenu = new WpfControls.ContextMenu();
|
||||||
|
|
||||||
string content = File.ReadAllText(Core.InputConfPath);
|
string content = File.ReadAllText(Core.InputConfPath);
|
||||||
var items = CommandItem.GetItems(content);
|
var items = CommandItem.GetItems(content);
|
||||||
|
|
||||||
@@ -613,16 +630,21 @@ namespace mpvnet
|
|||||||
if (string.IsNullOrEmpty(item.Path))
|
if (string.IsNullOrEmpty(item.Path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MenuItem menuItem = ContextMenu.Add(item.Path.Replace("&", "&&"), () => {
|
var menuItem = MenuHelp.Add(ContextMenu.Items, item.Path);
|
||||||
try {
|
|
||||||
Core.Command(item.Command);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Msg.ShowException(ex);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (menuItem != null)
|
if (menuItem != null)
|
||||||
menuItem.ShortcutKeyDisplayString = item.Input.Replace("&", "&&") + " ";
|
{
|
||||||
|
menuItem.Click += (sender, args) => {
|
||||||
|
try {
|
||||||
|
Core.Command(item.Command);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Msg.ShowException(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
menuItem.InputGestureText = item.Input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,6 +752,21 @@ namespace mpvnet
|
|||||||
if (Core.WindowHandle != IntPtr.Zero)
|
if (Core.WindowHandle != IntPtr.Zero)
|
||||||
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||||
break;
|
break;
|
||||||
|
case 0x0204: // WM_RBUTTONDOWN
|
||||||
|
if (IsMouseInOSC() && Core.WindowHandle != IntPtr.Zero)
|
||||||
|
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||||
|
break;
|
||||||
|
case 0x0205: // WM_RBUTTONUP
|
||||||
|
if (!IsMouseInOSC())
|
||||||
|
{
|
||||||
|
CursorHelp.Show();
|
||||||
|
UpdateMenu();
|
||||||
|
ContextMenu.IsOpen = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (Core.WindowHandle != IntPtr.Zero)
|
||||||
|
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||||
|
break;
|
||||||
case 0x319: // WM_APPCOMMAND
|
case 0x319: // WM_APPCOMMAND
|
||||||
{
|
{
|
||||||
string value = Input.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
|
string value = Input.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
|
||||||
@@ -848,7 +885,7 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
else if (Environment.TickCount - LastCursorChanged > 1500 &&
|
else if (Environment.TickCount - LastCursorChanged > 1500 &&
|
||||||
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
|
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
|
||||||
ActiveForm == this && !ContextMenu.Visible && !IsCommandPaletteVissible())
|
ActiveForm == this && !ContextMenu.IsVisible && !IsCommandPaletteVissible())
|
||||||
|
|
||||||
CursorHelp.Hide();
|
CursorHelp.Hide();
|
||||||
}
|
}
|
||||||
@@ -958,9 +995,9 @@ namespace mpvnet
|
|||||||
if (Core.GPUAPI == "vulkan")
|
if (Core.GPUAPI == "vulkan")
|
||||||
Core.ProcessCommandLine(false);
|
Core.ProcessCommandLine(false);
|
||||||
|
|
||||||
BuildMenu();
|
|
||||||
ContextMenuStrip = ContextMenu;
|
|
||||||
WPF.Init();
|
WPF.Init();
|
||||||
|
App.UpdateWpfColors();
|
||||||
|
BuildMenu();
|
||||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||||
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
||||||
UpdateCheck.DailyCheck();
|
UpdateCheck.DailyCheck();
|
||||||
@@ -1074,17 +1111,39 @@ namespace mpvnet
|
|||||||
AdjustCommandPaletteLeftAndWidth();
|
AdjustCommandPaletteLeftAndWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ElementHostEx : ElementHost
|
||||||
|
{
|
||||||
|
protected override void OnHandleCreated(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnHandleCreated(e);
|
||||||
|
const int LWA_ColorKey = 1;
|
||||||
|
SetLayeredWindowAttributes(Handle, 0x111111, 255, LWA_ColorKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override CreateParams CreateParams {
|
||||||
|
get {
|
||||||
|
const int WS_EX_LAYERED = 0x00080000;
|
||||||
|
CreateParams cp = base.CreateParams;
|
||||||
|
cp.ExStyle = cp.ExStyle | WS_EX_LAYERED;
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, int crKey, byte alpha, int dwFlags);
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowCommandPalette()
|
public void ShowCommandPalette()
|
||||||
{
|
{
|
||||||
if (CommandPaletteHost == null)
|
if (CommandPaletteHost == null)
|
||||||
{
|
{
|
||||||
CommandPaletteHost = new ElementHost();
|
CommandPaletteHost = new ElementHostEx();
|
||||||
|
CommandPaletteHost.BackColor = Color.FromArgb(0x111111);
|
||||||
|
|
||||||
AdjustCommandPaletteLeftAndWidth();
|
AdjustCommandPaletteLeftAndWidth();
|
||||||
CommandPaletteHost.Child = CommandPalette.Instance;
|
CommandPaletteHost.Child = CommandPalette.Instance;
|
||||||
CommandPalette.Instance.AdjustHeight();
|
CommandPalette.Instance.AdjustHeight();
|
||||||
Controls.Add(CommandPaletteHost);
|
Controls.Add(CommandPaletteHost);
|
||||||
CommandPalette.Instance.Resources.Add("PrimaryTextBrush"
|
|
||||||
, new System.Windows.Media.SolidColorBrush(Theme.Current.GetColor("foreground")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1093,13 +1152,14 @@ namespace mpvnet
|
|||||||
if (CommandPaletteHost != null)
|
if (CommandPaletteHost != null)
|
||||||
{
|
{
|
||||||
CommandPaletteHost.Visible = false;
|
CommandPaletteHost.Visible = false;
|
||||||
|
|
||||||
CommandPalette.Instance.Items.Clear();
|
CommandPalette.Instance.Items.Clear();
|
||||||
CommandPalette.Instance.SearchControl.SearchTextBox.Text = "";
|
CommandPalette.Instance.SearchControl.SearchTextBox.Text = "";
|
||||||
CommandPalette.Instance.UpdateLayout();
|
CommandPalette.Instance.UpdateLayout();
|
||||||
CommandPalette.Instance.Resources.Remove("PrimaryTextBrush");
|
|
||||||
|
|
||||||
ActiveControl = null;
|
ActiveControl = null;
|
||||||
Controls.Remove(CommandPaletteHost);
|
Controls.Remove(CommandPaletteHost);
|
||||||
|
|
||||||
CommandPaletteHost.Child = null;
|
CommandPaletteHost.Child = null;
|
||||||
CommandPaletteHost.Dispose();
|
CommandPaletteHost.Dispose();
|
||||||
CommandPaletteHost = null;
|
CommandPaletteHost = null;
|
||||||
@@ -21,20 +21,12 @@ namespace mpvnet
|
|||||||
public Brush MenuBackground { get; set; }
|
public Brush MenuBackground { get; set; }
|
||||||
public Brush MenuHighlight { get; set; }
|
public Brush MenuHighlight { get; set; }
|
||||||
|
|
||||||
public System.Drawing.Color GetWinFormsColor(string key)
|
|
||||||
{
|
|
||||||
return System.Drawing.ColorTranslator.FromHtml(Dictionary[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Brush GetBrush(string key)
|
public Brush GetBrush(string key)
|
||||||
{
|
{
|
||||||
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(Dictionary[key]));
|
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(Dictionary[key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetColor(string key)
|
public Color GetColor(string key) => (Color)ColorConverter.ConvertFromString(Dictionary[key]);
|
||||||
{
|
|
||||||
return (Color)ColorConverter.ConvertFromString(Dictionary[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Init(string customContent, string defaultContent, string activeTheme)
|
public static void Init(string customContent, string defaultContent, string activeTheme)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ name = dark-mode
|
|||||||
file = mpvnet
|
file = mpvnet
|
||||||
default = always
|
default = always
|
||||||
filter = UI
|
filter = UI
|
||||||
help = Enables a dark theme. (mpv.net specific setting)
|
help = Changes between a light and dark theme.\nmpv.net must be restarted after a change.\nmpv.net specific setting.
|
||||||
|
|
||||||
option = always
|
option = always
|
||||||
option = system Available on Windows 10 or higher
|
option = system Available on Windows 10 or higher
|
||||||
@@ -663,11 +663,11 @@ name = dark-theme
|
|||||||
file = mpvnet
|
file = mpvnet
|
||||||
filter = UI
|
filter = UI
|
||||||
url = https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#color-theme
|
url = https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#color-theme
|
||||||
help = Color theme used in dark mode. Default: dark
|
help = Color theme used in dark mode.\nmpv.net must be restarted after a change.\nmpv.net specific setting. Default: dark
|
||||||
|
|
||||||
[setting]
|
[setting]
|
||||||
name = light-theme
|
name = light-theme
|
||||||
file = mpvnet
|
file = mpvnet
|
||||||
filter = UI
|
filter = UI
|
||||||
url = https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#color-theme
|
url = https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#color-theme
|
||||||
help = Color theme used in light mode. Default: light
|
help = Color theme used in light mode.\nmpv.net must be restarted after a change.\nmpv.net specific setting. Default: light
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ heading = #3C8CC8
|
|||||||
foreground = #DDDDDD
|
foreground = #DDDDDD
|
||||||
foreground2 = #AAAAAA
|
foreground2 = #AAAAAA
|
||||||
background = #323232
|
background = #323232
|
||||||
|
highlight = #404040
|
||||||
|
|
||||||
menu-foreground = #DDDDDD
|
menu-foreground = #DDDDDD
|
||||||
menu-background = #323232
|
menu-background = #323232
|
||||||
menu-highlight = #505050
|
menu-highlight = #505050
|
||||||
menu-border = #FFFFFF
|
|
||||||
menu-checked = #5A5A5A
|
|
||||||
|
|
||||||
|
|
||||||
[light]
|
[light]
|
||||||
@@ -19,9 +18,8 @@ heading = #0068B2
|
|||||||
foreground = #000000
|
foreground = #000000
|
||||||
foreground2 = #4C4C4C
|
foreground2 = #4C4C4C
|
||||||
background = #F7F7F7
|
background = #F7F7F7
|
||||||
|
highlight = #DFDFDF
|
||||||
|
|
||||||
menu-foreground = #000000
|
menu-foreground = #000000
|
||||||
menu-background = #DFDFDF
|
menu-background = #DFDFDF
|
||||||
menu-highlight = #BFBFBF
|
menu-highlight = #BFBFBF
|
||||||
menu-border = #6A6A6A
|
|
||||||
menu-checked = #AAAAAA
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
FontSize="13"
|
FontSize="13"
|
||||||
Loaded="OnLoaded"
|
Loaded="OnLoaded"
|
||||||
Background="{Binding Theme.Background}"
|
Background="#111111"
|
||||||
>
|
>
|
||||||
|
|
||||||
<UserControl.InputBindings>
|
<UserControl.InputBindings>
|
||||||
@@ -17,21 +17,35 @@
|
|||||||
<KeyBinding Gesture="Enter" Command="{Binding ExecuteCommand}"/>
|
<KeyBinding Gesture="Enter" Command="{Binding ExecuteCommand}"/>
|
||||||
</UserControl.InputBindings>
|
</UserControl.InputBindings>
|
||||||
|
|
||||||
|
<Border BorderThickness="1,0,1,1"
|
||||||
|
CornerRadius="0,0,5,5"
|
||||||
|
Padding="0,0,0,5"
|
||||||
|
BorderBrush="{Binding Theme.MenuHighlight}"
|
||||||
|
Background="{Binding Theme.Background}"
|
||||||
|
SnapsToDevicePixels="True"
|
||||||
|
>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Border BorderBrush="{Binding Theme.Heading}"
|
||||||
|
BorderThickness="1"
|
||||||
|
CornerRadius="3"
|
||||||
|
Margin="7"
|
||||||
|
>
|
||||||
|
|
||||||
<local:SearchTextBoxUserControl
|
<local:SearchTextBoxUserControl
|
||||||
HintText="Search"
|
HintText="Search"
|
||||||
x:Name="SearchControl"
|
x:Name="SearchControl"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Padding="1,1,1,0"
|
Padding="1,1,1,0"
|
||||||
/>
|
/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<ListView
|
<ListView Name="MainListView"
|
||||||
Name="MainListView"
|
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Foreground="{Binding Theme.Foreground}"
|
Foreground="{Binding Theme.Foreground}"
|
||||||
Background="{Binding Theme.Background}"
|
Background="{Binding Theme.Background}"
|
||||||
@@ -45,6 +59,46 @@
|
|||||||
<Style TargetType="ListBoxItem">
|
<Style TargetType="ListBoxItem">
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||||
<Setter Property="Height" Value="25"></Setter>
|
<Setter Property="Height" Value="25"></Setter>
|
||||||
|
<Setter Property="BorderThickness" Value="0"></Setter>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||||
|
<Border x:Name="BD"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
SnapsToDevicePixels="true">
|
||||||
|
|
||||||
|
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<MultiTrigger>
|
||||||
|
<MultiTrigger.Conditions>
|
||||||
|
<Condition Property="IsMouseOver" Value="True" />
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
<Setter Property="Background" TargetName="BD" Value="{DynamicResource HighlightBrush}" />
|
||||||
|
</MultiTrigger>
|
||||||
|
<MultiTrigger>
|
||||||
|
<MultiTrigger.Conditions>
|
||||||
|
<Condition Property="Selector.IsSelectionActive" Value="False" />
|
||||||
|
<Condition Property="IsSelected" Value="True" />
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
<Setter Property="Background" TargetName="BD" Value="{DynamicResource BorderBrush}" />
|
||||||
|
</MultiTrigger>
|
||||||
|
<MultiTrigger>
|
||||||
|
<MultiTrigger.Conditions>
|
||||||
|
<Condition Property="Selector.IsSelectionActive" Value="True" />
|
||||||
|
<Condition Property="IsSelected" Value="True" />
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
<Setter Property="Background" TargetName="BD" Value="OrangeRed" />
|
||||||
|
</MultiTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
<Style.Resources>
|
<Style.Resources>
|
||||||
<Style TargetType="Border">
|
<Style TargetType="Border">
|
||||||
@@ -74,4 +128,5 @@
|
|||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</Border>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Windows;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
@@ -31,7 +32,6 @@ namespace mpvnet
|
|||||||
ExecuteCommand = new RelayCommand(OnExecuteCommand);
|
ExecuteCommand = new RelayCommand(OnExecuteCommand);
|
||||||
SearchControl.SearchTextBox.PreviewKeyDown += SearchTextBox_PreviewKeyDown;
|
SearchControl.SearchTextBox.PreviewKeyDown += SearchTextBox_PreviewKeyDown;
|
||||||
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
|
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
|
||||||
SearchControl.SearchTextBox.BorderBrush = Theme.Background;
|
|
||||||
SearchControl.HideClearButton = true;
|
SearchControl.HideClearButton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public void AdjustHeight()
|
public void AdjustHeight()
|
||||||
{
|
{
|
||||||
double actualHeight = SearchControl.ActualHeight + MainListView.ActualHeight;
|
double actualHeight = SearchControl.ActualHeight + MainListView.ActualHeight + 5 + 16;
|
||||||
int dpi = Native.GetDPI(MainForm.Instance.Handle);
|
int dpi = Native.GetDPI(MainForm.Instance.Handle);
|
||||||
MainForm.Instance.CommandPaletteHost.Height = (int)(actualHeight / 96.0 * dpi);
|
MainForm.Instance.CommandPaletteHost.Height = (int)(actualHeight / 96.0 * dpi);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace mpvnet
|
|||||||
List<ConfItem> ConfItems = new List<ConfItem>();
|
List<ConfItem> ConfItems = new List<ConfItem>();
|
||||||
public ObservableCollection<string> FilterStrings { get; } = new ObservableCollection<string>();
|
public ObservableCollection<string> FilterStrings { get; } = new ObservableCollection<string>();
|
||||||
string InitialContent;
|
string InitialContent;
|
||||||
|
string ThemeConf = GetThemeConf();
|
||||||
|
|
||||||
public ConfWindow()
|
public ConfWindow()
|
||||||
{
|
{
|
||||||
@@ -35,6 +36,8 @@ namespace mpvnet
|
|||||||
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
|
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string GetThemeConf() => App.IsDarkMode + App.DarkTheme + App.LightTheme;
|
||||||
|
|
||||||
public Theme Theme => Theme.Current;
|
public Theme Theme => Theme.Current;
|
||||||
|
|
||||||
void LoadSettings()
|
void LoadSettings()
|
||||||
@@ -103,6 +106,10 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
|
|
||||||
App.InitTheme();
|
App.InitTheme();
|
||||||
|
App.UpdateWpfColors();
|
||||||
|
|
||||||
|
if (ThemeConf != GetThemeConf())
|
||||||
|
Msg.ShowInfo("Changed theme settings require mpv.net being restarted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetCompareString()
|
string GetCompareString()
|
||||||
|
|||||||
52
src/WPF/HandyControl/Controls/Attach/BorderElement.cs
Normal file
52
src/WPF/HandyControl/Controls/Attach/BorderElement.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
using HandyControl.Data;
|
||||||
|
using HandyControl.Tools.Converter;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls
|
||||||
|
{
|
||||||
|
public class BorderElement
|
||||||
|
{
|
||||||
|
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"CornerRadius", typeof(CornerRadius), typeof(BorderElement), new FrameworkPropertyMetadata(default(CornerRadius), FrameworkPropertyMetadataOptions.Inherits));
|
||||||
|
|
||||||
|
public static void SetCornerRadius(DependencyObject element, CornerRadius value) => element.SetValue(CornerRadiusProperty, value);
|
||||||
|
|
||||||
|
public static CornerRadius GetCornerRadius(DependencyObject element) => (CornerRadius) element.GetValue(CornerRadiusProperty);
|
||||||
|
|
||||||
|
public static readonly DependencyProperty CircularProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"Circular", typeof(bool), typeof(BorderElement), new PropertyMetadata(ValueBoxes.FalseBox, OnCircularChanged));
|
||||||
|
|
||||||
|
private static void OnCircularChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (d is Border border)
|
||||||
|
{
|
||||||
|
if ((bool) e.NewValue)
|
||||||
|
{
|
||||||
|
var binding = new MultiBinding
|
||||||
|
{
|
||||||
|
Converter = new BorderCircularConverter()
|
||||||
|
};
|
||||||
|
binding.Bindings.Add(new Binding(FrameworkElement.ActualWidthProperty.Name) { Source = border });
|
||||||
|
binding.Bindings.Add(new Binding(FrameworkElement.ActualHeightProperty.Name) { Source = border });
|
||||||
|
border.SetBinding(Border.CornerRadiusProperty, binding);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BindingOperations.ClearBinding(border, FrameworkElement.ActualWidthProperty);
|
||||||
|
BindingOperations.ClearBinding(border, FrameworkElement.ActualHeightProperty);
|
||||||
|
BindingOperations.ClearBinding(border, Border.CornerRadiusProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetCircular(DependencyObject element, bool value)
|
||||||
|
=> element.SetValue(CircularProperty, ValueBoxes.BooleanBox(value));
|
||||||
|
|
||||||
|
public static bool GetCircular(DependencyObject element)
|
||||||
|
=> (bool) element.GetValue(CircularProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
111
src/WPF/HandyControl/Controls/Attach/MenuTopLineAttach.cs
Normal file
111
src/WPF/HandyControl/Controls/Attach/MenuTopLineAttach.cs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
|
||||||
|
using HandyControl.Tools;
|
||||||
|
using HandyControl.Tools.Interop;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls
|
||||||
|
{
|
||||||
|
public class MenuTopLineAttach
|
||||||
|
{
|
||||||
|
public static readonly DependencyProperty PopupProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"Popup", typeof(Popup), typeof(MenuTopLineAttach), new PropertyMetadata(default(Popup), OnPopupChanged));
|
||||||
|
|
||||||
|
private static void OnPopupChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var topLine = (FrameworkElement)d;
|
||||||
|
|
||||||
|
if (e.NewValue is Popup)
|
||||||
|
{
|
||||||
|
Popup popup = e.NewValue as Popup;
|
||||||
|
MenuItem menuItem = popup.TemplatedParent as MenuItem;
|
||||||
|
SetTopLine(menuItem, topLine);
|
||||||
|
menuItem.Loaded += MenuItem_Loaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MenuItem_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var menuItem = (FrameworkElement)sender;
|
||||||
|
menuItem.Unloaded += MenuItem_Unloaded;
|
||||||
|
var topLine = GetTopLine(menuItem);
|
||||||
|
var popup = GetPopup(topLine);
|
||||||
|
if (popup != null)
|
||||||
|
{
|
||||||
|
popup.Opened += Popup_Opened;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MenuItem_Unloaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var menuItem = (FrameworkElement)sender;
|
||||||
|
menuItem.Unloaded -= MenuItem_Unloaded;
|
||||||
|
var topLine = GetTopLine(menuItem);
|
||||||
|
var popup = GetPopup(topLine);
|
||||||
|
if (popup != null)
|
||||||
|
{
|
||||||
|
popup.Opened -= Popup_Opened;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Popup_Opened(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var popup = (Popup)sender;
|
||||||
|
if (popup.TemplatedParent is MenuItem menuItem)
|
||||||
|
{
|
||||||
|
var topLine = GetTopLine(menuItem);
|
||||||
|
if (topLine == null) return;
|
||||||
|
|
||||||
|
topLine.HorizontalAlignment = HorizontalAlignment.Left;
|
||||||
|
topLine.Width = menuItem.ActualWidth;
|
||||||
|
topLine.Margin = new Thickness();
|
||||||
|
|
||||||
|
var positionLeftTop = menuItem.PointToScreen(new Point());
|
||||||
|
var positionRightBottom = menuItem.PointToScreen(new Point(menuItem.ActualWidth, menuItem.ActualHeight));
|
||||||
|
ScreenHelper.FindMonitorRectsFromPoint(InteropMethods.GetCursorPos(), out _, out var workAreaRect);
|
||||||
|
var panel = VisualHelper.GetParent<Panel>(topLine);
|
||||||
|
|
||||||
|
if (positionLeftTop.X < 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
topLine.Margin = new Thickness(positionLeftTop.X - panel.Margin.Left, 0, 0, 0);
|
||||||
|
}
|
||||||
|
else if (positionLeftTop.X + panel.ActualWidth > workAreaRect.Right)
|
||||||
|
{
|
||||||
|
var overflowWidth = positionRightBottom.X - workAreaRect.Right;
|
||||||
|
if (overflowWidth > 0)
|
||||||
|
{
|
||||||
|
topLine.Width -= overflowWidth + panel.Margin.Right;
|
||||||
|
}
|
||||||
|
topLine.HorizontalAlignment = HorizontalAlignment.Left;
|
||||||
|
topLine.Margin = new Thickness(positionLeftTop.X + panel.ActualWidth - workAreaRect.Right + panel.Margin.Right, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (positionRightBottom.Y > workAreaRect.Bottom)
|
||||||
|
{
|
||||||
|
topLine.Width = 0;
|
||||||
|
topLine.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||||
|
topLine.Margin = new Thickness();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetPopup(DependencyObject element, Popup value)
|
||||||
|
=> element.SetValue(PopupProperty, value);
|
||||||
|
|
||||||
|
public static Popup GetPopup(DependencyObject element)
|
||||||
|
=> (Popup)element.GetValue(PopupProperty);
|
||||||
|
|
||||||
|
internal static readonly DependencyProperty TopLineProperty = DependencyProperty.RegisterAttached(
|
||||||
|
"TopLine", typeof(FrameworkElement), typeof(MenuTopLineAttach), new PropertyMetadata(default(FrameworkElement)));
|
||||||
|
|
||||||
|
internal static void SetTopLine(DependencyObject element, FrameworkElement value)
|
||||||
|
=> element.SetValue(TopLineProperty, value);
|
||||||
|
|
||||||
|
internal static FrameworkElement GetTopLine(DependencyObject element)
|
||||||
|
=> (FrameworkElement)element.GetValue(TopLineProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
internal double CurrentVerticalOffset
|
internal double CurrentVerticalOffset
|
||||||
{
|
{
|
||||||
// ReSharper disable once UnusedMember.Local
|
|
||||||
get => (double) GetValue(CurrentVerticalOffsetProperty);
|
get => (double) GetValue(CurrentVerticalOffsetProperty);
|
||||||
set => SetValue(CurrentVerticalOffsetProperty, value);
|
set => SetValue(CurrentVerticalOffsetProperty, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
|
|
||||||
<ResourceDictionary
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
|
||||||
>
|
|
||||||
|
|
||||||
<Geometry o:Freeze="True" x:Key="CalendarGeometry">M377.897477 116.291025l265.298718 0 0 47.459125-265.298718 0 0-47.459125ZM888.317416 116.291025 748.229288 116.291025l0 47.459125 123.54866 0c18.167626 0 32.894732 14.727106 32.894732 32.894732l0 92.92987L115.42936 289.574752l0-92.92987c0-18.167626 14.727106-32.894732 32.894732-32.894732l123.54866 0 0-47.459125L131.776437 116.291025c-35.244356 0-63.814389 28.571056-63.814389 63.815412l0.004093 713.966329c0 35.243333 28.571056 63.814389 63.814389 63.814389l756.540979 0c35.244356 0 63.814389-28.571056 63.814389-63.815412l-0.004093-713.966329C952.131805 144.861058 923.560749 116.291025 888.317416 116.291025zM904.67268 337.033877l0 540.498398c0 18.167626-14.727106 32.894732-32.894732 32.894732L148.324092 910.427007c-18.167626 0-32.894732-14.727106-32.894732-32.894732L115.42936 337.033877 904.67268 337.033877zM300.659736 64.801927l47.459125 0 0 170.241292-47.459125 0 0-170.241292ZM672.97481 64.801927l47.450938 0 0 170.241292-47.450938 0 0-170.241292ZM358.384138 547.939214l0 231.021432 52.863464 0L411.247602 459.226591l-34.580198 0-2.651514 3.804835c-18.000819 25.896006-41.448959 48.758786-69.681285 67.955908l-3.886703 2.643327 0 53.742526 13.441772-8.069156C330.690097 569.215794 345.588103 558.712075 358.384138 547.939214zM618.031888 726.552576c-10.287791 6.395971-24.435678 8.069156-42.059902 4.948946-16.094309-2.842881-27.898712-18.373321-35.082666-46.159464l-2.261615-8.753781-48.312603 13.424375 1.68956 8.129534c6.270098 30.168514 18.347737 52.052967 35.884976 65.017855 17.120734 12.705979 35.542152 19.777364 54.731087 21.043255 3.358652 0.225138 6.655903 0.337707 9.897892 0.337707 14.859119 0 28.430857-2.374184 40.452211-7.072408 14.417029-5.641758 26.88866-13.338413 37.076162-22.86278 10.365566-9.723922 18.230051-22.143362 23.378552-36.920612 4.918246-14.170401 7.739636-28.296797 8.385373-42.025108 0.60685-13.658723-0.667228-26.650218-3.791531-38.619382l-0.008187-0.017397c-3.111-11.777796-8.133628-23.738773-14.946104-35.551363-7.353831-12.679372-19.028268-22.750211-34.710165-29.952586-15.037183-6.872854-30.927843-10.685876-47.24729-11.32752-11.414505-0.415482-23.487027 1.386646-36.04462 5.434017 3.813022-14.568486 7.648557-31.884681 11.465673-51.775637l113.87693 0 0-49.357449L535.645647 464.492778l-1.495122 7.028404c-24.621928 115.77116-31.589954 145.497585-33.102473 150.039235l-3.432334 10.338958 45.829943 5.391036 3.054716-4.20292c8.146931-11.214951 18.247448-18.139996 30.879746-21.164011 13.004799-3.137607 24.743707-3.180588 34.879018-0.129966 9.857981 2.95545 17.822756 8.771178 24.327202 17.758284 6.512633 9.03111 10.084143 20.392401 10.617311 33.757421 0.519864 13.849067-1.603598 26.442477-6.314102 37.440476C636.315153 711.429431 628.843637 719.871089 618.031888 726.552576z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DeleteGeometry">M512 620.544l253.3376 253.3376a76.6976 76.6976 0 1 0 108.544-108.544L620.6464 512l253.2352-253.3376a76.6976 76.6976 0 1 0-108.544-108.544L512 403.3536 258.6624 150.1184a76.6976 76.6976 0 1 0-108.544 108.544L403.3536 512 150.1184 765.3376a76.6976 76.6976 0 1 0 108.544 108.544L512 620.6464z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DeleteFillCircleGeometry">M7.4038057,6.4038057 C7.1478834,6.4038057 6.8919611,6.5014372 6.6966991,6.6966991 6.3061748,7.0872235 6.3061748,7.7203884 6.6966991,8.1109123 L10.585787,12 6.6966991,15.889088 C6.3061748,16.279612 6.3061748,16.912777 6.6966991,17.303301 7.0872235,17.693825 7.7203879,17.693825 8.1109123,17.303301 L12,13.414213 15.889088,17.303301 C16.279612,17.693825 16.912777,17.693825 17.303301,17.303301 17.693825,16.912777 17.693825,16.279612 17.303301,15.889088 L13.414213,12 17.303301,8.1109123 C17.693825,7.7203884 17.693825,7.0872235 17.303301,6.6966991 16.912777,6.3061748 16.279612,6.3061748 15.889088,6.6966991 L12,10.585787 8.1109123,6.6966991 C7.9156504,6.5014372 7.6597281,6.4038057 7.4038057,6.4038057 z M12,0 C18.627417,0 24,5.3725829 24,12 24,18.627417 18.627417,24 12,24 5.3725829,24 0,18.627417 0,12 0,5.3725829 5.3725829,0 12,0 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="CloseGeometry">M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DownGeometry">M512 801.6896L5.12 282.0096l58.1632-59.5968L512 682.3936l448.7168-460.0832 58.1632 59.5968-506.88 519.7824z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="UpGeometry">M50.000001,0 L100,51.262779 94.262627,57.141584 50.000001,11.767713 5.7373757,57.151686 0,51.27288 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="ClockGeometry">M498.506684 256.571517 425.359734 256.571517 425.359734 622.190635 720.166063 622.190635 720.166063 549.725206 498.506684 549.725206ZM512.714268 80.162738c-245.740844 0-445.181175 197.577914-445.181175 441.024505s199.439308 441.024505 445.181175 441.024505c245.738797 0 445.178105-197.577914 445.178105-441.024505S758.453065 80.162738 512.714268 80.162738zM512.714268 874.005824c-195.880249 0-356.145349-158.768003-356.145349-352.818581s160.2651-352.821651 356.145349-352.821651c195.877179 0 356.14228 158.77005 356.14228 352.821651S708.591447 874.005824 512.714268 874.005824z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="LeftGeometry">M394.24 512L683.52 248.32c10.24-10.24 10.24-25.6 0-35.84-10.24-10.24-25.6-10.24-35.84 0l-307.2 279.04c-5.12 5.12-7.68 12.8-7.68 20.48 0 7.68 2.56 15.36 7.68 20.48l307.2 279.04c10.24 10.24 25.6 10.24 35.84 0 10.24-10.24 10.24-25.6 0-35.84L394.24 512z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="RightGeometry">M4.1666641,0 C5.2083321,0 6.25,0.41666794 7.0833321,1.25 L57.083331,46.666664 C57.916664,47.499998 58.33333,48.749998 58.333329,49.999998 58.33333,51.249997 57.916664,52.499997 57.083331,53.333331 L7.0833321,98.749996 C5.4166641,100.41666 2.9166641,100.41666 1.2499962,98.749996 -0.41666794,97.083328 -0.41666794,94.583328 1.2499962,92.916664 L48.333331,49.999998 1.2499962,7.0833321 C-0.41666794,5.4166641 -0.41666794,2.9166641 1.2499962,1.25 2.0833282,0.41666794 3.1249962,0 4.1666641,0 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="RotateLeftGeometry">M165.238899 508.178506C164.450369 456.442676 171.767779 404.485842 187.244542 353.863631 266.138632 95.812692 533.436225-51.353028 784.380224 25.368251 1035.324219 102.08953 1174.62994 373.566359 1095.735851 631.617298 1016.84176 889.66824 749.544168 1036.833959 498.600172 960.11268 424.134741 937.346313 357.837833 896.870788 303.973868 842.276436 291.310328 829.441176 291.396506 808.495802 304.166356 795.493625 316.936205 782.491452 337.554042 782.356136 350.217582 795.191397 396.640587 842.243889 453.73137 877.098901 517.975091 896.740177 734.436966 962.919213 965.320335 835.802028 1033.557737 612.607541 1101.795139 389.413057 981.467179 154.919792 765.005305 88.740755 548.543428 22.561718 317.660056 149.678904 249.422655 372.873388 235.597198 418.094418 229.294871 464.461039 230.4403 510.559881L311.240978 429.759202C323.584094 417.416085 343.892513 417.712357 356.601099 430.420946 369.309686 443.129535 369.605959 463.437952 357.262842 475.781068L230.778782 602.265128C229.273826 605.769679 227.098877 609.041396 224.251145 611.889128 211.908029 624.232245 191.59961 623.935974 178.891024 611.227385L40.825428 473.16179C28.11684 460.453206 27.820569 440.144784 40.163685 427.801668 52.506801 415.458551 72.815218 415.754827 85.523806 428.463411L165.238899 508.178506Z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="RotateRightGeometry">M13.1117823382705,0.00108644926083379C18.7165758868546,0.0742913923738762 23.9197352191299,3.84162509632329 25.6893389483779,9.62980814885544 26.1165926715226,11.0273168346189 26.3185999652236,12.461670228202 26.296833302626,13.8899238456496L28.4974711200089,11.6892569876356C28.8483088275283,11.3384168617557 29.4089472552627,11.330238049977 29.7496950885147,11.6709881771838 30.0904429217666,12.0117402117628 30.0822642108291,12.572387459387 29.7314265033096,12.923229492639L25.9199488421768,16.7347560556155C25.5691111346572,17.0855980888674 25.0084688922257,17.0937769006462 24.6677210589736,16.7530248660672 24.5891077777236,16.674408708165 24.5290644427627,16.5840870073788 24.4875185748428,16.4873374624474L20.9957621356339,12.9955379708416C20.6550143023818,12.6547878436347 20.6631930133193,12.0941405960106 21.0140307208389,11.7432985627585 21.3648684283584,11.3924565295065 21.9255068560928,11.3842777177278 22.2662546893447,11.7250297523068L24.4968645831436,13.9556652415401C24.5284846087783,12.6830303030582 24.3545000811904,11.4030042974954 23.9728319903702,10.1546044295501 22.0890505572647,3.99295504901009 15.7152140399307,0.483677352708723 9.73950221742095,2.3106585349176 3.76379420960845,4.13763876344051 0.441986348280352,10.6112083411418 2.32576778138575,16.7728577216819 4.20954921449125,22.9345051948497 10.5833819171279,26.4437838448372 16.5590937396377,24.6168036163144 18.3326227923721,24.0745720467974 19.9086878558486,23.1123447593618 21.1902544757217,21.8133823630949 21.5398485919327,21.4590441166922 22.1090319415421,21.4627806587338 22.4615595599502,21.8217271162507 22.8140871783584,22.1806735737676 22.8164675494522,22.7589048852417 22.4668734332412,23.1132431316444 20.9798891803115,24.6204085496776 19.1496775409072,25.7378005615073 17.0939638873428,26.3663063881084 10.1663286944717,28.484321088751 2.78723170960845,24.4215726325395 0.609260823377952,17.2976520950044 -1.56871387754975,10.1737353722136 2.27700069154205,2.6791733248245 9.20463588441315,0.561156716809679 10.5035670062393,0.164028483596132 11.8183710833877,-0.0158071458708005 13.1117823382705,0.00108644926083379z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="EnlargeGeometry">M750.3 198.7C598 46.4 351.1 46.4 198.7 198.7s-152.3 399.2 0 551.5C345.1 896.6 578.8 902.3 732 767.3l172.1 172.1 35.4-35.4-172.1-171.9c135-153.2 129.3-387-17.1-533.4z m39.3 403.8c-17.1 42.1-42.2 80-74.7 112.4-32.5 32.5-70.3 57.6-112.4 74.7-40.7 16.5-83.8 24.9-128 24.9s-87.2-8.4-128-24.9c-42.1-17.1-80-42.2-112.4-74.7s-57.6-70.3-74.7-112.4c-16.5-40.7-24.9-83.8-24.9-128s8.4-87.2 24.9-128c17.1-42.1 42.2-80 74.7-112.4s70.3-57.6 112.4-74.7c40.7-16.5 83.8-24.9 128-24.9s87.2 8.4 128 24.9c42.1 17.1 80 42.2 112.4 74.7 32.5 32.5 57.6 70.3 74.7 112.4 16.5 40.7 24.9 83.8 24.9 128s-8.4 87.3-24.9 128zM671 502H496v175h-50V502H271v-50h175V277h50v175h175v50z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="ReduceGeometry">M750.3 198.7C598 46.4 351.1 46.4 198.7 198.7s-152.3 399.2 0 551.5C345.1 896.6 578.8 902.3 732 767.3l172.1 172.1 35.4-35.4-172.1-171.9c135-153.2 129.3-387-17.1-533.4z m39.3 403.8c-17.1 42.1-42.2 80-74.7 112.4-32.5 32.5-70.3 57.6-112.4 74.7-40.7 16.5-83.8 24.9-128 24.9s-87.2-8.4-128-24.9c-42.1-17.1-80-42.2-112.4-74.7s-57.6-70.3-74.7-112.4c-16.5-40.7-24.9-83.8-24.9-128s8.4-87.2 24.9-128c17.1-42.1 42.2-80 74.7-112.4s70.3-57.6 112.4-74.7c40.7-16.5 83.8-24.9 128-24.9s87.2 8.4 128 24.9c42.1 17.1 80 42.2 112.4 74.7 32.5 32.5 57.6 70.3 74.7 112.4 16.5 40.7 24.9 83.8 24.9 128s-8.4 87.3-24.9 128zM671 502H271v-50h400v50z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DownloadGeometry">M868.100096 742.600704l-0.049152 0L216.246272 742.600704l-0.049152 0c-13.98784 0-25.327616 11.33568-25.327616 25.352192 0 13.993984 11.360256 25.327616 25.327616 25.327616l0.049152 0 651.804672 0 0.049152 0c13.996032 0 25.33376-11.333632 25.33376-25.327616C893.431808 753.936384 882.096128 742.600704 868.100096 742.600704L868.100096 742.600704 868.100096 742.600704M523.15136 688.433152c4.728832 4.757504 11.237376 7.733248 18.47296 7.733248l0 0 0 0c7.231488 0 13.740032-2.951168 18.42176-7.757824l314.836992-314.83904c4.732928-4.704256 7.714816-11.214848 7.7312-18.395136 0-14.342144-11.712512-25.9584-25.972736-25.9584-7.213056-0.02048-13.694976 2.930688-18.376704 7.636992L567.578624 607.51872 567.578624 117.52448c-0.024576-0.026624-0.024576-0.026624-0.024576-0.0512 0.024576-14.344192-11.59168-25.980928-25.901056-25.980928-14.348288 0-25.960448 11.634688-25.960448 25.980928 0 0 0 0.024576 0.024576 0.0512l0 489.967616L245.055488 336.826368c-4.683776-4.704256-11.2128-7.6288-18.374656-7.60832-14.342144-0.02048-25.954304 11.614208-26.005504 25.9072 0 7.20896 2.951168 13.768704 7.684096 18.423808L523.15136 688.433152 523.15136 688.433152 523.15136 688.433152M523.15136 688.433152 523.15136 688.433152z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="SaveGeometry">M608 320C625.664 320 640 305.696 640 288L640 160C640 142.304 625.664 128 608 128 590.336 128 576 142.304 576 160L576 288C576 305.696 590.336 320 608 320L608 320ZM960 896C960 931.328 931.328 960 896 960L128 960C92.672 960 64 931.328 64 896L64 128C64 92.672 92.672 64 128 64L192 64 192 384C192 419.328 220.672 448 256 448L768 448C803.328 448 832 419.328 832 384L832 64 896 64C931.328 64 960 92.672 960 128L960 896 960 896ZM256 64 768 64 768 352C768 369.696 753.664 384 736 384L288 384C270.336 384 256 369.696 256 352L256 64 256 64ZM896 0 128 0C57.312 0 0 57.312 0 128L0 896C0 966.688 57.312 1024 128 1024L896 1024C966.688 1024 1024 966.688 1024 896L1024 128C1024 57.312 966.688 0 896 0L896 0Z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="WindowsGeometry">M426.276571 574.829714l0 372.004571-389.705143-53.686857 0-318.317714 389.705143 0zM426.276571 150.308571l0 376.539429-389.705143 0 0-322.852571zM987.428571 574.829714l0 449.170286-518.290286-71.460571 0-377.709714 518.290286 0zM987.428571 73.142857l0 453.705143-518.290286 0 0-382.317714z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="FullScreenGeometry">M942 82v320h-50V167.4l-274 274-35.4-35.4 274-274H622V82h320zM406 582.6l-274 274V622H82v320h320v-50H167.4l274-274-35.4-35.4zM132 132h302V82H82v352h50V132z m760 760H590v50h352V590h-50v302z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="FullScreenReturnGeometry">M94.186081,59.07 L100,59.07 100,100 59.07,100 59.07,94.186081 94.186081,94.186081 z M4.5814285,58.208999 L41.791,58.208999 41.791,95.418571 35.977005,95.418571 35.977005,68.139304 4.1163101,100 0,95.88369 31.860695,64.022995 4.5814285,64.022995 z M95.88369,0 L100,4.1163101 68.139304,35.977005 95.418571,35.977005 95.418571,41.791 58.208999,41.791 58.208999,4.5814285 64.022995,4.5814285 64.022995,31.860695 z M0,0 L40.929998,0 40.929998,5.8139191 5.8139191,5.8139191 5.8139191,40.929998 0,40.929998 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="SearchGeometry">M716.6003 213.800623c-138.851102-138.915088-364.020238-138.915088-502.935326 0s-138.915088 364.084225 0 502.935326a355.573996 355.573996 0 0 0 502.935326 0 355.573996 355.573996 0 0 0 0-502.935326z m-580.359212 580.359212a465.183184 465.183184 0 1 1 657.783099 0 465.183184 465.183184 0 0 1-657.783099 0z m868.939152 211.156054a63.474789 63.474789 0 0 1-89.837303 0l-89.773316-89.837303a63.410803 63.410803 0 1 1 89.773316-89.773316l89.837303 89.773316a63.346816 63.346816 0 0 1 0 89.837303z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="UpDownGeometry">M454.464 143.68l-253.44 253.44c-12.032 12.032-12.032 31.36 0 43.392 11.968 11.968 31.36 11.968 43.328 0l237.376-237.376 237.376 237.376c11.968 11.968 31.36 11.968 43.328 0 12.032-12.032 12.032-31.36 0-43.392l-253.44-253.44C491.264 126.016 478.016 124.032 454.464 143.68zM507.968 947.648l252.48-253.376c11.968-11.968 11.968-31.36 0-43.392-11.968-11.968-31.296-11.968-43.264 0l-236.48 237.376L244.16 650.88c-11.968-11.968-31.296-11.968-43.264 0-11.968 12.032-11.968 31.424 0 43.392l252.48 253.376C465.984 960 491.136 964.48 507.968 947.648z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="WindowMinGeometry">M0,4 L10,4 L10,5 L0,5 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="WindowRestoreGeometry">M1,3 L1,9 L7,9 L7,3 z M3,1 L3,2 L8,2 L8,7 L9,7 L9,1 z M2,0 L10,0 L10,8 L8,8 L8,10 L0,10 L0,2 L2,2 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="WindowMaxGeometry">M1,1 L1,9 L9,9 L9,1 z M0,0 L10,0 L10,10 L0,10 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="CheckedGeometry">M 0,2 3,5 8,0</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignLeftGeometry">M0,8 L4,8 4,10 0,10 z M0,4 L8,4 8,6 0,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignRightGeometry">M8,8 L12,8 12,10 8,10 z M4,4 L12,4 12,6 4,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignHCenterGeometry">M4,8 L8,8 8,10 4,10 z M2,4 L10,4 10,6 2,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignHStretchGeometry">M0,8 L12,8 12,10 0,10 z M0,4 L12,4 12,6 0,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignTopGeometry">M8,0 L10,0 10,4 8,4 z M4,0 L6,0 6,8 4,8 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignBottomGeometry">M8,8 L10,8 10,12 8,12 z M4,4 L6,4 6,12 4,12 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignVCenterGeometry">M8,4 L10,4 10,8 8,8 z M4,2 L6,2 6,10 4,10 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AlignVStretchGeometry">M8,0 L10,0 10,12 8,12 z M4,0 L6,0 6,12 4,12 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="PageModeGeometry">M1.0000002,12 L1.0000002,13 11,13 11,12 z M1.0000002,10 L1.0000002,11 11,11 11,10 z M1.0000002,8 L1.0000002,9 11,9 11,8 z M1.0000002,6 L1.0000002,7 11,7 11,6 z M1.0000002,4 L1.0000002,5 11,5 11,4 z M1.0000002,2 L1.0000002,3 11,3 11,2 z M0,0 L12,0 12,14 0,14 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="TwoPageModeGeometry">M8.99999988079071,12L8.99999988079071,13 13,13 13,12z M1,12L1,13 5,13 5,12z M9.00000011920929,10L9.00000011920929,11 13,11 13,10z M1,10L1,11 5,11 5,10z M9.00000011920929,8L9.00000011920929,9 13,9 13,8z M1,8L1,9 5,9 5,8z M9.00000011920929,6L9.00000011920929,7 13,7 13,6z M1,6L1,7 5,7 5,6z M9.00000011920929,4L9.00000011920929,5 13,5 13,4z M1,4L1,5 5,5 5,4z M8.99999988079071,2L8.99999988079071,3 13,3 13,2z M1,2L1,3 5,3 5,2z M7.99999994039536,0L14,0 14,14 7.99999994039536,14z M0,0L6,0 6,14 0,14z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="ScrollModeGeometry">M1,12L1,13 8,13 8,12z M1,10L1,11 8,11 8,10z M1,8L1,9 8,9 8,8z M1,6L1,7 8,7 8,6z M11.0000002384186,5L11.0000002384186,9 13,9 13,5z M1,4L1,5 8,5 8,4z M1,2L1,3 8,3 8,2z M10.0000000298023,0L14,0 14,14 10.0000000298023,14z M0,0L9.00000011920929,0 9.00000011920929,14 0,14z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="EyeOpenGeometry">M928 406.4c-100.8-137.6-249.6-224-416-224s-315.2 86.4-416 224c-44.8 60.8-44.8 150.4 0 211.2 102.4 137.6 251.2 224 416 224 166.4 0 315.2-86.4 416-224 46.4-60.8 46.4-150.4 0-211.2zM512 721.6c-115.2 0-209.6-94.4-209.6-209.6 0-115.2 94.4-209.6 209.6-209.6 115.2 0 209.6 94.4 209.6 209.6 1.6 115.2-92.8 209.6-209.6 209.6z m0-360c-83.2 0-150.4 67.2-150.4 150.4s67.2 150.4 150.4 150.4 150.4-67.2 150.4-150.4-67.2-150.4-150.4-150.4z m0 0</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="EyeCloseGeometry">M950.4 361.6c8-20.8 0-43.2-19.2-54.4-9.6-4.8-20.8-6.4-32-3.2s-19.2 11.2-24 22.4c-56 132.8-208 228.8-361.6 228.8-155.2 0-307.2-97.6-363.2-232-4.8-11.2-12.8-19.2-24-24-9.6-4.8-20.8-3.2-32 0-20.8 9.6-30.4 35.2-20.8 56 25.6 60.8 67.2 118.4 123.2 164.8l-67.2 70.4c-14.4 16-14.4 40 0 57.6 8 8 17.6 14.4 28.8 14.4s22.4-3.2 30.4-11.2l76.8-81.6c35.2 20.8 73.6 38.4 113.6 49.6l-28.8 83.2c-8 22.4 3.2 46.4 24 54.4 4.8 1.6 9.6 3.2 14.4 3.2 6.4 0 11.2-1.6 17.6-3.2 9.6-4.8 17.6-12.8 22.4-24l33.6-96c41.6 4.8 81.6 3.2 123.2-3.2l32 94.4c3.2 11.2 11.2 19.2 22.4 24 9.6 4.8 20.8 4.8 32 1.6 20.8-8 32-32 24-54.4l-28.8-84.8c30.4-9.6 59.2-22.4 86.4-38.4l62.4 65.6c14.4 16 43.2 16 57.6 0 16-16 16-43.2 0-60.8l-51.2-54.4c56-43.2 100.8-100.8 128-164.8z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AudioGeometry">M627.52666696 962L550.66666696 890.47999971c116.82-92.99999971 191.09999971-230.94 191.09999971-385.2 0-146.99999971-67.61999971-279-174.96-371.57999942L643.84666667 62C770.86666638 172.99999971 850.66666667 330.2 850.66666667 505.09999971c0 182.27999971-86.58 345.42-223.13999971 456.90000029zM405.64666638 782l-76.32-77.22a227.88 227.88 0 0 0 116.40000058-199.26A228.06 228.06 0 0 0 347.86666638 317.84000029L422.86666696 242A334.37999971 334.37999971 0 0 1 550.66666696 505.52 334.62 334.62 0 0 1 405.64666638 782zM205.66666638 596.6C164.26666638 596.6 130.66666667 562.51999971 130.66666667 520.64 130.66666667 478.76000029 164.26666638 444.79999971 205.66666638 444.79999971s74.99999971 33.95999971 75.00000058 75.90000058c0 41.87999971-33.59999971 75.84000029-75.00000058 75.83999942z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="BubbleTailGeometry">M0,0L28,0 28,14.0000006258488 28,15.0010000765324 28.0151405334473,15.0010000765324 28.0455417633057,15.8010965883732C28.4084091186524,22.9596563875675,30.92209815979,29.5507589876652,34.9532623291016,34.9410597383976L34.9984359741211,34.9999815523624 34.0966339111328,34.9885679781437C15.1841707229614,34.5094191133976,2.0535663480814E-07,19.0279375612736,0,0z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="StarGeometry">M535.9 165.2l96.5 195.4c3.9 7.9 11.4 13.3 20.1 14.6l215.7 31.3c21.9 3.2 30.6 30 14.8 45.5L726.8 604.1c-6.3 6.1-9.1 14.9-7.7 23.6L756 842.5c3.7 21.8-19.1 38.4-38.7 28.1L524.4 769.2c-7.8-4.1-17-4.1-24.8 0L306.7 870.6c-19.6 10.3-42.4-6.3-38.7-28.1l36.8-214.8c1.5-8.6-1.4-17.5-7.7-23.6L141.1 452c-15.8-15.4-7.1-42.3 14.8-45.5l215.7-31.3c8.7-1.3 16.2-6.7 20.1-14.6l96.5-195.4c9.7-19.9 37.9-19.9 47.7 0z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AddGeometry">M8,0 C8.5522847,0 9,0.44771525 9,1 L9,7 15,7 C15.552285,7 16,7.4477153 16,8 16,8.5522852 15.552285,9 15,9 L9,9 9,15 C9,15.552285 8.5522847,16 8,16 7.4477153,16 7,15.552285 7,15 L7,9 1,9 C0.44771528,9 0,8.5522852 0,8 0,7.4477153 0.44771528,7 1,7 L7,7 7,1 C7,0.44771525 7.4477153,0 8,0 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="RemoveGeometry">M10.899495,0 C11.155417,0 11.411339,0.097630501 11.606602,0.29289246 11.997126,0.68341732 11.997126,1.3165817 11.606602,1.7071066 L7.3639612,5.9497471 11.606602,10.192388 C11.997126,10.582912 11.997126,11.216077 11.606602,11.606601 11.216077,11.997126 10.582912,11.997126 10.192388,11.606601 L5.9497476,7.3639607 1.7071068,11.606601 C1.3165827,11.997126 0.68341756,11.997126 0.29289341,11.606601 -0.097630978,11.216077 -0.097630978,10.582912 0.29289341,10.192388 L4.5355338,5.9497471 0.29289341,1.7071066 C-0.097630978,1.3165817 -0.097630978,0.68341732 0.29289341,0.29289246 0.48815536,0.097630501 0.74407768,0 1,0 1.2559223,0 1.5118446,0.097630501 1.7071068,0.29289246 L5.9497476,4.5355334 10.192388,0.29289246 C10.38765,0.097630501 10.643572,0 10.899495,0 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="SubGeometry">M62.5797 488.9508c0.2632 42.5185 34.985 77.2116 77.5035 77.5035l743.0216-0.6728c42.5185 0.3215 76.7437-33.9333 76.4518-76.4805l0 0c-0.2918-42.5175-34.985-77.2106-77.5045-77.5035l-743.0216-0.087C96.513 411.4473 62.2879 446.4323 62.5797 488.9508L62.5797 488.9508z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="WarningGeometry">M943.644188 827.215696l-351.176649-608.204749c-42.945473-74.36249-113.147387-74.36249-156.092861 0l-351.176649 608.204749c-42.946498 74.431167-7.811716 135.14955 78.012605 135.14955l702.420949 0C951.455904 962.36422 986.555836 901.645838 943.644188 827.215696zM466.187532 391.579035c12.621133-13.644108 28.66175-20.466675 48.233578-20.466675 19.580028 0 35.612444 6.75389 48.241778 20.194018 12.544256 13.473954 18.820484 30.325365 18.820484 50.587035 0 17.430551-26.19759 145.621205-34.929778 238.882082l-63.105666 0c-7.666162-93.259852-36.090106-221.450507-36.090106-238.882082C447.358847 421.938226 453.643275 405.155491 466.187532 391.579035zM561.76804 835.026386c-13.268949 12.928641-29.062535 19.375023-47.345906 19.375023-18.275171 0-34.076957-6.447407-47.346931-19.375023-13.235123-12.89379-19.818859-28.517221-19.818859-46.869269 0-18.249546 6.583736-34.043131 19.818859-47.278254 13.268949-13.235123 29.07176-19.852685 47.346931-19.852685 18.283371 0 34.076957 6.617562 47.345906 19.852685 13.235123 13.235123 19.827059 29.028709 19.827059 47.278254C581.595099 806.51019 575.003163 822.132597 561.76804 835.026386z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="InfoGeometry">M505.6512 39.0144c-261.2224 3.4816-470.1184 218.112-466.6368 479.4368 3.4816 261.12 218.112 470.1184 479.3344 466.6368 261.2224-3.4816 470.1184-218.112 466.7392-479.3344C981.504 244.4288 766.8736 35.5328 505.6512 39.0144zM558.08 196.608c48.128 0 62.2592 27.9552 62.2592 59.8016 0 39.8336-31.9488 76.6976-86.3232 76.6976-45.568 0-67.1744-22.9376-65.9456-60.8256C468.0704 240.4352 494.7968 196.608 558.08 196.608zM434.7904 807.6288c-32.8704 0-56.9344-19.968-33.8944-107.6224l37.6832-155.5456c6.5536-24.8832 7.68-34.9184 0-34.9184-9.8304 0-52.5312 17.2032-77.7216 34.2016l-16.384-26.9312c79.9744-66.7648 171.8272-105.8816 211.2512-105.8816 32.8704 0 38.2976 38.912 21.9136 98.6112l-43.2128 163.5328c-7.68 28.8768-4.4032 38.912 3.2768 38.912 9.9328 0 42.1888-11.9808 73.9328-36.9664l18.6368 24.8832C552.5504 777.728 467.6608 807.6288 434.7904 807.6288z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="ErrorGeometry">M495.469714 0C224.621714 0 0 224.621714 0 495.469714c0 270.884571 224.621714 495.506286 495.469714 495.506286 270.884571 0 495.506286-224.621714 495.506286-495.506286C990.976 224.621714 766.354286 0 495.469714 0z m211.419429 634.221714c19.821714 19.821714 19.821714 46.226286 0 66.048s-46.226286 19.821714-66.048 0l-138.752-138.715428-145.334857 145.334857a51.858286 51.858286 0 0 1-72.667429 0 51.858286 51.858286 0 0 1 0-72.667429l145.334857-145.334857-138.752-138.752c-19.821714-19.821714-19.821714-46.226286 0-66.048s46.262857-19.821714 66.084572 0l138.715428 138.715429 145.371429-145.334857a51.858286 51.858286 0 0 1 72.667428 0 51.858286 51.858286 0 0 1 0 72.667428l-145.371428 145.334857 138.752 138.752z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="SuccessGeometry">M512.66048 64.64c-247.424 0-448 200.57728-448 448s200.576 448 448 448 448-200.57728 448-448c0-247.424-200.57728-448-448-448z m250.71232 334.86336L480.98176 681.89312c-15.49568 15.49696-40.61952 15.49696-56.11648 0l-162.9184-162.9184c-15.49568-15.49568-15.49568-40.61824 0-56.1152s40.61952-15.49568 56.11648 0l134.85952 134.85952L707.25504 343.3856c15.49568-15.49568 40.61952-15.49568 56.11648 0s15.49696 40.6208 0.00128 56.11776z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="FatalGeometry">M716.8 375.466667l34.133333 34.133333c17.066667 17.066667 42.666667 17.066667 59.733334 0 17.066667-17.066667 17.066667-42.666667 0-59.733333l-34.133334-34.133334 34.133334-34.133333c17.066667-17.066667 17.066667-42.666667 0-59.733333-17.066667-17.066667-42.666667-17.066667-59.733334 0l-34.133333 34.133333-34.133333-34.133333c-17.066667-17.066667-42.666667-17.066667-59.733334 0-17.066667 17.066667-17.066667 42.666667 0 59.733333l34.133334 34.133333-34.133334 34.133334c-17.066667 17.066667-17.066667 42.666667 0 59.733333 17.066667 17.066667 42.666667 17.066667 59.733334 0l34.133333-34.133333z m-426.666667 0l34.133334 34.133333c17.066667 17.066667 42.666667 17.066667 59.733333 0 17.066667-17.066667 17.066667-42.666667 0-59.733333l-34.133333-34.133334 34.133333-34.133333c17.066667-17.066667 17.066667-42.666667 0-59.733333-17.066667-17.066667-42.666667-17.066667-59.733333 0l-34.133334 34.133333-34.133333-34.133333c-17.066667-17.066667-42.666667-17.066667-59.733333 0-17.066667 17.066667-17.066667 42.666667 0 59.733333l34.133333 34.133333-34.133333 34.133334c-17.066667 17.066667-17.066667 42.666667 0 59.733333 17.066667 17.066667 42.666667 17.066667 59.733333 0l34.133333-34.133333zM0 85.333333c0-51.2 42.666667-85.333333 85.333333-85.333333h853.333334c51.2 0 85.333333 42.666667 85.333333 85.333333v853.333334c0 51.2-42.666667 85.333333-85.333333 85.333333H85.333333c-51.2 0-85.333333-42.666667-85.333333-85.333333V85.333333z m512 469.333334c-136.533333 0-230.4 68.266667-290.133333 196.266666-8.533333 17.066667 0 42.666667 17.066666 59.733334s42.666667 0 59.733334-17.066667c51.2-93.866667 110.933333-145.066667 221.866666-145.066667 102.4 0 170.666667 51.2 221.866667 145.066667 8.533333 17.066667 34.133333 25.6 59.733333 17.066667 17.066667-8.533333 25.6-34.133333 17.066667-59.733334-76.8-128-170.666667-196.266667-307.2-196.266666z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AskGeometry">M512 0 30.11843 240.941297l0 542.117406 481.88157 240.941297 481.88157-240.941297L993.88157 240.941297 512 0zM575.776472 768.799969 460.188012 768.799969 460.188012 656.222073l115.588459 0L575.776472 768.799969zM623.335603 509.329685c-52.375829 36.723353-59.600363 55.988096-59.600363 84.885211l0 19.866447L468.616977 614.081343l0-26.489278c0-45.754021 13.846342-80.67124 61.406497-116.791866 46.957428-36.723353 57.79423-62.0082 57.79423-84.282484 0-25.284848-21.67258-54.181962-55.386393-54.181962-42.743457 0-70.436142 26.489278-82.477374 85.486914l-105.956088-21.67258c24.683144-111.976192 82.477374-157.127486 205.289345-157.127486 98.12985 0 157.72919 63.212631 157.72919 131.842639C707.017407 423.240044 688.956071 461.76953 623.335603 509.329685z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="AllGeometry">M 721.005 638.949 C 758.74 638.949 789.333 669.56 789.333 707.312 C 789.333 745.047 758.74 775.657 721.005 775.657 C 683.253 775.657 652.66 745.047 652.66 707.312 C 652.66 669.56 683.253 638.949 721.005 638.949 Z M 512.017 638.949 C 549.77 638.949 580.38 669.56 580.38 707.312 C 580.38 745.047 549.77 775.657 512.017 775.657 C 474.265 775.657 443.672 745.047 443.672 707.312 C 443.672 669.56 474.265 638.949 512.017 638.949 Z M 303.029 638.949 C 340.781 638.949 371.392 669.56 371.392 707.312 C 371.392 745.047 340.781 775.657 303.029 775.657 C 265.277 775.657 234.667 745.047 234.667 707.312 C 234.667 669.56 265.277 638.949 303.029 638.949 Z M 721.005 443.655 C 758.74 443.655 789.333 474.265 789.333 512.017 C 789.333 549.769 758.74 580.363 721.005 580.363 C 683.253 580.363 652.66 549.769 652.66 512.017 C 652.66 474.265 683.253 443.655 721.005 443.655 Z M 512.017 443.655 C 549.77 443.655 580.38 474.265 580.38 512.017 C 580.38 549.769 549.77 580.363 512.017 580.363 C 474.265 580.363 443.672 549.769 443.672 512.017 C 443.672 474.265 474.265 443.655 512.017 443.655 Z M 303.029 443.655 C 340.781 443.655 371.392 474.265 371.392 512.017 C 371.392 549.769 340.781 580.363 303.029 580.363 C 265.277 580.363 234.667 549.769 234.667 512.017 C 234.667 474.265 265.277 443.655 303.029 443.655 Z M 721.005 248.343 C 758.74 248.343 789.333 278.953 789.333 316.688 C 789.333 354.44 758.74 385.051 721.005 385.051 C 683.253 385.051 652.66 354.44 652.66 316.688 C 652.66 278.953 683.253 248.343 721.005 248.343 Z M 512.017 248.343 C 549.77 248.343 580.38 278.953 580.38 316.688 C 580.38 354.44 549.77 385.051 512.017 385.051 C 474.265 385.051 443.672 354.44 443.672 316.688 C 443.672 278.953 474.265 248.343 512.017 248.343 Z M 303.029 248.343 C 340.781 248.343 371.392 278.953 371.392 316.688 C 371.392 354.44 340.781 385.051 303.029 385.051 C 265.277 385.051 234.667 354.44 234.667 316.688 C 234.667 278.953 265.277 248.343 303.029 248.343 Z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DragVerticalGeometry">M2,12 C3.1045694,12 4,12.895431 4,14 4,15.104569 3.1045694,16 2,16 0.89543051,16 0,15.104569 0,14 0,12.895431 0.89543051,12 2,12 z M2,6 C3.1045694,6 4,6.8954306 4,8 4,9.1045694 3.1045694,10 2,10 0.89543051,10 0,9.1045694 0,8 0,6.8954306 0.89543051,6 2,6 z M2,0 C3.1045694,0 4,0.89543056 4,2 4,3.1045694 3.1045694,4 2,4 0.89543051,4 0,3.1045694 0,2 0,0.89543056 0.89543051,0 2,0 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DragHorizontalGeometry">M14,0 C15.104569,0 16,0.89543051 16,2 16,3.1045694 15.104569,4 14,4 12.895431,4 12,3.1045694 12,2 12,0.89543051 12.895431,0 14,0 z M8,0 C9.1045694,0 10,0.89543051 10,2 10,3.1045694 9.1045694,4 8,4 6.8954306,4 6,3.1045694 6,2 6,0.89543051 6.8954306,0 8,0 z M2,0 C3.1045694,0 4,0.89543051 4,2 4,3.1045694 3.1045694,4 2,4 0.89543056,4 0,3.1045694 0,2 0,0.89543051 0.89543056,0 2,0 z</Geometry>
|
|
||||||
<Geometry o:Freeze="True" x:Key="DropperGeometry">M798.165333 97.834667a42.624 42.624 0 0 0-60.330666 0l-140.629334 140.629333-55.381333-55.296-60.330667 60.330667 55.381334 55.296-353.706667 353.706666a42.709333 42.709333 0 0 0-11.221333 19.84l-42.666667 170.666667a42.538667 42.538667 0 0 0 51.712 51.712l170.666667-42.666667c7.509333-1.877333 14.378667-5.76 19.84-11.221333l353.792-353.792 55.210666 55.125333 60.330667-60.330666-55.210667-55.125334 140.544-140.544a42.624 42.624 0 0 0 0-60.330666l-128-128zM319.488 772.138667l-90.197333 22.570666 22.570666-90.197333 345.386667-345.386667 67.669333 67.584-345.429333 345.429334z</Geometry>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
using HandyControl.Tools.Extension;
|
using HandyControl.Tools.Extension;
|
||||||
|
|
||||||
namespace HandyControl.Tools
|
namespace HandyControl.Tools
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools.Converter
|
||||||
|
{
|
||||||
|
public class BorderCircularConverter : IMultiValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (values.Length == 2 && values[0] is double width && values[1] is double height)
|
||||||
|
{
|
||||||
|
if (width < double.Epsilon || height < double.Epsilon)
|
||||||
|
{
|
||||||
|
return new CornerRadius();
|
||||||
|
}
|
||||||
|
|
||||||
|
var min = Math.Min(width, height);
|
||||||
|
return new CornerRadius(min / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DependencyProperty.UnsetValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
87
src/WPF/HandyControl/Tools/Helper/ScreenHelper.cs
Normal file
87
src/WPF/HandyControl/Tools/Helper/ScreenHelper.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
using HandyControl.Tools.Interop;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools
|
||||||
|
{
|
||||||
|
internal class ScreenHelper
|
||||||
|
{
|
||||||
|
internal static void FindMaximumSingleMonitorRectangle(Rect windowRect, out Rect screenSubRect, out Rect monitorRect)
|
||||||
|
{
|
||||||
|
var windowRect2 = new InteropValues.RECT(windowRect);
|
||||||
|
FindMaximumSingleMonitorRectangle(windowRect2, out var rect, out var rect2);
|
||||||
|
screenSubRect = new Rect(rect.Position, rect.Size);
|
||||||
|
monitorRect = new Rect(rect2.Position, rect2.Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FindMaximumSingleMonitorRectangle(InteropValues.RECT windowRect, out InteropValues.RECT screenSubRect, out InteropValues.RECT monitorRect)
|
||||||
|
{
|
||||||
|
var rects = new List<InteropValues.RECT>();
|
||||||
|
InteropMethods.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero,
|
||||||
|
delegate (IntPtr hMonitor, IntPtr hdcMonitor, ref InteropValues.RECT rect, IntPtr lpData)
|
||||||
|
{
|
||||||
|
var monitorInfo = default(InteropValues.MONITORINFO);
|
||||||
|
monitorInfo.cbSize = (uint) Marshal.SizeOf(typeof(InteropValues.MONITORINFO));
|
||||||
|
InteropMethods.GetMonitorInfo(hMonitor, ref monitorInfo);
|
||||||
|
rects.Add(monitorInfo.rcWork);
|
||||||
|
return true;
|
||||||
|
}, IntPtr.Zero);
|
||||||
|
|
||||||
|
var num = 0L;
|
||||||
|
|
||||||
|
screenSubRect = new InteropValues.RECT
|
||||||
|
{
|
||||||
|
Left = 0,
|
||||||
|
Right = 0,
|
||||||
|
Top = 0,
|
||||||
|
Bottom = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
monitorRect = new InteropValues.RECT
|
||||||
|
{
|
||||||
|
Left = 0,
|
||||||
|
Right = 0,
|
||||||
|
Top = 0,
|
||||||
|
Bottom = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var current in rects)
|
||||||
|
{
|
||||||
|
var rect = current;
|
||||||
|
InteropMethods.IntersectRect(out var rECT2, ref rect, ref windowRect);
|
||||||
|
var num2 = (long) (rECT2.Width * rECT2.Height);
|
||||||
|
if (num2 > num)
|
||||||
|
{
|
||||||
|
screenSubRect = rECT2;
|
||||||
|
monitorRect = current;
|
||||||
|
num = num2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void FindMonitorRectsFromPoint(Point point, out Rect monitorRect, out Rect workAreaRect)
|
||||||
|
{
|
||||||
|
var intPtr = InteropMethods.MonitorFromPoint(new InteropValues.POINT
|
||||||
|
{
|
||||||
|
X = (int) point.X,
|
||||||
|
Y = (int) point.Y
|
||||||
|
}, 2);
|
||||||
|
|
||||||
|
monitorRect = new Rect(0.0, 0.0, 0.0, 0.0);
|
||||||
|
workAreaRect = new Rect(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
if (intPtr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
InteropValues.MONITORINFO monitorInfo = default;
|
||||||
|
monitorInfo.cbSize = (uint) Marshal.SizeOf(typeof(InteropValues.MONITORINFO));
|
||||||
|
InteropMethods.GetMonitorInfo(intPtr, ref monitorInfo);
|
||||||
|
monitorRect = new Rect(monitorInfo.rcMonitor.Position, monitorInfo.rcMonitor.Size);
|
||||||
|
workAreaRect = new Rect(monitorInfo.rcWork.Position, monitorInfo.rcWork.Size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/WPF/HandyControl/Tools/Helper/VisualHelper.cs
Normal file
82
src/WPF/HandyControl/Tools/Helper/VisualHelper.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using HandyControl.Tools.Interop;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools
|
||||||
|
{
|
||||||
|
public static class VisualHelper
|
||||||
|
{
|
||||||
|
internal static VisualStateGroup TryGetVisualStateGroup(DependencyObject d, string groupName)
|
||||||
|
{
|
||||||
|
var root = GetImplementationRoot(d);
|
||||||
|
if (root == null) return null;
|
||||||
|
|
||||||
|
return VisualStateManager
|
||||||
|
.GetVisualStateGroups(root)?
|
||||||
|
.OfType<VisualStateGroup>()
|
||||||
|
.FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static FrameworkElement GetImplementationRoot(DependencyObject d) =>
|
||||||
|
1 == VisualTreeHelper.GetChildrenCount(d)
|
||||||
|
? VisualTreeHelper.GetChild(d, 0) as FrameworkElement
|
||||||
|
: null;
|
||||||
|
|
||||||
|
public static T GetChild<T>(DependencyObject d) where T : DependencyObject
|
||||||
|
{
|
||||||
|
if (d == null) return default;
|
||||||
|
if (d is T t) return t;
|
||||||
|
|
||||||
|
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(d); i++)
|
||||||
|
{
|
||||||
|
var child = VisualTreeHelper.GetChild(d, i);
|
||||||
|
|
||||||
|
var result = GetChild<T>(child);
|
||||||
|
if (result != null) return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T GetParent<T>(DependencyObject d) where T : DependencyObject
|
||||||
|
{
|
||||||
|
if (d == null)
|
||||||
|
return default;
|
||||||
|
|
||||||
|
if (d is T)
|
||||||
|
return d as T;
|
||||||
|
|
||||||
|
if (d is Window)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return GetParent<T>(VisualTreeHelper.GetParent(d));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr GetHandle(this Visual visual) => (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero;
|
||||||
|
|
||||||
|
internal static void HitTestVisibleElements(Visual visual, HitTestResultCallback resultCallback, HitTestParameters parameters) =>
|
||||||
|
VisualTreeHelper.HitTest(visual, ExcludeNonVisualElements, resultCallback, parameters);
|
||||||
|
|
||||||
|
private static HitTestFilterBehavior ExcludeNonVisualElements(DependencyObject potentialHitTestTarget)
|
||||||
|
{
|
||||||
|
if (!(potentialHitTestTarget is Visual)) return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
|
||||||
|
|
||||||
|
if (!(potentialHitTestTarget is UIElement uIElement) || uIElement.IsVisible && uIElement.IsEnabled)
|
||||||
|
return HitTestFilterBehavior.Continue;
|
||||||
|
|
||||||
|
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool ModifyStyle(IntPtr hWnd, int styleToRemove, int styleToAdd)
|
||||||
|
{
|
||||||
|
var windowLong = InteropMethods.GetWindowLong(hWnd, InteropValues.GWL.STYLE);
|
||||||
|
var num = (windowLong & ~styleToRemove) | styleToAdd;
|
||||||
|
if (num == windowLong) return false;
|
||||||
|
InteropMethods.SetWindowLong(hWnd, InteropValues.GWL.STYLE, num);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/WPF/HandyControl/Tools/Interop/Handle/BitmapHandle.cs
Normal file
42
src/WPF/HandyControl/Tools/Interop/Handle/BitmapHandle.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.ConstrainedExecution;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools.Interop
|
||||||
|
{
|
||||||
|
internal sealed class BitmapHandle : WpfSafeHandle
|
||||||
|
{
|
||||||
|
[SecurityCritical]
|
||||||
|
private BitmapHandle() : this(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
private BitmapHandle(bool ownsHandle) : base(ownsHandle, CommonHandles.GDI)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||||
|
protected override bool ReleaseHandle()
|
||||||
|
{
|
||||||
|
return InteropMethods.DeleteObject(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal HandleRef MakeHandleRef(object obj)
|
||||||
|
{
|
||||||
|
return new HandleRef(obj, handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static BitmapHandle CreateFromHandle(IntPtr hbitmap, bool ownsHandle = true)
|
||||||
|
{
|
||||||
|
return new BitmapHandle(ownsHandle)
|
||||||
|
{
|
||||||
|
handle = hbitmap,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/WPF/HandyControl/Tools/Interop/Handle/CommonHandles.cs
Normal file
14
src/WPF/HandyControl/Tools/Interop/Handle/CommonHandles.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
namespace HandyControl.Tools.Interop
|
||||||
|
{
|
||||||
|
internal static class CommonHandles
|
||||||
|
{
|
||||||
|
public static readonly int Icon = HandleCollector.RegisterType(nameof(Icon), 20, 500);
|
||||||
|
|
||||||
|
public static readonly int HDC = HandleCollector.RegisterType(nameof(HDC), 100, 2);
|
||||||
|
|
||||||
|
public static readonly int GDI = HandleCollector.RegisterType(nameof(GDI), 50, 500);
|
||||||
|
|
||||||
|
public static readonly int Kernel = HandleCollector.RegisterType(nameof(Kernel), 0, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
132
src/WPF/HandyControl/Tools/Interop/Handle/HandleCollector.cs
Normal file
132
src/WPF/HandyControl/Tools/Interop/Handle/HandleCollector.cs
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
// reference from https://referencesource.microsoft.com/#WindowsBase/Shared/MS/Win32/HandleCollector.cs,d0f99220d8e1b708
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools.Interop
|
||||||
|
{
|
||||||
|
internal static class HandleCollector
|
||||||
|
{
|
||||||
|
private static HandleType[] HandleTypes;
|
||||||
|
private static int HandleTypeCount;
|
||||||
|
|
||||||
|
private static readonly object HandleMutex = new object();
|
||||||
|
|
||||||
|
internal static IntPtr Add(IntPtr handle, int type)
|
||||||
|
{
|
||||||
|
HandleTypes[type - 1].Add();
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Security.SecuritySafeCritical]
|
||||||
|
internal static SafeHandle Add(SafeHandle handle, int type)
|
||||||
|
{
|
||||||
|
HandleTypes[type - 1].Add();
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Add(int type)
|
||||||
|
{
|
||||||
|
HandleTypes[type - 1].Add();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static int RegisterType(string typeName, int expense, int initialThreshold)
|
||||||
|
{
|
||||||
|
lock (HandleMutex)
|
||||||
|
{
|
||||||
|
if (HandleTypeCount == 0 || HandleTypeCount == HandleTypes.Length)
|
||||||
|
{
|
||||||
|
HandleType[] newTypes = new HandleType[HandleTypeCount + 10];
|
||||||
|
if (HandleTypes != null)
|
||||||
|
{
|
||||||
|
Array.Copy(HandleTypes, 0, newTypes, 0, HandleTypeCount);
|
||||||
|
}
|
||||||
|
HandleTypes = newTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleTypes[HandleTypeCount++] = new HandleType(expense, initialThreshold);
|
||||||
|
return HandleTypeCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static IntPtr Remove(IntPtr handle, int type)
|
||||||
|
{
|
||||||
|
HandleTypes[type - 1].Remove();
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Security.SecuritySafeCritical]
|
||||||
|
internal static SafeHandle Remove(SafeHandle handle, int type)
|
||||||
|
{
|
||||||
|
HandleTypes[type - 1].Remove();
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Remove(int type)
|
||||||
|
{
|
||||||
|
HandleTypes[type - 1].Remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class HandleType
|
||||||
|
{
|
||||||
|
private readonly int _initialThreshHold;
|
||||||
|
private int _threshHold;
|
||||||
|
private int _handleCount;
|
||||||
|
private readonly int _deltaPercent;
|
||||||
|
|
||||||
|
internal HandleType(int expense, int initialThreshHold)
|
||||||
|
{
|
||||||
|
_initialThreshHold = initialThreshHold;
|
||||||
|
_threshHold = initialThreshHold;
|
||||||
|
_deltaPercent = 100 - expense;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Add()
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
_handleCount++;
|
||||||
|
var performCollect = NeedCollection();
|
||||||
|
|
||||||
|
if (!performCollect)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GC.Collect();
|
||||||
|
|
||||||
|
var sleep = (100 - _deltaPercent) / 4;
|
||||||
|
System.Threading.Thread.Sleep(sleep);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool NeedCollection()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_handleCount > _threshHold)
|
||||||
|
{
|
||||||
|
_threshHold = _handleCount + _handleCount * _deltaPercent / 100;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var oldThreshHold = 100 * _threshHold / (100 + _deltaPercent);
|
||||||
|
if (oldThreshHold >= _initialThreshHold && _handleCount < (int) (oldThreshHold * .9F))
|
||||||
|
{
|
||||||
|
_threshHold = oldThreshHold;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Remove()
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
_handleCount--;
|
||||||
|
|
||||||
|
_handleCount = Math.Max(0, _handleCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/WPF/HandyControl/Tools/Interop/Handle/WpfSafeHandle.cs
Normal file
24
src/WPF/HandyControl/Tools/Interop/Handle/WpfSafeHandle.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Security;
|
||||||
|
using Microsoft.Win32.SafeHandles;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools.Interop
|
||||||
|
{
|
||||||
|
internal abstract class WpfSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
|
||||||
|
{
|
||||||
|
private readonly int _collectorId;
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
protected WpfSafeHandle(bool ownsHandle, int collectorId) : base(ownsHandle)
|
||||||
|
{
|
||||||
|
HandleCollector.Add(collectorId);
|
||||||
|
_collectorId = collectorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical, SecuritySafeCritical]
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
HandleCollector.Remove(_collectorId);
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
706
src/WPF/HandyControl/Tools/Interop/InteropMethods.cs
Normal file
706
src/WPF/HandyControl/Tools/Interop/InteropMethods.cs
Normal file
@@ -0,0 +1,706 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.ConstrainedExecution;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
using System.Security;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools.Interop
|
||||||
|
{
|
||||||
|
internal class InteropMethods
|
||||||
|
{
|
||||||
|
#region common
|
||||||
|
|
||||||
|
internal const int E_FAIL = unchecked((int) 0x80004005);
|
||||||
|
|
||||||
|
internal static readonly IntPtr HRGN_NONE = new IntPtr(-1);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int RegisterWindowMessage(string msg);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
|
||||||
|
int dwSize, out int lpNumberOfBytesRead);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
|
||||||
|
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.RECT lpBuffer,
|
||||||
|
int dwSize, out int lpNumberOfBytesRead);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
|
||||||
|
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TRAYDATA lpBuffer,
|
||||||
|
int dwSize, out int lpNumberOfBytesRead);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern bool AttachThreadInput(in uint currentForegroundWindowThreadId,
|
||||||
|
in uint thisWindowThreadId, bool isAttach);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern IntPtr OpenProcess(InteropValues.ProcessAccess dwDesiredAccess,
|
||||||
|
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize,
|
||||||
|
InteropValues.AllocationType flAllocationType, InteropValues.MemoryProtection flProtect);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern int CloseHandle(IntPtr hObject);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, InteropValues.FreeType dwFreeType);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass,
|
||||||
|
string lpszWindow);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern int GetWindowRect(IntPtr hwnd, out InteropValues.RECT lpRect);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern bool GetCursorPos(out InteropValues.POINT pt);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern IntPtr GetDesktopWindow();
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool AddClipboardFormatListener(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern bool EnableMenuItem(IntPtr hMenu, int UIDEnabledItem, int uEnable);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = "DestroyMenu", CharSet = CharSet.Auto)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern bool IntDestroyMenu(HandleRef hMenu);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = nameof(GetDC),
|
||||||
|
CharSet = CharSet.Auto)]
|
||||||
|
internal static extern IntPtr IntGetDC(HandleRef hWnd);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static IntPtr GetDC(HandleRef hWnd)
|
||||||
|
{
|
||||||
|
var hDc = IntGetDC(hWnd);
|
||||||
|
if (hDc == IntPtr.Zero) throw new Win32Exception();
|
||||||
|
|
||||||
|
return HandleCollector.Add(hDc, CommonHandles.HDC);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = nameof(ReleaseDC), CharSet = CharSet.Auto)]
|
||||||
|
internal static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
|
||||||
|
{
|
||||||
|
HandleCollector.Remove((IntPtr) hDC, CommonHandles.HDC);
|
||||||
|
return IntReleaseDC(hWnd, hDC);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern int GetSystemMetrics(InteropValues.SM nIndex);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, EntryPoint = nameof(DestroyIcon), CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
private static extern bool IntDestroyIcon(IntPtr hIcon);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static bool DestroyIcon(IntPtr hIcon)
|
||||||
|
{
|
||||||
|
var result = IntDestroyIcon(hIcon);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, EntryPoint = nameof(DeleteObject), CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
private static extern bool IntDeleteObject(IntPtr hObject);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static bool DeleteObject(IntPtr hObject)
|
||||||
|
{
|
||||||
|
var result = IntDeleteObject(hObject);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//[SecurityCritical]
|
||||||
|
//internal static BitmapHandle CreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
|
||||||
|
// ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset)
|
||||||
|
//{
|
||||||
|
// hSection ??= new SafeFileMappingHandle(IntPtr.Zero);
|
||||||
|
|
||||||
|
// var hBitmap = PrivateCreateDIBSection(hdc, ref bitmapInfo, iUsage, ref ppvBits, hSection, dwOffset);
|
||||||
|
// return hBitmap;
|
||||||
|
//}
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "CloseHandle", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
internal static extern bool IntCloseHandle(HandleRef handle);
|
||||||
|
|
||||||
|
//[SecurityCritical]
|
||||||
|
//[SuppressUnmanagedCodeSecurity]
|
||||||
|
//[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
|
||||||
|
// EntryPoint = nameof(CreateDIBSection))]
|
||||||
|
//private static extern BitmapHandle PrivateCreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
|
||||||
|
// ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset);
|
||||||
|
|
||||||
|
//[SecurityCritical]
|
||||||
|
//[SuppressUnmanagedCodeSecurity]
|
||||||
|
//[DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
|
||||||
|
// EntryPoint = nameof(CreateIconIndirect))]
|
||||||
|
//private static extern IconHandle PrivateCreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
|
||||||
|
// InteropValues.ICONINFO iconInfo);
|
||||||
|
|
||||||
|
//[SecurityCritical]
|
||||||
|
//internal static IconHandle CreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
|
||||||
|
// InteropValues.ICONINFO iconInfo)
|
||||||
|
//{
|
||||||
|
// var hIcon = PrivateCreateIconIndirect(iconInfo);
|
||||||
|
// return hIcon;
|
||||||
|
//}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
|
||||||
|
EntryPoint = nameof(CreateBitmap))]
|
||||||
|
private static extern BitmapHandle PrivateCreateBitmap(int width, int height, int planes, int bitsPerPixel,
|
||||||
|
byte[] lpvBits);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static BitmapHandle CreateBitmap(int width, int height, int planes, int bitsPerPixel, byte[] lpvBits)
|
||||||
|
{
|
||||||
|
var hBitmap = PrivateCreateBitmap(width, height, planes, bitsPerPixel, lpvBits);
|
||||||
|
return hBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "GetModuleFileName", CharSet = CharSet.Unicode,
|
||||||
|
SetLastError = true)]
|
||||||
|
private static extern int IntGetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
internal static string GetModuleFileName(HandleRef hModule)
|
||||||
|
{
|
||||||
|
var buffer = new StringBuilder(InteropValues.Win32Constant.MAX_PATH);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var size = IntGetModuleFileName(hModule, buffer, buffer.Capacity);
|
||||||
|
if (size == 0) throw new Win32Exception();
|
||||||
|
|
||||||
|
if (size == buffer.Capacity)
|
||||||
|
{
|
||||||
|
buffer.EnsureCapacity(buffer.Capacity * 2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//[SecurityCritical]
|
||||||
|
//[SuppressUnmanagedCodeSecurity]
|
||||||
|
//[DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
|
||||||
|
//internal static extern int ExtractIconEx(string szExeFileName, int nIconIndex, out IconHandle phiconLarge,
|
||||||
|
// out IconHandle phiconSmall, int nIcons);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern int Shell_NotifyIcon(int message, InteropValues.NOTIFYICONDATA pnid);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateWindowExW")]
|
||||||
|
internal static extern IntPtr CreateWindowEx(
|
||||||
|
int dwExStyle,
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] string lpWindowName,
|
||||||
|
int dwStyle,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
IntPtr hWndParent,
|
||||||
|
IntPtr hMenu,
|
||||||
|
IntPtr hInstance,
|
||||||
|
IntPtr lpParam);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
|
||||||
|
internal static extern short RegisterClass(InteropValues.WNDCLASS4ICON wc);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
internal static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
internal static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
internal static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
internal static extern IntPtr SetWindowsHookEx(int idHook, InteropValues.HookProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
internal static extern IntPtr GetWindowDC(IntPtr window);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
|
||||||
|
internal static extern uint GetPixel(IntPtr dc, int x, int y);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
internal static extern int ReleaseDC(IntPtr window, IntPtr dc);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||||
|
internal static extern IntPtr GetDC(IntPtr ptr);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static extern bool GetWindowPlacement(IntPtr hwnd, InteropValues.WINDOWPLACEMENT lpwndpl);
|
||||||
|
|
||||||
|
internal static InteropValues.WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
|
||||||
|
{
|
||||||
|
InteropValues.WINDOWPLACEMENT wINDOWPLACEMENT = new InteropValues.WINDOWPLACEMENT();
|
||||||
|
if (GetWindowPlacement(hwnd, wINDOWPLACEMENT))
|
||||||
|
{
|
||||||
|
return wINDOWPLACEMENT;
|
||||||
|
}
|
||||||
|
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static int GetXLParam(int lParam) => LoWord(lParam);
|
||||||
|
|
||||||
|
internal static int GetYLParam(int lParam) => HiWord(lParam);
|
||||||
|
|
||||||
|
internal static int HiWord(int value) => (short) (value >> 16);
|
||||||
|
|
||||||
|
internal static int LoWord(int value) => (short) (value & 65535);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool EnumThreadWindows(uint dwThreadId, InteropValues.EnumWindowsProc lpfn, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool DeleteDC(IntPtr hdc);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
|
||||||
|
internal static extern IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, ExactSpelling = true, SetLastError = true)]
|
||||||
|
internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
|
internal static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern IntPtr MonitorFromPoint(InteropValues.POINT pt, int flags);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern IntPtr GetWindow(IntPtr hwnd, int nCmd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool IsWindowVisible(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool IsIconic(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool IsZoomed(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);
|
||||||
|
|
||||||
|
internal static System.Windows.Point GetCursorPos()
|
||||||
|
{
|
||||||
|
var result = default(System.Windows.Point);
|
||||||
|
if (GetCursorPos(out var point))
|
||||||
|
{
|
||||||
|
result.X = point.X;
|
||||||
|
result.Y = point.Y;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
internal static int GetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex) => GetWindowLong(hWnd, (int) nIndex);
|
||||||
|
|
||||||
|
internal static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||||
|
{
|
||||||
|
if (IntPtr.Size == 4)
|
||||||
|
{
|
||||||
|
return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
|
||||||
|
}
|
||||||
|
return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLong")]
|
||||||
|
internal static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLongPtr")]
|
||||||
|
internal static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||||
|
|
||||||
|
internal static IntPtr SetWindowLongPtr(IntPtr hWnd, InteropValues.GWLP nIndex, IntPtr dwNewLong)
|
||||||
|
{
|
||||||
|
if (IntPtr.Size == 8)
|
||||||
|
{
|
||||||
|
return SetWindowLongPtr(hWnd, (int) nIndex, dwNewLong);
|
||||||
|
}
|
||||||
|
return new IntPtr(SetWindowLong(hWnd, (int) nIndex, dwNewLong.ToInt32()));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static int SetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex, int dwNewLong) => SetWindowLong(hWnd, (int) nIndex, dwNewLong);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
|
||||||
|
internal static extern ushort RegisterClass(ref InteropValues.WNDCLASS lpWndClass);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Kernel32)]
|
||||||
|
internal static extern uint GetCurrentThreadId();
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
|
internal static extern IntPtr CreateWindowEx(int dwExStyle, IntPtr classAtom, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool DestroyWindow(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool UnregisterClass(IntPtr classAtom, IntPtr hInstance);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDest, ref InteropValues.POINT pptDest, ref InteropValues.SIZE psize, IntPtr hdcSrc, ref InteropValues.POINT pptSrc, uint crKey, [In] ref InteropValues.BLENDFUNCTION pblend, uint dwFlags);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, InteropValues.RedrawWindowFlags flags);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, InteropValues.EnumMonitorsDelegate lpfnEnum, IntPtr dwData);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool IntersectRect(out InteropValues.RECT lprcDst, [In] ref InteropValues.RECT lprcSrc1, [In] ref InteropValues.RECT lprcSrc2);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool GetMonitorInfo(IntPtr hMonitor, ref InteropValues.MONITORINFO monitorInfo);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
|
||||||
|
internal static extern IntPtr CreateDIBSection(IntPtr hdc, ref InteropValues.BITMAPINFO pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.MsImg)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, InteropValues.BLENDFUNCTION pfn);
|
||||||
|
|
||||||
|
internal static int GET_SC_WPARAM(IntPtr wParam) => (int) wParam & 65520;
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern IntPtr ChildWindowFromPointEx(IntPtr hwndParent, InteropValues.POINT pt, int uFlags);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||||
|
internal static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int width, int height);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||||
|
internal static extern bool BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern bool EnableWindow(IntPtr hWnd, bool enable);
|
||||||
|
|
||||||
|
[ReflectionPermission(SecurityAction.Assert, Unrestricted = true), SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||||
|
internal static object PtrToStructure(IntPtr lparam, Type cls) => Marshal.PtrToStructure(lparam, cls);
|
||||||
|
|
||||||
|
[ReflectionPermission(SecurityAction.Assert, Unrestricted = true),
|
||||||
|
SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||||
|
internal static void PtrToStructure(IntPtr lparam, object data) => Marshal.PtrToStructure(lparam, data);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.Shell32, CallingConvention = CallingConvention.StdCall)]
|
||||||
|
internal static extern uint SHAppBarMessage(int dwMessage, ref InteropValues.APPBARDATA pData);
|
||||||
|
|
||||||
|
[SecurityCritical]
|
||||||
|
[DllImport(InteropValues.ExternDll.DwmApi, EntryPoint = "DwmGetColorizationColor", PreserveSig = true)]
|
||||||
|
internal static extern int DwmGetColorizationColor(out uint pcrColorization, out bool pfOpaqueBlend);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal class Gdip
|
||||||
|
{
|
||||||
|
private const string ThreadDataSlotName = "system.drawing.threaddata";
|
||||||
|
|
||||||
|
private static IntPtr InitToken;
|
||||||
|
|
||||||
|
private static bool Initialized => InitToken != IntPtr.Zero;
|
||||||
|
|
||||||
|
internal const int
|
||||||
|
Ok = 0,
|
||||||
|
GenericError = 1,
|
||||||
|
InvalidParameter = 2,
|
||||||
|
OutOfMemory = 3,
|
||||||
|
ObjectBusy = 4,
|
||||||
|
InsufficientBuffer = 5,
|
||||||
|
NotImplemented = 6,
|
||||||
|
Win32Error = 7,
|
||||||
|
WrongState = 8,
|
||||||
|
Aborted = 9,
|
||||||
|
FileNotFound = 10,
|
||||||
|
ValueOverflow = 11,
|
||||||
|
AccessDenied = 12,
|
||||||
|
UnknownImageFormat = 13,
|
||||||
|
FontFamilyNotFound = 14,
|
||||||
|
FontStyleNotFound = 15,
|
||||||
|
NotTrueTypeFont = 16,
|
||||||
|
UnsupportedGdiplusVersion = 17,
|
||||||
|
GdiplusNotInitialized = 18,
|
||||||
|
PropertyNotFound = 19,
|
||||||
|
PropertyNotSupported = 20,
|
||||||
|
E_UNEXPECTED = unchecked((int) 0x8000FFFF);
|
||||||
|
|
||||||
|
static Gdip()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct StartupInput
|
||||||
|
{
|
||||||
|
private int GdiplusVersion;
|
||||||
|
|
||||||
|
private readonly IntPtr DebugEventCallback;
|
||||||
|
|
||||||
|
private bool SuppressBackgroundThread;
|
||||||
|
|
||||||
|
private bool SuppressExternalCodecs;
|
||||||
|
|
||||||
|
public static StartupInput GetDefault()
|
||||||
|
{
|
||||||
|
var result = new StartupInput
|
||||||
|
{
|
||||||
|
GdiplusVersion = 1,
|
||||||
|
SuppressBackgroundThread = false,
|
||||||
|
SuppressExternalCodecs = false
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private readonly struct StartupOutput
|
||||||
|
{
|
||||||
|
private readonly IntPtr hook;
|
||||||
|
|
||||||
|
private readonly IntPtr unhook;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
[ResourceConsumption(ResourceScope.AppDomain, ResourceScope.AppDomain)]
|
||||||
|
[SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")]
|
||||||
|
private static void Initialize()
|
||||||
|
{
|
||||||
|
var input = StartupInput.GetDefault();
|
||||||
|
|
||||||
|
var status = GdiplusStartup(out InitToken, ref input, out _);
|
||||||
|
|
||||||
|
if (status != Ok)
|
||||||
|
{
|
||||||
|
throw StatusException(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentDomain = AppDomain.CurrentDomain;
|
||||||
|
currentDomain.ProcessExit += OnProcessExit;
|
||||||
|
|
||||||
|
if (!currentDomain.IsDefaultAppDomain())
|
||||||
|
{
|
||||||
|
currentDomain.DomainUnload += OnProcessExit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[PrePrepareMethod]
|
||||||
|
[ResourceExposure(ResourceScope.AppDomain)]
|
||||||
|
[ResourceConsumption(ResourceScope.AppDomain)]
|
||||||
|
private static void OnProcessExit(object sender, EventArgs e) => Shutdown();
|
||||||
|
|
||||||
|
[SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")]
|
||||||
|
[ResourceExposure(ResourceScope.AppDomain)]
|
||||||
|
[ResourceConsumption(ResourceScope.AppDomain)]
|
||||||
|
private static void Shutdown()
|
||||||
|
{
|
||||||
|
if (Initialized)
|
||||||
|
{
|
||||||
|
ClearThreadData();
|
||||||
|
// unhook our shutdown handlers as we do not need to shut down more than once
|
||||||
|
var currentDomain = AppDomain.CurrentDomain;
|
||||||
|
currentDomain.ProcessExit -= OnProcessExit;
|
||||||
|
if (!currentDomain.IsDefaultAppDomain())
|
||||||
|
{
|
||||||
|
currentDomain.DomainUnload -= OnProcessExit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
|
private static void ClearThreadData()
|
||||||
|
{
|
||||||
|
var slot = Thread.GetNamedDataSlot(ThreadDataSlotName);
|
||||||
|
Thread.SetData(slot, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipImageGetFrameDimensionsCount(HandleRef image, out int count);
|
||||||
|
|
||||||
|
internal static Exception StatusException(int status)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipImageGetFrameDimensionsList(HandleRef image, IntPtr buffer, int count);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipImageGetFrameCount(HandleRef image, ref Guid dimensionId, int[] count);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetPropertyItemSize(HandleRef image, int propid, out int size);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetPropertyItem(HandleRef image, int propid, int size, IntPtr buffer);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.Machine)]
|
||||||
|
internal static extern int GdipCreateHBITMAPFromBitmap(HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipImageSelectActiveFrame(HandleRef image, ref Guid dimensionId, int frameIndex);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.Machine)]
|
||||||
|
internal static extern int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipImageForceValidation(HandleRef image);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, EntryPoint = "GdipDisposeImage", CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
private static extern int IntGdipDisposeImage(HandleRef image);
|
||||||
|
|
||||||
|
internal static int GdipDisposeImage(HandleRef image)
|
||||||
|
{
|
||||||
|
if (!Initialized) return Ok;
|
||||||
|
var result = IntGdipDisposeImage(image);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.Process)]
|
||||||
|
private static extern int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetImageRawFormat(HandleRef image, ref Guid format);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.User32)]
|
||||||
|
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref InteropValues.WINCOMPATTRDATA data);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.Machine)]
|
||||||
|
internal static extern int GdipCreateBitmapFromStream(InteropValues.IStream stream, out IntPtr bitmap);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.Machine)]
|
||||||
|
internal static extern int GdipCreateBitmapFromHBITMAP(HandleRef hbitmap, HandleRef hpalette, out IntPtr bitmap);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetImageEncodersSize(out int numEncoders, out int size);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetImageDecodersSize(out int numDecoders, out int size);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetImageDecoders(int numDecoders, int size, IntPtr decoders);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipGetImageEncoders(int numEncoders, int size, IntPtr encoders);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
|
[ResourceExposure(ResourceScope.None)]
|
||||||
|
internal static extern int GdipSaveImageToStream(HandleRef image, InteropValues.IStream stream, ref Guid classId, HandleRef encoderParams);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.NTdll)]
|
||||||
|
internal static extern int RtlGetVersion(out InteropValues.RTL_OSVERSIONINFOEX lpVersionInformation);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
999
src/WPF/HandyControl/Tools/Interop/InteropValues.cs
Normal file
999
src/WPF/HandyControl/Tools/Interop/InteropValues.cs
Normal file
@@ -0,0 +1,999 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools.Interop
|
||||||
|
{
|
||||||
|
internal class InteropValues
|
||||||
|
{
|
||||||
|
internal static class ExternDll
|
||||||
|
{
|
||||||
|
public const string
|
||||||
|
User32 = "user32.dll",
|
||||||
|
Gdi32 = "gdi32.dll",
|
||||||
|
GdiPlus = "gdiplus.dll",
|
||||||
|
Kernel32 = "kernel32.dll",
|
||||||
|
Shell32 = "shell32.dll",
|
||||||
|
MsImg = "msimg32.dll",
|
||||||
|
NTdll = "ntdll.dll",
|
||||||
|
DwmApi = "dwmapi.dll";
|
||||||
|
}
|
||||||
|
|
||||||
|
internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
internal delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal delegate bool EnumMonitorsDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData);
|
||||||
|
|
||||||
|
internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||||
|
|
||||||
|
internal const int
|
||||||
|
BITSPIXEL = 12,
|
||||||
|
PLANES = 14,
|
||||||
|
BI_RGB = 0,
|
||||||
|
DIB_RGB_COLORS = 0,
|
||||||
|
E_FAIL = unchecked((int) 0x80004005),
|
||||||
|
NIF_MESSAGE = 0x00000001,
|
||||||
|
NIF_ICON = 0x00000002,
|
||||||
|
NIF_TIP = 0x00000004,
|
||||||
|
NIF_INFO = 0x00000010,
|
||||||
|
NIM_ADD = 0x00000000,
|
||||||
|
NIM_MODIFY = 0x00000001,
|
||||||
|
NIM_DELETE = 0x00000002,
|
||||||
|
NIIF_NONE = 0x00000000,
|
||||||
|
NIIF_INFO = 0x00000001,
|
||||||
|
NIIF_WARNING = 0x00000002,
|
||||||
|
NIIF_ERROR = 0x00000003,
|
||||||
|
WM_ACTIVATE = 0x0006,
|
||||||
|
WM_QUIT = 0x0012,
|
||||||
|
WM_GETMINMAXINFO = 0x0024,
|
||||||
|
WM_WINDOWPOSCHANGING = 0x0046,
|
||||||
|
WM_WINDOWPOSCHANGED = 0x0047,
|
||||||
|
WM_SETICON = 0x0080,
|
||||||
|
WM_NCCREATE = 0x0081,
|
||||||
|
WM_NCDESTROY = 0x0082,
|
||||||
|
WM_NCHITTEST = 0x0084,
|
||||||
|
WM_NCACTIVATE = 0x0086,
|
||||||
|
WM_NCRBUTTONDOWN = 0x00A4,
|
||||||
|
WM_NCRBUTTONUP = 0x00A5,
|
||||||
|
WM_NCRBUTTONDBLCLK = 0x00A6,
|
||||||
|
WM_NCUAHDRAWCAPTION = 0x00AE,
|
||||||
|
WM_NCUAHDRAWFRAME = 0x00AF,
|
||||||
|
WM_KEYDOWN = 0x0100,
|
||||||
|
WM_KEYUP = 0x0101,
|
||||||
|
WM_SYSKEYDOWN = 0x0104,
|
||||||
|
WM_SYSKEYUP = 0x0105,
|
||||||
|
WM_SYSCOMMAND = 0x112,
|
||||||
|
WM_MOUSEMOVE = 0x0200,
|
||||||
|
WM_LBUTTONUP = 0x0202,
|
||||||
|
WM_LBUTTONDBLCLK = 0x0203,
|
||||||
|
WM_RBUTTONUP = 0x0205,
|
||||||
|
WM_ENTERSIZEMOVE = 0x0231,
|
||||||
|
WM_EXITSIZEMOVE = 0x0232,
|
||||||
|
WM_CLIPBOARDUPDATE = 0x031D,
|
||||||
|
WM_USER = 0x0400,
|
||||||
|
WS_VISIBLE = 0x10000000,
|
||||||
|
MF_BYCOMMAND = 0x00000000,
|
||||||
|
MF_BYPOSITION = 0x400,
|
||||||
|
MF_GRAYED = 0x00000001,
|
||||||
|
MF_SEPARATOR = 0x800,
|
||||||
|
TB_GETBUTTON = WM_USER + 23,
|
||||||
|
TB_BUTTONCOUNT = WM_USER + 24,
|
||||||
|
TB_GETITEMRECT = WM_USER + 29,
|
||||||
|
VERTRES = 10,
|
||||||
|
DESKTOPVERTRES = 117,
|
||||||
|
LOGPIXELSX = 88,
|
||||||
|
LOGPIXELSY = 90,
|
||||||
|
SC_CLOSE = 0xF060,
|
||||||
|
SC_SIZE = 0xF000,
|
||||||
|
SC_MOVE = 0xF010,
|
||||||
|
SC_MINIMIZE = 0xF020,
|
||||||
|
SC_MAXIMIZE = 0xF030,
|
||||||
|
SC_RESTORE = 0xF120,
|
||||||
|
SRCCOPY = 0x00CC0020,
|
||||||
|
MONITOR_DEFAULTTONEAREST = 0x00000002;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||||
|
internal class NOTIFYICONDATA
|
||||||
|
{
|
||||||
|
public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
|
||||||
|
public IntPtr hWnd;
|
||||||
|
public int uID;
|
||||||
|
public int uFlags;
|
||||||
|
public int uCallbackMessage;
|
||||||
|
public IntPtr hIcon;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
public string szTip = string.Empty;
|
||||||
|
public int dwState = 0x01;
|
||||||
|
public int dwStateMask = 0x01;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string szInfo = string.Empty;
|
||||||
|
public int uTimeoutOrVersion;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
||||||
|
public string szInfoTitle = string.Empty;
|
||||||
|
public int dwInfoFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
internal struct TBBUTTON
|
||||||
|
{
|
||||||
|
public int iBitmap;
|
||||||
|
public int idCommand;
|
||||||
|
public IntPtr fsStateStylePadding;
|
||||||
|
public IntPtr dwData;
|
||||||
|
public IntPtr iString;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum AllocationType
|
||||||
|
{
|
||||||
|
Commit = 0x1000,
|
||||||
|
Reserve = 0x2000,
|
||||||
|
Decommit = 0x4000,
|
||||||
|
Release = 0x8000,
|
||||||
|
Reset = 0x80000,
|
||||||
|
Physical = 0x400000,
|
||||||
|
TopDown = 0x100000,
|
||||||
|
WriteWatch = 0x200000,
|
||||||
|
LargePages = 0x20000000
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum MemoryProtection
|
||||||
|
{
|
||||||
|
Execute = 0x10,
|
||||||
|
ExecuteRead = 0x20,
|
||||||
|
ExecuteReadWrite = 0x40,
|
||||||
|
ExecuteWriteCopy = 0x80,
|
||||||
|
NoAccess = 0x01,
|
||||||
|
ReadOnly = 0x02,
|
||||||
|
ReadWrite = 0x04,
|
||||||
|
WriteCopy = 0x08,
|
||||||
|
GuardModifierflag = 0x100,
|
||||||
|
NoCacheModifierflag = 0x200,
|
||||||
|
WriteCombineModifierflag = 0x400
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct TRAYDATA
|
||||||
|
{
|
||||||
|
public IntPtr hwnd;
|
||||||
|
public uint uID;
|
||||||
|
public uint uCallbackMessage;
|
||||||
|
public uint bReserved0;
|
||||||
|
public uint bReserved1;
|
||||||
|
public IntPtr hIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum FreeType
|
||||||
|
{
|
||||||
|
Decommit = 0x4000,
|
||||||
|
Release = 0x8000,
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct POINT
|
||||||
|
{
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
|
||||||
|
public POINT(int x, int y)
|
||||||
|
{
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum HookType
|
||||||
|
{
|
||||||
|
WH_KEYBOARD_LL = 13,
|
||||||
|
WH_MOUSE_LL = 14
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct MOUSEHOOKSTRUCT
|
||||||
|
{
|
||||||
|
public POINT pt;
|
||||||
|
public IntPtr hwnd;
|
||||||
|
public uint wHitTestCode;
|
||||||
|
public IntPtr dwExtraInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum ProcessAccess
|
||||||
|
{
|
||||||
|
AllAccess = CreateThread | DuplicateHandle | QueryInformation | SetInformation | Terminate | VMOperation | VMRead | VMWrite | Synchronize,
|
||||||
|
CreateThread = 0x2,
|
||||||
|
DuplicateHandle = 0x40,
|
||||||
|
QueryInformation = 0x400,
|
||||||
|
SetInformation = 0x200,
|
||||||
|
Terminate = 0x1,
|
||||||
|
VMOperation = 0x8,
|
||||||
|
VMRead = 0x10,
|
||||||
|
VMWrite = 0x20,
|
||||||
|
Synchronize = 0x100000
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||||
|
internal struct RECT
|
||||||
|
{
|
||||||
|
public int Left;
|
||||||
|
public int Top;
|
||||||
|
public int Right;
|
||||||
|
public int Bottom;
|
||||||
|
|
||||||
|
public RECT(int left, int top, int right, int bottom)
|
||||||
|
{
|
||||||
|
Left = left;
|
||||||
|
Top = top;
|
||||||
|
Right = right;
|
||||||
|
Bottom = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RECT(Rect rect)
|
||||||
|
{
|
||||||
|
Left = (int) rect.Left;
|
||||||
|
Top = (int) rect.Top;
|
||||||
|
Right = (int) rect.Right;
|
||||||
|
Bottom = (int) rect.Bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point Position => new Point(Left, Top);
|
||||||
|
public Size Size => new Size(Width, Height);
|
||||||
|
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get => Bottom - Top;
|
||||||
|
set => Bottom = Top + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get => Right - Left;
|
||||||
|
set => Right = Left + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct BLENDFUNCTION
|
||||||
|
{
|
||||||
|
public byte BlendOp;
|
||||||
|
public byte BlendFlags;
|
||||||
|
public byte SourceConstantAlpha;
|
||||||
|
public byte AlphaFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum GWL
|
||||||
|
{
|
||||||
|
STYLE = -16,
|
||||||
|
EXSTYLE = -20
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum GWLP
|
||||||
|
{
|
||||||
|
WNDPROC = -4,
|
||||||
|
HINSTANCE = -6,
|
||||||
|
HWNDPARENT = -8,
|
||||||
|
USERDATA = -21,
|
||||||
|
ID = -12
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct BITMAPINFOHEADER
|
||||||
|
{
|
||||||
|
internal uint biSize;
|
||||||
|
internal int biWidth;
|
||||||
|
internal int biHeight;
|
||||||
|
internal ushort biPlanes;
|
||||||
|
internal ushort biBitCount;
|
||||||
|
internal uint biCompression;
|
||||||
|
internal uint biSizeImage;
|
||||||
|
internal int biXPelsPerMeter;
|
||||||
|
internal int biYPelsPerMeter;
|
||||||
|
internal uint biClrUsed;
|
||||||
|
internal uint biClrImportant;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum RedrawWindowFlags : uint
|
||||||
|
{
|
||||||
|
Invalidate = 1u,
|
||||||
|
InternalPaint = 2u,
|
||||||
|
Erase = 4u,
|
||||||
|
Validate = 8u,
|
||||||
|
NoInternalPaint = 16u,
|
||||||
|
NoErase = 32u,
|
||||||
|
NoChildren = 64u,
|
||||||
|
AllChildren = 128u,
|
||||||
|
UpdateNow = 256u,
|
||||||
|
EraseNow = 512u,
|
||||||
|
Frame = 1024u,
|
||||||
|
NoFrame = 2048u
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal class WINDOWPOS
|
||||||
|
{
|
||||||
|
public IntPtr hwnd;
|
||||||
|
public IntPtr hwndInsertAfter;
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int cx;
|
||||||
|
public int cy;
|
||||||
|
public uint flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal class WINDOWPLACEMENT
|
||||||
|
{
|
||||||
|
public int length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
|
||||||
|
public int flags;
|
||||||
|
public int showCmd;
|
||||||
|
public POINT ptMinPosition;
|
||||||
|
public POINT ptMaxPosition;
|
||||||
|
public RECT rcNormalPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||||
|
internal struct SIZE
|
||||||
|
{
|
||||||
|
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
|
||||||
|
public int cx;
|
||||||
|
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
|
||||||
|
public int cy;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct MONITORINFO
|
||||||
|
{
|
||||||
|
public uint cbSize;
|
||||||
|
public RECT rcMonitor;
|
||||||
|
public RECT rcWork;
|
||||||
|
public uint dwFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum SM
|
||||||
|
{
|
||||||
|
CXSCREEN = 0,
|
||||||
|
CYSCREEN = 1,
|
||||||
|
CXVSCROLL = 2,
|
||||||
|
CYHSCROLL = 3,
|
||||||
|
CYCAPTION = 4,
|
||||||
|
CXBORDER = 5,
|
||||||
|
CYBORDER = 6,
|
||||||
|
CXFIXEDFRAME = 7,
|
||||||
|
CYFIXEDFRAME = 8,
|
||||||
|
CYVTHUMB = 9,
|
||||||
|
CXHTHUMB = 10,
|
||||||
|
CXICON = 11,
|
||||||
|
CYICON = 12,
|
||||||
|
CXCURSOR = 13,
|
||||||
|
CYCURSOR = 14,
|
||||||
|
CYMENU = 15,
|
||||||
|
CXFULLSCREEN = 16,
|
||||||
|
CYFULLSCREEN = 17,
|
||||||
|
CYKANJIWINDOW = 18,
|
||||||
|
MOUSEPRESENT = 19,
|
||||||
|
CYVSCROLL = 20,
|
||||||
|
CXHSCROLL = 21,
|
||||||
|
DEBUG = 22,
|
||||||
|
SWAPBUTTON = 23,
|
||||||
|
CXMIN = 28,
|
||||||
|
CYMIN = 29,
|
||||||
|
CXSIZE = 30,
|
||||||
|
CYSIZE = 31,
|
||||||
|
CXFRAME = 32,
|
||||||
|
CXSIZEFRAME = CXFRAME,
|
||||||
|
CYFRAME = 33,
|
||||||
|
CYSIZEFRAME = CYFRAME,
|
||||||
|
CXMINTRACK = 34,
|
||||||
|
CYMINTRACK = 35,
|
||||||
|
CXDOUBLECLK = 36,
|
||||||
|
CYDOUBLECLK = 37,
|
||||||
|
CXICONSPACING = 38,
|
||||||
|
CYICONSPACING = 39,
|
||||||
|
MENUDROPALIGNMENT = 40,
|
||||||
|
PENWINDOWS = 41,
|
||||||
|
DBCSENABLED = 42,
|
||||||
|
CMOUSEBUTTONS = 43,
|
||||||
|
SECURE = 44,
|
||||||
|
CXEDGE = 45,
|
||||||
|
CYEDGE = 46,
|
||||||
|
CXMINSPACING = 47,
|
||||||
|
CYMINSPACING = 48,
|
||||||
|
CXSMICON = 49,
|
||||||
|
CYSMICON = 50,
|
||||||
|
CYSMCAPTION = 51,
|
||||||
|
CXSMSIZE = 52,
|
||||||
|
CYSMSIZE = 53,
|
||||||
|
CXMENUSIZE = 54,
|
||||||
|
CYMENUSIZE = 55,
|
||||||
|
ARRANGE = 56,
|
||||||
|
CXMINIMIZED = 57,
|
||||||
|
CYMINIMIZED = 58,
|
||||||
|
CXMAXTRACK = 59,
|
||||||
|
CYMAXTRACK = 60,
|
||||||
|
CXMAXIMIZED = 61,
|
||||||
|
CYMAXIMIZED = 62,
|
||||||
|
NETWORK = 63,
|
||||||
|
CLEANBOOT = 67,
|
||||||
|
CXDRAG = 68,
|
||||||
|
CYDRAG = 69,
|
||||||
|
SHOWSOUNDS = 70,
|
||||||
|
CXMENUCHECK = 71,
|
||||||
|
CYMENUCHECK = 72,
|
||||||
|
SLOWMACHINE = 73,
|
||||||
|
MIDEASTENABLED = 74,
|
||||||
|
MOUSEWHEELPRESENT = 75,
|
||||||
|
XVIRTUALSCREEN = 76,
|
||||||
|
YVIRTUALSCREEN = 77,
|
||||||
|
CXVIRTUALSCREEN = 78,
|
||||||
|
CYVIRTUALSCREEN = 79,
|
||||||
|
CMONITORS = 80,
|
||||||
|
SAMEDISPLAYFORMAT = 81,
|
||||||
|
IMMENABLED = 82,
|
||||||
|
CXFOCUSBORDER = 83,
|
||||||
|
CYFOCUSBORDER = 84,
|
||||||
|
TABLETPC = 86,
|
||||||
|
MEDIACENTER = 87,
|
||||||
|
REMOTESESSION = 0x1000,
|
||||||
|
REMOTECONTROL = 0x2001
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum CacheSlot
|
||||||
|
{
|
||||||
|
DpiX,
|
||||||
|
|
||||||
|
FocusBorderWidth,
|
||||||
|
FocusBorderHeight,
|
||||||
|
HighContrast,
|
||||||
|
MouseVanish,
|
||||||
|
|
||||||
|
DropShadow,
|
||||||
|
FlatMenu,
|
||||||
|
WorkAreaInternal,
|
||||||
|
WorkArea,
|
||||||
|
|
||||||
|
IconMetrics,
|
||||||
|
|
||||||
|
KeyboardCues,
|
||||||
|
KeyboardDelay,
|
||||||
|
KeyboardPreference,
|
||||||
|
KeyboardSpeed,
|
||||||
|
SnapToDefaultButton,
|
||||||
|
WheelScrollLines,
|
||||||
|
MouseHoverTime,
|
||||||
|
MouseHoverHeight,
|
||||||
|
MouseHoverWidth,
|
||||||
|
|
||||||
|
MenuDropAlignment,
|
||||||
|
MenuFade,
|
||||||
|
MenuShowDelay,
|
||||||
|
|
||||||
|
ComboBoxAnimation,
|
||||||
|
ClientAreaAnimation,
|
||||||
|
CursorShadow,
|
||||||
|
GradientCaptions,
|
||||||
|
HotTracking,
|
||||||
|
ListBoxSmoothScrolling,
|
||||||
|
MenuAnimation,
|
||||||
|
SelectionFade,
|
||||||
|
StylusHotTracking,
|
||||||
|
ToolTipAnimation,
|
||||||
|
ToolTipFade,
|
||||||
|
UIEffects,
|
||||||
|
|
||||||
|
MinimizeAnimation,
|
||||||
|
Border,
|
||||||
|
CaretWidth,
|
||||||
|
ForegroundFlashCount,
|
||||||
|
DragFullWindows,
|
||||||
|
NonClientMetrics,
|
||||||
|
|
||||||
|
ThinHorizontalBorderHeight,
|
||||||
|
ThinVerticalBorderWidth,
|
||||||
|
CursorWidth,
|
||||||
|
CursorHeight,
|
||||||
|
ThickHorizontalBorderHeight,
|
||||||
|
ThickVerticalBorderWidth,
|
||||||
|
MinimumHorizontalDragDistance,
|
||||||
|
MinimumVerticalDragDistance,
|
||||||
|
FixedFrameHorizontalBorderHeight,
|
||||||
|
FixedFrameVerticalBorderWidth,
|
||||||
|
FocusHorizontalBorderHeight,
|
||||||
|
FocusVerticalBorderWidth,
|
||||||
|
FullPrimaryScreenWidth,
|
||||||
|
FullPrimaryScreenHeight,
|
||||||
|
HorizontalScrollBarButtonWidth,
|
||||||
|
HorizontalScrollBarHeight,
|
||||||
|
HorizontalScrollBarThumbWidth,
|
||||||
|
IconWidth,
|
||||||
|
IconHeight,
|
||||||
|
IconGridWidth,
|
||||||
|
IconGridHeight,
|
||||||
|
MaximizedPrimaryScreenWidth,
|
||||||
|
MaximizedPrimaryScreenHeight,
|
||||||
|
MaximumWindowTrackWidth,
|
||||||
|
MaximumWindowTrackHeight,
|
||||||
|
MenuCheckmarkWidth,
|
||||||
|
MenuCheckmarkHeight,
|
||||||
|
MenuButtonWidth,
|
||||||
|
MenuButtonHeight,
|
||||||
|
MinimumWindowWidth,
|
||||||
|
MinimumWindowHeight,
|
||||||
|
MinimizedWindowWidth,
|
||||||
|
MinimizedWindowHeight,
|
||||||
|
MinimizedGridWidth,
|
||||||
|
MinimizedGridHeight,
|
||||||
|
MinimumWindowTrackWidth,
|
||||||
|
MinimumWindowTrackHeight,
|
||||||
|
PrimaryScreenWidth,
|
||||||
|
PrimaryScreenHeight,
|
||||||
|
WindowCaptionButtonWidth,
|
||||||
|
WindowCaptionButtonHeight,
|
||||||
|
ResizeFrameHorizontalBorderHeight,
|
||||||
|
ResizeFrameVerticalBorderWidth,
|
||||||
|
SmallIconWidth,
|
||||||
|
SmallIconHeight,
|
||||||
|
SmallWindowCaptionButtonWidth,
|
||||||
|
SmallWindowCaptionButtonHeight,
|
||||||
|
VirtualScreenWidth,
|
||||||
|
VirtualScreenHeight,
|
||||||
|
VerticalScrollBarWidth,
|
||||||
|
VerticalScrollBarButtonHeight,
|
||||||
|
WindowCaptionHeight,
|
||||||
|
KanjiWindowHeight,
|
||||||
|
MenuBarHeight,
|
||||||
|
VerticalScrollBarThumbHeight,
|
||||||
|
IsImmEnabled,
|
||||||
|
IsMediaCenter,
|
||||||
|
IsMenuDropRightAligned,
|
||||||
|
IsMiddleEastEnabled,
|
||||||
|
IsMousePresent,
|
||||||
|
IsMouseWheelPresent,
|
||||||
|
IsPenWindows,
|
||||||
|
IsRemotelyControlled,
|
||||||
|
IsRemoteSession,
|
||||||
|
ShowSounds,
|
||||||
|
IsSlowMachine,
|
||||||
|
SwapButtons,
|
||||||
|
IsTabletPC,
|
||||||
|
VirtualScreenLeft,
|
||||||
|
VirtualScreenTop,
|
||||||
|
|
||||||
|
PowerLineStatus,
|
||||||
|
|
||||||
|
IsGlassEnabled,
|
||||||
|
UxThemeName,
|
||||||
|
UxThemeColor,
|
||||||
|
WindowCornerRadius,
|
||||||
|
WindowGlassColor,
|
||||||
|
WindowGlassBrush,
|
||||||
|
WindowNonClientFrameThickness,
|
||||||
|
WindowResizeBorderThickness,
|
||||||
|
|
||||||
|
NumSlots
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class Win32Constant
|
||||||
|
{
|
||||||
|
internal const int MAX_PATH = 260;
|
||||||
|
internal const int INFOTIPSIZE = 1024;
|
||||||
|
internal const int TRUE = 1;
|
||||||
|
internal const int FALSE = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
internal struct WNDCLASS
|
||||||
|
{
|
||||||
|
public uint style;
|
||||||
|
public Delegate lpfnWndProc;
|
||||||
|
public int cbClsExtra;
|
||||||
|
public int cbWndExtra;
|
||||||
|
public IntPtr hInstance;
|
||||||
|
public IntPtr hIcon;
|
||||||
|
public IntPtr hCursor;
|
||||||
|
public IntPtr hbrBackground;
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
public string lpszMenuName;
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
public string lpszClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||||
|
internal class WNDCLASS4ICON
|
||||||
|
{
|
||||||
|
public int style;
|
||||||
|
public WndProc lpfnWndProc;
|
||||||
|
public int cbClsExtra;
|
||||||
|
public int cbWndExtra;
|
||||||
|
public IntPtr hInstance;
|
||||||
|
public IntPtr hIcon;
|
||||||
|
public IntPtr hCursor;
|
||||||
|
public IntPtr hbrBackground;
|
||||||
|
public string lpszMenuName;
|
||||||
|
public string lpszClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||||
|
internal struct BITMAPINFO
|
||||||
|
{
|
||||||
|
public int biSize;
|
||||||
|
|
||||||
|
public int biWidth;
|
||||||
|
|
||||||
|
public int biHeight;
|
||||||
|
|
||||||
|
public short biPlanes;
|
||||||
|
|
||||||
|
public short biBitCount;
|
||||||
|
|
||||||
|
public int biCompression;
|
||||||
|
|
||||||
|
public int biSizeImage;
|
||||||
|
|
||||||
|
public int biXPelsPerMeter;
|
||||||
|
|
||||||
|
public int biYPelsPerMeter;
|
||||||
|
|
||||||
|
public int biClrUsed;
|
||||||
|
|
||||||
|
public int biClrImportant;
|
||||||
|
|
||||||
|
public BITMAPINFO(int width, int height, short bpp)
|
||||||
|
{
|
||||||
|
biSize = SizeOf();
|
||||||
|
biWidth = width;
|
||||||
|
biHeight = height;
|
||||||
|
biPlanes = 1;
|
||||||
|
biBitCount = bpp;
|
||||||
|
biCompression = 0;
|
||||||
|
biSizeImage = 0;
|
||||||
|
biXPelsPerMeter = 0;
|
||||||
|
biYPelsPerMeter = 0;
|
||||||
|
biClrUsed = 0;
|
||||||
|
biClrImportant = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SecuritySafeCritical]
|
||||||
|
private static int SizeOf()
|
||||||
|
{
|
||||||
|
return Marshal.SizeOf(typeof(BITMAPINFO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal class ICONINFO
|
||||||
|
{
|
||||||
|
public bool fIcon = false;
|
||||||
|
public int xHotspot = 0;
|
||||||
|
public int yHotspot = 0;
|
||||||
|
public BitmapHandle hbmMask = null;
|
||||||
|
public BitmapHandle hbmColor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum WINDOWCOMPOSITIONATTRIB
|
||||||
|
{
|
||||||
|
WCA_ACCENT_POLICY = 19
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct WINCOMPATTRDATA
|
||||||
|
{
|
||||||
|
public WINDOWCOMPOSITIONATTRIB Attribute;
|
||||||
|
public IntPtr Data;
|
||||||
|
public int DataSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum ACCENTSTATE
|
||||||
|
{
|
||||||
|
ACCENT_DISABLED = 0,
|
||||||
|
ACCENT_ENABLE_GRADIENT = 1,
|
||||||
|
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
||||||
|
ACCENT_ENABLE_BLURBEHIND = 3,
|
||||||
|
ACCENT_ENABLE_ACRYLICBLURBEHIND = 4,
|
||||||
|
ACCENT_INVALID_STATE = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct ACCENTPOLICY
|
||||||
|
{
|
||||||
|
public ACCENTSTATE AccentState;
|
||||||
|
public int AccentFlags;
|
||||||
|
public uint GradientColor;
|
||||||
|
public int AnimationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ComImport, Guid("0000000C-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
|
internal interface IStream
|
||||||
|
{
|
||||||
|
int Read([In] IntPtr buf, [In] int len);
|
||||||
|
|
||||||
|
int Write([In] IntPtr buf, [In] int len);
|
||||||
|
|
||||||
|
[return: MarshalAs(UnmanagedType.I8)]
|
||||||
|
long Seek([In, MarshalAs(UnmanagedType.I8)] long dlibMove, [In] int dwOrigin);
|
||||||
|
|
||||||
|
void SetSize([In, MarshalAs(UnmanagedType.I8)] long libNewSize);
|
||||||
|
|
||||||
|
[return: MarshalAs(UnmanagedType.I8)]
|
||||||
|
long CopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In, MarshalAs(UnmanagedType.I8)] long cb, [Out, MarshalAs(UnmanagedType.LPArray)] long[] pcbRead);
|
||||||
|
|
||||||
|
void Commit([In] int grfCommitFlags);
|
||||||
|
|
||||||
|
void Revert();
|
||||||
|
|
||||||
|
void LockRegion([In, MarshalAs(UnmanagedType.I8)] long libOffset, [In, MarshalAs(UnmanagedType.I8)] long cb, [In] int dwLockType);
|
||||||
|
|
||||||
|
void UnlockRegion([In, MarshalAs(UnmanagedType.I8)] long libOffset, [In, MarshalAs(UnmanagedType.I8)] long cb, [In] int dwLockType);
|
||||||
|
|
||||||
|
void Stat([In] IntPtr pStatstg, [In] int grfStatFlag);
|
||||||
|
|
||||||
|
[return: MarshalAs(UnmanagedType.Interface)]
|
||||||
|
IStream Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class StreamConsts
|
||||||
|
{
|
||||||
|
public const int LOCK_WRITE = 0x1;
|
||||||
|
public const int LOCK_EXCLUSIVE = 0x2;
|
||||||
|
public const int LOCK_ONLYONCE = 0x4;
|
||||||
|
public const int STATFLAG_DEFAULT = 0x0;
|
||||||
|
public const int STATFLAG_NONAME = 0x1;
|
||||||
|
public const int STATFLAG_NOOPEN = 0x2;
|
||||||
|
public const int STGC_DEFAULT = 0x0;
|
||||||
|
public const int STGC_OVERWRITE = 0x1;
|
||||||
|
public const int STGC_ONLYIFCURRENT = 0x2;
|
||||||
|
public const int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 0x4;
|
||||||
|
public const int STREAM_SEEK_SET = 0x0;
|
||||||
|
public const int STREAM_SEEK_CUR = 0x1;
|
||||||
|
public const int STREAM_SEEK_END = 0x2;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||||
|
internal class ImageCodecInfoPrivate
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.Struct)]
|
||||||
|
public Guid Clsid;
|
||||||
|
[MarshalAs(UnmanagedType.Struct)]
|
||||||
|
public Guid FormatID;
|
||||||
|
|
||||||
|
public IntPtr CodecName = IntPtr.Zero;
|
||||||
|
public IntPtr DllName = IntPtr.Zero;
|
||||||
|
public IntPtr FormatDescription = IntPtr.Zero;
|
||||||
|
public IntPtr FilenameExtension = IntPtr.Zero;
|
||||||
|
public IntPtr MimeType = IntPtr.Zero;
|
||||||
|
|
||||||
|
public int Flags;
|
||||||
|
public int Version;
|
||||||
|
public int SigCount;
|
||||||
|
public int SigSize;
|
||||||
|
|
||||||
|
public IntPtr SigPattern = IntPtr.Zero;
|
||||||
|
public IntPtr SigMask = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ComStreamFromDataStream : IStream
|
||||||
|
{
|
||||||
|
protected Stream DataStream;
|
||||||
|
|
||||||
|
// to support seeking ahead of the stream length...
|
||||||
|
private long _virtualPosition = -1;
|
||||||
|
|
||||||
|
internal ComStreamFromDataStream(Stream dataStream)
|
||||||
|
{
|
||||||
|
this.DataStream = dataStream ?? throw new ArgumentNullException(nameof(dataStream));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ActualizeVirtualPosition()
|
||||||
|
{
|
||||||
|
if (_virtualPosition == -1) return;
|
||||||
|
|
||||||
|
if (_virtualPosition > DataStream.Length)
|
||||||
|
DataStream.SetLength(_virtualPosition);
|
||||||
|
|
||||||
|
DataStream.Position = _virtualPosition;
|
||||||
|
|
||||||
|
_virtualPosition = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual IStream Clone()
|
||||||
|
{
|
||||||
|
NotImplemented();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Commit(int grfCommitFlags)
|
||||||
|
{
|
||||||
|
DataStream.Flush();
|
||||||
|
ActualizeVirtualPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual long CopyTo(IStream pstm, long cb, long[] pcbRead)
|
||||||
|
{
|
||||||
|
const int bufsize = 4096; // one page
|
||||||
|
var buffer = Marshal.AllocHGlobal(bufsize);
|
||||||
|
if (buffer == IntPtr.Zero) throw new OutOfMemoryException();
|
||||||
|
long written = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (written < cb)
|
||||||
|
{
|
||||||
|
var toRead = bufsize;
|
||||||
|
if (written + toRead > cb) toRead = (int) (cb - written);
|
||||||
|
var read = Read(buffer, toRead);
|
||||||
|
if (read == 0) break;
|
||||||
|
if (pstm.Write(buffer, read) != read)
|
||||||
|
{
|
||||||
|
throw EFail("Wrote an incorrect number of bytes");
|
||||||
|
}
|
||||||
|
written += read;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(buffer);
|
||||||
|
}
|
||||||
|
if (pcbRead != null && pcbRead.Length > 0)
|
||||||
|
{
|
||||||
|
pcbRead[0] = written;
|
||||||
|
}
|
||||||
|
|
||||||
|
return written;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Stream GetDataStream() => DataStream;
|
||||||
|
|
||||||
|
public virtual void LockRegion(long libOffset, long cb, int dwLockType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static ExternalException EFail(string msg) => throw new ExternalException(msg, E_FAIL);
|
||||||
|
|
||||||
|
protected static void NotImplemented() => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public virtual int Read(IntPtr buf, int length)
|
||||||
|
{
|
||||||
|
var buffer = new byte[length];
|
||||||
|
var count = Read(buffer, length);
|
||||||
|
Marshal.Copy(buffer, 0, buf, length);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int Read(byte[] buffer, int length)
|
||||||
|
{
|
||||||
|
ActualizeVirtualPosition();
|
||||||
|
return DataStream.Read(buffer, 0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Revert() => NotImplemented();
|
||||||
|
|
||||||
|
public virtual long Seek(long offset, int origin)
|
||||||
|
{
|
||||||
|
var pos = _virtualPosition;
|
||||||
|
if (_virtualPosition == -1)
|
||||||
|
{
|
||||||
|
pos = DataStream.Position;
|
||||||
|
}
|
||||||
|
var len = DataStream.Length;
|
||||||
|
|
||||||
|
switch (origin)
|
||||||
|
{
|
||||||
|
case StreamConsts.STREAM_SEEK_SET:
|
||||||
|
if (offset <= len)
|
||||||
|
{
|
||||||
|
DataStream.Position = offset;
|
||||||
|
_virtualPosition = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_virtualPosition = offset;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case StreamConsts.STREAM_SEEK_END:
|
||||||
|
if (offset <= 0)
|
||||||
|
{
|
||||||
|
DataStream.Position = len + offset;
|
||||||
|
_virtualPosition = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_virtualPosition = len + offset;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case StreamConsts.STREAM_SEEK_CUR:
|
||||||
|
if (offset + pos <= len)
|
||||||
|
{
|
||||||
|
DataStream.Position = pos + offset;
|
||||||
|
_virtualPosition = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_virtualPosition = offset + pos;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _virtualPosition != -1 ? _virtualPosition : DataStream.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetSize(long value) => DataStream.SetLength(value);
|
||||||
|
|
||||||
|
public virtual void Stat(IntPtr pstatstg, int grfStatFlag) => NotImplemented();
|
||||||
|
|
||||||
|
public virtual void UnlockRegion(long libOffset, long cb, int dwLockType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int Write(IntPtr buf, int length)
|
||||||
|
{
|
||||||
|
var buffer = new byte[length];
|
||||||
|
Marshal.Copy(buf, buffer, 0, length);
|
||||||
|
return Write(buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int Write(byte[] buffer, int length)
|
||||||
|
{
|
||||||
|
ActualizeVirtualPosition();
|
||||||
|
DataStream.Write(buffer, 0, length);
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal class MINMAXINFO
|
||||||
|
{
|
||||||
|
public POINT ptReserved;
|
||||||
|
public POINT ptMaxSize;
|
||||||
|
public POINT ptMaxPosition;
|
||||||
|
public POINT ptMinTrackSize;
|
||||||
|
public POINT ptMaxTrackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct APPBARDATA
|
||||||
|
{
|
||||||
|
public int cbSize;
|
||||||
|
public IntPtr hWnd;
|
||||||
|
public uint uCallbackMessage;
|
||||||
|
public uint uEdge;
|
||||||
|
public RECT rc;
|
||||||
|
public int lParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct RTL_OSVERSIONINFOEX
|
||||||
|
{
|
||||||
|
internal uint dwOSVersionInfoSize;
|
||||||
|
internal uint dwMajorVersion;
|
||||||
|
internal uint dwMinorVersion;
|
||||||
|
internal uint dwBuildNumber;
|
||||||
|
internal uint dwPlatformId;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
internal string szCSDVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum WindowPositionFlags
|
||||||
|
{
|
||||||
|
SWP_ASYNCWINDOWPOS = 0x4000,
|
||||||
|
SWP_DEFERERASE = 0x2000,
|
||||||
|
SWP_DRAWFRAME = 0x0020,
|
||||||
|
SWP_FRAMECHANGED = 0x0020,
|
||||||
|
SWP_HIDEWINDOW = 0x0080,
|
||||||
|
SWP_NOACTIVATE = 0x0010,
|
||||||
|
SWP_NOCOPYBITS = 0x0100,
|
||||||
|
SWP_NOMOVE = 0x0002,
|
||||||
|
SWP_NOOWNERZORDER = 0x0200,
|
||||||
|
SWP_NOREDRAW = 0x0008,
|
||||||
|
SWP_NOREPOSITION = 0x0200,
|
||||||
|
SWP_NOSENDCHANGING = 0x0400,
|
||||||
|
SWP_NOSIZE = 0x0001,
|
||||||
|
SWP_NOZORDER = 0x0004,
|
||||||
|
SWP_SHOWWINDOW = 0x0040
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,15 +31,9 @@
|
|||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<LinearGradientBrush x:Key="HeaderBrush" StartPoint="0.5,0" EndPoint="0.5,1">
|
|
||||||
<GradientStop Color="Gray" Offset="0"/>
|
|
||||||
<GradientStop Color="Gray" Offset="1"/>
|
|
||||||
<GradientStop Color="#323232" Offset="0.5"/>
|
|
||||||
</LinearGradientBrush>
|
|
||||||
|
|
||||||
<Style x:Key="HeaderStyle" TargetType="DataGridColumnHeader">
|
<Style x:Key="HeaderStyle" TargetType="DataGridColumnHeader">
|
||||||
<Setter Property="Background" Value="{StaticResource HeaderBrush}" />
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
<Setter Property="Foreground" Value="White" />
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
<Setter Property="MinHeight" Value="22" />
|
<Setter Property="MinHeight" Value="22" />
|
||||||
<Setter Property="Cursor" Value="Hand" />
|
<Setter Property="Cursor" Value="Hand" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|||||||
56
src/WPF/MenuHelp.cs
Normal file
56
src/WPF/MenuHelp.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace mpvnet
|
||||||
|
{
|
||||||
|
public class MenuHelp
|
||||||
|
{
|
||||||
|
public static MenuItem Add(ItemCollection items, string path)
|
||||||
|
{
|
||||||
|
string[] a = path.Split(new[] { " > ", " | " }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
ItemCollection itemCollection = items;
|
||||||
|
|
||||||
|
for (int x = 0; x < a.Length; x++)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
foreach (MenuItem i in itemCollection.OfType<MenuItem>())
|
||||||
|
{
|
||||||
|
if (x < a.Length - 1)
|
||||||
|
{
|
||||||
|
if ((string)i.Header == a[x])
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
itemCollection = i.Items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
if (x == a.Length - 1)
|
||||||
|
{
|
||||||
|
if (a[x] == "-")
|
||||||
|
itemCollection.Add(new Separator());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MenuItem item = new MenuItem() { Header = a[x] };
|
||||||
|
itemCollection.Add(item);
|
||||||
|
itemCollection = item.Items;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MenuItem item = new MenuItem() { Header = a[x] };
|
||||||
|
itemCollection.Add(item);
|
||||||
|
itemCollection = item.Items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,22 +2,56 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:hc="clr-namespace:HandyControl.Controls"
|
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||||
|
xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Setter Property="Padding" Value="1"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
|
<Border x:Name="border"
|
||||||
|
CornerRadius="3"
|
||||||
|
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
||||||
|
BorderThickness="1"
|
||||||
|
Background="{DynamicResource BorderBrush}">
|
||||||
|
|
||||||
|
<ContentPresenter HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
TextElement.FontWeight="Normal">
|
||||||
|
</ContentPresenter>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" TargetName="border" Value="{DynamicResource RegionBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter Property="BorderBrush" TargetName="border" Value="#2C628B"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter Property="Opacity" TargetName="border" Value="0.25"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="TextBox">
|
<Style TargetType="TextBox">
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||||
<Border
|
<Border x:Name="border"
|
||||||
x:Name="border"
|
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
Background="{TemplateBinding Background}"
|
Background="{TemplateBinding Background}"
|
||||||
CornerRadius="3"
|
CornerRadius="3"
|
||||||
SnapsToDevicePixels="True">
|
SnapsToDevicePixels="True">
|
||||||
|
|
||||||
<ScrollViewer
|
<ScrollViewer x:Name="PART_ContentHost"
|
||||||
x:Name="PART_ContentHost"
|
|
||||||
Focusable="false"
|
Focusable="false"
|
||||||
HorizontalScrollBarVisibility="Hidden"
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
VerticalScrollBarVisibility="Hidden"/>
|
VerticalScrollBarVisibility="Hidden"/>
|
||||||
@@ -131,6 +165,124 @@
|
|||||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Color x:Key="BorderColor">#e0e0e0</Color>
|
||||||
|
<Color x:Key="RegionColor">#ffffff</Color>
|
||||||
|
<Color x:Key="SecondaryRegionColor">#eeeeee</Color>
|
||||||
|
<Color x:Key="PrimaryTextColor">#212121</Color>
|
||||||
|
<Color x:Key="MenuBorderColor">#212121</Color>
|
||||||
|
<Color x:Key="HighlightColor">#212121</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightPrimaryColor">#f3fbff</Color>
|
||||||
|
<Color x:Key="PrimaryColor">#326cf3</Color>
|
||||||
|
<Color x:Key="DarkPrimaryColor">#326cf3</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightDangerColor">#fff6f7</Color>
|
||||||
|
<Color x:Key="DangerColor">#db3340</Color>
|
||||||
|
<Color x:Key="DarkDangerColor">#db3340</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightWarningColor">#fffcf5</Color>
|
||||||
|
<Color x:Key="WarningColor">#e9af20</Color>
|
||||||
|
<Color x:Key="DarkWarningColor">#e9af20</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightInfoColor">#f1fdff</Color>
|
||||||
|
<Color x:Key="InfoColor">#00bcd4</Color>
|
||||||
|
<Color x:Key="DarkInfoColor">#00bcd4</Color>
|
||||||
|
|
||||||
|
<Color x:Key="LightSuccessColor">#f3fff6</Color>
|
||||||
|
<Color x:Key="SuccessColor">#2db84d</Color>
|
||||||
|
<Color x:Key="DarkSuccessColor">#2db84d</Color>
|
||||||
|
|
||||||
|
<Color x:Key="SecondaryTextColor">#757575</Color>
|
||||||
|
<Color x:Key="ThirdlyTextColor">#bdbdbd</Color>
|
||||||
|
<Color x:Key="ReverseTextColor">#212121</Color>
|
||||||
|
<Color x:Key="TextIconColor">White</Color>
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundColor">#eeeeee</Color>
|
||||||
|
|
||||||
|
<Color x:Key="SecondaryBorderColor">#757575</Color>
|
||||||
|
<Color x:Key="ThirdlyRegionColor">White</Color>
|
||||||
|
<Color x:Key="TitleColor">#326cf3</Color>
|
||||||
|
<Color x:Key="SecondaryTitleColor">#326cf3</Color>
|
||||||
|
|
||||||
|
<Color x:Key="DefaultColor">White</Color>
|
||||||
|
<Color x:Key="DarkDefaultColor">#f5f5f5</Color>
|
||||||
|
|
||||||
|
<Color x:Key="AccentColor">#f8491e</Color>
|
||||||
|
<Color x:Key="DarkAccentColor">#f8491e</Color>
|
||||||
|
|
||||||
|
<Color x:Key="DarkMaskColor">#20000000</Color>
|
||||||
|
<Color x:Key="DarkOpacityColor">#40000000</Color>
|
||||||
|
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="LightPrimaryBrush" Color="{DynamicResource LightPrimaryColor}" />
|
||||||
|
<LinearGradientBrush o:Freeze="True" x:Key="PrimaryBrush" EndPoint="1,0" StartPoint="0,0">
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource PrimaryColor}" Offset="0" />
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource DarkPrimaryColor}" Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="HighlightBrush" Color="{DynamicResource HighlightColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="MenuBorderBrush" Color="{DynamicResource MenuBorderColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkPrimaryBrush" Color="{DynamicResource DarkPrimaryColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="PrimaryTextBrush" Color="{DynamicResource PrimaryTextColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="SecondaryTextBrush" Color="{DynamicResource SecondaryTextColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="ThirdlyTextBrush" Color="{DynamicResource ThirdlyTextColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="ReverseTextBrush" Color="{DynamicResource ReverseTextColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="TextIconBrush" Color="{DynamicResource TextIconColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="BorderBrush" Color="{DynamicResource BorderColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="SecondaryBorderBrush" Color="{DynamicResource SecondaryBorderColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="BackgroundBrush" Color="{DynamicResource BackgroundColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="RegionBrush" Color="{DynamicResource RegionColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="SecondaryRegionBrush" Color="{DynamicResource SecondaryRegionColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="ThirdlyRegionBrush" Color="{DynamicResource ThirdlyRegionColor}" />
|
||||||
|
<LinearGradientBrush o:Freeze="True" x:Key="TitleBrush" EndPoint="1,0" StartPoint="0,0">
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource TitleColor}" Offset="0" />
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource SecondaryTitleColor}" Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DefaultBrush" Color="{DynamicResource DefaultColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkDefaultBrush" Color="{DynamicResource DarkDefaultColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="LightDangerBrush" Color="{DynamicResource LightDangerColor}" />
|
||||||
|
<LinearGradientBrush o:Freeze="True" x:Key="DangerBrush" EndPoint="1,0" StartPoint="0,0">
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource DangerColor}" Offset="0" />
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource DarkDangerColor}" Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkDangerBrush" Color="{DynamicResource DarkDangerColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="LightWarningBrush" Color="{DynamicResource LightWarningColor}" />
|
||||||
|
<LinearGradientBrush o:Freeze="True" x:Key="WarningBrush" EndPoint="1,0" StartPoint="0,0">
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource WarningColor}" Offset="0" />
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource DarkWarningColor}" Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkWarningBrush" Color="{DynamicResource DarkWarningColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="LightInfoBrush" Color="{DynamicResource LightInfoColor}" />
|
||||||
|
<LinearGradientBrush o:Freeze="True" x:Key="InfoBrush" EndPoint="1,0" StartPoint="0,0">
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource InfoColor}" Offset="0" />
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource DarkInfoColor}" Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkInfoBrush" Color="{DynamicResource DarkInfoColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="LightSuccessBrush" Color="{DynamicResource LightSuccessColor}" />
|
||||||
|
<LinearGradientBrush o:Freeze="True" x:Key="SuccessBrush" EndPoint="1,0" StartPoint="0,0">
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource SuccessColor}" Offset="0" />
|
||||||
|
<GradientStop o:Freeze="True" Color="{DynamicResource DarkSuccessColor}" Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkSuccessBrush" Color="{DynamicResource DarkSuccessColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="AccentBrush" Color="{DynamicResource AccentColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkAccentBrush" Color="{DynamicResource DarkAccentColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkMaskBrush" Color="{DynamicResource DarkMaskColor}" />
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="DarkOpacityBrush" Color="{DynamicResource DarkOpacityColor}" />
|
||||||
|
|
||||||
|
<Color x:Key="EffectShadowColor">#88000000</Color>
|
||||||
|
|
||||||
|
<DropShadowEffect x:Key="EffectShadow2" BlurRadius="8" ShadowDepth="1.5" Direction="270" Color="{StaticResource EffectShadowColor}" Opacity=".2" RenderingBias="Performance" o:Freeze="True" />
|
||||||
|
|
||||||
|
<Thickness x:Key="DefaultControlPadding">10,6</Thickness>
|
||||||
|
|
||||||
|
<Geometry o:Freeze="True" x:Key="UpGeometry">M50.000001,0 L100,51.262779 94.262627,57.141584 50.000001,11.767713 5.7373757,57.151686 0,51.27288 z</Geometry>
|
||||||
|
|
||||||
|
<Geometry o:Freeze="True" x:Key="DownGeometry">M512 801.6896L5.12 282.0096l58.1632-59.5968L512 682.3936l448.7168-460.0832 58.1632 59.5968-506.88 519.7824z</Geometry>
|
||||||
|
|
||||||
|
<Geometry o:Freeze="True" x:Key="CheckedGeometry">M 0,2 3,5 8,0</Geometry>
|
||||||
|
|
||||||
|
<Geometry o:Freeze="True" x:Key="LeftGeometry">M394.24 512L683.52 248.32c10.24-10.24 10.24-25.6 0-35.84-10.24-10.24-25.6-10.24-35.84 0l-307.2 279.04c-5.12 5.12-7.68 12.8-7.68 20.48 0 7.68 2.56 15.36 7.68 20.48l307.2 279.04c10.24 10.24 25.6 10.24 35.84 0 10.24-10.24 10.24-25.6 0-35.84L394.24 512z</Geometry>
|
||||||
|
|
||||||
|
<Geometry o:Freeze="True" x:Key="RightGeometry">M4.1666641,0 C5.2083321,0 6.25,0.41666794 7.0833321,1.25 L57.083331,46.666664 C57.916664,47.499998 58.33333,48.749998 58.333329,49.999998 58.33333,51.249997 57.916664,52.499997 57.083331,53.333331 L7.0833321,98.749996 C5.4166641,100.41666 2.9166641,100.41666 1.2499962,98.749996 -0.41666794,97.083328 -0.41666794,94.583328 1.2499962,92.916664 L48.333331,49.999998 1.2499962,7.0833321 C-0.41666794,5.4166641 -0.41666794,2.9166641 1.2499962,1.25 2.0833282,0.41666794 3.1249962,0 4.1666641,0 z</Geometry>
|
||||||
|
|
||||||
<Style x:Key="ScrollBarBaseRepeatButton" TargetType="RepeatButton">
|
<Style x:Key="ScrollBarBaseRepeatButton" TargetType="RepeatButton">
|
||||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
@@ -535,6 +687,81 @@
|
|||||||
|
|
||||||
<Style BasedOn="{StaticResource ScrollViewerBaseStyle}" TargetType="hc:ScrollViewer"/>
|
<Style BasedOn="{StaticResource ScrollViewerBaseStyle}" TargetType="hc:ScrollViewer"/>
|
||||||
|
|
||||||
|
<Style x:Key="BaseStyle" TargetType="Control">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
|
<Setter Property="FontSize" Value="{StaticResource TextFontSize}" />
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ButtonBaseBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="ButtonBase">
|
||||||
|
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
|
||||||
|
<Setter Property="Padding" Value="{StaticResource DefaultControlPadding}" />
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center" />
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="RepeatButtonBaseStyle" BasedOn="{StaticResource ButtonBaseBaseStyle}" TargetType="RepeatButton">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="RepeatButton">
|
||||||
|
<hc:SimplePanel>
|
||||||
|
<Border Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
|
||||||
|
<Path x:Name="PathMain" Width="{TemplateBinding hc:IconElement.Width}" Height="{TemplateBinding hc:IconElement.Height}" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||||
|
<ContentPresenter x:Name="ContentPresenterMain" RecognizesAccessKey="True" VerticalAlignment="Center" Margin="6,0,0,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</hc:SimplePanel>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="Content" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" TargetName="ContentPresenterMain" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="hc:IconElement.Geometry" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" TargetName="PathMain" />
|
||||||
|
<Setter Property="Margin" Value="0" TargetName="ContentPresenterMain" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Opacity" Value=".9" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter Property="Opacity" Value=".6" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter Property="Opacity" Value="0.4" />
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="RepeatButtonIcon" BasedOn="{StaticResource RepeatButtonBaseStyle}" TargetType="RepeatButton">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="RepeatButton">
|
||||||
|
<Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||||
|
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||||
|
<Path Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Width="{TemplateBinding hc:IconElement.Width}" Height="{TemplateBinding hc:IconElement.Height}" Data="{TemplateBinding hc:IconElement.Geometry}" />
|
||||||
|
</ContentControl>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="ScrollViewerUpDownRepeatButtonStyle" BasedOn="{StaticResource RepeatButtonIcon}" TargetType="RepeatButton">
|
<Style x:Key="ScrollViewerUpDownRepeatButtonStyle" BasedOn="{StaticResource RepeatButtonIcon}" TargetType="RepeatButton">
|
||||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||||
<Setter Property="Height" Value="10"/>
|
<Setter Property="Height" Value="10"/>
|
||||||
@@ -543,6 +770,8 @@
|
|||||||
<Setter Property="ClickMode" Value="Hover"/>
|
<Setter Property="ClickMode" Value="Hover"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter"/>
|
||||||
|
|
||||||
<ControlTemplate x:Key="ScrollViewerUpDownControlTemplate" TargetType="ScrollViewer">
|
<ControlTemplate x:Key="ScrollViewerUpDownControlTemplate" TargetType="ScrollViewer">
|
||||||
<Grid x:Name="Grid" Background="{TemplateBinding Background}">
|
<Grid x:Name="Grid" Background="{TemplateBinding Background}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -579,4 +808,232 @@
|
|||||||
<Setter Property="Focusable" Value="False"/>
|
<Setter Property="Focusable" Value="False"/>
|
||||||
<Setter Property="Template" Value="{StaticResource ScrollViewerUpDownControlTemplate}"/>
|
<Setter Property="Template" Value="{StaticResource ScrollViewerUpDownControlTemplate}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ContextMenuBaseStyle" TargetType="ContextMenu">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ContextMenu">
|
||||||
|
<Border Effect="{StaticResource EffectShadow2}" Margin="8" Background="{TemplateBinding Background}" CornerRadius="5" MaxHeight="{TemplateBinding MaxHeight}" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}">
|
||||||
|
<ScrollViewer Style="{StaticResource ScrollViewerUpDown}" Margin="0,6">
|
||||||
|
<ItemsPresenter />
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style BasedOn="{StaticResource ContextMenuBaseStyle}" TargetType="ContextMenu"/>
|
||||||
|
|
||||||
|
<Style x:Key="MenuItemBaseStyle" TargetType="MenuItem">
|
||||||
|
<Setter Property="Padding" Value="10,1,10,1"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="FontSize" Value="14"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="hc:ScrollViewer.PanningMode" Value="Both"/>
|
||||||
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="MenuItem">
|
||||||
|
<Border x:Name="Bd" MinWidth="240" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||||
|
<Grid x:Name="Grid" Margin="{TemplateBinding Padding}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="26"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="30"/>
|
||||||
|
<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="20"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Margin="0,0,10,0" x:Name="Icon" ContentSource="Icon" HorizontalAlignment="Right" Height="16" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" Width="16"/>
|
||||||
|
<Border Margin="0,0,10,0" IsHitTestVisible="False" Grid.Column="0" x:Name="GlyphPanel" CornerRadius="2" Background="{DynamicResource PrimaryBrush}" ClipToBounds="False" HorizontalAlignment="Right" Height="16" Visibility="Hidden" VerticalAlignment="Center" Width="16">
|
||||||
|
<Path UseLayoutRounding="True" Width="12" Height="12" Data="{StaticResource CheckedGeometry}" StrokeThickness="2" Stretch="Uniform" Stroke="{DynamicResource TextIconBrush}"/>
|
||||||
|
</Border>
|
||||||
|
<ContentPresenter Grid.Column="1" x:Name="ContentPresenter" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentSource="Header" Margin="0,3" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
<TextBlock x:Name="InputGestureText" Margin="0,0,10,0" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{TemplateBinding InputGestureText}"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsChecked" Value="True">
|
||||||
|
<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="Icon" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="Role" Value="TopLevelHeader">
|
||||||
|
<Setter Property="Margin" Value="0"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="MenuItem">
|
||||||
|
<Border MinWidth="44" x:Name="templateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||||
|
<Grid VerticalAlignment="Center" Margin="{TemplateBinding Padding}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Margin="0,0,10,0" x:Name="Icon" ContentSource="Icon" HorizontalAlignment="Right" Height="16" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" Width="16"/>
|
||||||
|
<Border Margin="0,0,10,0" Grid.Column="0" x:Name="GlyphPanel" CornerRadius="2" Background="{DynamicResource PrimaryBrush}" ClipToBounds="False" HorizontalAlignment="Right" Height="16" Visibility="Collapsed" VerticalAlignment="Center" Width="16">
|
||||||
|
<Path UseLayoutRounding="True" Width="12" Height="12" Data="{StaticResource CheckedGeometry}" StrokeThickness="2" Stretch="Uniform" Stroke="{DynamicResource TextIconBrush}"/>
|
||||||
|
</Border>
|
||||||
|
<ContentPresenter x:Name="menuHeaderContainer" ContentTemplate="{TemplateBinding HeaderTemplate}" Grid.Column="1" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
<Popup Grid.Column="0" x:Name="PART_Popup" PlacementTarget="{Binding ElementName=templateRoot}" AllowsTransparency="True" Focusable="False" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom">
|
||||||
|
<hc:SimplePanel Effect="{StaticResource EffectShadow2}" Margin="8,0,8,8">
|
||||||
|
<Border CornerRadius="0,0,2,2" x:Name="SubMenuBorder" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource RegionBrush}">
|
||||||
|
<ScrollViewer Style="{StaticResource ScrollViewerUpDown}" Margin="0,6">
|
||||||
|
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle"/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
<Border hc:MenuTopLineAttach.Popup="{Binding ElementName=PART_Popup}" Height="1" Background="{DynamicResource RegionBrush}" VerticalAlignment="Top" BorderThickness="1,0" BorderBrush="{DynamicResource BorderBrush}" HorizontalAlignment="Left"/>
|
||||||
|
</hc:SimplePanel>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="Icon" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsChecked" Value="True">
|
||||||
|
<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
|
||||||
|
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsHighlighted" Value="True">
|
||||||
|
<Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||||
|
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsSubmenuOpen" Value="True">
|
||||||
|
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource BorderBrush}"/>
|
||||||
|
<Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource RegionBrush}"/>
|
||||||
|
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="Role" Value="TopLevelItem">
|
||||||
|
<Setter Property="Margin" Value="0"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="MenuItem">
|
||||||
|
<Border x:Name="templateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||||
|
<Grid Margin="{TemplateBinding Padding}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Margin="0,0,10,0" x:Name="Icon" HorizontalAlignment="Left" ContentSource="Icon" Height="16" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" Width="16"/>
|
||||||
|
<Border Margin="0,0,10,0" IsHitTestVisible="False" Grid.Column="0" x:Name="GlyphPanel" CornerRadius="2" Background="{DynamicResource PrimaryBrush}" ClipToBounds="False" HorizontalAlignment="Right" Height="16" Visibility="Collapsed" VerticalAlignment="Center" Width="16">
|
||||||
|
<Path UseLayoutRounding="True" Width="12" Height="12" Data="{StaticResource CheckedGeometry}" StrokeThickness="2" Stretch="Uniform" Stroke="{DynamicResource TextIconBrush}"/>
|
||||||
|
</Border>
|
||||||
|
<ContentPresenter x:Name="menuHeaderContainer" ContentTemplate="{TemplateBinding HeaderTemplate}" Grid.Column="1" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" HorizontalAlignment="Left" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="Icon" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsChecked" Value="True">
|
||||||
|
<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
|
||||||
|
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsHighlighted" Value="True">
|
||||||
|
<Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||||
|
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsSubmenuOpen" Value="True">
|
||||||
|
<Setter Property="Background" TargetName="templateRoot" Value="White"/>
|
||||||
|
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<MultiTrigger>
|
||||||
|
<MultiTrigger.Conditions>
|
||||||
|
<Condition Property="IsHighlighted" Value="True"/>
|
||||||
|
<Condition Property="IsEnabled" Value="False"/>
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
<Setter Property="Background" TargetName="templateRoot" Value="#0A000000"/>
|
||||||
|
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#21000000"/>
|
||||||
|
</MultiTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="Role" Value="SubmenuHeader">
|
||||||
|
<Setter Property="DockPanel.Dock" Value="Top"/>
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="MenuItem">
|
||||||
|
<Border x:Name="Bd" MinWidth="240" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||||
|
<Grid x:Name="Grid" Margin="{TemplateBinding Padding}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="26"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="30"/>
|
||||||
|
<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="20"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Margin="0,0,10,0" x:Name="Icon" ContentSource="Icon" HorizontalAlignment="Right" Height="16" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" Width="16"/>
|
||||||
|
<Border Margin="0,0,10,0" IsHitTestVisible="False" Grid.Column="0" x:Name="GlyphPanel" CornerRadius="2" Background="{DynamicResource PrimaryBrush}" ClipToBounds="False" HorizontalAlignment="Right" Height="16" Visibility="Hidden" VerticalAlignment="Center" Width="16">
|
||||||
|
<Path UseLayoutRounding="True" Width="12" Height="12" Data="{StaticResource CheckedGeometry}" StrokeThickness="2" Stretch="Uniform" Stroke="{DynamicResource TextIconBrush}"/>
|
||||||
|
</Border>
|
||||||
|
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,3" x:Name="ContentPresenter" ContentTemplate="{TemplateBinding HeaderTemplate}" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
<Path x:Name="Path" Grid.Column="4" Width="10" Height="10" HorizontalAlignment="Left" Data="{StaticResource RightGeometry}" Stretch="Uniform" Fill="{TemplateBinding Foreground}" VerticalAlignment="Center"/>
|
||||||
|
<Popup Grid.Column="1" x:Name="PART_Popup" AllowsTransparency="True" Focusable="False" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" VerticalOffset="-13" HorizontalOffset="10">
|
||||||
|
<Border Margin="8" CornerRadius="5" x:Name="SubMenuBorder" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource RegionBrush}">
|
||||||
|
<ScrollViewer Style="{StaticResource ScrollViewerUpDown}" Margin="0,6">
|
||||||
|
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle"/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsChecked" Value="True">
|
||||||
|
<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsHighlighted" Value="True">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter Property="Opacity" Value=".4"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="MenuBaseStyle" TargetType="Menu">
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||||
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||||
|
<Setter Property="FontSize" Value="12"/>
|
||||||
|
<Setter Property="FontStyle" Value="Normal"/>
|
||||||
|
<Setter Property="FontWeight" Value="Normal"/>
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Menu">
|
||||||
|
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
|
||||||
|
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style BasedOn="{StaticResource MenuItemBaseStyle}" TargetType="MenuItem"/>
|
||||||
|
|
||||||
|
<Style BasedOn="{StaticResource MenuBaseStyle}" TargetType="Menu"/>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -13,60 +13,121 @@
|
|||||||
Background="{Binding Theme.Background}"
|
Background="{Binding Theme.Background}"
|
||||||
SizeToContent="WidthAndHeight"
|
SizeToContent="WidthAndHeight"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
|
ResizeMode="NoResize"
|
||||||
>
|
>
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Style TargetType="Button">
|
|
||||||
<Setter Property="Margin" Value="3"></Setter>
|
|
||||||
<Setter Property="Height" Value="25"></Setter>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style TargetType="TextBlock">
|
|
||||||
<Setter Property="FontSize" Value="14"></Setter>
|
|
||||||
<Setter Property="Margin" Value="3,0,0,0"></Setter>
|
|
||||||
<Setter Property="TextAlignment" Value="Center"></Setter>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<ControlTemplate x:Key="ShieldButtonTemplate" TargetType="Button">
|
<ControlTemplate x:Key="ShieldButtonTemplate" TargetType="Button">
|
||||||
<Button Margin="0" HorizontalContentAlignment="Stretch">
|
<Border x:Name="border"
|
||||||
|
CornerRadius="3"
|
||||||
|
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
||||||
|
BorderThickness="1"
|
||||||
|
Background="{DynamicResource BorderBrush}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Image Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
|
||||||
<ColumnDefinition Width="Auto" />
|
HorizontalAlignment="Left"
|
||||||
<ColumnDefinition Width="*" />
|
Margin="9,0,0,0"
|
||||||
</Grid.ColumnDefinitions>
|
Width="20"
|
||||||
<Image
|
Height="20" />
|
||||||
Grid.Column="0"
|
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
|
|
||||||
Width="18"
|
|
||||||
Height="18"
|
|
||||||
Margin="3,0,0,0"
|
|
||||||
/>
|
|
||||||
<ContentPresenter Grid.Column="1" HorizontalAlignment="Center" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Button>
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" TargetName="border" Value="{DynamicResource RegionBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter Property="BorderBrush" TargetName="border" Value="#2C628B"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter Property="Opacity" TargetName="border" Value="0.25"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<StackPanel Width="180" Margin="5">
|
<StackPanel Width="140" Margin="25,5,5,5">
|
||||||
<TextBlock>Start Menu Shortcut</TextBlock>
|
<Border Height="50">
|
||||||
<Button Name="AddStartMenuShortcut" Click="AddStartMenuShortcut_Click">Add</Button>
|
<TextBlock TextWrapping="Wrap"
|
||||||
<Button Name="RemoveStartMenuShortcut" Click="RemoveStartMenuShortcut_Click">Remove</Button>
|
TextAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
>Start Menu Shortcut</TextBlock>
|
||||||
|
</Border>
|
||||||
|
<Button Name="AddStartMenuShortcut"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="AddStartMenuShortcut_Click"
|
||||||
|
>Add</Button>
|
||||||
|
<Button Name="RemoveStartMenuShortcut"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="RemoveStartMenuShortcut_Click"
|
||||||
|
>Remove</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Width="180" Margin="20,5,5,5">
|
<StackPanel Width="140" Margin="20,5,5,25">
|
||||||
<TextBlock>File Extensions</TextBlock>
|
<Border Height="50">
|
||||||
<Button Name="AddVideo" Click="AddVideo_Click" Template="{StaticResource ShieldButtonTemplate}">Add Video</Button>
|
<TextBlock TextWrapping="Wrap"
|
||||||
<Button Name="AddAudio" Click="AddAudio_Click" Template="{StaticResource ShieldButtonTemplate}">Add Audio</Button>
|
TextAlignment="Center"
|
||||||
<Button Name="AddImage" Click="AddImage_Click" Template="{StaticResource ShieldButtonTemplate}">Add Image</Button>
|
VerticalAlignment="Center"
|
||||||
<Button Name="RemoveFileAssociations" Margin="3,15,3,3" Click="RemoveFileAssociations_Click" Template="{StaticResource ShieldButtonTemplate}">Remove All</Button>
|
FontSize="14"
|
||||||
<Button Name="EditDefaultApp" Click="EditDefaultApp_Click">Edit Default App</Button>
|
>File Extensions</TextBlock>
|
||||||
|
</Border>
|
||||||
|
<Button Name="AddVideo"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="AddVideo_Click"
|
||||||
|
Template="{StaticResource ShieldButtonTemplate}"
|
||||||
|
>Add Video</Button>
|
||||||
|
<Button Name="AddAudio"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="AddAudio_Click"
|
||||||
|
Template="{StaticResource ShieldButtonTemplate}"
|
||||||
|
>Add Audio</Button>
|
||||||
|
<Button Name="AddImage"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="AddImage_Click"
|
||||||
|
Template="{StaticResource ShieldButtonTemplate}"
|
||||||
|
>Add Image</Button>
|
||||||
|
<Button Name="RemoveFileAssociations"
|
||||||
|
Margin="3,15,3,3"
|
||||||
|
Height="30"
|
||||||
|
Click="RemoveFileAssociations_Click"
|
||||||
|
Template="{StaticResource ShieldButtonTemplate}"
|
||||||
|
>Remove All</Button>
|
||||||
|
<Button Name="EditDefaultApp"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="EditDefaultApp_Click"
|
||||||
|
>Edit Default App</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Width="180" Margin="20,5,5,5">
|
<StackPanel Width="140" Margin="20,5,25,5">
|
||||||
<TextBlock>Path Environment Variable</TextBlock>
|
<Border Height="50">
|
||||||
<Button Name="AddToPathEnvVar" Click="AddToPathEnvVar_Click">Add</Button>
|
<TextBlock TextWrapping="Wrap"
|
||||||
<Button Name="RemoveFromPathEnvVar" Click="RemoveFromPathEnvVar_Click">Remove</Button>
|
TextAlignment="Center"
|
||||||
<Button Name="ShowEnvVarEditor" Click="ShowEnvVarEditor_Click">Show Editor</Button>
|
VerticalAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
>Path Environment Variable</TextBlock>
|
||||||
|
</Border>
|
||||||
|
<Button Name="AddToPathEnvVar"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="AddToPathEnvVar_Click"
|
||||||
|
>Add</Button>
|
||||||
|
<Button Name="RemoveFromPathEnvVar"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="RemoveFromPathEnvVar_Click"
|
||||||
|
>Remove</Button>
|
||||||
|
<Button Name="ShowEnvVarEditor"
|
||||||
|
Height="30"
|
||||||
|
Margin="3"
|
||||||
|
Click="ShowEnvVarEditor_Click"
|
||||||
|
>Show Editor</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -30,7 +30,8 @@
|
|||||||
x:Name="ValueTextBox"
|
x:Name="ValueTextBox"
|
||||||
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
Width="150"
|
Width="150"
|
||||||
Height="20"
|
FontSize="13"
|
||||||
|
Padding="2"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Foreground="{Binding Theme.Foreground}"
|
Foreground="{Binding Theme.Foreground}"
|
||||||
Background="{Binding Theme.Background}"
|
Background="{Binding Theme.Background}"
|
||||||
@@ -40,18 +41,12 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
x:Name="Button"
|
x:Name="Button"
|
||||||
Height="20"
|
Width="25"
|
||||||
|
Height="25"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="5,0,0,0"
|
Margin="5,0,0,0"
|
||||||
Width="20"
|
|
||||||
Click="Button_Click"
|
Click="Button_Click"
|
||||||
>...
|
>...
|
||||||
|
|
||||||
<Button.Resources>
|
|
||||||
<Style TargetType="Border">
|
|
||||||
<Setter Property="CornerRadius" Value="3"/>
|
|
||||||
</Style>
|
|
||||||
</Button.Resources>
|
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
@@ -1,398 +0,0 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Drawing.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
public class ContextMenuStripEx : ContextMenuStrip
|
|
||||||
{
|
|
||||||
public ContextMenuStripEx()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContextMenuStripEx(IContainer container) : base(container)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHandleCreated(EventArgs e)
|
|
||||||
{
|
|
||||||
base.OnHandleCreated(e);
|
|
||||||
Renderer = new ToolStripRendererEx();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuItem Add(string path)
|
|
||||||
{
|
|
||||||
return Add(path, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuItem Add(string path, Action action, bool enabled = true)
|
|
||||||
{
|
|
||||||
MenuItem ret = MenuItem.Add(Items, path, action);
|
|
||||||
if (ret == null) return null;
|
|
||||||
ret.Enabled = enabled;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MenuItem : ToolStripMenuItem
|
|
||||||
{
|
|
||||||
public Action Action { get; set; }
|
|
||||||
|
|
||||||
public MenuItem()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuItem(string text) : base(text)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuItem(string text, Action action) : base(text)
|
|
||||||
{
|
|
||||||
Action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnClick(EventArgs e)
|
|
||||||
{
|
|
||||||
Application.DoEvents();
|
|
||||||
Action?.Invoke();
|
|
||||||
base.OnClick(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MenuItem Add(ToolStripItemCollection items, string path, Action action)
|
|
||||||
{
|
|
||||||
string[] a = path.Split(new[] { " > ", " | " }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
var itemsCollection = items;
|
|
||||||
|
|
||||||
for (int x = 0; x < a.Length; x++)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
foreach (var i in itemsCollection.OfType<ToolStripMenuItem>())
|
|
||||||
{
|
|
||||||
if (x < a.Length - 1)
|
|
||||||
{
|
|
||||||
if (i.Text == a[x] + " ")
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
itemsCollection = i.DropDownItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
if (x == a.Length - 1)
|
|
||||||
{
|
|
||||||
if (a[x] == "-")
|
|
||||||
itemsCollection.Add(new ToolStripSeparator());
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MenuItem item = new MenuItem(a[x] + " ", action);
|
|
||||||
itemsCollection.Add(item);
|
|
||||||
itemsCollection = item.DropDownItems;
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MenuItem item = new MenuItem();
|
|
||||||
item.Text = a[x] + " ";
|
|
||||||
itemsCollection.Add(item);
|
|
||||||
itemsCollection = item.DropDownItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Size GetPreferredSize(Size constrainingSize)
|
|
||||||
{
|
|
||||||
Size size = base.GetPreferredSize(constrainingSize);
|
|
||||||
size.Height = Convert.ToInt32(Font.Height * 1.4);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CloseAll(object item)
|
|
||||||
{
|
|
||||||
if (item is ToolStripItem)
|
|
||||||
CloseAll(((ToolStripItem)item).Owner);
|
|
||||||
|
|
||||||
if (item is ToolStripDropDown)
|
|
||||||
{
|
|
||||||
var d = (ToolStripDropDown)item;
|
|
||||||
d.Close();
|
|
||||||
CloseAll(d.OwnerItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ToolStripRendererEx : ToolStripSystemRenderer
|
|
||||||
{
|
|
||||||
public static Color ForegroundColor { get; set; }
|
|
||||||
public static Color BackgroundColor { get; set; }
|
|
||||||
public static Color SelectionColor { get; set; }
|
|
||||||
public static Color CheckedColor { get; set; }
|
|
||||||
public static Color BorderColor { get; set; }
|
|
||||||
|
|
||||||
int TextOffset;
|
|
||||||
|
|
||||||
public static void SetDefaultColors()
|
|
||||||
{
|
|
||||||
ForegroundColor = Color.FromArgb(unchecked((int)0xFF000000));
|
|
||||||
BackgroundColor = Color.FromArgb(unchecked((int)0xFFDFDFDF));
|
|
||||||
SelectionColor = Color.FromArgb(unchecked((int)0xFFBFBFBF));
|
|
||||||
CheckedColor = Color.FromArgb(unchecked((int)0xFFAAAAAA));
|
|
||||||
BorderColor = Color.FromArgb(unchecked((int)0xFF6A6A6A));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
|
|
||||||
{
|
|
||||||
Rectangle r = e.AffectedBounds;
|
|
||||||
r.Inflate(-1, -1);
|
|
||||||
ControlPaint.DrawBorder(e.Graphics, r, BackgroundColor, ButtonBorderStyle.Solid);
|
|
||||||
ControlPaint.DrawBorder(e.Graphics, e.AffectedBounds, BorderColor, ButtonBorderStyle.Solid);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Item is ToolStripMenuItem && !(e.Item.Owner is MenuStrip))
|
|
||||||
{
|
|
||||||
Rectangle rect = e.TextRectangle;
|
|
||||||
var dropDown = e.ToolStrip as ToolStripDropDownMenu;
|
|
||||||
|
|
||||||
if (dropDown == null || dropDown.ShowImageMargin || dropDown.ShowCheckMargin)
|
|
||||||
TextOffset = Convert.ToInt32(e.Item.Height * 1.1);
|
|
||||||
else
|
|
||||||
TextOffset = Convert.ToInt32(e.Item.Height * 0.2);
|
|
||||||
|
|
||||||
e.TextColor = ForegroundColor;
|
|
||||||
e.TextRectangle = new Rectangle(TextOffset, Convert.ToInt32((e.Item.Height - rect.Height) / 2.0), rect.Width, rect.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnRenderItemText(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
|
|
||||||
{
|
|
||||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
|
||||||
|
|
||||||
if (!(e.Item.Owner is MenuStrip))
|
|
||||||
e.Graphics.Clear(BackgroundColor);
|
|
||||||
|
|
||||||
if (e.Item.Selected && e.Item.Enabled)
|
|
||||||
{
|
|
||||||
rect = new Rectangle(rect.X + 2, rect.Y, rect.Width - 4, rect.Height - 1);
|
|
||||||
rect.Inflate(-1, -1);
|
|
||||||
|
|
||||||
using (SolidBrush b = new SolidBrush(SelectionColor))
|
|
||||||
e.Graphics.FillRectangle(b, rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Direction == ArrowDirection.Down)
|
|
||||||
throw new NotImplementedException();
|
|
||||||
|
|
||||||
float x1 = e.Item.Width - e.Item.Height * 0.6f;
|
|
||||||
float y1 = e.Item.Height * 0.25f;
|
|
||||||
float x2 = x1 + e.Item.Height * 0.25f;
|
|
||||||
float y2 = e.Item.Height / 2f;
|
|
||||||
float x3 = x1;
|
|
||||||
float y3 = e.Item.Height * 0.75f;
|
|
||||||
|
|
||||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
||||||
|
|
||||||
using (Brush brush = new SolidBrush(ForegroundColor))
|
|
||||||
{
|
|
||||||
using (Pen pen = new Pen(brush, Control.DefaultFont.Height / 20f))
|
|
||||||
{
|
|
||||||
e.Graphics.DrawLine(pen, x1, y1, x2, y2);
|
|
||||||
e.Graphics.DrawLine(pen, x2, y2, x3, y3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Item.GetType() != typeof(MenuItem))
|
|
||||||
return;
|
|
||||||
|
|
||||||
MenuItem item = e.Item as MenuItem;
|
|
||||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
||||||
|
|
||||||
if (!item.Checked)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
|
||||||
rect = new Rectangle(rect.X + 2, rect.Y, rect.Height - 1, rect.Height - 1);
|
|
||||||
rect.Inflate(-1, -1);
|
|
||||||
|
|
||||||
using (Brush brush = new SolidBrush(CheckedColor))
|
|
||||||
e.Graphics.FillRectangle(brush, rect);
|
|
||||||
|
|
||||||
float ellipseWidth = rect.Height / 3f;
|
|
||||||
|
|
||||||
RectangleF rectF = new RectangleF(rect.X + rect.Height / 2f - ellipseWidth / 2f,
|
|
||||||
rect.Y + rect.Height / 2f - ellipseWidth / 2f,
|
|
||||||
ellipseWidth, ellipseWidth);
|
|
||||||
|
|
||||||
using (Brush brush = new SolidBrush(ForegroundColor))
|
|
||||||
e.Graphics.FillEllipse(brush, rectF);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
|
|
||||||
{
|
|
||||||
e.Graphics.Clear(BackgroundColor);
|
|
||||||
int top = e.Item.Height / 2;
|
|
||||||
top -= 1;
|
|
||||||
int offset = Convert.ToInt32(e.Item.Font.Height * 0.7);
|
|
||||||
|
|
||||||
using (Pen p = new Pen(BorderColor))
|
|
||||||
e.Graphics.DrawLine(p,
|
|
||||||
new Point(offset, top),
|
|
||||||
new Point(e.Item.Width - offset, top));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct HSLColor
|
|
||||||
{
|
|
||||||
public HSLColor(Color color) : this()
|
|
||||||
{
|
|
||||||
SetRGB(color.R, color.G, color.B);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HSLColor(int h, int s, int l) : this()
|
|
||||||
{
|
|
||||||
Hue = h;
|
|
||||||
Saturation = s;
|
|
||||||
Luminosity = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
double _Hue;
|
|
||||||
|
|
||||||
public int Hue {
|
|
||||||
get => System.Convert.ToInt32(_Hue * 240);
|
|
||||||
set => _Hue = CheckRange(value / 240.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
double _Saturation;
|
|
||||||
|
|
||||||
public int Saturation {
|
|
||||||
get => System.Convert.ToInt32(_Saturation * 240);
|
|
||||||
set => _Saturation = CheckRange(value / 240.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
double _Luminosity;
|
|
||||||
|
|
||||||
public int Luminosity {
|
|
||||||
get => System.Convert.ToInt32(_Luminosity * 240);
|
|
||||||
set => _Luminosity = CheckRange(value / 240.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
double CheckRange(double value)
|
|
||||||
{
|
|
||||||
if (value < 0)
|
|
||||||
value = 0;
|
|
||||||
else if (value > 1)
|
|
||||||
value = 1;
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color ToColorAddLuminosity(int luminosity)
|
|
||||||
{
|
|
||||||
Luminosity += luminosity;
|
|
||||||
return ToColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color ToColorSetLuminosity(int luminosity)
|
|
||||||
{
|
|
||||||
Luminosity = luminosity;
|
|
||||||
return ToColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color ToColor()
|
|
||||||
{
|
|
||||||
double r = 0, g = 0, b = 0;
|
|
||||||
|
|
||||||
if (_Luminosity != 0)
|
|
||||||
{
|
|
||||||
if (_Saturation == 0)
|
|
||||||
{
|
|
||||||
b = _Luminosity;
|
|
||||||
g = _Luminosity;
|
|
||||||
r = _Luminosity;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double temp2 = GetTemp2(this);
|
|
||||||
double temp1 = 2.0 * _Luminosity - temp2;
|
|
||||||
r = GetColorComponent(temp1, temp2, _Hue + 1.0 / 3.0);
|
|
||||||
g = GetColorComponent(temp1, temp2, _Hue);
|
|
||||||
b = GetColorComponent(temp1, temp2, _Hue - 1.0 / 3.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Color.FromArgb(
|
|
||||||
System.Convert.ToInt32(255 * r),
|
|
||||||
System.Convert.ToInt32(255 * g),
|
|
||||||
System.Convert.ToInt32(255 * b));
|
|
||||||
}
|
|
||||||
|
|
||||||
static double GetColorComponent(double temp1, double temp2, double temp3)
|
|
||||||
{
|
|
||||||
temp3 = MoveIntoRange(temp3);
|
|
||||||
|
|
||||||
if (temp3 < 1 / 6.0)
|
|
||||||
return temp1 + (temp2 - temp1) * 6.0 * temp3;
|
|
||||||
else if (temp3 < 0.5)
|
|
||||||
return temp2;
|
|
||||||
else if (temp3 < 2 / 3.0)
|
|
||||||
return temp1 + ((temp2 - temp1) * (2 / 3.0 - temp3) * 6);
|
|
||||||
else
|
|
||||||
return temp1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double MoveIntoRange(double temp3)
|
|
||||||
{
|
|
||||||
if (temp3 < 0)
|
|
||||||
temp3++;
|
|
||||||
else if (temp3 > 1)
|
|
||||||
temp3--;
|
|
||||||
|
|
||||||
return temp3;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double GetTemp2(HSLColor hslColor)
|
|
||||||
{
|
|
||||||
double temp2;
|
|
||||||
|
|
||||||
if (hslColor._Luminosity < 0.5)
|
|
||||||
temp2 = hslColor._Luminosity * (1.0 + hslColor._Saturation);
|
|
||||||
else
|
|
||||||
temp2 = hslColor._Luminosity + hslColor._Saturation - (hslColor._Luminosity * hslColor._Saturation);
|
|
||||||
|
|
||||||
return temp2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HSLColor Convert(Color c)
|
|
||||||
{
|
|
||||||
HSLColor r = new HSLColor();
|
|
||||||
r._Hue = c.GetHue() / 360.0;
|
|
||||||
r._Luminosity = c.GetBrightness();
|
|
||||||
r._Saturation = c.GetSaturation();
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRGB(int red, int green, int blue)
|
|
||||||
{
|
|
||||||
HSLColor hc = Convert(Color.FromArgb(red, green, blue));
|
|
||||||
_Hue = hc._Hue;
|
|
||||||
_Saturation = hc._Saturation;
|
|
||||||
_Luminosity = hc._Luminosity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -80,6 +80,18 @@
|
|||||||
<Compile Include="Misc\App.cs" />
|
<Compile Include="Misc\App.cs" />
|
||||||
<Compile Include="Misc\Common.cs" />
|
<Compile Include="Misc\Common.cs" />
|
||||||
<Compile Include="Misc\JSONParser.cs" />
|
<Compile Include="Misc\JSONParser.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Controls\Attach\BorderElement.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Controls\Attach\MenuTopLineAttach.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Converter\BorderCircularConverter.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Helper\ScreenHelper.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Helper\VisualHelper.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Interop\Handle\BitmapHandle.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Interop\Handle\CommonHandles.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Interop\Handle\HandleCollector.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Interop\Handle\WpfSafeHandle.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Interop\InteropMethods.cs" />
|
||||||
|
<Compile Include="WPF\HandyControl\Tools\Interop\InteropValues.cs" />
|
||||||
|
<Compile Include="WPF\MenuHelp.cs" />
|
||||||
<Compile Include="WPF\HandyControl\Controls\Attach\IconElement.cs" />
|
<Compile Include="WPF\HandyControl\Controls\Attach\IconElement.cs" />
|
||||||
<Compile Include="WPF\HandyControl\Controls\Attach\ScrollViewerAttach.cs" />
|
<Compile Include="WPF\HandyControl\Controls\Attach\ScrollViewerAttach.cs" />
|
||||||
<Compile Include="WPF\HandyControl\Controls\ScrollViewer.cs" />
|
<Compile Include="WPF\HandyControl\Controls\ScrollViewer.cs" />
|
||||||
@@ -97,6 +109,7 @@
|
|||||||
<None Include="..\docs\Manual.md">
|
<None Include="..\docs\Manual.md">
|
||||||
<Link>Manual.md</Link>
|
<Link>Manual.md</Link>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include=".editorconfig" />
|
||||||
<None Include="Resources\mpvnet-santa.png" />
|
<None Include="Resources\mpvnet-santa.png" />
|
||||||
<None Include="Resources\editor_conf.txt" />
|
<None Include="Resources\editor_conf.txt" />
|
||||||
<Content Include="Resources\theme.txt" />
|
<Content Include="Resources\theme.txt" />
|
||||||
@@ -104,10 +117,6 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="WPF\HandyControl\Theme\Theme.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Include="WPF\SearchTextBoxUserControl.xaml">
|
<Page Include="WPF\SearchTextBoxUserControl.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -150,19 +159,16 @@
|
|||||||
<Compile Include="Misc\ExtensionMethods.cs" />
|
<Compile Include="Misc\ExtensionMethods.cs" />
|
||||||
<Compile Include="Native\MediaInfo.cs" />
|
<Compile Include="Native\MediaInfo.cs" />
|
||||||
<Compile Include="Native\Taskbar.cs" />
|
<Compile Include="Native\Taskbar.cs" />
|
||||||
<Compile Include="WinForms\Menu.cs">
|
|
||||||
<SubType>Component</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Native\libmpv.cs" />
|
<Compile Include="Native\libmpv.cs" />
|
||||||
<Compile Include="WinForms\MainForm.cs">
|
<Compile Include="Misc\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="WinForms\MainForm.Designer.cs">
|
<Compile Include="Misc\MainForm.Designer.cs">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Misc\Misc.cs" />
|
<Compile Include="Misc\Misc.cs" />
|
||||||
@@ -187,7 +193,7 @@
|
|||||||
<DependentUpon>InputWindow.xaml</DependentUpon>
|
<DependentUpon>InputWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="WPF\WPF.cs" />
|
<Compile Include="WPF\WPF.cs" />
|
||||||
<EmbeddedResource Include="WinForms\MainForm.resx">
|
<EmbeddedResource Include="Misc\MainForm.resx">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net.csproj",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingExtension", "extensions\RatingExtension\RatingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingExtension", "extensions\RatingExtension\RatingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{464E3334-1CF4-403B-92B3-06799AC5C60F}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.editorconfig = .editorconfig
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|||||||
Reference in New Issue
Block a user