Exemple #1
0
        public void Copy(ChartTheme theme)
        {
            if (theme == null)
            {
                throw new ArgumentNullException();
            }

            //Copy((Style)theme);

            Name            = theme.Name;
            RootBackColor   = theme.RootBackColor;
            RootForeColor   = theme.RootForeColor;
            RootBorderColor = theme.RootBorderColor;
            IsInternal      = theme.IsInternal;

            BackColor     = theme.BackColor;
            ForeColor     = theme.ForeColor;
            LineColor     = theme.LineColor;
            BorderColor   = theme.BorderColor;
            Font          = theme.Font;
            LineWidth     = theme.LineWidth;
            BorderWidth   = theme.BorderWidth;
            NodeBackColor = theme.NodeBackColor;
            NodeForeColor = theme.NodeForeColor;
            SelectColor   = theme.SelectColor;
            HoverColor    = theme.HoverColor;
            LinkLineColor = theme.LinkLineColor;
            ItemsSpace    = theme.ItemsSpace;
            LayerSpace    = theme.LayerSpace;
        }
Exemple #2
0
 public ChartTheme(ChartTheme copyTheme)
 {
     if (copyTheme != null)
     {
         Copy(copyTheme);
     }
 }
Exemple #3
0
        static void LoadFromXml(XmlElement xmlElement, ChartThemeFolder folder)
        {
            // folder
            XmlNodeList foldNodes = xmlElement.SelectNodes("folder");

            foreach (XmlElement foldNode in foldNodes)
            {
                ChartThemeFolder subFolder = new ChartThemeFolder();
                subFolder.Name = foldNode.GetAttribute("name");
                LoadFromXml(foldNode, subFolder);
                if (subFolder.Themes.Count > 0 || subFolder.Folders.Count > 0)
                {
                    folder.Folders.Add(subFolder);
                }
            }

            // theme
            XmlNodeList nodes = xmlElement.SelectNodes("theme");

            if (nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    if (node is XmlElement)
                    {
                        ChartTheme theme = DeserializeTheme(node as XmlElement);
                        if (theme != null)
                        {
                            theme.SetIsInternal(true);
                            folder.Themes.Add(theme);
                        }
                    }
                }
            }
        }
        private static ChartThemeFolder LoadThemesFromReg()
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Appearance\Schemes", false);

            if (key == null)
            {
                return(null);
            }

            ChartThemeFolder folder = new ChartThemeFolder("Windows Color Schemes");

            string[] schemes = key.GetValueNames();
            foreach (string scheme in schemes)
            {
                int si = scheme.IndexOf('(');
                if (si > -1 && folder.HasTheme(scheme.Substring(0, si).Trim()))
                {
                    continue;
                }

                ChartTheme theme = new ChartTheme(scheme);
                LoadWindowScheme(theme, (byte[])key.GetValue(scheme));
                folder.Themes.Add(theme);
            }

            return(folder);
        }
Exemple #5
0
        static void SerializeTheme(XmlElement node, ChartTheme theme)
        {
            if (theme == null || node == null)
            {
                throw new ArgumentNullException();
            }

            //SerializeMapStyle(theme, node);

            node.SetAttribute("name", theme.Name);
            ST.SerializeColor(node, "root_back_color", theme.RootBackColor);
            ST.SerializeColor(node, "root_fore_color", theme.RootForeColor);
            ST.SerializeColor(node, "root_border_color", theme.RootBorderColor);
            ST.SerializeColor(node, "back_color", theme.BackColor);
            ST.SerializeColor(node, "fore_color", theme.ForeColor);
            ST.SerializeColor(node, "line_color", theme.LineColor);
            ST.SerializeColor(node, "border_color", theme.BorderColor);
            ST.SerializeColor(node, "node_back_color", theme.NodeBackColor);
            ST.SerializeColor(node, "node_fore_color", theme.NodeForeColor);
            ST.SerializeColor(node, "select_color", theme.SelectColor);
            ST.SerializeColor(node, "hover_color", theme.HoverColor);
            ST.SerializeColor(node, "link_line_color", theme.LinkLineColor);

            if (!string.IsNullOrEmpty(theme.Description))
            {
                ST.WriteTextNode(node, "description", theme.Description);
            }

            if (theme.LayerSpace != MindMapStyle.DefaultLayerSpace)
            {
                ST.WriteTextNode(node, "layer_space", theme.LayerSpace.ToString());
            }

            if (theme.ItemsSpace != MindMapStyle.DefaultItemsSpace)
            {
                ST.WriteTextNode(node, "items_space", theme.ItemsSpace.ToString());
            }

            if (theme.Font != null)
            {
                XmlElement font = node.OwnerDocument.CreateElement("font");
                ST.WriteFontNode(font, theme.Font);
                node.AppendChild(font);
            }
        }
Exemple #6
0
        public static void Delete(ChartTheme theme)
        {
            if (theme.Folder != null)
            {
                theme.Folder.Themes.Remove(theme);
            }

            if (!string.IsNullOrEmpty(theme.Filename) && File.Exists(theme.Filename))
            {
                try
                {
                    File.Delete(theme.Filename);
                }
                catch (System.Exception ex)
                {
                    Helper.WriteLog(ex);
                }
            }
        }
Exemple #7
0
        private ChartTheme LoadTheme(string filename)
        {
            XmlDocument dom = new XmlDocument();

            dom.Load(filename);
            if (dom.DocumentElement.Name != "theme")
            {
                throw new Exception(Lang._("Invalid file type"));
            }

            ChartTheme theme = DeserializeTheme(dom.DocumentElement);

            if (theme != null)
            {
                theme.Filename = filename;
            }

            return(theme);
        }
Exemple #8
0
        private void LoadExtersionThemes(string direcotry, ChartThemeFolder parentFolder)
        {
            if (!Directory.Exists(direcotry))
            {
                return;
            }

            string[] dirs = Directory.GetDirectories(direcotry);
            foreach (string dir in dirs)
            {
                ChartThemeFolder folder = new ChartThemeFolder(Path.GetFileName(dir));
                LoadExtersionThemes(dir, folder);
                if (folder.Folders.Count > 0 || folder.Themes.Count > 0)
                {
                    parentFolder.Folders.Add(folder);
                }
            }

            string[] files = Directory.GetFiles(direcotry, "*.xml");
            foreach (string filename in files)
            {
                try
                {
                    ChartTheme theme = LoadTheme(filename);
                    if (theme != null)
                    {
                        parentFolder.Themes.Add(theme);
                    }
                }
                catch (System.Exception ex)
                {
                    Helper.WriteLog(ex);
                }
            }

            //if (folder.Themes.Count > 0 || folder.Folders.Count > 0)
            //{
            //    parentFolder.Folders.Add(folder);
            //}
        }
Exemple #9
0
        public void SaveTheme(ChartTheme theme, string filename)
        {
            if (theme == null || string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException();
            }

            string dir = Path.GetDirectoryName(filename);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            XmlDocument dom = new XmlDocument();

            dom.LoadXml("<?xml version='1.0' encoding='utf-8' ?><theme/>");

            SerializeTheme(dom.DocumentElement, theme);

            dom.Save(filename);
            theme.Filename = filename;
        }
Exemple #10
0
        static ChartTheme DeserializeTheme(XmlElement node)
        {
            var theme = new ChartTheme();

            //DeserializeMapStyle(node, theme);
            theme.BackColor     = ST.DeserializeColor(node, "back_color", theme.BackColor);
            theme.ForeColor     = ST.DeserializeColor(node, "fore_color", theme.ForeColor);
            theme.LineColor     = ST.DeserializeColor(node, "line_color", theme.LineColor);
            theme.BorderColor   = ST.DeserializeColor(node, "border_color", theme.BorderColor);
            theme.NodeBackColor = ST.DeserializeColor(node, "node_back_color", theme.NodeBackColor);
            theme.NodeForeColor = ST.DeserializeColor(node, "node_fore_color", theme.NodeForeColor);
            theme.SelectColor   = ST.DeserializeColor(node, "select_color", theme.SelectColor);
            theme.HoverColor    = ST.DeserializeColor(node, "hover_color", theme.HoverColor);
            theme.LinkLineColor = ST.DeserializeColor(node, "link_line_color", theme.LinkLineColor);
            theme.LayerSpace    = ST.GetInt(ST.ReadTextNode(node, "layer_space"), MindMapStyle.DefaultLayerSpace);
            theme.ItemsSpace    = ST.GetInt(ST.ReadTextNode(node, "items_space"), MindMapStyle.DefaultItemsSpace);

            XmlElement fontNode = node.SelectSingleNode("font") as XmlElement;

            if (fontNode != null)
            {
                theme.Font = ST.ReadFontNode(fontNode);
            }

            theme.Name            = node.GetAttribute("name");
            theme.RootBackColor   = ST.DeserializeColor(node, "root_back_color", theme.RootBackColor);
            theme.RootForeColor   = ST.DeserializeColor(node, "root_fore_color", theme.RootForeColor);
            theme.RootBorderColor = ST.DeserializeColor(node, "root_border_color", theme.RootBorderColor);
            theme.Description     = ST.ReadCDataNode(node, "description");
            if (theme.Description == string.Empty)
            {
                theme.Description = ST.ReadTextNode(node, "description");
            }


            return(theme);
        }
        private static void LoadWindowScheme(ChartTheme theme, byte[] data)
        {
            const int COLOR_3DDKSHADOW = 21;
            //const int COLOR_3DFACE = 15;
            //const int COLOR_3DHIGHLIGHT = 20;
            //const int COLOR_3DHILIGHT = 20;
            //const int COLOR_3DLIGHT = 22;
            //const int COLOR_3DSHADOW = 16;
            //const int COLOR_ACTIVEBORDER = 10;
            const int COLOR_ACTIVECAPTION = 2;
            //const int COLOR_APPWORKSPACE = 12;
            //const int COLOR_BACKGROUND = 1;
            const int COLOR_BTNFACE = 15;
            //const int COLOR_BTNHIGHLIGHT = 20;
            const int COLOR_BTNSHADOW   = 16;
            const int COLOR_BTNTEXT     = 18;
            const int COLOR_CAPTIONTEXT = 9;
            //const int COLOR_DESKTOP = 1;
            const int COLOR_GRADIENTACTIVECAPTION = 27;
            //const int COLOR_GRADIENTINACTIVECAPTION = 28;
            //const int COLOR_GRAYTEXT = 17;
            const int COLOR_HIGHLIGHT = 13;
            //const int COLOR_HIGHLIGHTTEXT = 14;
            const int COLOR_HOTLIGHT = 26;
            //const int COLOR_INACTIVEBORDER = 11;
            //const int COLOR_INACTIVECAPTION = 3;
            //const int COLOR_INACTIVECAPTIONTEXT = 19;
            //const int COLOR_INFOBK = 24;
            //const int COLOR_INFOTEXT = 23;
            //const int COLOR_MENU = 4;
            //const int COLOR_MENUHILIGHT = 29;
            //const int COLOR_MENUBAR = 30;
            //const int COLOR_MENUTEXT = 7;
            //const int COLOR_SCROLLBAR = 0;
            const int COLOR_WINDOW = 5;
            //const int COLOR_WINDOWFRAME = 6;
            const int COLOR_WINDOWTEXT = 8;

            theme.SetIsInternal(true);

            theme.BackColor       = GetColor(data, COLOR_WINDOW);
            theme.ForeColor       = GetColor(data, COLOR_WINDOWTEXT);
            theme.LineColor       = GetColor(data, COLOR_3DDKSHADOW);
            theme.BorderColor     = GetColor(data, COLOR_BTNSHADOW);
            theme.NodeBackColor   = GetColor(data, COLOR_BTNFACE);
            theme.NodeForeColor   = GetColor(data, COLOR_BTNTEXT);
            theme.RootBackColor   = GetColor(data, COLOR_ACTIVECAPTION);
            theme.RootForeColor   = GetColor(data, COLOR_CAPTIONTEXT);
            theme.RootBorderColor = GetColor(data, COLOR_GRADIENTACTIVECAPTION);
            theme.SelectColor     = GetColor(data, COLOR_HIGHLIGHT);
            theme.HoverColor      = GetColor(data, COLOR_HOTLIGHT);
            theme.LinkLineColor   = GetColor(data, COLOR_ACTIVECAPTION);

            //<back_color>Window</back_color>
            //<fore_color>WindowText</fore_color>
            //<line_color>ControlDarkDark</line_color>
            //<border_color>ControlDark</border_color>
            //<node_back_color>Control</node_back_color>
            //<node_fore_color>ControlText</node_fore_color>
            //<root_back_color>ActiveCaption</root_back_color>
            //<root_fore_color>ActiveCaptionText</root_fore_color>
            //<root_border_color>GradientActiveCaption</root_border_color>
            //<select_color>Highlight</select_color>
            //<hover_color>HotTrack</hover_color>
        }