private void RemoveInvalidPrinterTypeFromSelection(LabelPrinterTypes invalidPrinterType)
        {
            List <string> currentPrinterTypes = new List <string>(((string[])PrinterTypeComboBox.ItemsSource));
            List <string> newPrinterTypes     = currentPrinterTypes.FindAll(p => !p.Equals(invalidPrinterType.ToString()));

            PrinterTypeComboBox.ItemsSource = newPrinterTypes.ToArray();
        }
 private bool AnyPrintersOfCurrentTypeArePresent(LabelPrinterTypes currentPrinterType)
 {
     if (printerView == null)
     {
         return(false);
     }
     return(((List <LabelPrinter>)printerView.SourceCollection).Exists(p => p.Type.Equals(currentPrinterType)));
 }
 private void FilterPrintersInComboBox(LabelPrinterTypes filterType)
 {
     if (printerView == null)
     {
         return;
     }
     printerView.Filter = p =>
                          ((LabelPrinter)p).Type.Equals(filterType);
 }
        private bool CheckForValidPrinters(LabelPrinterTypes currentPrinterType)
        {
            if (!AnyPrintersOfCurrentTypeArePresent(currentPrinterType))
            {
                MessageBox.Show(String.Format("There are not any [{0}] printers currently installed on this computer. Please install a [{0}] printer.", currentPrinterType),
                                "No Valid Printer", MessageBoxButton.OK, MessageBoxImage.Error);

                RemoveInvalidPrinterTypeFromSelection(currentPrinterType);

                return(false);
            }

            return(true);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Loading up valid values for the printer types
            PrinterTypeComboBox.ItemsSource = Enum.GetNames(typeof(LabelPrinterTypes));

            // Setting the current configured value for printer type
            LabelPrinterTypes currentPrinterType = (LabelPrinterTypes)Enum.Parse(typeof(LabelPrinterTypes),
                                                                                 Properties.Settings.Default.PrinterType);

            // Loading up valid values for the printers
            printerView = CollectionViewSource.GetDefaultView(ValidLabelPrinters.Printers);
            printerView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            PrinterComboBox.ItemsSource       = printerView;
            PrinterComboBox.DisplayMemberPath = "Name";

            if (CheckForValidPrinters(currentPrinterType))
            {
                CurrentPrinterType = currentPrinterType;

                FilterPrintersInComboBox(currentPrinterType);

                printerView.MoveCurrentTo(ValidLabelPrinters.Printers.Find(p =>
                                                                           p.Type.Equals(currentPrinterType) && p.Name.Equals(Properties.Settings.Default.PrinterName)));
            }

            if (currentPrinterType == LabelPrinterTypes.Dymo)
            {
                LabelTemplateFile = Properties.Settings.Default.LabelTemplateFile;
            }

            // Loading up valid values for the DepartmentComboBox
            List <string> departments = new List <string>();

            departments.Add(Infrastructure.Departments.Children);
            departments.Add(Infrastructure.Departments.LadiesBibleStudy);
            departments.Add(Infrastructure.Departments.MOPS);
            departments.Add(Infrastructure.Departments.Preschool);
            DepartmentComboBox.ItemsSource = departments;

            // Setting the current configured value for TargetDepartment
            TargetDepartment = Properties.Settings.Default.TargetDepartment;
        }