Example #1
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'MainWindow.MainWindow()'
        public MainWindow()
        {
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'MainWindow.MainWindow()'
            InitializeComponent();

            partNumberRegex = new Regex(@"^((?:(?:G|T)\\d{5}(?:(?=-)-\\d{1,3}(?:(?=[A-Z])[A-Z]\\d|)|))|(?:(?:V)?\\d{6,7}Z))$");

            defaultPartNumberBorderBrush = ProductNumber.BorderBrush;

            try
            {
                bomConfigurations = (ConfigurationSectionBoms)ConfigurationManager.GetSection(Properties.Resources.BOM_CONFIGURATION_SECTION);
            }
            catch (Exception e)
            {
                int indexOfParan = e.Message.IndexOf("(");
                int messageEnd   = indexOfParan == -1 ? e.Message.Length : indexOfParan;
                int indexOfLine  = e.Message.IndexOf("line");

                string lineNumber = indexOfLine == -1 ? "" : e.Message.Substring(indexOfLine);
                string lineError  = indexOfLine == -1 ? "" : lineNumber.Substring(0, lineNumber.Length - 1);

                MessageBox.Show("Configuration Error:\n\n" + e.Message.Substring(0, messageEnd) + (indexOfLine == -1 ? "" : "\n\n") + lineError, "Error Occured", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
        }
        public BomSelectionModel(IFormatterConfiguration formatter)
        {
            ConfigurationSectionBoms configuration = formatter.BomConfiguration;

            foreach (ConfigurationElementBom bom in configuration.BomCollection)
            {
                if (bom.Enabled)
                {
                    _boms.Add(bom.Name, bom.DisplayName);
                    _bomKeyList.Add(bom.Name);
                    NumberBoms++;
                }
            }
        }