private void ckWindowService_Checked(object sender, RoutedEventArgs e) { try{ appConfig.SaveValue("WindowsService", "yes"); ApplicationStartUp.Save(Environment.CurrentDirectory + @"\PhoneDirectory.exe"); } catch (Exception ex) { MessageBox.Show("Options - General Settings " + ex.Message); Utilities.Log.Create("Options - General Settings " + ex.Message); } }
public MainGUI() { InitializeComponent(); try { //Run the thread to load all contacts _QuickSearch = new QuickSearch(); _QuickSearch.RunBackgroundWorker(); //Check Start up try { if (Constants.IsRunAsWindowsService() && !ApplicationStartUp.IsExistRunKey()) { ApplicationStartUp.Save(Environment.CurrentDirectory + @"\PhoneDirectory.exe"); } } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } //register event for shortkey // register the event that is fired after the key press. hook.KeyPressed += new EventHandler <KeyPressedEventArgs>(hook_KeyPressed); // register the control + alt + F12 combination as hot key. //Register Control + Alt + P for host key hook.RegisterHotKey(KeyboardHookLib.ModifierKeys.Control | KeyboardHookLib.ModifierKeys.Alt, Keys.P); //Setup icon and menu NotifyMenu = new System.Windows.Forms.ContextMenuStrip(); mnuAboutUs = new System.Windows.Forms.ToolStripMenuItem(); mnuExit = new System.Windows.Forms.ToolStripMenuItem(); //mnuOptions = new System.Windows.Forms.ToolStripMenuItem(); mnuRefresh = new System.Windows.Forms.ToolStripMenuItem(); mnuEditMyProfile = new System.Windows.Forms.ToolStripMenuItem(); mnuAddNewContact = new System.Windows.Forms.ToolStripMenuItem(); mnuEditMyProfile.Click += new EventHandler(mnuEditMyProfile_Click); mnuRefresh.Click += new EventHandler(mnuRefresh_Click); mnuAddNewContact.Click += new EventHandler(mnuAddNewContact_Click); mnuAboutUs.Click += new EventHandler(mnuAboutUs_Click); // // mnuAboutUs // mnuAboutUs.Name = "mnuAboutUs"; mnuAboutUs.Size = new System.Drawing.Size(152, 22); mnuAboutUs.Text = "About Us"; // // mnuExit // mnuExit.Name = "mnuExit"; mnuExit.Size = new System.Drawing.Size(152, 22); mnuExit.Text = "Exit"; mnuExit.Click += new EventHandler(mnuExit_Click); // // mnuRefresh // mnuRefresh.Name = "mnuRefresh"; mnuRefresh.Size = new System.Drawing.Size(152, 22); mnuRefresh.Text = "Refresh"; // // mnuOptions // mnuEditMyProfile.Name = "mnuEditMyProfile"; mnuEditMyProfile.Size = new System.Drawing.Size(152, 22); mnuEditMyProfile.Text = "Edit My Profile"; // // mnuAddNewContact // mnuAddNewContact.Name = "mnuAddNewContact"; mnuAddNewContact.Size = new System.Drawing.Size(152, 22); mnuAddNewContact.Text = "Add New Contact"; // // NotifyMenu // NotifyMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuAboutUs, mnuAddNewContact, mnuEditMyProfile, mnuRefresh, mnuExit }); NotifyMenu.Name = "NotifyMenu"; NotifyMenu.Size = new System.Drawing.Size(153, 92); // NotifyIcon m_notifyIcon = new System.Windows.Forms.NotifyIcon(); m_notifyIcon.ContextMenuStrip = NotifyMenu; m_notifyIcon.BalloonTipText = "The app has been minimised. Click the tray icon to show."; m_notifyIcon.BalloonTipTitle = "Telephone Directory"; m_notifyIcon.Text = "Telephone Directory"; m_notifyIcon.Icon = new System.Drawing.Icon(Constants.GetApplicationPath() + @"Icons\Icon.ico"); m_notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(m_notifyIcon_MouseClick); ShowTrayIcon(true); //Copy compulsory library for outllok to run //try //{ // CommonLibrary.AppConfig appConfig = new CommonLibrary.AppConfig(CommonLibrary.Constants.GetConfigFilePath()); // if (CommonLibrary.Constants.IsOutlookExpress()) // { // DirectoryInfo di = new DirectoryInfo("C:/Program files/NKTWab/bin"); // if (!di.Exists) // { // di.Create(); // File.Copy(Constants.GetApplicationPath() + "nktwab.dll", @"C:\Program files\NKTWab\bin\nktwab.dll"); // } // } //} //catch (Exception ex) //{ // //System.Windows.Forms.MessageBox.Show(ex.Message); // CommonLibrary.Utilities.Log.Create(ex.Message); //} //Checking the License int i = ProductLib.Licensing.LicenseHandler.IsProductActivated(); if (i == 0) { System.Windows.Forms.MessageBox.Show("Telephone Directory;Your product has not activated yet!"); Close(); } if (i == 1) { System.Windows.Forms.MessageBox.Show("Telephone Directory;Your product key is expired!"); Close(); } } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } }