private void OnCopysValidationHasError(object sender, RoutedPropertyChangedEventArgs <bool> e) { IsCopiesValidate = !e.NewValue; if (e.NewValue) { PrintButton.IsEnabled = false; } else { if (common.IsOffline(m_currentStatus)) { PrintButton.IsEnabled = false; } else { PrintButton.IsEnabled = true; } } if (e.NewValue) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_The_valid_range_is_1_99__please_confirm_and_enter_again_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); } }
private void OnValidationHasErrorChanged(object sender, RoutedPropertyChangedEventArgs <bool> e) { btnCopy.IsEnabled = (false == common.IsOffline(m_currentStatus) && false == spinCtlCopies.ValidationHasError); if (e.NewValue) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_The_valid_range_is_1_99__please_confirm_and_enter_again_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); } }
private void btnLogin_Click(object sender, RoutedEventArgs e) { bool isApplySuccess = false; string strpwd = pbPwd.Password; string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; string strDrvName = ""; if (false == common.GetPrinterDrvName(strPrinterName, ref strDrvName)) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_can_not_be_carried_out_due_to_software_has_error__please_try__again_after_reinstall_the_Driver_and_Virtual_Operation_Panel_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); return; } if (strpwd.Length > 0) { PasswordRecord m_rec = new PasswordRecord(strPrinterName, strpwd); AsyncWorker worker = new AsyncWorker(this); if (worker.InvokeMethod <PasswordRecord>(strPrinterName, ref m_rec, DllMethodType.ConfirmPassword, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { ((MainWindow)App.Current.MainWindow).m_strPassword = strpwd; isApplySuccess = true; } } if (!isApplySuccess) { ((MainWindow)App.Current.MainWindow).m_strPassword = ""; pbPwd.Focus(); pbPwd.SelectAll(); tbkErrorInfo.Foreground = new SolidColorBrush(Colors.Red); tbkErrorInfo.Text = (string)this.FindResource("ResStr_Authentication_error__please_enter_the_password_again_"); } else { this.DialogResult = true; this.Close(); } } else { tbkErrorInfo.Foreground = new SolidColorBrush(Colors.Red); tbkErrorInfo.Text = (string)this.FindResource("ResStr_The_new_password_can_not_be_empty_"); } }
private void OnClickImagePrint(object sender, System.Windows.Input.MouseButtonEventArgs e) { OpenFileDialog open = null; bool? result = null; open = new OpenFileDialog(); open.Filter = "All Images|*.jpg;*.bmp;*.png;*.tif|JPEG|*.jpg|BMP|*.bmp|PNG|*.png|TIFF|*.tif"; open.Multiselect = true; IsInitPrintSettingPage = true; result = open.ShowDialog(); if (result == true) { try { for (int i = 0; i < open.FileNames.Length; i++) { if (!IsValidImage(open.FileNames[i])) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_This_file_is_not_supported__please_select_another_one_") + " -- " + open.SafeFileNames[i], (string)this.FindResource("ResStr_Warning")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); return; } } this.m_MainWin.winPrintPage.FilePaths = new List <string>(open.FileNames); this.m_MainWin.subPageView.Child = this.m_MainWin.winPrintPage; this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintImages; } catch (OutOfMemoryException) { VOP.Controls.MessageBoxEx.Show( VOP.Controls.MessageBoxExStyle.Simple, m_MainWin, (string)this.FindResource("ResStr_Operation_cannot_be_carried_out_due_to_insufficient_memory_or_hard_disk_space_Please_try_again_after_freeing_memory_or_hard_disk_space_"), (string)this.FindResource("ResStr_Error") ); } catch (Exception) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_This_file_is_not_supported__please_select_another_one_"), (string)this.FindResource("ResStr_Warning")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); } } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (myComboBox.Text.Trim() != "") { double w = GetWidthTextValue(); double h = GetHeightTextValue(); var result = (from item in UserDefinedSizeItems where item.UserDefinedName == myComboBox.Text.Trim() select item).ToList(); if (result.Count == 1) { UserDefinedSizeItem item = (UserDefinedSizeItem)result[0]; item.UserDefinedName = myComboBox.Text.Trim(); item.IsMM = (bool)RadioButtonMM.IsChecked; item.Width = w; item.Height = h; } else if (result.Count == 0) { if (UserDefinedSizeItems.Count() < 20) { UserDefinedSizeItems.Add(new UserDefinedSizeItem() { UserDefinedName = myComboBox.Text.Trim(), IsMM = (bool)RadioButtonMM.IsChecked, Width = w, Height = h }); } else { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple( (string)this.FindResource("ResStr_Warning_Custom_Exceed"), (string)this.FindResource("ResStr_Warning_2")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); } } myComboBox.Text = ""; } }
private void ApplyButtonClick(object sender, RoutedEventArgs e) { string strDrvName = ""; string strPrinterName = m_MainWin.statusPanelPage.m_selectedPrinter; PrintError printRes = PrintError.Print_OK; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); CRM_PrintInfo crmPrintInfo = new CRM_PrintInfo(); if (true == common.IsError(m_currentStatus)) { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, m_MainWin, (string)this.FindResource("ResStr_Operation_can_not_be_carried_out_due_to_machine_malfunction_"), (string)this.FindResource("ResStr_Error")); return; } if (false == common.GetPrinterDrvName(strPrinterName, ref strDrvName)) { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_can_not_be_carried_out_due_to_software_has_error__please_try__again_after_reinstall_the_Driver_and_Virtual_Operation_Panel_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); return; } //Collect user info crmPrintInfo.SetPrintDocType(CurrentPrintType); crmPrintInfo.m_strPrinterName = strPrinterName; crmPrintInfo.m_strPrintCopys = String.Format("{0}", (sbyte)spinnerControl1.Value); //bool isSFP = common.IsSFPPrinter(strDrvName); //bool isWiFiModel = common.IsSupportWifi(strDrvName); //if (isSFP) //{ // if (isWiFiModel) // crmPrintInfo.m_strPrinterModel = "Lenovo LJ2208W"; // else // crmPrintInfo.m_strPrinterModel = "Lenovo LJ2208"; //} //else //{ // if (isWiFiModel) // crmPrintInfo.m_strPrinterModel = "Lenovo M7208W"; // else // crmPrintInfo.m_strPrinterModel = "Lenovo M7208"; //} crmPrintInfo.m_strPrinterModel = strDrvName; if (CurrentPrintType == PrintType.PrintFile_Txt) { dll.SetCopies(m_MainWin.statusPanelPage.m_selectedPrinter, 1); } else { dll.SetCopies(m_MainWin.statusPanelPage.m_selectedPrinter, (sbyte)spinnerControl1.Value); } switch (CurrentPrintType) { case PrintType.PrintFile: case PrintType.PrintFile_Image: case PrintType.PrintFile_Txt: case PrintType.PrintFile_Pdf: case PrintType.PrintFile_PPT: try { if (FilePaths.Count == 1) { string fileExt = System.IO.Path.GetExtension(FilePaths[0]).ToLower(); if (fileExt == ".xls" || fileExt == ".xlsx") { ExcelHelper helper = new ExcelHelper(FilePaths[0]); if (helper.Open()) { helper.Print(m_MainWin.statusPanelPage.m_selectedPrinter, (int)spinnerControl1.Value); helper.Close(); } else { printRes = PrintError.Print_File_Not_Support; } } else if (fileExt == ".pub") { PubHelper helper = new PubHelper(FilePaths[0]); dll.VopSetDefaultPrinter(m_MainWin.statusPanelPage.m_selectedPrinter); if (helper.Open()) { helper.Print(m_MainWin.statusPanelPage.m_selectedPrinter, (int)spinnerControl1.Value); helper.Close(); } else { printRes = PrintError.Print_File_Not_Support; } } //else if (fileExt == ".ppt" // || fileExt == ".pptx") //{ // PPTHelper helper = new PPTHelper(FilePaths[0]); // if (helper.Open()) // { // helper.PrintAll(m_MainWin.statusPanelPage.m_selectedPrinter, // (int)spinnerControl1.Value); // helper.Close(); // } // else // { // printRes = PrintError.Print_File_Not_Support; // } //} else if (fileExt == ".pdf") { dll.VopSetDefaultPrinter(m_MainWin.statusPanelPage.m_selectedPrinter); // printRes = (PrintError)worker.InvokeDoWorkMethod(DoPdfPrint); print.Print(FilePaths[0]); } else { printRes = worker.InvokePrintFileMethod(dll.PrintFile, m_MainWin.statusPanelPage.m_selectedPrinter, FilePaths[0], needFitToPage, (int)CurrentDuplexType, IsPortrait, (int)spinnerControl1.Value, scalingValue); } } } catch (COMException ex) { if ((uint)ex.ErrorCode == 0x80ff000d) //Open file is locked by other process { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple(ex.Message, (string)this.FindResource("ResStr_Warning")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); } else if ((uint)ex.ErrorCode == 0x800a03ec) //Insufficient disk space { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); VOP.Controls.MessageBoxEx.Show( VOP.Controls.MessageBoxExStyle.Simple, m_MainWin, (string)this.FindResource("ResStr_Operation_cannot_be_carried_out_due_to_insufficient_memory_or_hard_disk_space_Please_try_again_after_freeing_memory_or_hard_disk_space_"), (string)this.FindResource("ResStr_Error") ); } else { printRes = PrintError.Print_File_Not_Support; } } catch (Exception) { printRes = PrintError.Print_File_Not_Support; } break; case PrintType.PrintImages: if (FilePaths.Count == 1) { printRes = worker.InvokePrintFileMethod(dll.PrintFile, m_MainWin.statusPanelPage.m_selectedPrinter, FilePaths[0], needFitToPage, (int)CurrentDuplexType, IsPortrait, (int)spinnerControl1.Value, scalingValue); } else { if (dll.PrintInit(m_MainWin.statusPanelPage.m_selectedPrinter, "Neo_Multi_Pictures", (int)enumIdCardType.NonIdCard, new IdCardSize(), needFitToPage, (int)CurrentDuplexType, IsPortrait, scalingValue)) { foreach (string path in FilePaths) { dll.AddImagePath(path); } printRes = (PrintError)worker.InvokeDoWorkMethod(dll.DoPrintImage); } else { printRes = PrintError.Print_Operation_Fail; } } break; case PrintType.PrintIdCard: IdCardSize idCardSize = new IdCardSize(); idCardSize.Width = SelectedTypeItem.Width; idCardSize.Height = SelectedTypeItem.Height; if (dll.PrintInit(m_MainWin.statusPanelPage.m_selectedPrinter, SelectedTypeItem.Name, (int)SelectedTypeItem.TypeId, idCardSize, needFitToPage, (int)DuplexPrintType.NonDuplex, IsPortrait, scalingValue)) { using (IdCardPrintHelper helper = new IdCardPrintHelper()) { int i = 0; foreach (BitmapSource src in IdCardEditWindow.croppedImageList) { helper.AddImage(src); dll.AddImageRotation(IdCardEditWindow.imageRotationList[i]); i++; } printRes = (PrintError)worker.InvokeDoWorkMethod(dll.DoPrintIdCard); } } else { printRes = PrintError.Print_Operation_Fail; } break; } if (printRes == PrintError.Print_File_Not_Support) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_This_file_is_not_supported__please_select_another_one_"), (string)this.FindResource("ResStr_Warning")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); this.m_MainWin.subPageView.Child = this.m_MainWin.winFileSelectionPage; crmPrintInfo.m_strPrintSuccess = "false"; } else if (printRes == PrintError.Print_Memory_Fail) { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_Memory_Alloc_Fail"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); crmPrintInfo.m_strPrintSuccess = "false"; } else if (printRes == PrintError.Print_Insufficient_Memory_Or_Disk_Space) { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); VOP.Controls.MessageBoxEx.Show( VOP.Controls.MessageBoxExStyle.Simple, m_MainWin, (string)this.FindResource("ResStr_Operation_cannot_be_carried_out_due_to_insufficient_memory_or_hard_disk_space_Please_try_again_after_freeing_memory_or_hard_disk_space_"), (string)this.FindResource("ResStr_Error") ); crmPrintInfo.m_strPrintSuccess = "false"; } else if (printRes == PrintError.Print_Operation_Fail) { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_can_not_be_carried_out_due_to_software_has_error__please_try__again_after_reinstall_the_Driver_and_Virtual_Operation_Panel_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); crmPrintInfo.m_strPrintSuccess = "false"; } else if (printRes == PrintError.Print_Get_Default_Printer_Fail) { m_MainWin.statusPanelPage.ShowMessage((string)this.TryFindResource("ResStr_Print_Fail"), Brushes.Red); MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_can_not_be_carried_out_due_to_software_has_error__please_try__again_after_reinstall_the_Driver_and_Virtual_Operation_Panel_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); crmPrintInfo.m_strPrintSuccess = "false"; } else { crmPrintInfo.m_strPrintSuccess = "true"; } m_MainWin.UploadPrintInfo(crmPrintInfo); }
private void OnClickIdCardPrint(object sender, System.Windows.Input.MouseButtonEventArgs e) { bool?result = null; IdCardTypeSelectWindow selectWin = null; OpenFileDialog open = null; imageFileCount = 0; IsInitPrintSettingPage = true; currentState = FileSelectionState.SelectWindow; IdCardEditWindow.croppedImageList.Clear(); IdCardEditWindow.imageRotationList.Clear(); while (currentState != FileSelectionState.Exit) { switch (currentState) { case FileSelectionState.SelectWindow: selectWin = new IdCardTypeSelectWindow(); selectWin.Owner = App.Current.MainWindow; result = selectWin.ShowDialog(); if (result == true) { currentState = FileSelectionState.OpenFile; } else { currentState = FileSelectionState.Exit; } break; case FileSelectionState.OpenFile: open = new OpenFileDialog(); open.Filter = "All Images|*.jpg;*.bmp;*.png;*.tif|JPEG|*.jpg|BMP|*.bmp|PNG|*.png|TIFF|*.tif"; result = open.ShowDialog(); if (result == true) { currentState = FileSelectionState.EditWindow; } else { currentState = FileSelectionState.Exit; } break; case FileSelectionState.EditWindow: try { IdCardEditWindow editWin = new IdCardEditWindow(); editWin.Owner = App.Current.MainWindow; editWin.ImageUri = new Uri(open.FileName); editWin.SelectedTypeItem = selectWin.SelectedTypeItem; ImageCropper.designerItemWHRatio = selectWin.SelectedTypeItem.Width / selectWin.SelectedTypeItem.Height; editWin.TitleBarText.Text = selectWin.SelectedTypeItem.Name; if (selectWin.SelectedTypeItem.PrintSides == enumIdCardPrintSides.TwoSides) { editWin.TitleBarText.Text = selectWin.SelectedTypeItem.Name + " " + this.FindResource("ResStr_Front"); editWin.GreenOkButton.Content = this.FindResource("ResStr_Next"); editWin.GreenOkButton.ToolTip = this.FindResource("ResStr_Select_photo_of_the_reverse_side"); if (imageFileCount == 1) { editWin.TitleBarText.Text = selectWin.SelectedTypeItem.Name + " " + this.FindResource("ResStr_Back_2"); editWin.GreenOkButton.Content = this.FindResource("ResStr_OK"); editWin.GreenOkButton.ToolTip = null; } } result = editWin.ShowDialog(); if (result == true) { currentState = FileSelectionState.GoPrint; if (selectWin.SelectedTypeItem.PrintSides == enumIdCardPrintSides.TwoSides) { if (++imageFileCount < 2) { currentState = FileSelectionState.OpenFile; } } } else { currentState = FileSelectionState.Exit; } } catch (OutOfMemoryException) { VOP.Controls.MessageBoxEx.Show( VOP.Controls.MessageBoxExStyle.Simple, m_MainWin, (string)this.FindResource("ResStr_Operation_cannot_be_carried_out_due_to_insufficient_memory_or_hard_disk_space_Please_try_again_after_freeing_memory_or_hard_disk_space_"), (string)this.FindResource("ResStr_Error") ); currentState = FileSelectionState.Exit; } catch (Exception) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_This_file_is_not_supported__please_select_another_one_"), (string)this.FindResource("ResStr_Warning")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); currentState = FileSelectionState.Exit; } break; case FileSelectionState.GoPrint: this.m_MainWin.subPageView.Child = this.m_MainWin.winPrintPage; this.m_MainWin.winPrintPage.myImagePreviewPanel.myImagePreview.IdCardPreviewSource = PrintPreview.PreviewImageSource; this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintIdCard; this.m_MainWin.winPrintPage.SelectedTypeItem = selectWin.SelectedTypeItem; currentState = FileSelectionState.Exit; break; default: currentState = FileSelectionState.Exit; break; } } }
private void OnClickFilePrint(object sender, System.Windows.Input.MouseButtonEventArgs e) { OpenFileDialog open = null; bool? result = null; open = new OpenFileDialog(); open.Filter = "All Files|*.*"; IsInitPrintSettingPage = true; result = open.ShowDialog(); if (result == true) { try { List <string> strls = new List <string>(); strls.Add(open.FileName); this.m_MainWin.winPrintPage.FilePaths = strls; this.m_MainWin.subPageView.Child = this.m_MainWin.winPrintPage; string fileExt = System.IO.Path.GetExtension(open.FileName).ToLower(); if (fileExt == ".bmp" || fileExt == ".ico" || fileExt == ".gif" || fileExt == ".jpg" || fileExt == ".exif" || fileExt == ".png" || fileExt == ".tif" || fileExt == ".wmf" || fileExt == ".emf") { this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintFile_Image; } else if (fileExt == ".txt") { this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintFile_Txt; } else if (fileExt == ".pdf") { this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintFile_Pdf; } else if (fileExt == ".ppt" || fileExt == ".pptx") { this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintFile_PPT; } else { this.m_MainWin.winPrintPage.CurrentPrintType = PrintPage.PrintType.PrintFile; } } catch (OutOfMemoryException) { VOP.Controls.MessageBoxEx.Show( VOP.Controls.MessageBoxExStyle.Simple, m_MainWin, (string)this.FindResource("ResStr_Operation_cannot_be_carried_out_due_to_insufficient_memory_or_hard_disk_space_Please_try_again_after_freeing_memory_or_hard_disk_space_"), (string)this.FindResource("ResStr_Error") ); } catch (Exception) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_This_file_is_not_supported__please_select_another_one_"), (string)this.FindResource("ResStr_Warning")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); } } }