Exemple #1
0
        /// <summary>
        /// This method parses the "Colors" section of the app.config value.
        /// It creates ColorSchemeInfo objects and populates these objects
        /// with the values mentioned in app.config.
        /// </summary>
        /// <param name="parent">Parent object.</param>
        /// <param name="configContext"> Configuration context object.</param>
        /// <param name="section">Colors Section XML node.</param>
        /// <returns>list of all the color schemes mentioned in the app.config file.</returns>
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            XmlNodeList colorSchemeNodes = section.SelectNodes(COLORSCHEME);

            foreach (XmlNode colorSchemeNode in colorSchemeNodes)
            {
                ColorSchemeInfo info = new ColorSchemeInfo();
                info.Name = ReadAttribute(colorSchemeNode, NAME);

                string defaultColor = ReadAttribute(colorSchemeNode.SelectSingleNode(DEFAULT), COLOR);
                info.ColorMapping.Add(DEFAULT, defaultColor);

                XmlNodeList symbolNodes = colorSchemeNode.SelectNodes(SYMBOL);

                foreach (XmlNode symbolNode in symbolNodes)
                {
                    string alphabet = ReadAttribute(symbolNode, CHAR);
                    string color    = ReadAttribute(symbolNode, COLOR);

                    if (!info.ColorMapping.ContainsKey(alphabet))
                    {
                        info.ColorMapping.Add(alphabet, color);
                    }
                }

                this.colorschemes.Add(info);
            }

            return(this.colorschemes);
        }
Exemple #2
0
        /// <summary>
        /// This method is called when the user wishes the change the sequence color.
        /// </summary>
        /// <param name="sender">Change Colors menu item.</param>
        /// <param name="e">Event data.</param>
        private void OnChangeColorsClicked(object sender, RoutedEventArgs e)
        {
            ColorSchemeDialog dialog = new ColorSchemeDialog(colorSchemeInfo, chosenColorScheme);

            dialog.Owner = Application.Current.MainWindow;
            ColorSchemeInfo info = dialog.Show();

            SequenceAssembly.chosenColorScheme = info;

            assembler.customSequenceView.ApplyCurrentColor();
            assembler.consensusCustomView.ApplyCurrentColor();
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the ColorSchemeDialog class.
        /// </summary>
        /// <param name="colorSchemes">
        /// List of of color schemes mentioned in App.config.
        /// </param>
        /// <param name="currentlyChosenColorScheme">
        /// The current color scheme chosen.
        /// </param>
        public ColorSchemeDialog(IList <ColorSchemeInfo> colorSchemes, ColorSchemeInfo currentlyChosenColorScheme)
        {
            this.InitializeComponent();
            this.colorSchemes      = colorSchemes;
            this.chosenColorScheme = currentlyChosenColorScheme;
            this.btnSave.Click    += new RoutedEventHandler(this.OnSaveColorScheme);
            this.btnCancel.Click  += new RoutedEventHandler(this.OnCancelColorScheme);
            this.Owner             = Application.Current.MainWindow;
            this.SetColorSchemes();

            this.btnSave.Focus();
        }
Exemple #4
0
        /// <summary>
        /// This method is called when the user has made his selection
        /// for the color scheme and has decided to save it.
        /// </summary>
        /// <param name="sender">btnSave instance.</param>
        /// <param name="e">Event data.</param>
        private void OnSaveColorScheme(object sender, RoutedEventArgs e)
        {
            string selectedItem = this.cmbColorScheme.SelectedItem as string;

            foreach (ColorSchemeInfo info in this.colorSchemes)
            {
                if (info.Name.Equals(selectedItem))
                {
                    this.chosenColorScheme = info;
                    break;
                }
            }

            this.Close();
        }