Example #1
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isFirstInstance;

            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, "RFIDKeybWedge", out isFirstInstance)) {
                if (isFirstInstance)
                {
                    NotificationIcon notificationIcon = new NotificationIcon();
                    notificationIcon.notifyIcon.Visible = true;
                    if (notificationIcon.connectReader())
                    {
                        if (notificationIcon.connectedToReader())
                        {
                            notificationIcon.connectItem.Enabled    = false;
                            notificationIcon.disconnectItem.Enabled = true;
                        }
                        else
                        {
                            notificationIcon.connectItem.Enabled    = true;
                            notificationIcon.disconnectItem.Enabled = false;
                        }
                    }
                    else
                    {
                        notificationIcon.connectItem.Enabled    = false;
                        notificationIcon.disconnectItem.Enabled = false;
                        serialConfig = new frmSerial();
                        serialConfig.Show();
                    }

                    if (NotificationIcon._incCRLF)
                    {
                        notificationIcon.crlfConfig.Checked = true;
                    }


                    //NotificationIcon.mainProgram = new Thread(notificationIcon.startSchemaRead);
                    mainProgram = new Thread(new ThreadStart(notificationIcon.startSchemaRead));
                    mainProgram.Start();



                    //NotificationIcon.mainProgram = new Thread(notificationIcon.startSchemaRead);

                    Application.Run();
                    notificationIcon.notifyIcon.Dispose();
                    //notificationIcon.startSchemaRead();
                }
                else
                {
                    // The application is already running
                    // TODO: Display message box or change focus to existing application instance
                }
            }             // releases the Mutex
        }
Example #2
0
 private void menuSerialConfigClick(object sender, EventArgs e)
 {
     if (serialConfig == null)
     {
         serialConfig = new frmSerial();
     }
     if (serialConfig.IsDisposed)
     {
         serialConfig = new frmSerial();
     }
     if (!serialConfig.Visible)
     {
         serialConfig.Show();
     }
 }
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isFirstInstance;
            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, "RFIDKeybWedge", out isFirstInstance)) {
                if (isFirstInstance) {
                    NotificationIcon notificationIcon = new NotificationIcon();
                    notificationIcon.notifyIcon.Visible = true;
                    if(notificationIcon.connectReader())
                    {
                        if (notificationIcon.connectedToReader()) {
                            notificationIcon.connectItem.Enabled = false;
                            notificationIcon.disconnectItem.Enabled = true;
                        }
                        else {
                            notificationIcon.connectItem.Enabled = true;
                            notificationIcon.disconnectItem.Enabled = false;
                        }
                    }else{
                        notificationIcon.connectItem.Enabled = false;
                        notificationIcon.disconnectItem.Enabled = false;
                        serialConfig = new frmSerial();
                        serialConfig.Show();
                    }

                    if (NotificationIcon._incCRLF)
                        notificationIcon.crlfConfig.Checked = true;

                    //NotificationIcon.mainProgram = new Thread(notificationIcon.startSchemaRead);
                    mainProgram = new Thread(new ThreadStart(notificationIcon.startSchemaRead));
                    mainProgram.Start();

                    //NotificationIcon.mainProgram = new Thread(notificationIcon.startSchemaRead);

                    Application.Run();
                    notificationIcon.notifyIcon.Dispose();
                    //notificationIcon.startSchemaRead();

                } else {
                    // The application is already running
                    // TODO: Display message box or change focus to existing application instance
                }
            } // releases the Mutex
        }