Beispiel #1
0
        private void LoadTemplate(FileInfo fileInfo)
        {
            ChartColorTemplateXmlDocument templateXmlDocument = new ChartColorTemplateXmlDocument();

            ((XmlDocument)templateXmlDocument).Load(fileInfo.FullName);
            ChartColorTemplate chartColorTemplate = new ChartColorTemplate(templateXmlDocument.TemplateName);
            IEnumerator        enumerator         = ((ListXmlNode <PropertyXmlNode>)templateXmlDocument.Properties).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    PropertyXmlNode propertyXmlNode = (PropertyXmlNode)enumerator.Current;
                    string[]        strArray        = propertyXmlNode.Value.Split(new char[]  { ',' });
                    int             alpha           = int.Parse(strArray[0]);
                    int             red             = int.Parse(strArray[1]);
                    int             green           = int.Parse(strArray[2]);
                    int             blue            = int.Parse(strArray[3]);
                    chartColorTemplate.Settings[propertyXmlNode.Name] = Color.FromArgb(alpha, red, green, blue);
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            this.templateNameList.Add(chartColorTemplate.Name);
            this.templates.Add(chartColorTemplate.Name.ToLower(), chartColorTemplate);
        }
Beispiel #2
0
 public void RemoveTemplate(ChartColorTemplate template)
 {
     this.templates.Remove(template.Name.ToLower());
     this.templateNameList.Remove(template.Name);
     string path = this.directory.FullName + "\\" + template.Name + ".cctp";
     if (!File.Exists(path))
         return;
     File.Delete(path);
 }
 private void LoadConfig()
 {
     ChartColorTemplateConfigXmlDocument doc = new ChartColorTemplateConfigXmlDocument();
     if (File.Exists(this.configFile.FullName))
         doc.Load(this.configFile.FullName);
     string defaultTemplate = doc.DefaultTemplate;
     if (defaultTemplate != null && this.templates.TryGetValue(defaultTemplate.ToLower(), out this.defaultTemplate))
         return;
     this.defaultTemplate = new ChartColorTemplate("Default Template");
 }
Beispiel #4
0
        public void RemoveTemplate(ChartColorTemplate template)
        {
            this.templates.Remove(template.Name.ToLower());
            this.templateNameList.Remove(template.Name);
            string path = this.directory.FullName + "\\" + template.Name + ".cctp";

            if (!File.Exists(path))
            {
                return;
            }
            File.Delete(path);
        }
Beispiel #5
0
        public void RemoveTemplate(ChartColorTemplate template)
        {
            this.templates.Remove(template.Name.ToLower());
            this.templateNameList.Remove(template.Name);
            string path = Path.Combine(this.directory.FullName, string.Format("{0}{1}", template.Name, TEMPLATE_EXT));

            if (!File.Exists(path))
            {
                return;
            }
            File.Delete(path);
        }
Beispiel #6
0
        private void SaveTemplate(string name, ChartColorTemplate template)
        {
            ChartColorTemplateXmlDocument templateXmlDocument = new ChartColorTemplateXmlDocument();

            templateXmlDocument.TemplateName = template.Name;
            foreach (KeyValuePair <string, Color> keyValuePair in template.Settings)
            {
                Color  color = keyValuePair.Value;
                string str   = (string)(object)color.A + (object)"," + (string)(object)color.R + "," + (string)(object)color.G + "," + (string)(object)color.B;
                templateXmlDocument.Properties.Add(keyValuePair.Key, typeof(Color), str);
            }
            ((XmlDocument)templateXmlDocument).Save(this.directory.FullName + "\\" + name + ".cctp");
        }
Beispiel #7
0
 internal void SelectTemplate(ChartColorTemplate template)
 {
     this.currentTemplate = template;
     this.updating        = true;
     foreach (KeyValuePair <string, Color> keyValuePair in template.Settings)
     {
         if (this.propertyViewItems.ContainsKey(keyValuePair.Key))
         {
             this.propertyViewItems[keyValuePair.Key].Color = keyValuePair.Value;
         }
     }
     this.updating = false;
 }
Beispiel #8
0
        private void SaveTemplate(string name, ChartColorTemplate template)
        {
            ChartColorTemplateXmlDocument doc = new ChartColorTemplateXmlDocument();

            doc.TemplateName = template.Name;
            foreach (KeyValuePair <string, Color> pair in template.Settings)
            {
                Color  color = pair.Value;
                string str   = (string)(object)color.A + "," + (string)(object)color.R + "," + (string)(object)color.G + "," + (string)(object)color.B;
                doc.Properties.Add(pair.Key, typeof(Color), str);
            }
            doc.Save(Path.Combine(this.directory.FullName, string.Format("{0}{1}" + name + TEMPLATE_EXT)));
        }
Beispiel #9
0
        private void LoadConfig()
        {
            ChartColorTemplateConfigXmlDocument doc = new ChartColorTemplateConfigXmlDocument();

            if (File.Exists(this.configFile.FullName))
            {
                doc.Load(this.configFile.FullName);
            }
            string defaultTemplate = doc.DefaultTemplate;

            if (defaultTemplate != null && this.templates.TryGetValue(defaultTemplate.ToLower(), out this.defaultTemplate))
            {
                return;
            }
            this.defaultTemplate = new ChartColorTemplate("Default Template");
        }
Beispiel #10
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            NewChartColorTemplateDialog colorTemplateDialog = new NewChartColorTemplateDialog();

            if (colorTemplateDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            ChartColorTemplate template = new ChartColorTemplate(colorTemplateDialog.TemplateName);

            foreach (KeyValuePair <string, Color> keyValuePair in Global.ChartManager.ColorTemplates.DefaultTemplate.Settings)
            {
                template.Settings.Add(keyValuePair.Key, keyValuePair.Value);
            }
            Global.ChartManager.ColorTemplates.AddTemplate(colorTemplateDialog.TemplateName, template);
            ChartColorTemplateViewItem templateViewItem = new ChartColorTemplateViewItem(template);

            this.ltvTemplates.Items.Add((ListViewItem)templateViewItem);
            templateViewItem.Selected = true;
        }
Beispiel #11
0
        private void btnSetDefault_Click(object sender, EventArgs e)
        {
            if (this.ltvTemplates.SelectedItems.Count <= 0)
            {
                return;
            }
            ChartColorTemplate template = (this.ltvTemplates.SelectedItems[0] as ChartColorTemplateViewItem).Template;

            if (MessageBox.Show((IWin32Window)this, "Are you sure that you want to set " + template.Name + " as default?", "Default Template", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            Global.ChartManager.ColorTemplates.DefaultTemplate = template;
            this.ltvTemplates.BeginUpdate();
            foreach (ChartColorTemplateViewItem templateViewItem in this.ltvTemplates.Items)
            {
                templateViewItem.CheckDefault();
            }
            this.ltvTemplates.EndUpdate();
        }
Beispiel #12
0
        private void LoadTemplate(FileInfo fileInfo)
        {
            ChartColorTemplateXmlDocument doc = new ChartColorTemplateXmlDocument();

            doc.Load(fileInfo.FullName);
            ChartColorTemplate template = new ChartColorTemplate(doc.TemplateName);

            foreach (PropertyXmlNode node in doc.Properties)
            {
                string[] array = node.Value.Split(new char[]  { ',' });
                int      a     = int.Parse(array[0]);
                int      r     = int.Parse(array[1]);
                int      g     = int.Parse(array[2]);
                int      b     = int.Parse(array[3]);
                template.Settings[node.Name] = Color.FromArgb(a, r, g, b);
            }

//            IEnumerator enumerator = ((ListXmlNode<PropertyXmlNode>)doc.Properties).GetEnumerator();
//            try
//            {
//                while (enumerator.MoveNext())
//                {
//                    PropertyXmlNode propertyXmlNode = (PropertyXmlNode)enumerator.Current;
//                    string[] strArray = propertyXmlNode.Value.Split(new char[]  { ',' });
//                    int alpha = int.Parse(strArray[0]);
//                    int red = int.Parse(strArray[1]);
//                    int green = int.Parse(strArray[2]);
//                    int blue = int.Parse(strArray[3]);
//                    template.Settings[propertyXmlNode.Name] = Color.FromArgb(alpha, red, green, blue);
//                }
//            }
//            finally
//            {
//                IDisposable disposable = enumerator as IDisposable;
//                if (disposable != null)
//                    disposable.Dispose();
//            }
            this.templateNameList.Add(template.Name);
            this.templates.Add(template.Name.ToLower(), template);
        }
Beispiel #13
0
        private void LoadTemplate(FileInfo fileInfo)
        {
            ChartColorTemplateXmlDocument doc = new ChartColorTemplateXmlDocument();
            doc.Load(fileInfo.FullName);
            ChartColorTemplate template = new ChartColorTemplate(doc.TemplateName);

            foreach (PropertyXmlNode node in doc.Properties)
            {
                string[] array = node.Value.Split(new char[]  { ',' });
                int a = int.Parse(array[0]);
                int r = int.Parse(array[1]);
                int g = int.Parse(array[2]);
                int b = int.Parse(array[3]);
                template.Settings[node.Name] = Color.FromArgb(a, r, g, b);
            }

//            IEnumerator enumerator = ((ListXmlNode<PropertyXmlNode>)doc.Properties).GetEnumerator();
//            try
//            {
//                while (enumerator.MoveNext())
//                {
//                    PropertyXmlNode propertyXmlNode = (PropertyXmlNode)enumerator.Current;
//                    string[] strArray = propertyXmlNode.Value.Split(new char[]  { ',' });
//                    int alpha = int.Parse(strArray[0]);
//                    int red = int.Parse(strArray[1]);
//                    int green = int.Parse(strArray[2]);
//                    int blue = int.Parse(strArray[3]);
//                    template.Settings[propertyXmlNode.Name] = Color.FromArgb(alpha, red, green, blue);
//                }
//            }
//            finally
//            {
//                IDisposable disposable = enumerator as IDisposable;
//                if (disposable != null)
//                    disposable.Dispose();
//            }
            this.templateNameList.Add(template.Name);
            this.templates.Add(template.Name.ToLower(), template);
        }
 public ChartColorTemplateViewItem(ChartColorTemplate template) : base(template.Name, 0)
 {
     this.template = template;
     this.CheckDefault();
 }
Beispiel #15
0
 public void AddTemplate(string name, ChartColorTemplate template)
 {
     this.templates.Add(name.ToLower(), template);
     this.templateNameList.Add(name);
     this.SaveTemplate(name, template);
 }
Beispiel #16
0
 private void SaveTemplate(string name, ChartColorTemplate template)
 {
     ChartColorTemplateXmlDocument doc = new ChartColorTemplateXmlDocument();
     doc.TemplateName = template.Name;
     foreach (KeyValuePair<string, Color> pair in template.Settings)
     {
         Color color = pair.Value;
         string str = (string)(object)color.A + "," + (string)(object)color.R + "," + (string)(object)color.G + "," + (string)(object)color.B;
         doc.Properties.Add(pair.Key, typeof(Color), str);
     }
     doc.Save(Path.Combine(this.directory.FullName, string.Format("{0}{1}" + name + TEMPLATE_EXT)));
 }
Beispiel #17
0
 public void RemoveTemplate(ChartColorTemplate template)
 {
     this.templates.Remove(template.Name.ToLower());
     this.templateNameList.Remove(template.Name);
     string path = Path.Combine(this.directory.FullName, string.Format("{0}{1}", template.Name, TEMPLATE_EXT));
     if (!File.Exists(path))
         return;
     File.Delete(path);
 }
 public ChartColorTemplateViewItem(ChartColorTemplate template) : base(template.Name, 0)
 {
     this.template = template;
     this.CheckDefault();
 }
Beispiel #19
0
 internal void SelectTemplate(ChartColorTemplate template)
 {
     this.currentTemplate = template;
     this.updating = true;
     foreach (KeyValuePair<string, Color> keyValuePair in template.Settings)
     {
         if (this.propertyViewItems.ContainsKey(keyValuePair.Key))
             this.propertyViewItems[keyValuePair.Key].Color = keyValuePair.Value;
     }
     this.updating = false;
 }
Beispiel #20
0
 public void AddTemplate(string name, ChartColorTemplate template)
 {
     this.templates.Add(name.ToLower(), template);
     this.templateNameList.Add(name);
     this.SaveTemplate(name, template);
 }
Beispiel #21
0
 private void SaveTemplate(string name, ChartColorTemplate template)
 {
     ChartColorTemplateXmlDocument templateXmlDocument = new ChartColorTemplateXmlDocument();
     templateXmlDocument.TemplateName = template.Name;
     foreach (KeyValuePair<string, Color> keyValuePair in template.Settings)
     {
         Color color = keyValuePair.Value;
         string str = (string)(object)color.A + (object)"," + (string)(object)color.R + "," + (string)(object)color.G + "," + (string)(object)color.B;
         templateXmlDocument.Properties.Add(keyValuePair.Key, typeof(Color), str);
     }
     ((XmlDocument)templateXmlDocument).Save(this.directory.FullName + "\\" + name + ".cctp");
 }
Beispiel #22
0
 private void LoadTemplate(FileInfo fileInfo)
 {
     ChartColorTemplateXmlDocument templateXmlDocument = new ChartColorTemplateXmlDocument();
     ((XmlDocument)templateXmlDocument).Load(fileInfo.FullName);
     ChartColorTemplate chartColorTemplate = new ChartColorTemplate(templateXmlDocument.TemplateName);
     IEnumerator enumerator = ((ListXmlNode<PropertyXmlNode>)templateXmlDocument.Properties).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             PropertyXmlNode propertyXmlNode = (PropertyXmlNode)enumerator.Current;
             string[] strArray = propertyXmlNode.Value.Split(new char[]  { ',' });
             int alpha = int.Parse(strArray[0]);
             int red = int.Parse(strArray[1]);
             int green = int.Parse(strArray[2]);
             int blue = int.Parse(strArray[3]);
             chartColorTemplate.Settings[propertyXmlNode.Name] = Color.FromArgb(alpha, red, green, blue);
         }
     }
     finally
     {
         IDisposable disposable = enumerator as IDisposable;
         if (disposable != null)
             disposable.Dispose();
     }
     this.templateNameList.Add(chartColorTemplate.Name);
     this.templates.Add(chartColorTemplate.Name.ToLower(), chartColorTemplate);
 }
Beispiel #23
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     NewChartColorTemplateDialog colorTemplateDialog = new NewChartColorTemplateDialog();
     if (colorTemplateDialog.ShowDialog() != DialogResult.OK)
         return;
     ChartColorTemplate template = new ChartColorTemplate(colorTemplateDialog.TemplateName);
     foreach (KeyValuePair<string, Color> keyValuePair in Global.ChartManager.ColorTemplates.DefaultTemplate.Settings)
         template.Settings.Add(keyValuePair.Key, keyValuePair.Value);
     Global.ChartManager.ColorTemplates.AddTemplate(colorTemplateDialog.TemplateName, template);
     ChartColorTemplateViewItem templateViewItem = new ChartColorTemplateViewItem(template);
     this.ltvTemplates.Items.Add((ListViewItem)templateViewItem);
     templateViewItem.Selected = true;
 }