namespace IndexFormula.Finance.Win { using IndexFormula.Finance; using IndexFormula.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() { IndexFormula.Finance.ExchangeIntraday exchangeIntraday1 = new IndexFormula.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 IndexFormula.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 = IndexFormula.Finance.ChartDragMode.Axis; this.ChartControl.CrossCursorMouseMode = IndexFormula.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 = IndexFormula.Finance.LatestValueType.None; this.ChartControl.Location = new System.Drawing.Point(15, 36); this.ChartControl.MaxPrice = 0D; this.ChartControl.MinPrice = 0D; this.ChartControl.MouseWheelMode = IndexFormula.Finance.Win.MouseWheelMode.Scroll; this.ChartControl.MouseZoomMode = IndexFormula.Finance.Win.MouseZoomMode.Rect; this.ChartControl.Name = "ChartControl"; this.ChartControl.PriceLabelFormat = null; this.ChartControl.ScaleType = IndexFormula.Finance.ScaleType.Default; this.ChartControl.SelectFormulaMouseMode = IndexFormula.Finance.MouseAction.MouseDown; this.ChartControl.ShowHorizontalGrid = IndexFormula.Finance.Win.ShowLineMode.Default; this.ChartControl.ShowStatistic = false; this.ChartControl.ShowVerticalGrid = IndexFormula.Finance.Win.ShowLineMode.Default; this.ChartControl.Size = new System.Drawing.Size(693, 428); this.ChartControl.StartTime = new System.DateTime(((long)(0))); this.ChartControl.StickRenderType = IndexFormula.Finance.StickRenderType.Default; this.ChartControl.StockBars = 70; this.ChartControl.StockRenderType = IndexFormula.Finance.StockRenderType.Default; this.ChartControl.Symbol = "Test"; this.ChartControl.TabIndex = 5; this.ChartControl.ValueTextMode = IndexFormula.Finance.ValueTextMode.Default; this.ChartControl.ZoomPosition = IndexFormula.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(); } } }