using Microsoft.VisualBasic.CompilerServices; using MuchInfo.Chart.Data; using MuchInfo.Chart.Data.EnumTypes; using MuchInfo.Chart.Infrastructure.Helpers; using MuchInfo.Chart.WPF.Controls.Drawing; using MuchInfo.Chart.WPF.Helpers; using MuchInfo.Chart.WPF.Primitives.Interfaces; using System; using System.Collections.Generic; using System.Windows; using System.Windows.Input; using System.Windows.Media; namespace MuchInfo.Chart.WPF.Primitives.Drawing { public class DrawingTrendLine : Drawing2PointBase { #region Fields private ExtendableLine _extendableLine; #endregion Fields #region Properties #region Public Properties public override string RootName { get { return "DrawTrendLine"; } } #endregion Public Properties #endregion Properties #region Methods #region Public Methods public override string Abbreviation() { bool flag = this.mExtendLeft || this.mExtendRight; return LanguageManager.FindResource(flag ? LanguageConst.DrawingTool_Abbreviation_TrendLineExtend : LanguageConst.DrawingTool_Abbreviation_TrendLine); } public override IDrawingTool Clone() { return new DrawingTrendLine { mColor = Colors.White, mExtendLeft = this.mExtendLeft, mExtendRight = this.mExtendRight }; } public override string Description() { return this.MenuDescription(); } public override ImageSource Icon() { ImageSource result; try { result = ImageHelper.GetImage("TrendLine.png"); } catch (Exception expr_3A) { ProjectData.SetProjectError(expr_3A); result = null; ProjectData.ClearProjectError(); } return result; } public override string MenuDescription() { return LanguageManager.FindResource(LanguageConst.DrawingTool_Edit_Description_TrendLine); } public override DrawingToolType ToolType() { return DrawingToolType.TrendLine; } #endregion Public Methods #region Internal Methods internal void CreateParallel() { bool flag = this.mLastScale != null; if (flag) { var drawingTrendLine = new DrawingTrendLine(); var info = new DrawingToolInfo(); this.GetDrawingInfo(info); drawingTrendLine.FromInfo(info); drawingTrendLine.DrawingValue1 = this.mLastScale.GetRightValueScaler().ValueFromPercent((float)((double)this.mLastScale.GetRightValueScaler().PercentFromValue(this.DrawingValue1) - 0.1)); drawingTrendLine.DrawingValue2 = this.mLastScale.GetRightValueScaler().ValueFromPercent((float)((double)this.mLastScale.GetRightValueScaler().PercentFromValue(this.DrawingValue2) - 0.1)); IDrawingToolSpec drawingToolSpec = this.mLastScale.AddDrawing(this.Chart.CurrentSymbol, drawingTrendLine, this.Chart.CurrentTimeFrame); this.Chart.Refresh(); } } internal bool drawingTrendLine_3758() { var flag = this.mLastScale != null && this.mLastScale.HasPricePlot(); if (flag) { //bool flag2 = this.mOwner != null && this.mOwner.CurrentSymbol != null && this.mOwner.CurrentSymbol is BasicSymbol; //if (flag2) //{ // bool flag3 = !((BasicSymbol)this.mOwner.CurrentSymbol).IsFund() && !((BasicSymbol)this.mOwner.CurrentSymbol).IsPinkBullie(); // result = flag3; //} //else //{ // result = true; //} var symbol = this.Chart.CurrentSymbol; return !string.IsNullOrWhiteSpace(symbol); } return false; } internal void drawingTrendLine_3759(MouseEventArgs pos) { //bool flag = !UserDataManager.LoggedIn(); //if (flag) //{ // LoginControl.LoginShower.ShowLogin(null); //} //else //{ // flag = !AlertManager.UnderQuota(); // if (flag) // { // MarketingDialogs.ShowTooManyAlerts(); // } // else // { // dlgCreateTrendlineAlert dlgCreateTrendlineAlert = new dlgCreateTrendlineAlert(); // dlgCreateTrendlineAlert.Show(pos, this); // } //} } internal void drawingTrendLine_3760(int Freq, DateTime? ExpireDate, string aNote) { //try //{ // AlertXMLItem alertXMLItem = new AlertXMLItem(); // alertXMLItem.AlertType = 2; // alertXMLItem.BFCID = ((BasicSymbol)this.mOwner.CurrentSymbol).BFCid; // alertXMLItem.NotificationFrequency = Freq; // alertXMLItem.WebUserID = UserDataManager.UserID; // alertXMLItem.CreationDate = DateTime.Now; // alertXMLItem.Date1 = this.P1Date; // alertXMLItem.Date2 = this.P2Date; // alertXMLItem.Val1 = this.P1Val; // alertXMLItem.Val2 = this.P2Val; // alertXMLItem.Timeframe = this.mOwner.CurrentTimeFrame; // alertXMLItem.ExpireDate = ExpireDate; // alertXMLItem.IsLogScale = false; // ScaleLayer mLastScale = this.mLastScale; // bool flag = mLastScale != null && mLastScale.ScaleLayer_5525() != null && mLastScale.ScaleLayer_5525() is ValueScalerArithmetic; // if (flag) // { // alertXMLItem.IsLogScale = (((ValueScalerArithmetic)this.mLastScale.ScaleLayer_5525()).ScaleMode == ValueScalerArithmetic.enumScaleMethod.eLog); // } // XMLSaveFlags.AllowedDrawingSaveSymbols allowedDrawingSaveSymbols = new XMLSaveFlags.AllowedDrawingSaveSymbols(); // allowedDrawingSaveSymbols.SymbolUIDs.Add(this.mOwner.CurrentSymbol.UniqueID); // List list = new List(); // list.Add(allowedDrawingSaveSymbols); // string text = this.mOwner.ToAlertXML(); // MemoryStream memoryStream = new MemoryStream(); // try // { // BinaryWriter binaryWriter = new BinaryWriter(memoryStream); // try // { // binaryWriter.Write(1); // binaryWriter.Write(text); // MemoryStream memoryStream2 = Zipper.ZipToMS(memoryStream.ToArray()); // byte[] xTraXML; // try // { // xTraXML = memoryStream2.ToArray(); // } // finally // { // flag = (memoryStream2 != null); // if (flag) // { // memoryStream2.Dispose(); // } // } // alertXMLItem.XTraXML = xTraXML; // } // finally // { // flag = (binaryWriter != null); // if (flag) // { // binaryWriter.Dispose(); // } // } // } // finally // { // flag = (memoryStream != null); // if (flag) // { // memoryStream.Dispose(); // } // } // flag = (Operators.CompareString(aNote, "", false) != 0); // if (flag) // { // XElement xElement = new XElement("Alert"); // xElement.Add(AlertXMLItem.CreateNoteElement(aNote)); // alertXMLItem.AlertDef = xElement.ToString(); // } // AlertManager.AddAlert(alertXMLItem); //} //catch (Exception expr_288) //{ // ProjectData.SetProjectError(expr_288); // ProjectData.ClearProjectError(); //} } #endregion Internal Methods #region Protected Methods protected override bool CanExtendLeft() { return true; } protected override bool CanExtendRight() { return true; } protected override void ColorChanged() { if (this._extendableLine != null) { this._extendableLine.Stroke = new SolidColorBrush(this.mColor); this._extendableLine.ExtensionStroke = new SolidColorBrush(this.mExtensionColor); } } protected override List GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect) { var list = new List(); bool flag = this._extendableLine == null; if (flag) { this._extendableLine = new ExtendableLine(this, owner) { Stroke = new SolidColorBrush(this.mColor), ExtensionStroke = new SolidColorBrush(this.mExtensionColor), StrokeThickness = 1.4 }; } this.MoveDrawingToNewLocations(aRect); list.Add(this._extendableLine); return list; } protected override void MoveDrawingToNewLocations(Rect aRect) { if (this._extendableLine != null) { try { this._extendableLine.SetPosition(this.mDrawP1, this.mDrawP2, this.ExtendLeft, this.ExtendRight, aRect); } catch (Exception expr_54) { ProjectData.SetProjectError(expr_54); ProjectData.ClearProjectError(); } } } #endregion Protected Methods #endregion Methods } }