public static void SendCommandsWithProgressBarInternal(byte[] commands, string portName, string portSettings, int timeout, bool checkCondition, bool showResult)
        {
            CommunicationResult result = new CommunicationResult();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                if (checkCondition)
                {
                    result = SendCommands(commands, portName, portSettings, timeout);
                }
                else
                {
                    result = SendCommandsDoNotCheckCondition(commands, portName, portSettings, timeout);
                }
            });

            progressBarWindow.ShowDialog();

            if (!showResult &&
                result.Result == Result.Success)
            {
                return;
            }

            ShowCommunicationResultMessage(result);
        }
        private void ApplyBluetoothSettingsWithProgressBar()
        {
            string errorMessage = null;

            LoadSettingsFromUI();

            string caption, message;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                errorMessage = ApplyBluetoothSettings();
            });

            progressBarWindow.ShowDialog();

            if (errorMessage == null)
            {
                caption = "Complete";
                message = "To apply settings, please turn the device power OFF and ON, and establish pairing again.";
            }
            else
            {
                caption = "Error";
                message = errorMessage;

                SetAllFunctionDisable();
            }

            MessageBox.Show(message, caption);
        }
Exemplo n.º 3
0
        public static void SendCommandsWithProgressBarInternal(byte[] commands, IPort port, bool checkCondition, bool showResult)
        {
            CommunicationResult result = CommunicationResult.ErrorUnknown;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                if (checkCondition)
                {
                    result = SendCommands(commands, port);
                }
                else
                {
                    result = SendCommandsDoNotCheckCondition(commands, port);
                }
            });

            progressBarWindow.ShowDialog();

            if (!showResult &&
                result == CommunicationResult.Success)
            {
                return;
            }

            ShowCommunicationResultMessage(result);
        }
        private Communication.PeripheralStatus CallFunctionWithProgressBar(SelectSettingWindow windowResult)
        {
            Communication.PeripheralStatus result = Communication.PeripheralStatus.Invalid;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = Communication.PeripheralStatus.Impossible;

                IPort port = null;

                try
                {
                    string portName     = SharedInformationManager.SelectedPortName;
                    string portSettings = SharedInformationManager.SelectedPortSettings;

                    port = Factory.I.GetPort(portName, portSettings, 30000);

                    result = CallFunction(windowResult, port);
                }
                catch (PortException)
                {
                }
                finally
                {
                    if (port != null)
                    {
                        Factory.I.ReleasePort(port);
                    }
                }
            });

            progressBarWindow.ShowDialog();

            return(result);
        }
        private void PrintReceiptViaPrinterDriverWithProgressBar()
        {
            string portName = SharedInformationManager.GetSelectedPortName();

            PrintQueue[]    printQueues     = starPrintPortJobMonitor.PrintQueues;
            LocalizeReceipt localizeReceipt = SharedInformationManager.GetSelectedLocalizeReceipt();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                Thread thread = new Thread(
                    () =>
                {
                    foreach (PrintQueue printQueue in printQueues)
                    {
                        PrinterDriverManager.PrintViaPrinterDriver(printQueue, localizeReceipt.CreateRasterImageText(), localizeReceipt.RasterReceiptFont);
                    }
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
            });

            progressBarWindow.ShowDialog();

            Util.FocusMainWindow();
        }
        public static void PrintLocalizeReceiptWithAllReceipts(ReceiptInformationManager receiptInfo)
        {
            CommunicationResult result = new CommunicationResult();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                // Create print receipt with AllReceipts commands.
                byte[] commands = CreateLocalizeReceiptWithAllReceiptsCommands(receiptInfo);

                if (commands == null) // All print settings (Receipt, Information, QR Code) are OFF.
                {
                    result.Result = Communication.Result.Success;
                    result.Code   = StarResultCode.Succeeded;

                    return;
                }

                // Your printer PortName and PortSettings.
                string portName     = SharedInformationManager.SelectedPortName;
                string portSettings = SharedInformationManager.SelectedPortSettings;

                // Send commands to printer
                result = Communication.SendCommands(commands, portName, portSettings, 30000);
            });

            progressBarWindow.ShowDialog();

            Communication.ShowCommunicationResultMessage(result);
        }
Exemplo n.º 7
0
        private void PrintReceipt()
        {
            lock (lockObject)
            {
                CommunicationResult result = new CommunicationResult();

                ReceiptInformationManager receiptInfo = SharedInformationManager.ReceiptInformationManager;

                ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
                {
                    byte[] commands = AllReceiptsSampleManager.CreateLocalizeReceiptWithAllReceiptsCommands(receiptInfo);

                    if (commands == null) // All print settings (Receipt, Information, QR Code) are OFF.
                    {
                        result.Result = Communication.Result.Success;
                        result.Code   = StarResultCode.Succeeded;

                        return;
                    }

                    result = Communication.SendCommands(commands, port);
                });

                progressBarWindow.ShowDialog();

                Communication.ShowCommunicationResultMessage(result);
            }
        }
        private void ReloadDeviceInformationWithProgressBar()
        {
            DeviceStatusListBox.ItemsSource        = null;
            FirmwareInformationListBox.ItemsSource = null;

            StarPrinterStatus           status = null;
            Dictionary <string, string> firmwareInformation = null;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                status = GetDeviceStatus();
                if (status == null)
                {
                    return;
                }

                firmwareInformation = GetFirmwareInformation();
            });

            progressBarWindow.ShowDialog();

            if (status == null && firmwareInformation == null) // Communication failure.
            {
                Util.ShowMessage("Error", "Communication error");

                return;
            }

            // Parse printer status.
            ParsePrinterStatus(status, SharedInformationManager.GetDrawerOpenStatus());

            // Parse firmware information.
            ParseFirmwareInformation(firmwareInformation);
        }
Exemplo n.º 9
0
        private void ConnectWithProgressBar()
        {
            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                Connect();
            });

            progressBarWindow.ShowDialog();
        }
Exemplo n.º 10
0
        private void PlayRegisteredSoundWithProgressBar()
        {
            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                PlayRegisteredSound();
            });

            progressBarWindow.ShowDialog();
        }
Exemplo n.º 11
0
        private void PlaySoundDataWithProgressBar()
        {
            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                PlaySoundData();
            });

            progressBarWindow.ShowDialog();
        }
Exemplo n.º 12
0
        private void DisconnectWithProgressBar()
        {
            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Disconneting Printer...", () =>
            {
                Disconnect();
            });

            progressBarWindow.ShowDialog();
        }
        public static CommunicationResult SetUSBSerialNumberWithProgressBar(byte[] serialNumber, bool isEnabled, IPort port)
        {
            CommunicationResult result = new CommunicationResult();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = SetUSBSerialNumber(serialNumber, isEnabled, port);
            });

            progressBarWindow.ShowDialog();

            return(result);
        }
        public static CommunicationResult InitializeUSBSerialNumberWithProgressBar(bool isEnabled, string portName, string portSettings, int timeout)
        {
            CommunicationResult result = new CommunicationResult();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = InitializeUSBSerialNumber(isEnabled, portName, portSettings, timeout);
            });

            progressBarWindow.ShowDialog();

            return(result);
        }
Exemplo n.º 15
0
        public static Communication.CommunicationResult ParseDoNotCheckConditionWithProgressBar(IPeripheralCommandParser parser, IPort port)
        {
            Communication.CommunicationResult result = Communication.CommunicationResult.ErrorUnknown;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = ParseDoNotCheckCondition(parser, port);
            });

            progressBarWindow.ShowDialog();

            return(result);
        }
Exemplo n.º 16
0
        public List <PortInfo> SearchPrinterWithProgressBar()
        {
            List <PortInfo> portInfoList = new List <PortInfo>();

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                portInfoList = SearchPrinterWithAllInterface();
            });

            progressBarWindow.ShowDialog();

            return(portInfoList);
        }
        private void CallDisplayFunctionWithProgressBar(DisplayFunctionManager.FunctionType type, int selectedIndex)
        {
            Communication.PeripheralStatus result = Communication.PeripheralStatus.Invalid;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = CallDisplayFunction(type, selectedIndex);
            });

            progressBarWindow.ShowDialog();

            if (result != Communication.PeripheralStatus.Connect)
            {
                Communication.ShowPeripheralStatusResultMessage("Display", result);
            }
        }
        private void SendUnitChangeCommandsWithProgressBar()
        {
            Communication.PeripheralStatus result = Communication.PeripheralStatus.Invalid;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = SendUnitChangeCommands();
            });

            progressBarWindow.ShowDialog();

            if (result != Communication.PeripheralStatus.Connect)
            {
                Communication.ShowPeripheralStatusResultMessage("Scale", result);
            }
        }
Exemplo n.º 19
0
        public static CommunicationResult GetSerialNumberWithProgressBar(ref string serialNumber, IPort port)
        {
            CommunicationResult result = CommunicationResult.ErrorUnknown;

            string temp = "";

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = GetSerialNumber(ref temp, port);
            });

            progressBarWindow.ShowDialog();

            serialNumber = temp;

            return(result);
        }
        public static CommunicationResult GetProductSerialNumberWithProgressBar(ref string serialNumber, string portName, string portSettings, int timeout)
        {
            CommunicationResult result = new CommunicationResult();

            string temp = "";

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                result = GetProductSerialNumber(ref temp, portName, portSettings, timeout);
            });

            progressBarWindow.ShowDialog();

            serialNumber = temp;

            return(result);
        }
        public static void SendCommandsForRedirectionWithProgressBar(byte[] commands, string[] portNameArray, string[] portSettingsArray, int[] timeoutMillisArray)
        {
            CommunicationResult[] results = (CommunicationResult[])Enumerable.Empty <CommunicationResult>();;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                results = SendCommandsForRedirection(commands, portNameArray, portSettingsArray, timeoutMillisArray);
            });

            progressBarWindow.ShowDialog();

            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < results.Length; i++)
            {
                if (i == 0)
                {
                    builder.Append("[Destination]");
                }
                else
                {
                    builder.Append("[Backup]");
                }

                builder.Append(Environment.NewLine);
                builder.Append("Port Name : ");
                builder.Append(portNameArray[i]);
                builder.Append(" ->");
                builder.Append(Environment.NewLine);
                builder.Append(GetCommunicationResultMessage(results[i]));

                if (i != results.Length - 1)
                {
                    builder.Append(Environment.NewLine);
                    builder.Append(Environment.NewLine);
                }
            }

            MessageBox.Show(builder.ToString(), "Communication Result");
        }
Exemplo n.º 22
0
        public static Communication.PeripheralStatus CallScaleFunctionWithProgressBar(CallScaleFunctionClickEvent.ScallFunctionType type, ref DisplayedWeightStatus weightStatus, ref string weight)
        {
            Communication.PeripheralStatus result = Communication.PeripheralStatus.Invalid;

            DisplayedWeightStatus tempWeightStatus = DisplayedWeightStatus.Invalid;
            string tempWeight = "";

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                IPort port = null;

                try
                {
                    string portName     = SharedInformationManager.GetSelectedPortName();
                    string portSettings = SharedInformationManager.GetSelectedPortStrrings();

                    port = Factory.I.GetPort(portName, portSettings, 30000);

                    result = CallScaleFunction(type, port, ref tempWeightStatus, ref tempWeight);
                }
                catch (PortException)
                {
                }
                finally
                {
                    if (port != null)
                    {
                        Factory.I.ReleasePort(port);
                    }
                }
            });

            progressBarWindow.ShowDialog();

            weightStatus = tempWeightStatus;
            weight       = tempWeight;

            return(result);
        }
        private void GetBluetoothSettingsWithProgressBar()
        {
            string errorMessage = null;

            ProgressBarWindow progressBarWindow = new ProgressBarWindow("Communicating...", () =>
            {
                errorMessage = GetBluetoothSettings();
            });

            progressBarWindow.ShowDialog();

            if (errorMessage == null)
            {
                ShowBlueoothSettings();
            }
            else
            {
                MessageBox.Show(errorMessage, "Error");

                SetAllFunctionDisable();
            }
        }