Exemplo n.º 1
0
 public MainWindow()
 {
     foreach (string s in App.Arguments)
     {
         if (s == "-FS")
         {
             FullScreen = false;
         }
         if (s == "-SI")
         {
             Silent = true;
         }
         if (s == "-SL")
         {
             ShowLog = true;
         }
     }
     InitializeComponent();
     foInputText          = new InputText();
     foServerSettings     = new ServerSettings();
     foWhiteScreen        = new WhiteScreen();
     foPrintTemplate      = new PrintTemplate();
     foTurnsVizualization = new TurnsVizualization();
     foDays            = new Days();
     client            = new Client_Terminal();
     lbLog.ItemsSource = client.Log;
     client.Log.Add("Клиент включен.");
     if (ShowLog)
     {
         lbLog.Visibility = Visibility.Visible;
     }
     client.cbClientPrint            = ClientPrint;
     client.cbShowMessage            = ShowMessage;
     client.cbConnectErrorHideScreen = HideScreen;
     if (!FullScreen)
     {
         this.WindowState = System.Windows.WindowState.Normal;
         this.ResizeMode  = System.Windows.ResizeMode.CanResize;
         this.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
         foTurnsVizualization.WindowState = System.Windows.WindowState.Normal;
         foTurnsVizualization.ResizeMode  = System.Windows.ResizeMode.NoResize;
         foInputText.WindowState          = System.Windows.WindowState.Normal;
         foInputText.ResizeMode           = System.Windows.ResizeMode.NoResize;
         foWhiteScreen.WindowState        = System.Windows.WindowState.Normal;
         foWhiteScreen.ResizeMode         = System.Windows.ResizeMode.NoResize;
         foDays.WindowState = System.Windows.WindowState.Normal;
         foDays.ResizeMode  = System.Windows.ResizeMode.NoResize;
     }
 }
Exemplo n.º 2
0
        private void ClientPrint()
        {
            foreach (Turn t in client.turns)
            {
                if (t.Id == client.user.TurnId)
                {
                    t.Enabled = client.user.turnEnabled;
                }
            }
            string timeToPrint = "00:00:00";

            if (client.user.StatusTime.IndexOf(".") > -1)
            {
                timeToPrint = client.user.StatusTime.Substring(0, client.user.StatusTime.IndexOf(".") - 3);
            }
            else
            {
                timeToPrint = client.user.StatusTime.Substring(0, client.user.StatusTime.Length - 3);
            }

            if (client.IsComPrinter)
            {
                // PRINT TO SERIAL (COM-PORT)
                try
                {
                    // generate string
                    string dataToPrint = CP866 + FONT_A + "------------------------" + CR +
                                         CR +
                                         CR +
                                         FONT_B_DH_DW_B + "Ваш номер в очереди:" + CR +
                                         CR +
                                         FONT_A_DH_DW_B + " " + client.user.TurnPrefix + " " + client.user.Index + CR +
                                         CR +
                                         CR +
                                         FONT_B_DH_DW_B + client.user.TurnLine + CR +
                                         CR +
                                         CR +
                                         FONT_A_DH_DW + "КЛИЕНТ-ID: " + client.user.Id + CR +
                                         CR +
                                         CR +
                                         FONT_B_DH_DW_B + "ВРЕМЯ: " + timeToPrint + CR +
                                         CR +
                                         CR +
                                         FONT_B_DH_DW_B + " СОХРАНЯЙТЕ ТАЛОН!" + CR +
                                         CR + CR +
                                         "------------------------" +
                                         CR + CR +
                                         CR + CR +
                                         CUT;
                    // create serial if null
                    if (client.Serial == null)
                    {
                        client.Serial = new System.IO.Ports.SerialPort(client.ComPort, client.ComBaudRate);
                        client.Serial.WriteTimeout = 500;
                    }
                    // connect serial
                    client.Serial.Open();
                    // write to serial
                    client.Serial.Write(dataToPrint);
                    // close serial
                    client.Serial.Close();
                    System.Threading.Thread.Sleep(2000);
                }
                catch (Exception ex)
                {
                    client.LogAdd(ex.Message);
                }
                finally
                {
                    if (client.Serial.IsOpen)
                    {
                        client.Serial.Close();
                    }
                }
            }
            else
            {
                // MANUAL PRINT
                foPrintTemplate = new PrintTemplate();
                foPrintTemplate.laId.Content        = client.user.Id;
                foPrintTemplate.laNumber.Content    = client.user.TurnPrefix + client.user.Index;
                foPrintTemplate.laTime.Content      = timeToPrint;
                foPrintTemplate.lbInfos.ItemsSource = client.user.Infos;
                foPrintTemplate.tbTurnName.Text     = client.user.TurnLine;
                foPrintTemplate.RefreshSize();
                foPrintTemplate.Show();
                System.Threading.Thread.Sleep(2000);
                // Увеличить вывод в 5 раз
                PrintDialog printDialog = new PrintDialog();
                foPrintTemplate.grMain.LayoutTransform = new ScaleTransform(5, 5);
                // Напечатать элемент
                printDialog.PrintVisual(foPrintTemplate.grMain, "Печать чека" + client.user.TurnPrefix + client.user.Index);
                // Удалить трансформацию и снова сделать элемент видимым
                foPrintTemplate.grMain.LayoutTransform = null;
                foPrintTemplate.Hide();
            }
            ResetButtons();
            client.user = new User();
        }