| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- namespace Easychart.Finance.Win
- {
- using Easychart.Finance;
- using Easychart.Finance.DataProvider;
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.IO;
- using System.Windows.Forms;
- using System.Xml.Serialization;
- [ToolboxItem(false)]
- public class SkinEditor : Form
- {
- private Button btnCreateNew;
- private Button btnOK;
- private Button btnSave;
- private ComboBox cbSkin;
- private ChartWinControl ChartControl;
- private Container components = null;
- private Label lBuildin;
- private PropertyGrid pg;
- private Panel pnClient;
- private Panel pnRight;
- private Splitter spVerticle;
- public SkinEditor()
- {
- this.InitializeComponent();
- }
- private void btnCreateNew_Click(object sender, EventArgs e)
- {
- string str = "CustomSkin";
- for (int i = 1; i < 10; i++)
- {
- if (FormulaSkin.CheckSkinName(str + i))
- {
- FormulaSkin selectedObject = (FormulaSkin) this.pg.SelectedObject;
- selectedObject = selectedObject.Clone();
- selectedObject.SkinName = str + i;
- selectedObject.Save();
- this.cbSkin.Items.Add(selectedObject.SkinName);
- this.cbSkin.SelectedIndex = this.cbSkin.Items.Count - 1;
- this.cbSkin_SelectedIndexChanged(this, null);
- break;
- }
- }
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- base.Close();
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- XmlSerializer serializer = new XmlSerializer(typeof(FormulaSkin));
- Directory.CreateDirectory(FormulaHelper.SkinRoot);
- ((FormulaSkin) this.pg.SelectedObject).Save();
- }
- private void cbSkin_SelectedIndexChanged(object sender, EventArgs e)
- {
- FormulaSkin skinByName = FormulaSkin.GetSkinByName(this.cbSkin.SelectedItem.ToString());
- this.pg.SelectedObject = skinByName;
- skinByName.CollectionValueChanged -= new EventHandler(this.fs_CollectionValueChanged);
- skinByName.CollectionValueChanged += new EventHandler(this.fs_CollectionValueChanged);
- this.ChartControl.Skin = this.cbSkin.SelectedItem.ToString();
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing && (this.components != null))
- {
- this.components.Dispose();
- }
- base.Dispose(disposing);
- }
- private void fs_CollectionValueChanged(object sender, EventArgs e)
- {
- this.ChartControl.ApplySkin((FormulaSkin) this.pg.SelectedObject);
- }
- private void InitializeComponent()
- {
- Easychart.Finance.ExchangeIntraday exchangeIntraday1 = new Easychart.Finance.ExchangeIntraday();
- this.pnClient = new System.Windows.Forms.Panel();
- this.pnRight = new System.Windows.Forms.Panel();
- this.lBuildin = new System.Windows.Forms.Label();
- this.ChartControl = new Easychart.Finance.Win.ChartWinControl();
- this.btnCreateNew = new System.Windows.Forms.Button();
- this.btnSave = new System.Windows.Forms.Button();
- this.btnOK = new System.Windows.Forms.Button();
- this.cbSkin = new System.Windows.Forms.ComboBox();
- this.spVerticle = new System.Windows.Forms.Splitter();
- this.pnClient.SuspendLayout();
- this.pnRight.SuspendLayout();
- this.SuspendLayout();
- //
- // pnClient
- //
- this.pnClient.Controls.Add(this.pnRight);
- this.pnClient.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pnClient.Font = new System.Drawing.Font("Verdana", 8.5F);
- this.pnClient.Location = new System.Drawing.Point(0, 0);
- this.pnClient.Name = "pnClient";
- this.pnClient.Size = new System.Drawing.Size(720, 510);
- this.pnClient.TabIndex = 1;
- //
- // pnRight
- //
- this.pnRight.Controls.Add(this.lBuildin);
- this.pnRight.Controls.Add(this.ChartControl);
- this.pnRight.Controls.Add(this.btnCreateNew);
- this.pnRight.Controls.Add(this.btnSave);
- this.pnRight.Controls.Add(this.btnOK);
- this.pnRight.Controls.Add(this.cbSkin);
- this.pnRight.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pnRight.Location = new System.Drawing.Point(0, 0);
- this.pnRight.Name = "pnRight";
- this.pnRight.Size = new System.Drawing.Size(720, 510);
- this.pnRight.TabIndex = 3;
- //
- // lBuildin
- //
- this.lBuildin.AutoSize = true;
- this.lBuildin.Location = new System.Drawing.Point(8, 8);
- this.lBuildin.Name = "lBuildin";
- this.lBuildin.Size = new System.Drawing.Size(94, 14);
- this.lBuildin.TabIndex = 6;
- this.lBuildin.Text = "Build-in skins:";
- //
- // ChartControl
- //
- this.ChartControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.ChartControl.CausesValidation = false;
- this.ChartControl.ChartDragMode = Easychart.Finance.ChartDragMode.Axis;
- this.ChartControl.CrossCursorMouseMode = Easychart.Finance.MouseAction.MouseMove;
- this.ChartControl.DefaultFormulas = "MAIN;VOLMA;RSI(14)#RSI(28);MACD";
- this.ChartControl.Designing = false;
- this.ChartControl.EndTime = new System.DateTime(((long)(0)));
- this.ChartControl.FavoriteFormulas = "VOLMA;RSI;CCI;OBV;ATR;FastSTO;SlowSTO;ROC;TRIX;WR;AD;CMF;PPO;StochRSI;ULT;BBWidth" +
- ";PVO";
- exchangeIntraday1.TimeZone = -4D;
- this.ChartControl.IntradayInfo = exchangeIntraday1;
- this.ChartControl.LatestValueType = Easychart.Finance.LatestValueType.None;
- this.ChartControl.Location = new System.Drawing.Point(15, 36);
- this.ChartControl.MaxPrice = 0D;
- this.ChartControl.MinPrice = 0D;
- this.ChartControl.MouseWheelMode = Easychart.Finance.Win.MouseWheelMode.Scroll;
- this.ChartControl.MouseZoomMode = Easychart.Finance.Win.MouseZoomMode.Rect;
- this.ChartControl.Name = "ChartControl";
- this.ChartControl.PriceLabelFormat = null;
- this.ChartControl.ScaleType = Easychart.Finance.ScaleType.Default;
- this.ChartControl.SelectFormulaMouseMode = Easychart.Finance.MouseAction.MouseDown;
- this.ChartControl.ShowHorizontalGrid = Easychart.Finance.Win.ShowLineMode.Default;
- this.ChartControl.ShowStatistic = false;
- this.ChartControl.ShowVerticalGrid = Easychart.Finance.Win.ShowLineMode.Default;
- this.ChartControl.Size = new System.Drawing.Size(693, 428);
- this.ChartControl.StartTime = new System.DateTime(((long)(0)));
- this.ChartControl.StickRenderType = Easychart.Finance.StickRenderType.Default;
- this.ChartControl.StockBars = 70;
- this.ChartControl.StockRenderType = Easychart.Finance.StockRenderType.Default;
- this.ChartControl.Symbol = "Test";
- this.ChartControl.TabIndex = 5;
- this.ChartControl.ValueTextMode = Easychart.Finance.ValueTextMode.Default;
- this.ChartControl.ZoomPosition = Easychart.Finance.Win.ZoomCenterPosition.Center;
- //
- // btnCreateNew
- //
- this.btnCreateNew.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btnCreateNew.Location = new System.Drawing.Point(444, 477);
- this.btnCreateNew.Name = "btnCreateNew";
- this.btnCreateNew.Size = new System.Drawing.Size(104, 23);
- this.btnCreateNew.TabIndex = 4;
- this.btnCreateNew.Text = "Create New";
- this.btnCreateNew.Click += new System.EventHandler(this.btnCreateNew_Click);
- //
- // btnSave
- //
- this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btnSave.Location = new System.Drawing.Point(556, 477);
- this.btnSave.Name = "btnSave";
- this.btnSave.Size = new System.Drawing.Size(75, 23);
- this.btnSave.TabIndex = 3;
- this.btnSave.Text = "Save";
- this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
- //
- // btnOK
- //
- this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.btnOK.Location = new System.Drawing.Point(636, 477);
- this.btnOK.Name = "btnOK";
- this.btnOK.Size = new System.Drawing.Size(75, 23);
- this.btnOK.TabIndex = 2;
- this.btnOK.Text = "Close";
- this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
- //
- // cbSkin
- //
- this.cbSkin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cbSkin.Location = new System.Drawing.Point(104, 3);
- this.cbSkin.Name = "cbSkin";
- this.cbSkin.Size = new System.Drawing.Size(121, 21);
- this.cbSkin.TabIndex = 0;
- this.cbSkin.SelectedIndexChanged += new System.EventHandler(this.cbSkin_SelectedIndexChanged);
- //
- // spVerticle
- //
- this.spVerticle.Location = new System.Drawing.Point(0, 0);
- this.spVerticle.Name = "spVerticle";
- this.spVerticle.Size = new System.Drawing.Size(3, 510);
- this.spVerticle.TabIndex = 2;
- this.spVerticle.TabStop = false;
- //
- // SkinEditor
- //
- this.AcceptButton = this.btnSave;
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.CancelButton = this.btnOK;
- this.ClientSize = new System.Drawing.Size(720, 510);
- this.Controls.Add(this.spVerticle);
- this.Controls.Add(this.pnClient);
- this.Name = "SkinEditor";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "Skin Manager";
- this.Load += new System.EventHandler(this.SkinForm_Load);
- this.pnClient.ResumeLayout(false);
- this.pnRight.ResumeLayout(false);
- this.pnRight.PerformLayout();
- this.ResumeLayout(false);
- }
- private void pg_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
- {
- this.ChartControl.ApplySkin((FormulaSkin) this.pg.SelectedObject);
- }
- private void SkinForm_Load(object sender, EventArgs e)
- {
- this.cbSkin.Items.AddRange(FormulaSkin.GetBuildInSkins());
- this.ChartControl.DataManager = new RandomDataManager();
- }
- }
- }
|