Example #1
0
        /// <summary>
        /// Initializes a new instance of the BedWizardDialog class.
        /// </summary>
        /// <param name="sheetName">Name of the sheet which has to be parsed.</param>
        /// <param name="columnNumbers">List of column numbers which have to be mapped to headers.</param>
        /// <param name="bedHeader">List of BED headers.</param>
        /// <param name="requiredHeaders">List of mandatory headers.</param>
        public BedWizardDialog(string sheetName, List<int> columnNumbers, List<string> bedHeader, List<string> requiredHeaders)
        {
            this.InitializeComponent();
            this.btnOK.Click += this.OnBedWizardSave;
            this.btnCancel.Click += this.OnCancelBedWizard;
            this.PreviewKeyUp += this.OnBedWizardDialogKeyUp;
            this.bedHeader = bedHeader;
            this.requiredHeaders = requiredHeaders;    
            
            this.txtSubText.Text = string.Format(Properties.Resources.HEADER_SUBTEXT, sheetName);
            
            foreach (string s in requiredHeaders)
            {
                ColumnMap map = new ColumnMap(columnNumbers, s);
                this.stkfirstPanel.Children.Add(map);
            }

            IEnumerable<string> optionalHeaders = bedHeader.Except(requiredHeaders);

            foreach (string s in optionalHeaders)
            {
                ColumnMap map = new ColumnMap(columnNumbers, s);
                this.stkSecondPanel.Children.Add(map);
            }
        }
Example #2
0
        /// <summary>
        /// This method is called when the user has chosen to save
        /// the BED wizard dialog contents. This method also
        /// validates to see if mandatory headers are selected
        /// and no column is selected more than once.
        /// </summary>
        /// <param name="sender">btnOk instance.</param>
        /// <param name="e">Event data.</param>
        private void OnBedWizardSave(object sender, RoutedEventArgs e)
        {
            this.mapping.Clear();
            List <UIElement> elements = new List <UIElement>();

            foreach (UIElement element in this.stkfirstPanel.Children)
            {
                elements.Add(element);
            }

            foreach (UIElement element in this.stkSecondPanel.Children)
            {
                elements.Add(element);
            }

            foreach (UIElement element in elements)
            {
                ColumnMap map = element as ColumnMap;
                if (map != null && map.ColumnNumber.HasValue)
                {
                    if (this.mapping.ContainsValue(map.ColumnNumber.Value))
                    {
                        MessageBox.Show(Properties.Resources.ONE_COLUMN, Properties.Resources.CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    else
                    {
                        this.mapping.Add(map.ColumnHeader, map.ColumnNumber.Value);
                    }
                }
            }

            foreach (string s in this.requiredHeaders)
            {
                if (!this.mapping.ContainsKey(s))
                {
                    MessageBox.Show(Properties.Resources.MANDATORY_COLUMNS, Properties.Resources.CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            this.submitSelected = true;
            this.Close();
        }