public backgroungWorker()
        {
            this.Width         = 0;
            this.Height        = 0;
            this.WindowStyle   = WindowStyle.None;
            this.ShowInTaskbar = false;
            this.ShowActivated = false;
            //InitializeComponent();

            // init context menu
            System.Windows.Forms.MenuItem mwMenuItem = new System.Windows.Forms.MenuItem();
            mwMenuItem.Text = "Main Window";
            cm.MenuItems.Add(mwMenuItem);
            mwMenuItem.Click += mwMenuItem_Click;
            System.Windows.Forms.MenuItem eMenuItem = new System.Windows.Forms.MenuItem();
            eMenuItem.Text = "Exit";
            cm.MenuItems.Add(eMenuItem);
            eMenuItem.Click += eMenuItem_Click;

            // init the notify icon
            //ComponentResourceManager resources = new ComponentResourceManager(typeof(backgroungWorker));
            nIcon.Icon        = new Icon(System.AppDomain.CurrentDomain.BaseDirectory + "icon.ico");
            nIcon.Visible     = true;
            nIcon.ContextMenu = cm;

            // load the configuration
            commonSet.LoadConfiguration();
            CheckNeedToShowWindow();

            // register auto start
            AutoRunRegister();

            // use the auto disable function
            AutoDisable();
        }
        public void InitConfigurationWindow()
        {
            InitializeComponent();

            // load configuration from the file
            commonSet.LoadConfiguration();
            commonSet.LoadNextTime();

            // set the UI elements accroading to the loaded configuration
            InitUIElement();
        }
        public BGWorker()
        {
            //InitializeComponent();
            //System.Windows.Forms.MessageBox.Show("001");
            // hide the window
            this.Width         = 0;
            this.Height        = 0;
            this.WindowStyle   = WindowStyle.None;
            this.ShowInTaskbar = false;
            this.ShowActivated = false;

            //System.Windows.Forms.MessageBox.Show("002");
            // init context menu
            System.Windows.Forms.MenuItem mwMenuItem = new System.Windows.Forms.MenuItem();
            mwMenuItem.Text = "Configuration";
            cm.MenuItems.Add(mwMenuItem);
            mwMenuItem.Click += cwMenuItem_Click;

            System.Windows.Forms.MenuItem rwMenuItem = new System.Windows.Forms.MenuItem();
            rwMenuItem.Text = "Print now";
            cm.MenuItems.Add(rwMenuItem);
            rwMenuItem.Click += rwMenuItem_Click;

            System.Windows.Forms.MenuItem eMenuItem = new System.Windows.Forms.MenuItem();
            eMenuItem.Text = "Exit";
            cm.MenuItems.Add(eMenuItem);
            eMenuItem.Click += eMenuItem_Click;
            //System.Windows.Forms.MessageBox.Show("003");

            // init the notify icon
            //System.Windows.MessageBox.Show(System.AppDomain.CurrentDomain.BaseDirectory + "icon.ico");
            nIcon.Icon        = new Icon(System.AppDomain.CurrentDomain.BaseDirectory + "icon.ico");
            nIcon.Visible     = true;
            nIcon.ContextMenu = cm;
            //System.Windows.Forms.MessageBox.Show("004");

            // load the configuration
            commonSet.LoadConfiguration();
            //System.Windows.Forms.MessageBox.Show("005");

            CheckIsTimeToPrint();
        }
        private void InitUIElement()
        {
            // Show the message to tell the user the command is loading
            LoadingMessage lm = new LoadingMessage();

            lm.Show();
            commonSet.LoadConfiguration();
            lm.Close();

            // set language
            if (commonSet.loadedLanguage.ToLower().Equals("english"))
            {
                LanguageComboBox.SelectedIndex = ENGLISH_INDEX;
            }
            // set autostart
            if (commonSet.loadedAutoStart.ToLower().Equals("true"))
            {
                AutoStartCheckBox.IsChecked = true;
            }
            else
            {
                AutoStartCheckBox.IsChecked = false;
            }
            // set auto disable
            if (commonSet.loadedAutoDisableAll.ToLower().Equals("true"))
            {
                AutoDisableAllCheckBox.IsChecked = true;
            }
            else
            {
                AutoDisableAllCheckBox.IsChecked = false;
            }
            if (commonSet.loadedAutoDisableMouse.ToLower().Equals("true"))
            {
                AutoDisableMouseCheckBox.IsChecked = true;
            }
            else
            {
                AutoDisableMouseCheckBox.IsChecked = false;
            }
            if (commonSet.loadedAutoDisableKeyboard.ToLower().Equals("true"))
            {
                AutoDisableKeyboardCheckBox.IsChecked = true;
            }
            else
            {
                AutoDisableKeyboardCheckBox.IsChecked = false;
            }
            // set auto show window
            if (commonSet.loadedAutoShowWindow.ToLower().Equals("true"))
            {
                ShowWindowCheckBox.IsChecked = true;
            }
            else
            {
                ShowWindowCheckBox.IsChecked = false;
            }

            // put the value into variable
            commonSet.language            = commonSet.loadedLanguage;
            commonSet.autoStart           = commonSet.loadedAutoStart;
            commonSet.autoDisableAll      = commonSet.loadedAutoDisableAll;
            commonSet.autoDisableMouse    = commonSet.loadedAutoDisableMouse;
            commonSet.autoDisableKeyboard = commonSet.loadedAutoDisableKeyboard;
            commonSet.autoShowWindow      = commonSet.loadedAutoShowWindow;

            commonSet.SaveConfiguration();
        }