using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Xml; using System.Windows.Forms; using TradeIdeas.TIProData; using TradeIdeas.TIProData.Configuration; using TradeIdeas.XML; namespace TradeIdeas.TIProGUI { public partial class StratgyColors : Form,ICultureListener { private List _phrases; Label _label = new Label(); // static private int[] _customColors; /// /// Constructor for the StrategyColors Class /// /// live data object passed to constructory public StratgyColors(MultiStrategy.DataWatcher data) { InitializeComponent(); MinimizeBox = false; Icon = GuiEnvironment.Icon; _phrases = GuiEnvironment.XmlConfig.Node("MULTI_STRATEGY_WINDOW").Node("PHRASES"); lblColor.ForeColor = data.Style.ForeColor; lblColor.BackColor = data.Style.BackColor; _label.ForeColor = lblColor.ForeColor; _label.BackColor = lblColor.BackColor; CultureChanged(); Font = GuiEnvironment.FontSettings; StartPosition = FormStartPosition.CenterParent; } /// /// responsible for language changes /// public void CultureChanged() { btnForeground.Text = _phrases.Node("FOREGROUND").PropertyForCulture("TEXT", "***"); btnBackground.Text = _phrases.Node("BACKGROUND").PropertyForCulture("TEXT", "***"); lblColor.Text = _phrases.Node("SAMPLE_COLORS").PropertyForCulture("TEXT", "***"); btnOK.Text = GuiEnvironment.XmlConfig.Node("COMMON_PHRASES").Node("OK").PropertyForCulture("TEXT", "***"); btnCancel.Text = GuiEnvironment.XmlConfig.Node("COMMON_PHRASES").Node("CANCEL").PropertyForCulture("TEXT", "***"); } private void btnForeground_Click(object sender, EventArgs e) { // colorDialog1.CustomColors = _customColors; colorDialog1.Color = lblColor.ForeColor; SetColor( true); } private void btnBackground_Click(object sender, EventArgs e) { // colorDialog1.CustomColors = _customColors; colorDialog1.Color = lblColor.BackColor; SetColor(false); } private void btnOK_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; } /// /// Returns a color /// /// returns a label object (which has forecolor and backcolor attributes which can be extracted public Label returnColors() { return _label; } private void SetColor( bool foreground) { if (colorDialog1.ShowDialog() == DialogResult.OK) { if (foreground) { _label.ForeColor = colorDialog1.Color; lblColor.ForeColor = colorDialog1.Color; } else { _label.BackColor = colorDialog1.Color; lblColor.BackColor = colorDialog1.Color; } // _customColors = (int[])colorDialog1.CustomColors.Clone(); } } private void btnCancel_Click(object sender, EventArgs e) { this.Dispose(); } } }