mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-26 10:00:49 +12:00
parent
24c370b738
commit
814908fdfe
16
Config.cs
16
Config.cs
|
@ -10,13 +10,7 @@ namespace SystemTrayMenu
|
|||
{
|
||||
public const string Language = "en";
|
||||
|
||||
public static string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
return Properties.Settings.Default.PathDirectory;
|
||||
}
|
||||
}
|
||||
public static string Path => Properties.Settings.Default.PathDirectory;
|
||||
|
||||
public static void UpgradeIfNotUpgraded()
|
||||
{
|
||||
|
@ -51,9 +45,11 @@ namespace SystemTrayMenu
|
|||
{
|
||||
bool pathOK = false;
|
||||
bool userAborted = false;
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
|
||||
dialog.InitialDirectory = Path;
|
||||
dialog.IsFolderPicker = true;
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog
|
||||
{
|
||||
InitialDirectory = Path,
|
||||
IsFolderPicker = true
|
||||
};
|
||||
do
|
||||
{
|
||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
|
|
|
@ -46,14 +46,8 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public Assembly AppEntryAssembly
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EntryAssembly;
|
||||
}
|
||||
set
|
||||
{
|
||||
_EntryAssembly = value;
|
||||
}
|
||||
get => _EntryAssembly;
|
||||
set => _EntryAssembly = value;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
|
@ -65,14 +59,8 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public string AppTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppTitleLabel.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppTitleLabel.Text = value;
|
||||
}
|
||||
get => AppTitleLabel.Text;
|
||||
set => AppTitleLabel.Text = value;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
|
@ -84,10 +72,7 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public string AppDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppDescriptionLabel.Text;
|
||||
}
|
||||
get => AppDescriptionLabel.Text;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
@ -111,10 +96,7 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public string AppVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppVersionLabel.Text;
|
||||
}
|
||||
get => AppVersionLabel.Text;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
@ -139,10 +121,7 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public string AppCopyright
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppCopyrightLabel.Text;
|
||||
}
|
||||
get => AppCopyrightLabel.Text;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
@ -165,14 +144,8 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public Image AppImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return ImagePictureBox.Image;
|
||||
}
|
||||
set
|
||||
{
|
||||
ImagePictureBox.Image = value;
|
||||
}
|
||||
get => ImagePictureBox.Image;
|
||||
set => ImagePictureBox.Image = value;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
|
@ -186,10 +159,7 @@ namespace SystemTrayMenu.Controls
|
|||
// </remarks>
|
||||
public string AppMoreInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return MoreRichTextBox.Text;
|
||||
}
|
||||
get => MoreRichTextBox.Text;
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
@ -209,14 +179,8 @@ namespace SystemTrayMenu.Controls
|
|||
// </summary>
|
||||
public bool AppDetailsButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return buttonDetails.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
buttonDetails.Visible = value;
|
||||
}
|
||||
get => buttonDetails.Visible;
|
||||
set => buttonDetails.Visible = value;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
|
@ -474,8 +438,10 @@ namespace SystemTrayMenu.Controls
|
|||
{
|
||||
if (!string.IsNullOrEmpty(Value))
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem();
|
||||
lvi.Text = Key;
|
||||
ListViewItem lvi = new ListViewItem
|
||||
{
|
||||
Text = Key
|
||||
};
|
||||
lvi.SubItems.Add(Value);
|
||||
lvw.Items.Add(lvi);
|
||||
}
|
||||
|
@ -523,9 +489,11 @@ namespace SystemTrayMenu.Controls
|
|||
|
||||
string strAssemblyName = a.GetName().Name;
|
||||
|
||||
ListViewItem lvi = new ListViewItem();
|
||||
lvi.Text = strAssemblyName;
|
||||
lvi.Tag = strAssemblyName;
|
||||
ListViewItem lvi = new ListViewItem
|
||||
{
|
||||
Text = strAssemblyName,
|
||||
Tag = strAssemblyName
|
||||
};
|
||||
if (strAssemblyName == _CallingAssemblyName)
|
||||
{
|
||||
lvi.Text += " (calling)";
|
||||
|
|
|
@ -21,10 +21,14 @@ namespace SystemTrayMenu.Controls
|
|||
|
||||
public ContextMenuStrip Create()
|
||||
{
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
menu.BackColor = SystemColors.Control;
|
||||
ToolStripMenuItem changeFolder = new ToolStripMenuItem();
|
||||
changeFolder.Text = Language.Translate("Folder");
|
||||
ContextMenuStrip menu = new ContextMenuStrip
|
||||
{
|
||||
BackColor = SystemColors.Control
|
||||
};
|
||||
ToolStripMenuItem changeFolder = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.Translate("Folder")
|
||||
};
|
||||
changeFolder.Click += ChangeFolder_Click;
|
||||
void ChangeFolder_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -64,8 +68,10 @@ namespace SystemTrayMenu.Controls
|
|||
}
|
||||
menu.Items.Add(changeLanguage);
|
||||
|
||||
ToolStripMenuItem autostart = new ToolStripMenuItem();
|
||||
autostart.Text = Language.Translate("Autostart");
|
||||
ToolStripMenuItem autostart = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.Translate("Autostart")
|
||||
};
|
||||
//autostart.Image.HorizontalResolution.wi.c.sc.Select .ImageScaling = ToolStripItemImageScaling.None;
|
||||
if (Properties.Settings.Default.IsAutostartActivated)
|
||||
{
|
||||
|
@ -137,12 +143,16 @@ namespace SystemTrayMenu.Controls
|
|||
}
|
||||
menu.Items.Add(hotKey);
|
||||
|
||||
ToolStripSeparator seperator = new ToolStripSeparator();
|
||||
seperator.BackColor = SystemColors.Control;
|
||||
ToolStripSeparator seperator = new ToolStripSeparator
|
||||
{
|
||||
BackColor = SystemColors.Control
|
||||
};
|
||||
menu.Items.Add(seperator);
|
||||
|
||||
ToolStripMenuItem openLog = new ToolStripMenuItem();
|
||||
openLog.Text = Language.Translate("Log File");
|
||||
ToolStripMenuItem openLog = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.Translate("Log File")
|
||||
};
|
||||
openLog.Click += OpenLog_Click;
|
||||
void OpenLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -152,19 +162,23 @@ namespace SystemTrayMenu.Controls
|
|||
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
ToolStripMenuItem about = new ToolStripMenuItem();
|
||||
about.Text = Language.Translate("About");
|
||||
ToolStripMenuItem about = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.Translate("About")
|
||||
};
|
||||
about.Click += About_Click;
|
||||
void About_Click(object sender, EventArgs e)
|
||||
{
|
||||
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(
|
||||
Assembly.GetEntryAssembly().Location);
|
||||
AboutBox ab = new AboutBox();
|
||||
ab.AppTitle = versionInfo.ProductName;
|
||||
ab.AppDescription = versionInfo.FileDescription;
|
||||
ab.AppVersion = $"Version {versionInfo.FileVersion}";
|
||||
ab.AppCopyright = versionInfo.LegalCopyright;
|
||||
ab.AppMoreInfo = versionInfo.LegalCopyright;
|
||||
AboutBox ab = new AboutBox
|
||||
{
|
||||
AppTitle = versionInfo.ProductName,
|
||||
AppDescription = versionInfo.FileDescription,
|
||||
AppVersion = $"Version {versionInfo.FileVersion}",
|
||||
AppCopyright = versionInfo.LegalCopyright,
|
||||
AppMoreInfo = versionInfo.LegalCopyright
|
||||
};
|
||||
ab.AppMoreInfo += Environment.NewLine;
|
||||
ab.AppMoreInfo += "Markus Hofknecht (mailto:Markus@Hofknecht.eu)";
|
||||
ab.AppMoreInfo += Environment.NewLine;
|
||||
|
@ -184,8 +198,10 @@ namespace SystemTrayMenu.Controls
|
|||
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
ToolStripMenuItem restart = new ToolStripMenuItem();
|
||||
restart.Text = Language.Translate("Restart");
|
||||
ToolStripMenuItem restart = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.Translate("Restart")
|
||||
};
|
||||
restart.Click += Restart_Click;
|
||||
void Restart_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -193,8 +209,10 @@ namespace SystemTrayMenu.Controls
|
|||
}
|
||||
menu.Items.Add(restart);
|
||||
|
||||
ToolStripMenuItem exit = new ToolStripMenuItem();
|
||||
exit.Text = Language.Translate("Exit");
|
||||
ToolStripMenuItem exit = new ToolStripMenuItem
|
||||
{
|
||||
Text = Language.Translate("Exit")
|
||||
};
|
||||
exit.Click += Exit_Click;
|
||||
void Exit_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -25,21 +25,9 @@ namespace SystemTrayMenu
|
|||
MaxReached
|
||||
}
|
||||
|
||||
public bool IsFadingIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return FadeForm.IsFadingIn;
|
||||
}
|
||||
}
|
||||
public bool IsFadingIn => FadeForm.IsFadingIn;
|
||||
|
||||
public bool IsFadingOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return FadeForm.IsFadingOut;
|
||||
}
|
||||
}
|
||||
public bool IsFadingOut => FadeForm.IsFadingOut;
|
||||
|
||||
public int Level = 0;
|
||||
private readonly FadeForm FadeForm = null;
|
||||
|
@ -53,9 +41,11 @@ namespace SystemTrayMenu
|
|||
InitializeComponent();
|
||||
SetDoubleBuffer(dgv, true);
|
||||
|
||||
DataGridViewCellStyle dgvCellStyle = new DataGridViewCellStyle();
|
||||
dgvCellStyle.SelectionBackColor = MenuDefines.ColorSelectedItem;
|
||||
dgvCellStyle.SelectionForeColor = Color.Black;
|
||||
DataGridViewCellStyle dgvCellStyle = new DataGridViewCellStyle
|
||||
{
|
||||
SelectionBackColor = MenuDefines.ColorSelectedItem,
|
||||
SelectionForeColor = Color.Black
|
||||
};
|
||||
dgv.DefaultCellStyle = dgvCellStyle;
|
||||
|
||||
VScrollBar scrollBar = dgv.Controls.OfType<VScrollBar>().First();
|
||||
|
@ -352,7 +342,7 @@ namespace SystemTrayMenu
|
|||
private string _text;
|
||||
public override string Text
|
||||
{
|
||||
get { return _text; }
|
||||
get => _text;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
|
|
@ -284,11 +284,15 @@ namespace SystemTrayMenu.Controls
|
|||
try
|
||||
{
|
||||
//https://stackoverflow.com/questions/31627801/
|
||||
Process p = new Process();
|
||||
p.StartInfo = new ProcessStartInfo(TargetFilePath);
|
||||
p.StartInfo.Arguments = Arguments;
|
||||
p.StartInfo.WorkingDirectory = WorkingDirectory;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
Process p = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo(TargetFilePath)
|
||||
{
|
||||
Arguments = Arguments,
|
||||
WorkingDirectory = WorkingDirectory,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
p.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -6,21 +6,9 @@ namespace SystemTrayMenu
|
|||
{
|
||||
public class FadeForm : IDisposable
|
||||
{
|
||||
public bool IsFadingIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return timerFadeIn.Enabled;
|
||||
}
|
||||
}
|
||||
public bool IsFadingIn => timerFadeIn.Enabled;
|
||||
|
||||
public bool IsFadingOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return timerFadeOut.Enabled;
|
||||
}
|
||||
}
|
||||
public bool IsFadingOut => timerFadeOut.Enabled;
|
||||
|
||||
private readonly Timer timerFadeIn = new Timer();
|
||||
private readonly Timer timerFadeOut = new Timer();
|
||||
|
|
|
@ -129,15 +129,9 @@ namespace SystemTrayMenu.Helper
|
|||
_key = key;
|
||||
}
|
||||
|
||||
public KeyboardHookModifierKeys Modifier
|
||||
{
|
||||
get { return _modifier; }
|
||||
}
|
||||
public KeyboardHookModifierKeys Modifier => _modifier;
|
||||
|
||||
public Keys Key
|
||||
{
|
||||
get { return _key; }
|
||||
}
|
||||
public Keys Key => _key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -165,17 +165,19 @@ namespace SystemTrayMenu.Helper
|
|||
#region InvokeCommand
|
||||
private void InvokeCommand(IContextMenu oContextMenu, uint nCmd, string strFolder, Point pointInvoke)
|
||||
{
|
||||
CMINVOKECOMMANDINFOEX invoke = new CMINVOKECOMMANDINFOEX();
|
||||
invoke.cbSize = cbInvokeCommand;
|
||||
invoke.lpVerb = (IntPtr)(nCmd - CMD_FIRST);
|
||||
invoke.lpDirectory = strFolder;
|
||||
invoke.lpVerbW = (IntPtr)(nCmd - CMD_FIRST);
|
||||
invoke.lpDirectoryW = strFolder;
|
||||
invoke.fMask = CMIC.UNICODE | CMIC.PTINVOKE |
|
||||
CMINVOKECOMMANDINFOEX invoke = new CMINVOKECOMMANDINFOEX
|
||||
{
|
||||
cbSize = cbInvokeCommand,
|
||||
lpVerb = (IntPtr)(nCmd - CMD_FIRST),
|
||||
lpDirectory = strFolder,
|
||||
lpVerbW = (IntPtr)(nCmd - CMD_FIRST),
|
||||
lpDirectoryW = strFolder,
|
||||
fMask = CMIC.UNICODE | CMIC.PTINVOKE |
|
||||
((Control.ModifierKeys & Keys.Control) != 0 ? CMIC.CONTROL_DOWN : 0) |
|
||||
((Control.ModifierKeys & Keys.Shift) != 0 ? CMIC.SHIFT_DOWN : 0);
|
||||
invoke.ptInvoke = new POINT(pointInvoke.X, pointInvoke.Y);
|
||||
invoke.nShow = SW.SHOWNORMAL;
|
||||
((Control.ModifierKeys & Keys.Shift) != 0 ? CMIC.SHIFT_DOWN : 0),
|
||||
ptInvoke = new POINT(pointInvoke.X, pointInvoke.Y),
|
||||
nShow = SW.SHOWNORMAL
|
||||
};
|
||||
|
||||
oContextMenu.InvokeCommand(ref invoke);
|
||||
}
|
||||
|
@ -1558,10 +1560,12 @@ namespace SystemTrayMenu.Helper
|
|||
}
|
||||
|
||||
// Let clients determine what to do
|
||||
HookEventArgs e = new HookEventArgs();
|
||||
e.HookCode = code;
|
||||
e.wParam = wParam;
|
||||
e.lParam = lParam;
|
||||
HookEventArgs e = new HookEventArgs
|
||||
{
|
||||
HookCode = code,
|
||||
wParam = wParam,
|
||||
lParam = lParam
|
||||
};
|
||||
OnHookInvoked(e);
|
||||
|
||||
// Yield to the next hook in the chain
|
||||
|
|
|
@ -27,20 +27,8 @@ namespace SystemTrayMenu
|
|||
get;
|
||||
private set;
|
||||
}
|
||||
public Point Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return Bounds.Location;
|
||||
}
|
||||
}
|
||||
public Size Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return Bounds.Size;
|
||||
}
|
||||
}
|
||||
public Point Location => Bounds.Location;
|
||||
public Size Size => Bounds.Size;
|
||||
//Always returns false under Windows 7
|
||||
public bool AlwaysOnTop
|
||||
{
|
||||
|
@ -60,9 +48,11 @@ namespace SystemTrayMenu
|
|||
{
|
||||
IntPtr taskbarHandle = User32.FindWindow(Taskbar.ClassName, null);
|
||||
|
||||
APPBARDATA data = new APPBARDATA();
|
||||
data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
|
||||
data.hWnd = taskbarHandle;
|
||||
APPBARDATA data = new APPBARDATA
|
||||
{
|
||||
cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)),
|
||||
hWnd = taskbarHandle
|
||||
};
|
||||
IntPtr result = SHAppBarMessage(ABM.GetTaskbarPos, ref data);
|
||||
if (result == IntPtr.Zero)
|
||||
{
|
||||
|
|
|
@ -336,10 +336,12 @@ namespace SystemTrayMenu
|
|||
|
||||
private static MenuData ReadMenu(BackgroundWorker worker, string path, int level)
|
||||
{
|
||||
MenuData menuData = new MenuData();
|
||||
menuData.RowDatas = new List<RowData>();
|
||||
menuData.Validity = MenuDataValidity.Invalid;
|
||||
menuData.Level = level;
|
||||
MenuData menuData = new MenuData
|
||||
{
|
||||
RowDatas = new List<RowData>(),
|
||||
Validity = MenuDataValidity.Invalid,
|
||||
Level = level
|
||||
};
|
||||
if (!worker.CancellationPending)
|
||||
{
|
||||
string[] directories = Array.Empty<string>();
|
||||
|
|
Loading…
Reference in a new issue