コード例 #1
0
 public SymbolTableViewModel(S52ResourceFilesAnalyst s52ResourceFilesAnalyst, NauticalChartsDefaultColorSchema colorSchema)
 {
     this.s52ResourceFilesAnalyst = s52ResourceFilesAnalyst;
     symbolItems        = new ObservableCollection <SymbolItem>();
     symbolStyleSchemas = new ObservableCollection <SymbolType>();
     selectColorSchema  = colorSchema;
     IsEnabled          = true;
     chartTables        = this.s52ResourceFilesAnalyst.GetSymbolModules();
     colorTables        = this.s52ResourceFilesAnalyst.GetColorEntries();
     LoadSymbolStyleSchemas();
     LoadSymbolList();
     SelectedSymbolItem = symbolItems.Count > 0 ? symbolItems[0] : null;
 }
        public void UpdateColorEntry(NauticalChartsDefaultColorSchema colorSchema, ColorEntry newColorEntry)
        {
            XDocument document = XDocument.Load(resourceFile);
            XElement  element  = document.Root.XPathSelectElements("ColorSchemas/" + colorSchema.ToString().ToUpperInvariant() + "/Color").Where(x => x.Attribute("token").Value.ToString() == newColorEntry.Token).First();

            if (element != null)
            {
                element.Attribute("r").SetValue(newColorEntry.Color.RedComponent);
                element.Attribute("g").SetValue(newColorEntry.Color.GreenComponent);
                element.Attribute("b").SetValue(newColorEntry.Color.BlueComponent);
                document.Save(resourceFile);
            }
        }
コード例 #3
0
        internal static Dictionary <NauticalChartsDefaultColorSchema, ColorTable> Read(XmlDocument doc)
        {
            Dictionary <NauticalChartsDefaultColorSchema, ColorTable> colorTables = new Dictionary <NauticalChartsDefaultColorSchema, ColorTable>();
            XmlNode colorsNode = doc.DocumentElement.SelectSingleNode(@"ColorSchemas");

            foreach (XmlNode colorTableNode in colorsNode.ChildNodes)
            {
                ColorTable colorTable = new ColorTable(colorTableNode.Attributes["name"].Value);
                NauticalChartsDefaultColorSchema colorSchema = (NauticalChartsDefaultColorSchema)Enum.Parse(typeof(NauticalChartsDefaultColorSchema), colorTableNode.Attributes["name"].Value, true);

                Collection <ColorEntry> colorEntries = new Collection <ColorEntry>();
                foreach (XmlNode colorEntryNode in colorTableNode.ChildNodes)
                {
                    ColorEntry colorEntry = new ColorEntry(colorEntryNode.Attributes["token"].Value, short.Parse(colorEntryNode.Attributes["r"].Value), short.Parse(colorEntryNode.Attributes["g"].Value), short.Parse(colorEntryNode.Attributes["b"].Value));
                    colorEntries.Add(colorEntry);
                }

                colorTable.ColorEntries = colorEntries;
                colorTables.Add(colorSchema, colorTable);
            }

            return(colorTables);
        }
        public ColorEntry GetColorEntryByToken(NauticalChartsDefaultColorSchema colorSchema, string colorToken)
        {
            ColorTable colorTable = this.colorSchemas[colorSchema];

            return(colorTable.ColorEntries.Where(entry => entry.Token.Equals(colorToken, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault());
        }