public ChartSettings(string name, bool showLegend, LegendPossition possition, bool isLogarithmic) { Name = name; ShowLegend = showLegend; Possition = possition; IsLogarithmic = isLogarithmic; }
private void viewToolStripMenuItem_DropDownOpening(object sender, EventArgs e) { StepFrame selectedFrame = ApplicationManager.GetSelectedStepFrame(); bool state = selectedFrame != null; viewToolStripMenuItem.DropDownItems[6].Visible = state; // Separator. viewToolStripMenuItem.DropDownItems[8].Visible = state; // Show legend. viewToolStripMenuItem.DropDownItems[9].Visible = state; // Legend position. viewToolStripMenuItem.DropDownItems[10].Visible = state; // Logarithmic. if (!state) { return; } LegendPossition position = selectedFrame.SelectedChartPosition; foreach (ToolStripMenuItem menuItem in legendPossitionToolStripMenuItem.DropDownItems) { menuItem.Checked = menuItem.Text == position.ToString(); } showLegendToolStripMenuItem.Checked = selectedFrame.SelectedChartLegendIsVisible; logarithmicToolStripMenuItem.Checked = selectedFrame.SelectedChartIsLogarithmic; }
private void MoveLegend(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; LegendPossition position = (LegendPossition)Enum.Parse(typeof(LegendPossition), item.Text); StepFrame selectedFrame = ApplicationManager.GetSelectedStepFrame(); selectedFrame.SelectedChartPosition = position; foreach (ToolStripMenuItem menuItem in legendPossitionToolStripMenuItem.DropDownItems) { menuItem.Checked = menuItem.Text == item.Text; } }
public void SetLegenedPosition(LegendPossition position) { foreach (ToolStripMenuItem menuItem in legendPossitionToolStripMenuItem.DropDownItems) { menuItem.Checked = (LegendPossition)menuItem.Tag == position; } ChartArea legendArea = chart1.ChartAreas["ChartAreaLegend"]; switch (position) { case LegendPossition.Left: legendArea.Position = new ElementPosition(0, 0, 9, 100); legendArea.Tag = LegendPossition.Left; chartArea.Position = new ElementPosition(10, 0, 90, 100); break; case LegendPossition.Right: legendArea.Position = new ElementPosition(91, 0, 9, 100); legendArea.Tag = LegendPossition.Right; chartArea.Position = new ElementPosition(0, 0, 90, 100); break; case LegendPossition.Top: legendArea.Position = new ElementPosition(0, 0, 100, 9); legendArea.Tag = LegendPossition.Top; chartArea.Position = new ElementPosition(0, 10, 100, 90); break; case LegendPossition.Bottom: legendArea.Position = new ElementPosition(0, 91, 100, 9); legendArea.Tag = LegendPossition.Bottom; chartArea.Position = new ElementPosition(0, 0, 100, 90); break; } foreach (Legend legend in chart1.Legends) { legend.Position = legendArea.Position; } legendToolStripMenuItem.Visible = true; lastPossition = chartArea.Position; }
public void ReadXml(XmlReader reader) { // <TreeView Order> reader.ReadStartElement("TreeView"); reader.ReadStartElement("TreeViewOrder"); Layout.TreeView.treeViewOrder = (TreeViewOrder)Enum.Parse(typeof(TreeViewOrder), reader.ReadContentAsString()); reader.ReadEndElement(); reader.ReadEndElement(); // <//TreeViewOrder> // <ComboBoxes> reader.ReadStartElement("ComboBoxes"); int count = 0; while (reader.IsStartElement("ComboBox")) { // <ComboBox> reader.ReadStartElement("ComboBox"); reader.ReadStartElement("Name"); string name = reader.ReadContentAsString(); reader.ReadEndElement(); reader.ReadStartElement("Text"); string value = reader.ReadContentAsString(); reader.ReadEndElement(); // Set combo boxes. Layout.ComboBoxes.First(x => x.Name == name).Text = value; reader.ReadEndElement(); // </ComboBox> count++; } reader.ReadEndElement(); // </ComboBoxes> // <ToolStripButtons> reader.ReadStartElement("ToolStripButtons"); count = 0; while (reader.IsStartElement("Button")) { // <Button> reader.ReadStartElement("Button"); reader.ReadStartElement("Name"); string name = reader.ReadContentAsString(); reader.ReadEndElement(); reader.ReadStartElement("Checked"); bool isChecked = Boolean.Parse(reader.ReadContentAsString()); reader.ReadEndElement(); // Set buttons. var currentButton = Layout.Buttons.First(x => x.Name == name); currentButton.Checked = !isChecked; currentButton.PerformClick(); reader.ReadEndElement(); // </Button> count++; } reader.ReadEndElement(); // </ToolStripButtons> // <TrackBar> reader.ReadStartElement("TrackBar"); Layout.TrackBar.Value = Int32.Parse(reader.ReadContentAsString()); reader.ReadEndElement(); // </TrackBar> // <StepFrameSettings> reader.ReadStartElement("StepFrameSettings"); while (reader.IsStartElement("Frame")) { // <Frame> reader.ReadStartElement("Frame"); reader.ReadStartElement("Name"); string name = reader.ReadContentAsString(); reader.ReadEndElement(); TestMethod method = (TestMethod)Enum.Parse(typeof(TestMethod), name); List <ChartSettings> chartSettings = new List <ChartSettings>(); while (reader.IsStartElement("Chart")) { // <Chart> reader.ReadStartElement("Chart"); string chartName = null; if (!reader.IsEmptyElement) { reader.ReadStartElement("Name"); chartName = reader.ReadContentAsString(); } reader.Read(); reader.ReadStartElement("ShowLegend"); bool showLegend = Boolean.Parse(reader.ReadContentAsString()); reader.ReadEndElement(); reader.ReadStartElement("IsLogarithmic"); bool isLogarithmic = Boolean.Parse(reader.ReadContentAsString()); reader.ReadEndElement(); reader.ReadStartElement("Position"); string position = reader.ReadContentAsString(); LegendPossition possition = (LegendPossition)Enum.Parse(typeof(LegendPossition), position); reader.ReadEndElement(); chartSettings.Add(new ChartSettings(chartName, showLegend, possition, isLogarithmic)); reader.ReadEndElement(); // </Chart> } reader.ReadEndElement(); // </Frame> Layout.SelectFrame(method); Layout.StepFrames[method].SetSettings(chartSettings); } reader.ReadEndElement(); // <StepFrameSettings> }
public void ReadXml(XmlReader reader) { reader.ReadStartElement("XmlProjectPersist"); reader.ReadStartElement("Databases"); // Deserialize databases. while (reader.IsStartElement("IDatabase")) { Type dbType = Type.GetType(reader.GetAttribute("AssemblyQualifiedName")); bool state = Boolean.Parse(reader.GetAttribute("CheckedState")); reader.ReadStartElement("IDatabase"); XmlSerializer serial = new XmlSerializer(dbType); IDatabase db = (IDatabase)serial.Deserialize(reader); db.Color = ColorTranslator.FromHtml(reader.ReadContentAsString()); Databases.Add(db, state); reader.ReadEndElement(); // IDatabase. } reader.ReadEndElement(); // Databases. //Deserialize TreeView Order. IsCategoryOrder = bool.Parse(reader.GetAttribute("Value")); reader.ReadStartElement("TreeViewOrder");// TreeView order ends. // Deserialize ComboBoxes. reader.ReadStartElement("ComboBoxes"); while (reader.IsStartElement("ComboBox")) { string name = reader.GetAttribute("Name"); reader.ReadStartElement("ComboBox"); ComboBoxItems.Add(name, reader.ReadContentAsString()); reader.ReadEndElement(); // ComboBox. } reader.ReadEndElement(); // ComboBoxes. // Deserialize Buttons. reader.ReadStartElement("ToolStripButtons"); while (reader.IsStartElement("Button")) { string name = reader.GetAttribute("Name"); bool state = bool.Parse(reader.GetAttribute("Checked")); reader.ReadStartElement("Button"); Buttons.Add(name, state); } reader.ReadEndElement(); // Buttons. reader.ReadStartElement("TrackBar"); TrackBarValue = reader.ReadContentAsInt(); reader.ReadEndElement(); // TrackBar. reader.ReadStartElement("StepFrameSettings"); while (reader.IsStartElement("Frame")) { TestMethod method = (TestMethod)Enum.Parse(typeof(TestMethod), reader.GetAttribute("Name")); List <ChartSettings> chartSettings = new List <ChartSettings>(); reader.ReadStartElement("Frame"); while (reader.IsStartElement("Chart")) { string chartName = reader.GetAttribute("Name"); bool showLegend = Boolean.Parse(reader.GetAttribute("ShowLegend")); bool isLogarithmic = Boolean.Parse(reader.GetAttribute("IsLogarithmic")); reader.ReadStartElement(); LegendPossition possition = (LegendPossition)Enum.Parse(typeof(LegendPossition), reader.ReadContentAsString()); chartSettings.Add(new Charts.ChartSettings(chartName, showLegend, possition, isLogarithmic)); reader.ReadEndElement(); // Chart. } reader.ReadEndElement(); // Frame. ChartSettings.Add(new KeyValuePair <TestMethod, List <ChartSettings> >(method, chartSettings)); } reader.ReadEndElement(); // StepFrameSettings. reader.ReadEndElement(); // DatabaseXmlPersist. }
public void SetLegenedPosition(LegendPossition position) { foreach (ToolStripMenuItem menuItem in legendPossitionToolStripMenuItem.DropDownItems) menuItem.Checked = (LegendPossition)menuItem.Tag == position; ChartArea legendArea = chart1.ChartAreas["ChartAreaLegend"]; switch (position) { case LegendPossition.Left: legendArea.Position = new ElementPosition(0, 0, 9, 100); legendArea.Tag = LegendPossition.Left; chartArea.Position = new ElementPosition(10, 0, 90, 100); break; case LegendPossition.Right: legendArea.Position = new ElementPosition(91, 0, 9, 100); legendArea.Tag = LegendPossition.Right; chartArea.Position = new ElementPosition(0, 0, 90, 100); break; case LegendPossition.Top: legendArea.Position = new ElementPosition(0, 0, 100, 9); legendArea.Tag = LegendPossition.Top; chartArea.Position = new ElementPosition(0, 10, 100, 90); break; case LegendPossition.Bottom: legendArea.Position = new ElementPosition(0, 91, 100, 9); legendArea.Tag = LegendPossition.Bottom; chartArea.Position = new ElementPosition(0, 0, 100, 90); break; } foreach (Legend legend in chart1.Legends) legend.Position = legendArea.Position; legendToolStripMenuItem.Visible = true; lastPossition = chartArea.Position; }