示例#1
0
 private void chartToolStrip1_TemplateAction(object sender, TemplateActionEventArgs args)
 {
   switch (args.ActionType)
   {
     case TemplateActionType.Load:
       this.template = Global.ChartManager.Templates[args.TemplateName];
       this.ApplyTemplate();
       ((Control) this.chart).Refresh();
       break;
     case TemplateActionType.Save:
     case TemplateActionType.SaveAs:
       SaveTemplateDialog saveTemplateDialog = new SaveTemplateDialog();
       if (saveTemplateDialog.ShowDialog() != DialogResult.OK)
         break;
       Global.ChartManager.Templates.Add(saveTemplateDialog.TemplateName, this.template);
       break;
     case TemplateActionType.ChooseEmpty:
       this.template = Global.ChartManager.Templates.EmptyTemplate;
       this.ApplyTemplate();
       ((Control) this.chart).Refresh();
       break;
     case TemplateActionType.ChooseDefault:
       this.template = Global.ChartManager.Templates["Default Template"];
       this.ApplyTemplate();
       ((Control) this.chart).Refresh();
       break;
     case TemplateActionType.SetDefault:
       Global.ChartManager.Templates.Replace("Default Template", this.template);
       break;
   }
 }
示例#2
0
 internal ChartTemplate(ChartTemplate template)
 {
     foreach (KeyValuePair <int, PadTemplate> keyValuePair in template.padTemplates)
     {
         this.padTemplates.Add(keyValuePair.Key, new PadTemplate(keyValuePair.Value));
     }
 }
示例#3
0
        protected override void OnInit()
        {
            this.instrument = this.Key as Instrument;
            DataSeriesList dataSeries = this.instrument.GetDataSeries();

            this.template = Global.ChartManager.Templates["Default Template"];
            this.Text     = "Chart [" + ((FIXInstrument)this.instrument).Symbol + "]";
            this.instrumentListSource.AddInstrument(this.instrument);
            this.instrumentListSource.SelectedInstrument = this.instrument;
            IEnumerator enumerator = dataSeries.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    IDataSeries idataSeries = (IDataSeries)enumerator.Current;
                    string      key         = DataSeriesHelper.SeriesNameToString(idataSeries.Name);
                    if (key.StartsWith("Bar") || key == "Daily")
                    {
                        this.seriesNames.Add(key, idataSeries.Name);
                        this.instrumentListSource.AddSeries(this.instrument, new BarSeries(key));
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            this.instrumentListSource.Refresh();
        }
示例#4
0
 public void Replace(string name, ChartTemplate template)
 {
     this.templates[name.ToLower()] = template;
     if (!this.templateNames.Contains(name))
     {
         this.templateNames.Add(name);
     }
     this.SaveTemplate(name, template);
 }
示例#5
0
        private void SaveTemplate(string name, ChartTemplate template)
        {
            ChartTemplateXmlDocument templateXmlDocument = new ChartTemplateXmlDocument();

            foreach (KeyValuePair <int, PadTemplate> keyValuePair in template.PadTemplates)
            {
                PadTemplateXmlNode padTemplateXmlNode = templateXmlDocument.PadTemplates.Add();
                padTemplateXmlNode.Number = keyValuePair.Key;
                foreach (IndicatorTemplateItem indicatorTemplate in keyValuePair.Value.IndicatorTemplates)
                {
                    this.SaveIndicatorTemplate(padTemplateXmlNode.IndicatorTemplates.Add(), indicatorTemplate);
                }
            }
            ((XmlDocument)templateXmlDocument).Save(string.Format("{0}\\{1}{2}", (object)this.directory.FullName, (object)name, (object)".ctp"));
        }
示例#6
0
 private void LoadTemplate(FileInfo file)
 {
   ChartTemplateXmlDocument templateXmlDocument = new ChartTemplateXmlDocument();
   ((XmlDocument) templateXmlDocument).Load(file.FullName);
   ChartTemplate chartTemplate = new ChartTemplate();
   foreach (PadTemplateXmlNode padTemplateXmlNode in templateXmlDocument.PadTemplates)
   {
     PadTemplate padTemplate = new PadTemplate();
     chartTemplate.PadTemplates.Add(padTemplateXmlNode.Number, padTemplate);
     foreach (IndicatorTemplateXmlNode indicatorNode in padTemplateXmlNode.IndicatorTemplates)
     {
       IndicatorTemplateItem indicatorTemplate = new IndicatorTemplateItem(indicatorNode.Type);
       padTemplate.IndicatorTemplates.Add(indicatorTemplate);
       this.LoadIndicatorTemplate(indicatorTemplate, indicatorNode);
     }
   }
   string withoutExtension = Path.GetFileNameWithoutExtension(file.Name);
   this.templates.Add(withoutExtension.ToLower(), chartTemplate);
   this.templateNames.Add(withoutExtension);
 }
示例#7
0
        private void LoadTemplate(FileInfo file)
        {
            ChartTemplateXmlDocument templateXmlDocument = new ChartTemplateXmlDocument();

            ((XmlDocument)templateXmlDocument).Load(file.FullName);
            ChartTemplate chartTemplate = new ChartTemplate();

            foreach (PadTemplateXmlNode padTemplateXmlNode in templateXmlDocument.PadTemplates)
            {
                PadTemplate padTemplate = new PadTemplate();
                chartTemplate.PadTemplates.Add(padTemplateXmlNode.Number, padTemplate);
                foreach (IndicatorTemplateXmlNode indicatorNode in padTemplateXmlNode.IndicatorTemplates)
                {
                    IndicatorTemplateItem indicatorTemplate = new IndicatorTemplateItem(indicatorNode.Type);
                    padTemplate.IndicatorTemplates.Add(indicatorTemplate);
                    this.LoadIndicatorTemplate(indicatorTemplate, indicatorNode);
                }
            }
            string withoutExtension = Path.GetFileNameWithoutExtension(file.Name);

            this.templates.Add(withoutExtension.ToLower(), chartTemplate);
            this.templateNames.Add(withoutExtension);
        }
示例#8
0
        private void chartToolStrip1_TemplateAction(object sender, TemplateActionEventArgs args)
        {
            switch (args.ActionType)
            {
            case TemplateActionType.Load:
                this.template = Global.ChartManager.Templates[args.TemplateName];
                this.ApplyTemplate();
                ((Control)this.chart).Refresh();
                break;

            case TemplateActionType.Save:
            case TemplateActionType.SaveAs:
                SaveTemplateDialog saveTemplateDialog = new SaveTemplateDialog();
                if (saveTemplateDialog.ShowDialog() != DialogResult.OK)
                {
                    break;
                }
                Global.ChartManager.Templates.Add(saveTemplateDialog.TemplateName, this.template);
                break;

            case TemplateActionType.ChooseEmpty:
                this.template = Global.ChartManager.Templates.EmptyTemplate;
                this.ApplyTemplate();
                ((Control)this.chart).Refresh();
                break;

            case TemplateActionType.ChooseDefault:
                this.template = Global.ChartManager.Templates["Default Template"];
                this.ApplyTemplate();
                ((Control)this.chart).Refresh();
                break;

            case TemplateActionType.SetDefault:
                Global.ChartManager.Templates.Replace("Default Template", this.template);
                break;
            }
        }
示例#9
0
 protected override void OnInit()
 {
   this.instrument = this.Key as Instrument;
   DataSeriesList dataSeries = this.instrument.GetDataSeries();
   this.template = Global.ChartManager.Templates["Default Template"];
   this.Text = "Chart [" + ((FIXInstrument) this.instrument).Symbol + "]";
   this.instrumentListSource.AddInstrument(this.instrument);
   this.instrumentListSource.SelectedInstrument = this.instrument;
   IEnumerator enumerator = dataSeries.GetEnumerator();
   try
   {
     while (enumerator.MoveNext())
     {
       IDataSeries idataSeries = (IDataSeries) enumerator.Current;
       string key = DataSeriesHelper.SeriesNameToString(idataSeries.Name);
       if (key.StartsWith("Bar") || key == "Daily")
       {
         this.seriesNames.Add(key, idataSeries.Name);
         this.instrumentListSource.AddSeries(this.instrument, new BarSeries(key));
       }
     }
   }
   finally
   {
     IDisposable disposable = enumerator as IDisposable;
     if (disposable != null)
       disposable.Dispose();
   }
   this.instrumentListSource.Refresh();
 }
示例#10
0
 public void Replace(string name, ChartTemplate template)
 {
   this.templates[name.ToLower()] = template;
   if (!this.templateNames.Contains(name))
     this.templateNames.Add(name);
   this.SaveTemplate(name, template);
 }
示例#11
0
 public void Add(string name, ChartTemplate template)
 {
   this.templates.Add(name.ToLower(), template);
   this.templateNames.Add(name);
   this.SaveTemplate(name, template);
 }
示例#12
0
 private void SaveTemplate(string name, ChartTemplate template)
 {
   ChartTemplateXmlDocument templateXmlDocument = new ChartTemplateXmlDocument();
   foreach (KeyValuePair<int, PadTemplate> keyValuePair in template.PadTemplates)
   {
     PadTemplateXmlNode padTemplateXmlNode = templateXmlDocument.PadTemplates.Add();
     padTemplateXmlNode.Number = keyValuePair.Key;
     foreach (IndicatorTemplateItem indicatorTemplate in keyValuePair.Value.IndicatorTemplates)
       this.SaveIndicatorTemplate(padTemplateXmlNode.IndicatorTemplates.Add(), indicatorTemplate);
   }
   ((XmlDocument) templateXmlDocument).Save(string.Format("{0}\\{1}{2}", (object) this.directory.FullName, (object) name, (object) ".ctp"));
 }
示例#13
0
 internal ChartTemplate(ChartTemplate template)
 {
   foreach (KeyValuePair<int, PadTemplate> keyValuePair in template.padTemplates)
     this.padTemplates.Add(keyValuePair.Key, new PadTemplate(keyValuePair.Value));
 }
示例#14
0
 public void Add(string name, ChartTemplate template)
 {
     this.templates.Add(name.ToLower(), template);
     this.templateNames.Add(name);
     this.SaveTemplate(name, template);
 }