Esempio n. 1
0
        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;
            }

            SetModelInformation(selectedModelInformation);

            SetPortInfo(selectedPortInfo);

            if (SourceUri == null)
            {
                Util.GoBackMainPage();
            }
            else
            {
                Util.JumpPage(SourceUri);
            }
        }
        private static void SaveModelInfo(ModelInformation modelInfo)
        {
            Properties.Settings.Default.SelectedModelIndex = (int)modelInfo.Model;
            Properties.Settings.Default.PortSettings       = modelInfo.PortSettings;

            Properties.Settings.Default.Save();
        }
Esempio n. 3
0
        public static void RestorePreviousInfo()
        {
            if (!IsSavedAllPrinterSettings())
            {
                return;
            }

            List <PortInfo>         portInfoList         = new List <PortInfo>();
            List <ModelInformation> modelInformationList = new List <ModelInformation>();
            List <PaperSize>        paperSizeList        = new List <PaperSize>();

            for (int i = 0; i < Properties.Settings.Default.PortNames.Length; i++)
            {
                string portName        = Properties.Settings.Default.PortNames[i];
                string macAddress      = Properties.Settings.Default.MacAddresses[i];
                string modelName       = Properties.Settings.Default.ModelNames[i];
                string usbSerialNumber = Properties.Settings.Default.USBSerialNumbers[i];
                portInfoList.Add(new PortInfo(portName, macAddress, modelName, usbSerialNumber));

                int              selectedModelIndex = Properties.Settings.Default.SelectedModelIndexes[i];
                string           portSettings       = Properties.Settings.Default.PortSettings[i];
                bool             drawerOpenStatus   = Properties.Settings.Default.DrawerOpenStatuses[i];
                ModelInformation modelInformaiton   = new ModelInformation((PrinterModel)Enum.ToObject(typeof(PrinterModel), selectedModelIndex));
                modelInformaiton.PortSettings     = portSettings;
                modelInformaiton.DrawerOpenStatus = drawerOpenStatus;
                modelInformationList.Add(modelInformaiton);

                int papserSizeIndex = Properties.Settings.Default.SelectedPaperSizeIndexes[i];
                paperSizeList.Add(new PaperSize((PaperSizeType)Enum.ToObject(typeof(PaperSizeType), papserSizeIndex)));
            }

            SelectedAllPortInfo         = portInfoList.ToArray();
            SelectedAllModelInformation = modelInformationList.ToArray();
            SelectedAllPaperSizes       = paperSizeList.ToArray();
        }
Esempio n. 4
0
        private bool ShowModelConfirmWindow(PrinterModel model)
        {
            ModelInformation modelInformation = new ModelInformation(model);

            MessageBoxResult result = MessageBox.Show("Is your printer " + modelInformation.SimpleModelName + "?", "Confirm", MessageBoxButton.YesNo);

            return(result == MessageBoxResult.Yes);
        }
        private ModelInformation DecideModel(PortInfo portInfo)
        {
            ModelInformation.PrinterModel model = ModelFinder.FindPrinterModel(portInfo.ModelName);

            bool isDecideModel = false;

            if (model != ModelInformation.PrinterModel.Unknown)
            {
                isDecideModel = ShowModelConfirmWindow(model);
            }

            ModelInformation modelInformation;

            if (isDecideModel)
            {
                modelInformation = new ModelInformation(model);
            }
            else
            {
                modelInformation = ShowSelectModelWindow();
            }

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

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

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

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

            if (PortInfoManager.IsSerialPort(portInfo))
            {
                string portSettings = ShowManualPortSettingsWindowForSerialPort();

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

                modelInformation.PortSettings = portSettings;
            }

            return(modelInformation);
        }
Esempio n. 6
0
        private void SetPrinterManually()
        {
            string[] settings = ShowManualSettingWindow();

            if (settings == null)
            {
                return;
            }

            ModelInformation modelInformation = ShowSelectModelWindow();

            if (modelInformation == null)
            {
                return;
            }

            PaperSize selectedPaperSize = ShowSelectPaperSizeWindowIfNeed(modelInformation);

            if (selectedPaperSize == null)
            {
                return;
            }

            SetPaperSize(selectedPaperSize);

            if (modelInformation.ChangeCashDrawerPolarityIsEnabled)
            {
                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, "");

            SetModelInformation(modelInformation);

            SetPortInfo(portInfo);

            Util.GoBackMainPage();
        }
Esempio n. 7
0
        public static void SetSelectedModelInformation(ModelInformation modelInformation, int printerPriority)
        {
            List <ModelInformation> modelInformationList = new List <ModelInformation>(SelectedAllModelInformation);

            while (modelInformationList.Count < printerPriority + 1)
            {
                modelInformationList.Add(null);
            }

            modelInformationList[printerPriority] = modelInformation;

            SelectedAllModelInformation = modelInformationList.ToArray();
        }
        private bool ShowModelConfirmWindow(ModelInformation.PrinterModel model)
        {
            ModelInformation modelInformation = new ModelInformation(model);

            SelectSettingWindow confirmWindow = new SelectSettingWindow();

            confirmWindow.Title = "Confirm";
            confirmWindow.AcceptButtonContent = "Yes";
            confirmWindow.CancelButtonContent = "No";
            confirmWindow.SettingTitle        = "Is your printer " + modelInformation.SimpleModelName + "?";

            return((bool)confirmWindow.ShowDialog());
        }
Esempio n. 9
0
        private PaperSize ShowSelectPaperSizeWindowIfNeed(ModelInformation modelInfomation)
        {
            if (PrinterPriority != 0)
            {
                return(SharedInformationManager.SelectedPaperSize);
            }

            if (modelInfomation.Model == PrinterModel.SP700 || modelInfomation.Model == PrinterModel.BSC10)
            {
                return(modelInfomation.DefaultPaperSize);
            }

            return(ShowSelectPaperSizeWindow(modelInfomation.DefaultPaperSize.Type));
        }
        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();
        }
Esempio n. 11
0
        private ModelInformation ShowSelectModelWindow()
        {
            ModelInformation modelInformation = new ModelInformation();

            SelectSettingWindow selectModelWindow = new SelectSettingWindow(FindResource("SelectModelWindow") as SelectSettingWindow);

            bool?result = selectModelWindow.ShowDialog();

            if (result == true)
            {
                modelInformation = selectModelWindow.SelectedModel;
            }
            else
            {
                return(null);
            }

            return(modelInformation);
        }
        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();
        }
Esempio n. 13
0
        public string[] GetSelectedPortNameAndPortSettings(int printerPriority)
        {
            if (SelectedPorts.Length < printerPriority + 1 ||
                SelectedModels.Length < printerPriority + 1)
            {
                return((string[])Enumerable.Empty <string>());
            }

            PortInfo         selectedPort  = SelectedPorts[printerPriority];
            ModelInformation selectedModel = SelectedModels[printerPriority];

            List <string> settingsList = new List <string>();

            settingsList.Add(selectedPort.PortName);

            settingsList.Add(selectedModel.PortSettings);

            return(settingsList.ToArray());
        }
Esempio n. 14
0
        private string CreateSelectedSubModelDescription()
        {
            if (!IsSelectedSubModel)
            {
                return("Unselected State");
            }
            else
            {
                PortInfo         subPortInfo = SelectedPorts[1];
                ModelInformation subModel    = SelectedModels[1];

                string          modelName = CreateSelectedModelName(subPortInfo);
                PortInfoManager manager   = new PortInfoManager(subPortInfo);

                if (PortInfoManager.IsSerialPort(subPortInfo))
                {
                    return(modelName + "\n" + subPortInfo.PortName + " ( " + subModel.PortSettings + " )");
                }
                else
                {
                    return(modelName + "\n" + manager.Description);
                }
            }
        }
Esempio n. 15
0
 private void SetModelInformation(ModelInformation modelInformation)
 {
     SharedInformationManager.SetSelectedModelInformation(modelInformation, PrinterPriority);
 }
        public static void SetSelectedModelInformation(ModelInformation modelInfo)
        {
            SelectedModelManager.SelectedModel = modelInfo;

            SaveModelInfo(modelInfo);
        }