public MainWindow() { InitializeComponent(); isHookEnabled = true; autoComplete = new ObservableCollection<Entry>(); setupHook(); setupTimer(); DataContext = this; load(); autoComplete.CollectionChanged += AutoComplete_CollectionChanged; setupCustomEntries(); setupNotifyIcon(); _instance = this; }
public MainWindow() { InitializeComponent(); autoComplete = new ObservableCollection<Entry>(); notifyIcon = new NotifyIcon(); notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); // new System.Drawing.Icon(@"C:\icon.ico"); notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyIcon_MouseClick); notifyIcon.MouseDoubleClick += notifyIcon_MouseDoubleClick; notifyIcon.Visible = true; hook = new KeyboardHook(); hook.RegisterHotKey(ModifierKeys.Control, Keys.Space); hook.KeyPressed += hook_KeyPressed; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMinutes(5); timer.Tick += timer_Tick; timer.Start(); DataContext = this; load(); autoComplete.CollectionChanged += AutoComplete_CollectionChanged; //Custom entries var c = new[] { new Entry() { Title = "Mouse", Command = "main.cpl" }, new Entry() { Title = "Add/Remove Programs", Command = "appwiz.cpl" }, new Entry() { Title = "Date/Time Properties", Command = "timedate.cpl" }, new Entry() { Title = "Display Properties", Command = "desk.cpl" }, new Entry() { Title = "Sound Properties", Command = "mmsys.cpl" }, // new Entry() { Title = "Sky Drive", Command = @"C:\Users\marpe\SkyDrive\Dokument" }, absolute paths won't turn out well... }; var cm = new System.Windows.Forms.ContextMenu(); cm.MenuItems.Add("Show Entries", (x, y) => { showList(); }); cm.MenuItems.Add("Add File Entry", (x, y) => { AddNewFileEntry(); }); cm.MenuItems.Add("Add Directory Entry", (x, y) => { AddNewDirectoryEntry(); }); cm.MenuItems.Add("Close", (x, y) => { System.Windows.Application.Current.Shutdown(); }); notifyIcon.ContextMenu = cm; foreach (var e in c) AddEntry(e, false); _instance = this; }