internal void FireUserDrawingComplete(LineStudy.StudyTypeEnum studyTypeEnum, string key) { if (UserDrawingComplete != null) { UserDrawingComplete(this, new UserDrawingCompleteEventArgs(studyTypeEnum, key)); } }
private void ReadLineStudies(XmlNode xRoot) { XmlNode xmlLineStudies = xRoot.SelectSingleNode("LineStudies"); if (xmlLineStudies == null) { return; } int useablePanelsCount = UseablePanelsCount; foreach (XmlNode node in xmlLineStudies.ChildNodes) { if (node.Name != "LineStudy") { return; } int panelIndex = ConvertFromXmlEx("PanelIndex", node, -1); if (panelIndex == -1) { continue; } if (panelIndex >= useablePanelsCount) { panelIndex = 0; } string key = ConvertFromXmlEx("Key", node, String.Empty); string studyTypeS = ConvertFromXmlEx("StudyType", node, String.Empty); LineStudy.StudyTypeEnum studyType = (LineStudy.StudyTypeEnum)Enum.Parse(typeof(LineStudy.StudyTypeEnum), studyTypeS); Brush stroke = (Brush)ConvertFromXml("StrokeColor", node); object[] extrArgs = ConvertFromBinary(ConvertFromXmlEx("ExtraArgs", node, string.Empty)); LineStudy lineStudy = CreateLineStudy(studyType, key, stroke, panelIndex); lineStudy.SetArgs(extrArgs); double x1Value = ConvertFromXmlEx("X1Value", node, 0.0); double x2Value = ConvertFromXmlEx("X2Value", node, 0.0); double y1Value = ConvertFromXmlEx("Y1Value", node, 0.0); double y2Value = ConvertFromXmlEx("Y2Value", node, 0.0); lineStudy.SetXYValues(x1Value, y1Value, x2Value, y2Value); lineStudy._selectable = ConvertFromXmlEx("Selectable", node, false); lineStudy.StrokeThickness = ConvertFromXmlEx("StrokeThickness", node, 1.0); lineStudy.StrokeType = (LinePattern)Enum.Parse(typeof(LinePattern), ConvertFromXmlEx("StrokeType", node, LinePattern.Solid.ToString())); lineStudy.Opacity = ConvertFromXmlEx("Opacity", node, 1.0); if (lineStudy is IShapeAble) { IShapeAble shapeAble = (IShapeAble)lineStudy; shapeAble.Fill = (Brush)ConvertFromXml("Fill", node); } } }
internal static void RegisterLineStudy(LineStudy.StudyTypeEnum studyTypeEnum, Type CLRType, string friendlyName) { if (_lineStudiesTypes.ContainsKey(studyTypeEnum)) { return; } _lineStudiesTypes[studyTypeEnum] = new LineStudyParams() { CLRType = CLRType, FriendlyName = friendlyName, StudyTypeEnum = studyTypeEnum }; }
/// <summary> /// Initializes a new instance of the <see cref="UserDrawingCompleteEventArgs"/> class. /// </summary> /// <param name="studyTypeEnum">Study type that was painted</param> /// <param name="key">Unique associated with line study</param> public UserDrawingCompleteEventArgs(LineStudy.StudyTypeEnum studyTypeEnum, string key) { StudyType = studyTypeEnum; Key = key; }
/// <summary> /// Gets the CLR type by internal line study type. /// </summary> /// <param name="studyTypeEnum">Internal type</param> /// <returns>CLR Type</returns> public static Type GetLineStudyCLRType(LineStudy.StudyTypeEnum studyTypeEnum) { RegisterAll(); return(_lineStudiesTypes[studyTypeEnum].CLRType); }
internal static string GetLineStudyFriendlyName(LineStudy.StudyTypeEnum studyTypeEnum) { RegisterAll(); return(_lineStudiesTypes[studyTypeEnum].FriendlyName); }
public void AddLineStudy(LineStudy.StudyTypeEnum studyTypeEnum, Color color, object[] extraArgs = null) { object[] args = new object[0]; double strokeThicknes = 1; //set some extra parameters to line studies switch (studyTypeEnum) { case LineStudy.StudyTypeEnum.StaticText: args = new object[] { "Some text for testing" }; strokeThicknes = 12; //for text objects is FontSize break; case LineStudy.StudyTypeEnum.VerticalLine: //when first parameter is false, vertical line will display DataTime instead on record number args = new object[] { false, //true - show record number, false - show datetime true, //true - show text with line, false - show only line "d", //custom datetime format, when args[0] == false. See MSDN:DateTime.ToString(string) for legal values }; break; case LineStudy.StudyTypeEnum.ImageObject: args = new object[] { "Res/open.png" }; break; case LineStudy.StudyTypeEnum.FibonacciRetracements: if (extraArgs != null) { args = extraArgs; } else { args = new object[] { 1.0, 0.763932, 0.618034, 0.5, 0.381966, 0.236068, 0.0, } }; break; default: break; } UserDrawingActivated = true; string studyName = studyTypeEnum.ToString(); int count = _stockChartX.GetLineStudyCountByType(studyTypeEnum); if (count > 0) { studyName += count; } Brush fbrush = new SolidColorBrush(color); LineStudy lineStudy = _stockChartX.AddLineStudy(studyTypeEnum, studyName, fbrush, args); lineStudy.StrokeThickness = strokeThicknes; switch (studyTypeEnum) { case LineStudy.StudyTypeEnum.StaticText: //if linestudy is a text object we can change its text directly ((StaticText)lineStudy).Text = "Some other text for testing"; break; case LineStudy.StudyTypeEnum.HorizontalLine: //change the appearance of horizontal Line lineStudy.StrokeType = LinePattern.DashDot; break; case LineStudy.StudyTypeEnum.ImageObject: //set an additional ImageAlign property, this is very usefull when setting //images for close and open price, when you want to put image below or above a candle //for Open price you'd use ImageObject.ImageAlign.BottomMiddle //for Close price you'd use ImageObject.ImageAlign.TopMiddle ((ImageObject)lineStudy).Align = ImageObject.ImageAlign.Center; break; } if (studyTypeEnum == LineStudy.StudyTypeEnum.HorizontalLine) { lineStudy.ValuePresenterAlignment = LineStudy.ValuePresenterAlignmentType.Left; lineStudy.LineStudyValue = new CustomHorLineValueGetter(_stockChartX); } }
public void AddLineStudy(LineStudy.StudyTypeEnum studyTypeEnum, Color color) { AddLineStudy(studyTypeEnum, color, null); }
private void btnAddLineStudy_Click(object sender, RoutedEventArgs e) { LineStudy.StudyTypeEnum studyTypeEnum = ((StockChartX_LineStudiesParams.LineStudyParams)cmbLineStudies.SelectedItem).StudyTypeEnum; object[] args = new object[0]; double strokeThicknes = 1; //set some extra parameters to line studies switch (studyTypeEnum) { case LineStudy.StudyTypeEnum.StaticText: args = new object[] { "Some text for testing" }; strokeThicknes = 12; //for text objects is FontSize break; case LineStudy.StudyTypeEnum.VerticalLine: //when first parameter is false, vertical line will display DataTime instead on record number args = new object[] { false, //true - show record number, false - show datetime true, //true - show text with line, false - show only line "d", //custom datetime format, when args[0] == false. See MSDN:DateTime.ToString(string) for legal values }; break; case LineStudy.StudyTypeEnum.ImageObject: args = new object[] { "Res/open.png" }; break; default: break; } string studyName = studyTypeEnum.ToString(); int count = _stockChartX.GetLineStudyCountByType(studyTypeEnum); if (count > 0) { studyName += count; } LineStudy lineStudy = _stockChartX.AddLineStudy(studyTypeEnum, studyName, new SolidColorBrush(colorPicker.SelectedColor), args); lineStudy.StrokeThickness = strokeThicknes; switch (studyTypeEnum) { case LineStudy.StudyTypeEnum.StaticText: //if linestudy is a text object we can change its text directly ((StaticText)lineStudy).Text = "Some other text for testing"; break; case LineStudy.StudyTypeEnum.HorizontalLine: //change the appearance of horizontal Line lineStudy.StrokeType = LinePattern.DashDot; break; case LineStudy.StudyTypeEnum.ImageObject: //set an additional ImageAlign property, this is very usefull when setting //images for close and open price, when you want to put image below or above a candle //for Open price you'd use ImageObject.ImageAlign.BottomMiddle //for Close price you'd use ImageObject.ImageAlign.TopMiddle ((ImageObject)lineStudy).Align = ImageObject.ImageAlign.Center; break; } btnAddLineStudy.IsEnabled = false; if (studyTypeEnum == LineStudy.StudyTypeEnum.HorizontalLine) { lineStudy.ValuePresenterAlignment = LineStudy.ValuePresenterAlignmentType.Left; lineStudy.LineStudyValue = new CustomHorLineValueGetter(_stockChartX); } }