public static void PrintLocalizeReceiptWithAllReceipts(ReceiptInformationManager receiptInfo)
        {
            Communication.CommunicationResult result = Communication.CommunicationResult.ErrorUnknown;

            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 = Communication.CommunicationResult.Success;

                    return;
                }

                // Your printer PortName and PortSettings.
                string portName     = SharedInformationManager.GetSelectedPortName();
                string portSettings = SharedInformationManager.GetSelectedPortStrrings();

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

            progressBarWindow.ShowDialog();

            Communication.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.GetSelectedPortName();
                    string portSettings = SharedInformationManager.GetSelectedPortStrrings();

                    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);
        }
        /// <summary>
        /// Sample : Monitoring printer process.
        /// </summary>
        private void MonitoringPrinter()
        {
            while (true)
            {
                lock (lockObject)
                {
                    try
                    {
                        if (port != null)
                        {
                            StarPrinterStatus status = port.GetParsedStatus();

                            // Your printer cash drawer open status.
                            bool cashDrawerOpenActiveHigh = SharedInformationManager.GetDrawerOpenStatus();

                            if (status.CompulsionSwitch == cashDrawerOpenActiveHigh) // Cash drawer open
                            {
                                OnCashDrawerOpen();
                            }
                            else
                            {
                                OnCashDrawerClose();                                 // Cash drawer close
                            }
                        }
                    }
                    catch (Exception) // Printer impossible
                    {
                        OnPrinterImpossible();
                    }

                    Thread.Sleep(1000);
                }
            }
        }
Esempio n. 4
0
        public static void Print(byte[] commands)
        {
            string portName     = SharedInformationManager.GetSelectedPortName();
            string portSettings = SharedInformationManager.GetSelectedPortStrrings();

            Communication.SendCommandsWithProgressBar(commands, portName, portSettings, 30000);
        }
        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);
        }
Esempio n. 6
0
        /// <summary>
        /// Sample : Display character set code page type.
        /// </summary>
        public static Communication.PeripheralStatus DoCharacterSetCodePagePattern(DisplayCodePageType codePageType, IPort port)
        {
            // Check display status.
            Communication.PeripheralStatus status = GetDiaplayStatus(port);

            if (status != Communication.PeripheralStatus.Connect) // Display is not connected.
            {
                return(status);
            }

            // Select character set.
            DisplayInternationalType internationalType = SharedInformationManager.GetSelectedInternationalType();

            // Create display commands.
            byte[] displayCommands = DisplayFunctions.CreateCharacterSet(internationalType, codePageType);

            // Send display commands.
            Communication.CommunicationResult result = Communication.SendCommandsDoNotCheckCondition(displayCommands, port);

            if (result != Communication.CommunicationResult.Success)
            {
                return(Communication.PeripheralStatus.Impossible);
            }
            else
            {
                return(Communication.PeripheralStatus.Connect);
            }
        }
Esempio n. 7
0
        public void AppendTextReceiptData(ICommandBuilder builder, bool utf8)
        {
            switch (PaperSize.Type)
            {
            default:
            case PaperSize.PaperSizeType.TwoInch:
                Append2inchTextReceiptData(builder, utf8);
                break;

            case PaperSize.PaperSizeType.ThreeInch:
                switch (SharedInformationManager.GetSelectedEmulation())
                {
                case Emulation.EscPos:
                case Emulation.EscPosMobile:
                    AppendEscPos3inchTextReceiptData(builder, utf8);
                    break;

                case Emulation.StarDotImpact:
                    AppendDotImpact3inchTextReceiptData(builder, utf8);
                    break;

                default:
                    Append3inchTextReceiptData(builder, utf8);
                    break;
                }
                break;

            case PaperSize.PaperSizeType.FourInch:
                Append4inchTextReceiptData(builder, utf8);
                break;
            }
        }
        /// <summary>
        /// Sample : Monitoring barcode reader process.
        /// </summary>
        private void MonitoringBarcodeReader()
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            while (true)
            {
                lock (lockObject)
                {
                    try
                    {
                        if (port != null)
                        {
                            CheckBarcodeReaderStatus();                                        // Check barcode reader status. (connect or disconnect)

                            if (barcodeReaderStatus == Communication.PeripheralStatus.Connect) // Barcode reader is connected.
                            {
                                ReadBarcodeReaderData();                                       // Read barcode reader data.
                            }
                        }
                    }
                    catch (PortException)
                    {
                        OnBarcodeReaderImpossible();
                    }
                }

                Thread.Sleep(100);
            }
        }
        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();
        }
        /// <summary>
        /// Sample : Starting monitoring scale.
        /// </summary>
        public void Connect()
        {
            try
            {
                if (port == null)
                {
                    // Your printer PortName and PortSettings.
                    string portName     = SharedInformationManager.GetSelectedPortName();
                    string portSettings = SharedInformationManager.GetSelectedPortStrrings();

                    port = Factory.I.GetPort(portName, portSettings, 10000);
                }
            }
            catch (PortException) // Port open is failed.
            {
                DidConnectFailed();

                return;
            }

            try
            {
                if (monitoringScaleThread == null || monitoringScaleThread.ThreadState == ThreadState.Stopped)
                {
                    monitoringScaleThread              = new Thread(MonitoringScale);
                    monitoringScaleThread.Name         = "MonitoringScaleThread";
                    monitoringScaleThread.IsBackground = true;
                    monitoringScaleThread.Start();
                }
            }
            catch (Exception) // Start monitoring display thread is failure.
            {
                DidConnectFailed();
            }
        }
Esempio n. 11
0
        public string CreateRasterImageText()
        {
            string rasterImageText;

            switch (PaperSize.Type)
            {
            default:
            case PaperSize.PaperSizeType.TwoInch:
                rasterImageText = Create2inchBitmapSourceText();
                break;

            case PaperSize.PaperSizeType.ThreeInch:
                switch (SharedInformationManager.GetSelectedEmulation())
                {
                case Emulation.EscPos:
                case Emulation.EscPosMobile:
                case Emulation.StarDotImpact:
                    rasterImageText = CreateEscPos3inchBitmapSourceText();
                    break;

                default:
                    rasterImageText = Create3inchBitmapSourceText();
                    break;
                }
                break;

            case PaperSize.PaperSizeType.FourInch:
                rasterImageText = Create4inchBitmapSourceText();
                break;
            }

            return(rasterImageText);
        }
        /// <summary>
        /// Sample : Sending commands to printer.
        /// </summary>
        public static void Print(byte[] commands)
        {
            // Your printer PortName and PortSettings.
            string portName     = SharedInformationManager.GetSelectedPortName();
            string portSettings = SharedInformationManager.GetSelectedPortStrrings();

            // Sending commands to printer sample is "Communication.SendCommands(byte[] commands, string portName, string portSettings, int timeout)".
            Communication.SendCommandsWithProgressBar(commands, portName, portSettings, 30000);
        }
        /// <summary>
        /// Sample : Monitoring printer process.
        /// </summary>
        private void MonitoringPrinter()
        {
            uint tickCount = (uint)Environment.TickCount;

            while (true)
            {
                // Check printer status is changed for update status to Star Cloud Services.
                isChangeStatus = false;

                lock (lockObject)
                {
                    try
                    {
                        if (port != null)
                        {
                            StarPrinterStatus status = port.GetParsedStatus();

                            // if printer status is changed "isChangeStatus" comes true.
                            CheckPrinterStatus(status); // Check printer status.

                            CheckPaperStatus(status);   // Check paper status.

                            CheckCoverStatus(status);   // Check cover status.

                            // Your printer cash drawer open status.
                            bool cashDrawerOpenActiveHigh = SharedInformationManager.GetDrawerOpenStatus();
                            CheckCashDrawerStatus(status, cashDrawerOpenActiveHigh);  // Check cash drawer status.
                        }
                    }
                    catch (Exception) // Printer impossible
                    {
                        OnPrinterImpossible();
                    }
                    finally
                    {
                        // if printer status is not changed for some times, update status.
                        if ((UInt32)Environment.TickCount - tickCount >= 300000)
                        {
                            isChangeStatus = true;
                        }

                        // if printer status is changed, upload printer status to Star Cloud Services.
                        if (isChangeStatus)
                        {
                            OnStatusUpdated();
                        }

                        tickCount = (UInt32)Environment.TickCount;
                    }

                    Thread.Sleep(1000);
                }
            }
        }
Esempio n. 14
0
        public App()
        {
            SharedInformationManager.SelectedModelManager = new SelectedModelManager();

            SharedInformationManager.ReceiptInformationManager = new ReceiptInformationManager();

            SharedInformationManager.DisplayFunctionManager = new DisplayFunctionManager();

            SharedInformationManager.AllReceiptsInfoManager = new AllReceiptsInfoManager();

            SharedInformationManager.RestorePreviousInfo();
        }
        private static string SetRegistrationConfigFilePath()
        {
            string filePath = ShowSelectXmlFileDialog();

            if (filePath == null)
            {
                return(null);
            }

            SharedInformationManager.SetAllReceiptsRegistrationFilePath(filePath);

            return(filePath);
        }
Esempio n. 16
0
        private void CheckCashDrawer(StarPrinterStatus status)
        {
            // Your printer cash drawer open status.
            bool cashDrawerOpenActiveHigh = SharedInformationManager.GetDrawerOpenStatus();

            if (status.CompulsionSwitch == cashDrawerOpenActiveHigh) // Cash drawer open
            {
                OnCashDrawerOpen();
            }
            else
            {
                OnCashDrawerClose();                                 // Cash drawer close
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Sample : Creating printing receipt and open cash drawer commands.
        /// </summary>
        private byte[] CreateLocalizeReceiptAndOpenCashDrawerCommands(ReceiptInformationManager receiptInfo)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // print paper size
            int paperSize = SharedInformationManager.GetSelectedActualPaperSize();

            // Creating localize receipt commands sample is in "LocalizeReceipts/'Language'Receipt.cs"
            ReceiptInformationManager.ReceiptType type = receiptInfo.Type;
            LocalizeReceipt localizeReceipt            = receiptInfo.LocalizeReceipt;

            byte[] commands;

            switch (type)
            {
            default:
            case ReceiptInformationManager.ReceiptType.Text:
                commands = CombinationFunctions.CreateTextReceiptData(emulation, localizeReceipt, false);
                break;

            case ReceiptInformationManager.ReceiptType.TextUTF8:
                commands = CombinationFunctions.CreateTextReceiptData(emulation, localizeReceipt, true);
                break;

            case ReceiptInformationManager.ReceiptType.Raster:
                commands = CombinationFunctions.CreateRasterReceiptData(emulation, localizeReceipt);
                break;

            case ReceiptInformationManager.ReceiptType.RasterBothScale:
                commands = CombinationFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, true);
                break;

            case ReceiptInformationManager.ReceiptType.RasterScale:
                commands = CombinationFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, false);
                break;

            case ReceiptInformationManager.ReceiptType.RasterCoupon:
                commands = CombinationFunctions.CreateCouponData(emulation, localizeReceipt, paperSize, BitmapConverterRotation.Normal);
                break;

            case ReceiptInformationManager.ReceiptType.RasterCouponRotation90:
                commands = CombinationFunctions.CreateCouponData(emulation, localizeReceipt, paperSize, BitmapConverterRotation.Right90);
                break;
            }

            return(commands);
        }
Esempio n. 18
0
        /// <summary>
        /// Sample : Sending API commands to printer.
        /// </summary>
        public static void SendAPICommands(APIManager.APIType type)
        {
            byte[] commands = CreateAPICommands(type);

            if (commands == null)
            {
                return;
            }

            // Your printer PortName and PortSettings.
            string portName     = SharedInformationManager.GetSelectedPortName();
            string portSettings = SharedInformationManager.GetSelectedPortStrrings();

            // Sending commands to printer sample is "Communication.SendCommands(byte[] commands, string portName, string portSettings, int timeout)".
            Communication.SendCommandsWithProgressBar(commands, portName, portSettings, 30000);
        }
        private void SetPrinterManually()
        {
            string[] settings = ShowManualSettingWindow();

            if (settings == null)
            {
                return;
            }

            ModelInformation modelInformation = ShowSelectModelWindow();

            if (modelInformation == null)
            {
                return;
            }

            if (modelInformation.ChangeDrawerOpenStatusIsEnabled)
            {
                bool?drawerOpenStatus = ShowSelectDrawerOpenStatusWindow();

                if (drawerOpenStatus == null)
                {
                    return;
                }

                modelInformation.DrawerOpenStatus = (bool)drawerOpenStatus;
            }
            else
            {
                modelInformation.DrawerOpenStatus = true;
            }

            string portName = settings[0];

            string portSettings = settings[1];

            modelInformation.PortSettings = portSettings;

            PortInfo portInfo = new PortInfo(portName, "", modelInformation.SimpleModelName, "");

            SharedInformationManager.SetSelectedModelInformation(modelInformation);

            SharedInformationManager.SetSelectedPortInfo(portInfo);

            Util.GoBackMainPage();
        }
        /// <summary>
        /// Sample : Getting device status.
        /// </summary>
        private StarPrinterStatus GetDeviceStatus()
        {
            // Your printer PortName and PortSettings.
            string portName     = SharedInformationManager.GetSelectedPortName();
            string portSettings = SharedInformationManager.GetSelectedPortStrrings();

            StarPrinterStatus status = null;

            Communication.CommunicationResult communicationResult = Communication.RetrieveStatus(ref status, portName, portSettings, 30000);

            if (communicationResult != Communication.CommunicationResult.Success)
            {
                return(null);
            }

            return(status);
        }
        /// <summary>
        /// Sample : Setting StarPrintJobMonitor object.
        /// </summary>
        private void SetStarPrintPortJobMonitor()
        {
            // Your printer PortName.
            string portName = SharedInformationManager.GetSelectedPortName();

            // Create StarPrintJobMonitor object.
            starPrintPortJobMonitor = new StarPrintPortJobMonitor(portName);
            starPrintPortJobMonitor.PrintQueueJobIsAdded          += OnPrintQueueJobIsAdded;          // Add called event when printer queue job is added.
            starPrintPortJobMonitor.PrintQueueJobIsRemoved        += OnPrintQueueJobIsRemoved;        // Add called event when printer queue job is added.
            starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted; // Add called event when printer queue all jobs are completed.
            PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;                                  // Can get current printer queue job count.

            // start printer queue job monitoring.
            starPrintPortJobMonitor.Start();

            //starPrintPortJobMonitor.Stop(); // if you would like stop monitoring job call this method.
        }
        /// <summary>
        /// Sample : Creating printing receipt with AllReceipts commands.
        /// </summary>
        public static byte[] CreateLocalizeReceiptWithAllReceiptsCommands(ReceiptInformationManager receiptInfo)
        {
            byte[] commands;

            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // print paper size
            int paperSize = receiptInfo.ActualPaperSize;

            // Creating localize receipt commands sample is in "LocalizeReceipts/'Language'Receipt.cs"
            ReceiptInformationManager.ReceiptType type = receiptInfo.Type;
            LocalizeReceipt localizeReceipt            = receiptInfo.LocalizeReceipt;

            // Select printing contents.
            bool printReceipt     = SharedInformationManager.GetAllReceiptsPrintReceipt();
            bool printInformation = SharedInformationManager.GetAllReceiptsPrintInformation();
            bool printQrCode      = SharedInformationManager.GetAllReceiptsPrintQrCode();

            switch (type)
            {
            default:
            case ReceiptInformationManager.ReceiptType.Text:
                commands = AllReceiptsFunctions.CreateTextReceiptData(emulation, localizeReceipt, paperSize, false, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.TextUTF8:
                commands = AllReceiptsFunctions.CreateTextReceiptData(emulation, localizeReceipt, paperSize, true, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.Raster:
                commands = AllReceiptsFunctions.CreateRasterReceiptData(emulation, localizeReceipt, paperSize, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.RasterBothScale:
                commands = AllReceiptsFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, true, printReceipt, printInformation, printQrCode);
                break;

            case ReceiptInformationManager.ReceiptType.RasterScale:
                commands = AllReceiptsFunctions.CreateScaleRasterReceiptData(emulation, localizeReceipt, paperSize, false, printReceipt, printInformation, printQrCode);
                break;
            }

            return(commands);
        }
Esempio n. 23
0
        /// <summary>
        /// Sample : Creating printing receipt with page mode commands.
        /// </summary>
        public static byte[] CreateLocalizeReceiptWithPageModeCommands(ReceiptInformationManager receiptInfo)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // Creating localize receipt commands sample is in "LocalizeReceipts/'Language'Receipt.cs"
            LocalizeReceipt localizeReceipt = receiptInfo.LocalizeReceipt;

            // Image height.
            int height = 30 * 8;

            // Image width.
            int width = SharedInformationManager.GetSelectedActualPaperSize();

            // Image rotation.
            BitmapConverterRotation rotation = receiptInfo.Rotation;

            // Print region.
            Rectangle printRegion;

            switch (rotation)
            {
            default:
            case BitmapConverterRotation.Normal:
                printRegion = new Rectangle(0, 0, width, height);
                break;

            case BitmapConverterRotation.Right90:
                printRegion = new Rectangle(0, 0, width, width);
                break;

            case BitmapConverterRotation.Rotate180:
                printRegion = new Rectangle(0, 0, width, height);
                rotation    = BitmapConverterRotation.Rotate180;
                break;

            case BitmapConverterRotation.Left90:
                printRegion = new Rectangle(0, 0, height, width);
                break;
            }

            byte[] commands = PrinterFunctions.CreateTextPageModeData(emulation, localizeReceipt, printRegion, rotation, false);

            return(commands);
        }
Esempio n. 24
0
        /// <summary>
        /// Sample : Creating printing paste text with black mark commands.
        /// </summary>
        private byte[] CreatePrintBlackMarkPasteTextCommands(string pasteText)
        {
            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // Creating localize receipt commands sample is in "LocalizeReceipts/'Language'Receipt.cs"
            LocalizeReceipt localizeReceipt = SharedInformationManager.GetSelectedLocalizeReceipt();

            // Select using double height.
            bool doubleHeight = (bool)DoubleHeightCheckBox.IsChecked;

            // Select black mark type.
            BlackMarkType blackMarkType = SharedInformationManager.GetSelectedBlackMarkType();

            byte[] commands = PrinterFunctions.CreatePasteTextBlackMarkData(emulation, localizeReceipt, pasteText, doubleHeight, blackMarkType, false);

            return(commands);
        }
        /// <summary>
        /// Sample : Getting firmware information.
        /// </summary>
        private Dictionary <string, string> GetFirmwareInformation()
        {
            // Your printer PortName and PortSettings.
            string portName     = SharedInformationManager.GetSelectedPortName();
            string portSettings = SharedInformationManager.GetSelectedPortStrrings();

            // Request firmware information.
            Dictionary <string, string> firmwareInformation = new Dictionary <string, string>();

            Communication.CommunicationResult communicationResult = Communication.RequestFirmwareInformation(ref firmwareInformation, portName, portSettings, 30000);

            if (communicationResult != Communication.CommunicationResult.Success)
            {
                return(null);
            }

            return(firmwareInformation);
        }
Esempio n. 26
0
        /// <summary>
        /// Sample : Starting monitoring printer.
        /// </summary>
        public void Connect()
        {
            try
            {
                if (port == null)
                {
                    // Your printer PortName and PortSettings.
                    string portName     = SharedInformationManager.GetSelectedPortName();
                    string portSettings = SharedInformationManager.GetSelectedPortStrrings();

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

                    // First, clear barcode reader buffer.
                    ClearBarcodeReaderBuffer();
                }
            }
            catch (PortException) // Port open is failed.
            {
                DidConnectFailed();

                return;
            }

            try
            {
                if (monitoringPrinterThread == null || monitoringPrinterThread.ThreadState == ThreadState.Stopped)
                {
                    monitoringPrinterThread              = new Thread(MonitoringPrinter);
                    monitoringPrinterThread.Name         = "MonitoringPrinterThread";
                    monitoringPrinterThread.IsBackground = true;
                    monitoringPrinterThread.Start();
                }
            }
            catch (Exception) // Start monitoring printer thread is failure.
            {
                DidConnectFailed();
            }

            currentPrinterStatus       = PrinterStatus.Invalid;
            currentPaperStatus         = PaperStatus.Invalid;
            currentCoverStatus         = CoverStatus.Invalid;
            currentCashDrawerStatus    = CashDrawerStatus.Invalid;
            currentBarcodeReaderStatus = Communication.PeripheralStatus.Invalid;
        }
        private void PortListBoxItem_Click(object sender, RoutedEventArgs e)
        {
            Button clickedButton = (Button)sender;

            PortInfo selectedPortInfo = (PortInfo)clickedButton.Tag;

            ModelInformation selectedModelInformation = DecideModel(selectedPortInfo);

            if (selectedModelInformation == null)
            {
                return;
            }

            SharedInformationManager.SetSelectedModelInformation(selectedModelInformation);

            SharedInformationManager.SetSelectedPortInfo(selectedPortInfo);

            Util.GoBackMainPage();
        }
        private void DisplayFunction_Updated(object sender, DataTransferEventArgs e)
        {
            DisplayFunctionManager.FunctionType type = SharedInformationManager.GetSelectedDisplayFunction();

            int selectedIndex = SharedInformationManager.GetDisplayFunctionDefaultPatternIndex();

            if (isConnect)
            {
                CallDisplayFunctionWithProgressBar(type, selectedIndex);
            }

            notCallFunction = true;

            SelectPatternComboBox.SelectedIndex = selectedIndex;

            SelectAdditionPatternComboBox.SelectedIndex = SharedInformationManager.GetDisplayFunctionDefaultAdditionPatternIndex();

            notCallFunction = false;
        }
        /// <summary>
        /// Sample : Printing photo from image file.
        /// </summary>
        public static void PrintPhotoFromLibrary()
        {
            // Get printing file path.
            string filePath = ShowSelectImageFileDialog();

            if (filePath == null)
            {
                return;
            }

            // Your printer emulation.
            Emulation emulation = SharedInformationManager.GetSelectedEmulation();

            // print paper size
            int paperSize = SharedInformationManager.GetSelectedActualPaperSize();

            byte[] commands = PrinterFunctions.CreateFileOpenData(emulation, filePath, paperSize);

            Print(commands);
        }
Esempio n. 30
0
        public static void ShowPrinterSerialNumber()
        {
            // Your printer PortName and PortSettings.
            string portName     = SharedInformationManager.GetSelectedPortName();
            string portSettings = SharedInformationManager.GetSelectedPortStrrings();

            string serialNumber = "";

            // Getting printer serial number is "Communication.GetSerialNumber(ref string serialNumber, IPort port)".
            Communication.CommunicationResult result = Communication.GetSerialNumberWithProgressBar(ref serialNumber, portName, portSettings, 30000);

            if (result == Communication.CommunicationResult.Success)
            {
                Util.ShowMessage("Serial Number", serialNumber);
            }
            else
            {
                Communication.ShowCommunicationResultMessage(result);
            }
        }