Esempio n. 1
0
        public static void SetConsoleWindowVisibility(bool visible)
        {
            FormConfig frmmain = new FormConfig();

            frmmain.Show();
        }
Esempio n. 2
0
        /*
         * show frmMain
         */
        public static void ShowConfiguration()
        {
            // initialize new FormConfig
            FormConfig frmConfig = new FormConfig();

            /*
             * event handler for btn StartServer
             * first check for configurations and start server
             */
            frmConfig.btnStartServer.Click += (s, e) =>
            {
                if (ServerController.isPrintServerStarted == false)
                {
                    /*
                     * if server is not started, check for printer name
                     * if printer name is not set,, stop and let user know
                     * otherwise, start the server, and change the text of the
                     * control button
                     */
                    if (frmConfig.cmbPrinters.Text == "")
                    {
                        MessageBox.Show("Please select Receipt Printer to continue."
                                        , "Receipt Printer Not Configured"
                                        , MessageBoxButtons.OK
                                        , MessageBoxIcon.Error);
                    }
                    else if (frmConfig.txtPrinterPort.Text == "")
                    {
                        MessageBox.Show("Please set your print server port. Default is 8123."
                                        , "Print Server Port not set"
                                        , MessageBoxButtons.OK
                                        , MessageBoxIcon.Error);
                    }
                    else if (frmConfig.txtServerPort.Text == "")
                    {
                        MessageBox.Show("Please set your web server port. Default is 8000."
                                        , "Web Server Port not set"
                                        , MessageBoxButtons.OK
                                        , MessageBoxIcon.Error);
                    }
                    else
                    {
                        Config.PrinterName     = frmConfig.cmbPrinters.Text;
                        Config.PrintServerPort = frmConfig.txtPrinterPort.Text;
                        Config.WebServerPort   = frmConfig.txtServerPort.Text;
                        Config.Save();
                        ServerController.StartPrintServer();
                        frmConfig.RefreshFormConponentsState();
                    }
                }
                else
                {
                    /*
                     * if server is started, stop the server and change the Txt of command
                     * button
                     */
                    ServerController.StopPrintServer();
                    frmConfig.RefreshFormConponentsState();
                }
            };

            // event handler for btn Launch POS
            frmConfig.btnLaunchPOS.Click += (s, e) =>
            {
                if (ServerController.isWebServerStarted)
                {
                    LaunchChromeBrowser();
                }
                else
                {
                    MessageBox.Show("Local POS is not started. Please restart the program, and download new version of POS and try again."
                                    , "POS Not Started"
                                    , MessageBoxButtons.OK
                                    , MessageBoxIcon.Error);
                }
            };

            // event handler for btn minimize
            frmConfig.btnMinimize.Click += (s, e) =>
            {
                frmConfig.Hide();
                frmConfig.Dispose();
            };

            // init the combo boxes
            foreach (string printerName in PrinterSettings.InstalledPrinters)
            {
                frmConfig.cmbPrinters.Items.Add(printerName);
            }
            foreach (string port in SerialPort.GetPortNames())
            {
                frmConfig.cmdDrawers.Items.Add(port);
            }

            frmConfig.RefreshFormConponentsState();

            // show the form
            frmConfig.Show();
        }