private void LoadSeriesList() { treeSeries.Nodes.Clear(); foreach (var sr in InteractiveObjectSeries.GetObjectSeriesTypes()) { var attrs = sr.GetCustomAttributes(typeof(SeriesToolButtonAttribute), false); var seriesName = attrs.Length == 1 ? ((SeriesToolButtonAttribute)attrs[0]).Title : sr.Name; var imageIndex = attrs.Length == 1 ? (int)((SeriesToolButtonAttribute)attrs[0]).ImageIndex : -1; var node = treeSeries.Nodes.Add(seriesName, seriesName, imageIndex, imageIndex); node.Tag = sr; } }
/// <summary> /// сохранить настройки серий (см LoadSeriesSettingsFromXml) /// </summary> public static void SaveSeriesSettingsInXml(XmlElement nodeRoot) { var seriesTypes = InteractiveObjectSeries.GetObjectSeriesTypes(); foreach (var series in seriesTypes) { var nodeSeries = nodeRoot.OwnerDocument.CreateElement(series.Name); if (!PropertyXMLTagAttribute.SaveStaticProperties(series, nodeSeries, false)) { continue; } if (nodeSeries.ChildNodes.Count == 0) { continue; } nodeRoot.AppendChild(nodeSeries); } }
/// <summary> /// загрузить настройки серий /// (размер шрифта, цветовая схема по-умолчанию и т.п.) /// </summary> public static void LoadSeriesSettingsFromXml(XmlElement nodeRoot) { if (nodeRoot == null) { return; } var seriesTypes = InteractiveObjectSeries.GetObjectSeriesTypes(); foreach (XmlElement node in nodeRoot) { var seriesName = node.Name; // найти серию var series = seriesTypes.FirstOrDefault(s => s.Name == seriesName); if (series == null) { continue; } // инициализировать статические параметры серии PropertyXMLTagAttribute.InitStaticProperties(series, node, false); } }
private void InitAllButtons() { // предустановленные режимы allButtons.Add(new ChartToolButtonSettings { Image = (int)ToolButtonImageIndex.Arrow, Tool = CandleChartControl.ChartTool.Cursor, DefaultVisible = true, Title = Localizer.GetString("TitleCursor"), ButtonType = ChartToolButtonSettings.ToolButtonType.Chart }); allButtons.Add(new ChartToolButtonSettings { Image = (int)ToolButtonImageIndex.Ruller, Tool = CandleChartControl.ChartTool.TrendLine, DefaultVisible = true, Title = Localizer.GetString("TitleMeasurement"), toolParams = new List <SeriesEditParameter> { new SeriesEditParameter("MeasureOnly", typeof(bool), true), new SeriesEditParameter("Subtitles", typeof(bool), true), new SeriesEditParameter("Edit", typeof(bool), false) }, ButtonType = ChartToolButtonSettings.ToolButtonType.Chart }); allButtons.Add(new ChartToolButtonSettings { Image = (int)ToolButtonImageIndex.CrossLines, Tool = CandleChartControl.ChartTool.Cross, DefaultVisible = true, Title = Localizer.GetString("TitleCrosshair"), ButtonType = ChartToolButtonSettings.ToolButtonType.Chart }); allButtons.Add(new ChartToolButtonSettings { Image = (int)ToolButtonImageIndex.Script, Tool = CandleChartControl.ChartTool.Script, DefaultVisible = true, Title = Localizer.GetString("TitleScript"), ButtonType = ChartToolButtonSettings.ToolButtonType.Chart }); // кнопки графика var lstSeries = InteractiveObjectSeries.GetObjectSeriesTypes(); foreach (var t in lstSeries) { var attrBtn = (SeriesToolButtonAttribute)t.GetCustomAttributes(typeof(SeriesToolButtonAttribute), false)[0]; var button = new ChartToolButtonSettings { Image = (int)attrBtn.ImageIndex, DefaultVisible = attrBtn.DefaultTool, Title = attrBtn.Title, ButtonType = ChartToolButtonSettings.ToolButtonType.Chart, Tool = attrBtn.Tool }; foreach (SeriesToolButtonParamAttribute ptrAttr in t.GetCustomAttributes(typeof(SeriesToolButtonParamAttribute), false)) { button.toolParams.Add(new SeriesEditParameter { Name = ptrAttr.ParamName, title = ptrAttr.ParamTitle, defaultValue = ptrAttr.DefaultValue, paramType = ptrAttr.ParamType }); } allButtons.Add(button); } // терминальные кнопки foreach (var systemButtonType in Enum.GetValues(typeof(SystemToolButton)).Cast <SystemToolButton>().ToList()) { if (systemButtonType == SystemToolButton.None) { continue; } var systemButton = CommonToolButtonName.GetButtonDisplayName(systemButtonType); if (HiddenModes.ManagerMode || !systemButton.b) { allButtons.Add(new ChartToolButtonSettings { Title = systemButton.a, Image = CommonToolButtonName.buttonImageIndex[systemButtonType], DefaultVisible = true, ButtonType = ChartToolButtonSettings.ToolButtonType.System, SystemTool = systemButtonType }); } } }