Added source code.

This commit is contained in:
2018-02-06 01:24:46 +02:00
parent 1d9f2990c8
commit 8b28da5b80
367 changed files with 22964 additions and 0 deletions

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace TibisMathematicsSuite.KeyboardIO
{
public static class Hotkey
{
private static HotkeyWindow window = new HotkeyWindow();
private static int currentId = 0;
public static event EventHandler<MyKeyEventArgs> HotkeyPressed
{
add { window.HotkeyPressed += value; }
remove { window.HotkeyPressed -= value; }
}
#region Winapi routines
// Registers a hot key with Windows.
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
// Unregisters the hot key with Windows.
[DllImport("user32.dll")]
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
#endregion
public static void Register(MyKey key)
{
currentId++;
if (!RegisterHotKey(window.Handle, currentId, (uint)key.Mods, (uint)key.Key))
throw new InvalidOperationException("Could not register the hotkey!");
}
public static void UnregisterAll()
{
for (; currentId > 0; currentId--)
UnregisterHotKey(window.Handle, currentId);
}
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TibisMathematicsSuite.KeyboardIO
{
class HotkeyWindow : NativeWindow, IDisposable
{
#region Constants
private const int WM_HOTKEY = 0x312;
#endregion
#region Events
public event EventHandler<MyKeyEventArgs> HotkeyPressed;
#endregion
#region Constructor
public HotkeyWindow()
{
this.CreateHandle(new System.Windows.Forms.CreateParams());
}
#endregion
#region Processor
protected override void WndProc(ref System.Windows.Forms.Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_HOTKEY && HotkeyPressed != null)
{
int vk = ((int)m.LParam >> 16) & 0xffff;
int mods = (int)m.LParam & 0xffff;
HotkeyPressed(this, new MyKeyEventArgs((Keys) vk, (MyKey.Modifiers) mods));
}
}
#endregion
#region Dispose
public void Dispose()
{
this.DestroyHandle();
}
#endregion
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TibisMathematicsSuite.KeyboardIO
{
class KeyMessageFilter : IMessageFilter
{
private const int WM_KEYDOWN = 0x0100;
private const int WM_KEYUP = 0x0101;
private Dictionary<Keys, bool> keyPressed = new Dictionary<Keys, bool>();
public Dictionary<Keys, bool> KeyPressedTable { get { return keyPressed; } }
public event EventHandler<KeyEventArgs> KeyDown;
public event EventHandler<KeyEventArgs> KeyUp;
public bool IsKeyPressed(Keys key)
{
return keyPressed[key];
}
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_KEYDOWN)
{
keyPressed[(Keys)m.WParam] = true;
if (KeyDown != null) KeyDown(this, new KeyEventArgs((Keys)m.WParam));
}
else if (m.Msg == WM_KEYUP)
{
keyPressed[(Keys)m.WParam] = false;
if (KeyUp != null) KeyUp(this, new KeyEventArgs((Keys)m.WParam));
}
return false;
}
}
}

View File

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace TibisMathematicsSuite.KeyboardIO
{
public class KeyShortcutBox : TextBox
{
#region Variables
private KeyMessageFilter keyFilter = new KeyMessageFilter();
private MyKey currentKey = new MyKey();
private bool inputFinished = false;
#endregion
#region Properties
public MyKey Key
{
get {
return MyKey.Parse(this.Text);
}
}
#endregion
#region Constructor
public KeyShortcutBox() : base()
{
this.ReadOnly = true;
this.BackColor = SystemColors.Window;
Application.AddMessageFilter(keyFilter);
keyFilter.KeyDown += new EventHandler<KeyEventArgs>(keyFilter_KeyDown);
keyFilter.KeyUp += new EventHandler<KeyEventArgs>(keyFilter_KeyUp);
}
#endregion
#region Key updating
private void keyFilter_KeyUp(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.LMenu:
case Keys.RMenu:
case Keys.Menu: currentKey.Mods &= ~MyKey.Modifiers.Alt; break;
case Keys.LShiftKey:
case Keys.RShiftKey:
case Keys.ShiftKey: currentKey.Mods &= ~MyKey.Modifiers.Shift; break;
case Keys.LControlKey:
case Keys.RControlKey:
case Keys.ControlKey: currentKey.Mods &= ~MyKey.Modifiers.Ctrl; break;
case Keys.LWin:
case Keys.RWin: currentKey.Mods &= ~MyKey.Modifiers.Win; break;
default:
inputFinished = true;
currentKey.Key = Keys.None;
break;
}
updateKey();
}
private void keyFilter_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.LMenu:
case Keys.RMenu:
case Keys.Menu: currentKey.Mods |= MyKey.Modifiers.Alt; break;
case Keys.LShiftKey:
case Keys.RShiftKey:
case Keys.ShiftKey: currentKey.Mods |= MyKey.Modifiers.Shift; break;
case Keys.LControlKey:
case Keys.RControlKey:
case Keys.ControlKey: currentKey.Mods |= MyKey.Modifiers.Ctrl; break;
case Keys.LWin:
case Keys.RWin: currentKey.Mods |= MyKey.Modifiers.Win; break;
default: currentKey.Key = e.KeyCode; break;
}
inputFinished = false;
updateKey();
}
private void updateKey()
{
if (!inputFinished && this.Focused && this.Enabled)
this.Text = currentKey.ToString();
}
#endregion
#region Reset
public void Reset()
{
this.Text = "";
this.inputFinished = false;
}
#endregion
}
}

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TibisMathematicsSuite.KeyboardIO
{
public class MyKey
{
#region Data types
[Flags]
public enum Modifiers
{
None = 0x0, Alt = 0x1, Ctrl = 0x2, Shift = 0x4, Win = 0x8
}
#endregion
#region Properties
public Modifiers Mods { get; set; }
public System.Windows.Forms.Keys Key { get; set; }
public bool TestModifier(Modifiers m)
{
return ((this.Mods & m) > 0);
}
#endregion
#region Constructors
public MyKey()
{
Mods = Modifiers.None;
Key = System.Windows.Forms.Keys.None;
}
public MyKey(System.Windows.Forms.Keys key)
{
Key = key;
Mods = Modifiers.None;
}
public MyKey(System.Windows.Forms.Keys key, Modifiers mods)
{
Key = key;
Mods = mods;
}
#endregion
#region To and from string
public static MyKey Parse(string str)
{
MyKey key = new MyKey();
System.Windows.Forms.Keys temp;
var keys = str.Split('+');
foreach (var i in keys)
switch (i)
{
case "Alt": key.Mods |= Modifiers.Alt; break;
case "Ctrl": key.Mods |= Modifiers.Ctrl; break;
case "Shift": key.Mods |= Modifiers.Shift; break;
case "Win": key.Mods |= Modifiers.Win; break;
default:
Enum.TryParse<System.Windows.Forms.Keys>(i, out temp);
key.Key = temp;
break;
}
return key;
}
public static string ToString(MyKey key)
{
StringBuilder str = new StringBuilder();
if ((key.Mods & Modifiers.Win) != 0) str.Append("Win+");
if ((key.Mods & Modifiers.Ctrl) != 0) str.Append("Ctrl+");
if ((key.Mods & Modifiers.Alt) != 0) str.Append("Alt+");
if ((key.Mods & Modifiers.Shift) != 0) str.Append("Shift+");
str.Append(Enum.GetName(typeof(System.Windows.Forms.Keys), key.Key));
return str.ToString();
}
public override string ToString()
{
return MyKey.ToString(this);
}
#endregion
#region Overloads
public override bool Equals(object obj)
{
MyKey b = obj as MyKey;
if (b == null) return false;
return (b.Key == this.Key && b.Mods == this.Mods);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public static bool operator== (MyKey A, MyKey B)
{
if ((object)A == null || (object)B == null) return ((object)A == (object)B);
return (A.Key == B.Key) && (A.Mods == B.Mods);
}
public static bool operator!=(MyKey A, MyKey B)
{
return !(A == B);
}
#endregion
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TibisMathematicsSuite.KeyboardIO
{
public class MyKeyEventArgs : EventArgs
{
public MyKey Key { get; set; }
public MyKeyEventArgs() : base() { }
public MyKeyEventArgs(MyKey key)
{
Key = key;
}
public MyKeyEventArgs(System.Windows.Forms.Keys k, MyKey.Modifiers mods = MyKey.Modifiers.None)
{
Key = new MyKey(k, mods);
}
}
}

View File

@ -0,0 +1,262 @@
namespace TibisMathematicsSuite
{
partial class MainWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
this.buttonCancel = new DynamicLink.Controls.MyButton();
this.buttonAccept = new DynamicLink.Controls.MyButton();
this.groupKeyboardShortcuts = new DynamicLink.Controls.MyGroupBox();
this.keyShortcutBox = new TibisMathematicsSuite.KeyboardIO.KeyShortcutBox();
this.buttonSet = new DynamicLink.Controls.MyButton();
this.buttonClear = new DynamicLink.Controls.MyButton();
this.labelShortcut = new System.Windows.Forms.Label();
this.listModules = new System.Windows.Forms.ListView();
this.listModules_Mod = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.listModules_Key = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.notify = new System.Windows.Forms.NotifyIcon(this.components);
this.notifyContext = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.notifyContextAbout = new System.Windows.Forms.ToolStripMenuItem();
this.notifyContextSettings = new System.Windows.Forms.ToolStripMenuItem();
this.notifyContextExit = new System.Windows.Forms.ToolStripMenuItem();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.groupKeyboardShortcuts.SuspendLayout();
this.notifyContext.SuspendLayout();
this.SuspendLayout();
//
// buttonCancel
//
this.buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(62, 246);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonAccept
//
this.buttonAccept.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.buttonAccept.Location = new System.Drawing.Point(143, 246);
this.buttonAccept.Name = "buttonAccept";
this.buttonAccept.Size = new System.Drawing.Size(75, 23);
this.buttonAccept.TabIndex = 4;
this.buttonAccept.Text = "Accept";
this.buttonAccept.UseVisualStyleBackColor = true;
this.buttonAccept.Click += new System.EventHandler(this.buttonAccept_Click);
//
// groupKeyboardShortcuts
//
this.groupKeyboardShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupKeyboardShortcuts.BackColor = System.Drawing.Color.Transparent;
this.groupKeyboardShortcuts.Controls.Add(this.keyShortcutBox);
this.groupKeyboardShortcuts.Controls.Add(this.buttonSet);
this.groupKeyboardShortcuts.Controls.Add(this.buttonClear);
this.groupKeyboardShortcuts.Controls.Add(this.labelShortcut);
this.groupKeyboardShortcuts.Controls.Add(this.listModules);
this.groupKeyboardShortcuts.Location = new System.Drawing.Point(12, 12);
this.groupKeyboardShortcuts.Name = "groupKeyboardShortcuts";
this.groupKeyboardShortcuts.Padding = new System.Windows.Forms.Padding(3, 7, 3, 3);
this.groupKeyboardShortcuts.Size = new System.Drawing.Size(257, 223);
this.groupKeyboardShortcuts.TabIndex = 2;
this.groupKeyboardShortcuts.TabStop = false;
this.groupKeyboardShortcuts.Text = "Global keyboard shortcuts";
//
// keyShortcutBox
//
this.keyShortcutBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.keyShortcutBox.BackColor = System.Drawing.SystemColors.Window;
this.keyShortcutBox.Enabled = false;
this.keyShortcutBox.Location = new System.Drawing.Point(62, 197);
this.keyShortcutBox.Name = "keyShortcutBox";
this.keyShortcutBox.ReadOnly = true;
this.keyShortcutBox.Size = new System.Drawing.Size(113, 20);
this.keyShortcutBox.TabIndex = 1;
//
// buttonSet
//
this.buttonSet.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSet.Location = new System.Drawing.Point(179, 197);
this.buttonSet.Margin = new System.Windows.Forms.Padding(1);
this.buttonSet.Name = "buttonSet";
this.buttonSet.Size = new System.Drawing.Size(35, 20);
this.buttonSet.TabIndex = 2;
this.buttonSet.Text = "Set";
this.buttonSet.UseVisualStyleBackColor = true;
this.buttonSet.Click += new System.EventHandler(this.buttonSet_Click);
//
// buttonClear
//
this.buttonClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonClear.Location = new System.Drawing.Point(216, 197);
this.buttonClear.Margin = new System.Windows.Forms.Padding(1);
this.buttonClear.Name = "buttonClear";
this.buttonClear.Size = new System.Drawing.Size(35, 20);
this.buttonClear.TabIndex = 3;
this.buttonClear.Text = "Clear";
this.buttonClear.UseVisualStyleBackColor = true;
this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
//
// labelShortcut
//
this.labelShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelShortcut.AutoSize = true;
this.labelShortcut.Location = new System.Drawing.Point(6, 200);
this.labelShortcut.Name = "labelShortcut";
this.labelShortcut.Size = new System.Drawing.Size(50, 13);
this.labelShortcut.TabIndex = 3;
this.labelShortcut.Text = "Shortcut:";
//
// listModules
//
this.listModules.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listModules.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.listModules.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.listModules_Mod,
this.listModules_Key});
this.listModules.FullRowSelect = true;
this.listModules.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listModules.HideSelection = false;
this.listModules.Location = new System.Drawing.Point(7, 24);
this.listModules.MultiSelect = false;
this.listModules.Name = "listModules";
this.listModules.Size = new System.Drawing.Size(244, 168);
this.listModules.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listModules.TabIndex = 0;
this.listModules.UseCompatibleStateImageBehavior = false;
this.listModules.View = System.Windows.Forms.View.Details;
this.listModules.SelectedIndexChanged += new System.EventHandler(this.listModules_SelectedIndexChanged);
//
// listModules_Mod
//
this.listModules_Mod.Text = "Module";
this.listModules_Mod.Width = 137;
//
// listModules_Key
//
this.listModules_Key.Text = "Shortcut";
this.listModules_Key.Width = 100;
//
// notify
//
this.notify.ContextMenuStrip = this.notifyContext;
this.notify.Icon = ((System.Drawing.Icon)(resources.GetObject("notify.Icon")));
this.notify.Text = "Tibi\'s Mathematics Suite";
this.notify.Visible = true;
//
// notifyContext
//
this.notifyContext.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripSeparator1,
this.notifyContextAbout,
this.notifyContextSettings,
this.notifyContextExit});
this.notifyContext.Name = "contextMenuStrip1";
this.notifyContext.Size = new System.Drawing.Size(117, 76);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(113, 6);
//
// notifyContextAbout
//
this.notifyContextAbout.Name = "notifyContextAbout";
this.notifyContextAbout.Size = new System.Drawing.Size(116, 22);
this.notifyContextAbout.Text = "&About";
this.notifyContextAbout.Click += new System.EventHandler(this.notifyContextAbout_Click);
//
// notifyContextSettings
//
this.notifyContextSettings.Image = ((System.Drawing.Image)(resources.GetObject("notifyContextSettings.Image")));
this.notifyContextSettings.Name = "notifyContextSettings";
this.notifyContextSettings.Size = new System.Drawing.Size(116, 22);
this.notifyContextSettings.Text = "&Settings";
this.notifyContextSettings.Click += new System.EventHandler(this.notifyContextSettings_Click);
//
// notifyContextExit
//
this.notifyContextExit.Image = ((System.Drawing.Image)(resources.GetObject("notifyContextExit.Image")));
this.notifyContextExit.Name = "notifyContextExit";
this.notifyContextExit.Size = new System.Drawing.Size(116, 22);
this.notifyContextExit.Text = "E&xit";
this.notifyContextExit.Click += new System.EventHandler(this.notifyContextExit_Click);
//
// MainWindow
//
this.AcceptButton = this.buttonAccept;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Gainsboro;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(281, 281);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAccept);
this.Controls.Add(this.groupKeyboardShortcuts);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "MainWindow";
this.Text = "Suite settings";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainWindow_FormClosing);
this.groupKeyboardShortcuts.ResumeLayout(false);
this.groupKeyboardShortcuts.PerformLayout();
this.notifyContext.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private DynamicLink.Controls.MyGroupBox groupKeyboardShortcuts;
private System.Windows.Forms.ListView listModules;
private DynamicLink.Controls.MyButton buttonAccept;
private DynamicLink.Controls.MyButton buttonCancel;
private System.Windows.Forms.ColumnHeader listModules_Mod;
private System.Windows.Forms.ColumnHeader listModules_Key;
private DynamicLink.Controls.MyButton buttonSet;
private DynamicLink.Controls.MyButton buttonClear;
private System.Windows.Forms.Label labelShortcut;
private System.Windows.Forms.NotifyIcon notify;
private System.Windows.Forms.ContextMenuStrip notifyContext;
private KeyboardIO.KeyShortcutBox keyShortcutBox;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem notifyContextAbout;
private System.Windows.Forms.ToolStripMenuItem notifyContextSettings;
private System.Windows.Forms.ToolStripMenuItem notifyContextExit;
private System.Windows.Forms.ToolTip toolTip;
}
}

View File

@ -0,0 +1,245 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TibisMathematicsSuite.KeyboardIO;
namespace TibisMathematicsSuite
{
public partial class MainWindow : Form
{
private Dictionary<string, MyKey> moduleShortcuts = new Dictionary<string, MyKey>();
bool allowExit = false, allowShow = false;
#region Constructor
public MainWindow()
{
InitializeComponent();
PopulateModules();
PopulateNotificationList();
UpdateGlobalHotkeys();
// Hotkey
Hotkey.HotkeyPressed += new EventHandler<MyKeyEventArgs>(Hotkey_HotkeyPressed);
// Show baloon message
notify.ShowBalloonTip(2, "Tibi's Mathematics Suite",
"The suite is running. Right click this icon to open an application.", ToolTipIcon.None);
}
#endregion
#region Rendering
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DynamicLink.Controls.BackgroundGradient.Paint(e.Graphics, new Rectangle(0, 0, this.Width, this.Height));
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
this.Invalidate();
}
#endregion
#region Update routines
private void PopulateModules()
{
// Collect data
if (DynamicLink.Modules.Items.Count == 0) DynamicLink.Modules.CollectData();
// Get the already made dictionary
var dict = TibisMathematicsSuite.Properties.Settings.Default.ModuleKeys;
if (dict == null) dict = new System.Collections.Specialized.StringDictionary();
foreach (var i in DynamicLink.Modules.Items)
{
if (dict.ContainsKey(i.Name)) moduleShortcuts.Add(i.Name, MyKey.Parse(dict[i.Name]));
else moduleShortcuts.Add(i.Name, null);
}
// Now that our dictionary is complete, add it to list box
UpdateModules();
}
private void PopulateNotificationList()
{
// Collect data
if (DynamicLink.Modules.Items.Count == 0) DynamicLink.Modules.CollectData();
// Add items
int j = 0;
foreach (var i in DynamicLink.Modules.Items.OrderBy(x => x.Name))
{
ToolStripMenuItem item = new ToolStripMenuItem(i.Name);
item.Click += new EventHandler(menuContextModule_Click);
item.Image = i.Icon.ToBitmap();
item.ToolTipText = i.Description;
notifyContext.Items.Insert(j++, item);
}
}
private void UpdateModules()
{
listModules.Items.Clear();
foreach (var i in moduleShortcuts)
if (i.Value == null) listModules.Items.Add(new ListViewItem (new string[] { i.Key, "" }));
else listModules.Items.Add(new ListViewItem(new string[] { i.Key, i.Value.ToString() }));
}
private void UpdateModule(string name)
{
foreach (ListViewItem i in listModules.Items)
if (i.Text == name)
{
if (moduleShortcuts[name] == null) i.SubItems[1].Text = "";
else i.SubItems[1].Text = moduleShortcuts[name].ToString();
return;
}
}
private void UpdateGlobalHotkeys()
{
KeyboardIO.Hotkey.UnregisterAll();
foreach (var i in moduleShortcuts)
if (i.Value != null) KeyboardIO.Hotkey.Register(i.Value);
}
#endregion
#region Buttons
private void buttonClear_Click(object sender, EventArgs e)
{
if (listModules.SelectedItems.Count != 1) return;
string name = listModules.SelectedItems[0].Text;
moduleShortcuts[name] = null;
UpdateModule(name);
}
private void buttonSet_Click(object sender, EventArgs e)
{
if (listModules.SelectedItems.Count != 1) return;
string name = listModules.SelectedItems[0].Text;
moduleShortcuts[name] = keyShortcutBox.Key;
UpdateModule(name);
}
private void buttonAccept_Click(object sender, EventArgs e)
{
// Update hotkey list
UpdateGlobalHotkeys();
// Save settings
if (TibisMathematicsSuite.Properties.Settings.Default.ModuleKeys == null)
TibisMathematicsSuite.Properties.Settings.Default.ModuleKeys = new System.Collections.Specialized.StringDictionary();
TibisMathematicsSuite.Properties.Settings.Default.ModuleKeys.Clear();
foreach (var i in moduleShortcuts)
if (i.Value != null) TibisMathematicsSuite.Properties.Settings.Default.ModuleKeys.Add(i.Key, i.Value.ToString());
// Hide window
this.Hide();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.Close();
}
void menuContextModule_Click(object sender, EventArgs e)
{
ToolStripMenuItem menu = sender as ToolStripMenuItem;
if (menu != null) DynamicLink.Launcher.StartModule(menu.Text);
}
#endregion
#region Context menu
private void notifyContextAbout_Click(object sender, EventArgs e)
{
DynamicLink.Launcher.About();
}
private void notifyContextSettings_Click(object sender, EventArgs e)
{
allowShow = true;
this.Show();
}
private void notifyContextExit_Click(object sender, EventArgs e)
{
allowExit = true;
Application.Exit();
}
#endregion
#region Other event handlers
void Hotkey_HotkeyPressed(object sender, MyKeyEventArgs e)
{
foreach (var i in moduleShortcuts)
if (e.Key == i.Value)
{
DynamicLink.Launcher.StartModule(i.Key);
return;
}
}
private void listModules_SelectedIndexChanged(object sender, EventArgs e)
{
if (listModules.SelectedItems.Count == 1) keyShortcutBox.Enabled = true;
else
{
keyShortcutBox.Reset();
keyShortcutBox.Enabled = false;
}
}
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing && !allowExit)
{
e.Cancel = true;
this.Hide();
}
else
{
notify.Visible = false;
TibisMathematicsSuite.Properties.Settings.Default.Save();
}
}
protected override void SetVisibleCore(bool value)
{
base.SetVisibleCore((allowShow) ? value : false);
// We need to reinitialize some settings
if (allowShow && value)
{
moduleShortcuts.Clear();
listModules.Items.Clear();
PopulateModules();
}
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace TibisMathematicsSuite
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainWindow());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Main application")]
[assembly: AssemblyDescription("This is the main application of the suite.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Tibi Software")]
[assembly: AssemblyProduct(".Tibi's Mathematics Suite")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e2784748-c70f-438c-aa4b-fbb512c39906")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.261
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TibisMathematicsSuite.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TibisMathematicsSuite.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.261
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TibisMathematicsSuite.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Specialized.StringDictionary ModuleKeys {
get {
return ((global::System.Collections.Specialized.StringDictionary)(this["ModuleKeys"]));
}
set {
this["ModuleKeys"] = value;
}
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TibisMathematicsSuite.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ModuleKeys" Type="System.Collections.Specialized.StringDictionary" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9A45DFCA-EA4F-4950-8519-F1BCE929D5CA}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TibisMathematicsSuite</RootNamespace>
<AssemblyName>TibisMathematicsSuite</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>suite.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release - Publish|x86'">
<OutputPath>..\..\TibisMathematicsSuite - Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="KeyboardIO\KeyShortcutBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="MainWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainWindow.Designer.cs">
<DependentUpon>MainWindow.cs</DependentUpon>
</Compile>
<Compile Include="KeyboardIO\Hotkey.cs" />
<Compile Include="KeyboardIO\HotkeyWindow.cs" />
<Compile Include="KeyboardIO\KeyMessageFilter.cs" />
<Compile Include="KeyboardIO\MyKey.cs" />
<Compile Include="KeyboardIO\MyKeyEventArgs.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainWindow.resx">
<DependentUpon>MainWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Launcher\DynamicLink.csproj">
<Project>{A04B247B-6A95-462B-9E07-3337A1C158F1}</Project>
<Name>DynamicLink</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="suite.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB