using Microsoft.VisualBasic.CompilerServices; using MuchInfo.Chart.Data; using MuchInfo.Chart.Data.EnumTypes; using MuchInfo.Chart.Infrastructure.Helpers; using MuchInfo.Chart.Infrastructure.Utilities; using MuchInfo.Chart.WPF.Controls.Drawing; using MuchInfo.Chart.WPF.Controls.Editors; using MuchInfo.Chart.WPF.Helpers; using MuchInfo.Chart.WPF.Primitives.Interfaces; using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; using System.Xml.Linq; namespace MuchInfo.Chart.WPF.Primitives.Drawing { public class DrawingGannFann : Drawing2PointBase { private Color drawingGannFann_1054; private List drawingGannFann_1055; private ExtendableLine drawingGannFann_1056; private int[] drawingGannFann_1057; public Color CenterColor { get { return this.drawingGannFann_1054; } set { bool flag = !value.Equals(this.drawingGannFann_1054); if (flag) { this.drawingGannFann_1054 = value; this.ColorChanged(); this.PropertyChanged(); } } } public DrawingGannFann() { this.drawingGannFann_1054 = Colors.White; this.drawingGannFann_1055 = new List(); this.drawingGannFann_1057 = new int[] { 2, 3, 4, 8 }; } public override DrawingToolType ToolType() { return DrawingToolType.GannFann; } public override IDrawingTool Clone() { return new DrawingGannFann { mColor = Colors.Blue }; } protected override List GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect) { bool flag = this.drawingGannFann_1056 == null; if (flag) { this.drawingGannFann_1056 = new ExtendableLine(this, owner); this.drawingGannFann_1056.Stroke = new SolidColorBrush(this.drawingGannFann_1054); this.drawingGannFann_1056.StrokeThickness = 1.4; DoubleCollection doubleCollection = new DoubleCollection(); doubleCollection.Add(10.0); doubleCollection.Add(10.0); this.drawingGannFann_1056.SetMainStrokeDash(doubleCollection); this.drawingGannFann_1056.ExtensionStroke = this.drawingGannFann_1056.Stroke; } flag = !ColorHelper.ColorIsContrasting(this.drawingGannFann_1054, owner.ChartBackgroundColor); if (flag) { this.drawingGannFann_1054 = ColorHelper.InverseColor(this.drawingGannFann_1054); } List list = new List(); this.drawingGannFann_1055.Clear(); int num = 0; checked { int arg_141_0; int num2; do { Line line = new Line(); line.Stroke = (new SolidColorBrush(this.mColor)); line.StrokeThickness = (1.4); this.drawingGannFann_1055.Add(line); list.Add(line); num++; arg_141_0 = num; num2 = 7; } while (arg_141_0 <= num2); this.MoveDrawingToNewLocations(aRect); list.Add(this.drawingGannFann_1056); return list; } } public override string RootName { get { return "DrawGannFan"; } } public override string MenuDescription() { return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_GannFan); } public override string Abbreviation() { return "Gann"; } public override string Description() { return this.MenuDescription(); } public override List GetPropertyEditors() { List list = new List(); ControlPair controlPair = new ControlPair(); TextBlock textBlock = new TextBlock(); textBlock.Text = ("Fann Color"); controlPair.ControlLeft = textBlock; ColorOpacityEditor controlRight = new ColorOpacityEditor(this, "Color", "", ""); controlPair.ControlRight = controlRight; list.Add(controlPair); controlPair = new ControlPair(); textBlock = new TextBlock(); textBlock.Text = ("Center Line Color"); controlPair.ControlLeft = textBlock; controlRight = new ColorOpacityEditor(this, "CenterColor", "", ""); controlPair.ControlRight = controlRight; list.Add(controlPair); return list; } protected override void ColorChanged() { this.drawingGannFann_1056.Stroke = new SolidColorBrush(this.drawingGannFann_1054); try { List.Enumerator enumerator = this.drawingGannFann_1055.GetEnumerator(); while (enumerator.MoveNext()) { Line current = enumerator.Current; current.Stroke = (new SolidColorBrush(this.mColor)); this.drawingGannFann_1056.ExtensionStroke = this.drawingGannFann_1056.Stroke; } } finally { //List.Enumerator enumerator; //enumerator.Dispose(); } } protected override void MoveDrawingToNewLocations(Rect aRect) { Point point; Point point2; bool flag; checked { point = new Point((double)((int)Math.Round(this.mDrawP1.X)), (double)((int)Math.Round(this.mDrawP1.Y))); point2 = new Point((double)((int)Math.Round(this.mDrawP2.X)), (double)((int)Math.Round(this.mDrawP2.Y))); Point point3 = new Point((double)((int)Math.Round( unchecked ( this.mDrawP2.X / 2.0 + this.mDrawP1.X / 2.0))), (double)((int)Math.Round(unchecked(this.mDrawP2.Y / 2.0 + this.mDrawP1.Y / 2.0)))); Size size = new Size(12.0, 12.0); flag = (point.X != point2.X); } double num; if (flag) { num = Math.Atan2(point2.Y - point.Y, point2.X - point.X); num *= 57.295779513082323; } else { flag = (point.Y > point2.Y); if (flag) { num = 270.0; } else { num = 90.0; } } this.drawingGannFann_1056.SetPosition(this.mDrawP1, this.mDrawP2, this.mDrawP1.X > this.mDrawP2.X, this.mDrawP1.X < this.mDrawP2.X, aRect); int num2 = 0; int arg_1C9_0 = 0; checked { int num3 = Enumerable.Count(this.drawingGannFann_1057) - 1; int num4 = arg_1C9_0; while (true) { int arg_405_0 = num4; int num5 = num3; if (arg_405_0 > num5) { break; } flag = (this.drawingGannFann_1057[num4] > 0); if (flag) { Point point4 = default(Point); float num6; float num7; num6 = (float)(aRect.Width + aRect.Height); num7 = (float)(Math.Atan2((double)this.drawingGannFann_1057[num4], 1.0) * 57.295779513082323); num7 = (float)((double)(num7 - 45f) + num); num7 = (float)((double)num7 * 3.1415926535897931 / 180.0); point4.X = ((double)((int)Math.Round(unchecked(point.X + (double)num6 * Math.Cos((double)num7))))); point4.Y = ((double)((int)Math.Round(unchecked(point.Y + (double)num6 * Math.Sin((double)num7))))); Point A = new Point(); Point B = new Point(); PointOfLineAtRectangleCalculator(ref A, ref B, point, point4, aRect); this.drawingGannFann_1055[num2].X1 = (A.X); this.drawingGannFann_1055[num2].Y1 = (A.Y); this.drawingGannFann_1055[num2].X2 = (B.X); this.drawingGannFann_1055[num2].Y2 = (B.Y); num2++; num7 = (float)(Math.Atan2(1.0, (double)this.drawingGannFann_1057[num4]) * 57.295779513082323); num7 = (float)((double)(num7 - 45f) + num); num7 = (float)((double)num7 * 3.1415926535897931 / 180.0); point4.X = ((double)((int)Math.Round(unchecked(point.X + (double)num6 * Math.Cos((double)num7))))); point4.Y = ((double)((int)Math.Round(unchecked(point.Y + (double)num6 * Math.Sin((double)num7))))); PointOfLineAtRectangleCalculator(ref A, ref B, point, point4, aRect); this.drawingGannFann_1055[num2].X1 = A.X; this.drawingGannFann_1055[num2].Y1 = A.Y; this.drawingGannFann_1055[num2].X2 = B.X; this.drawingGannFann_1055[num2].Y2 = B.Y; num2++; } num4++; } } } protected override void AddFromXml(XElement xml) { bool flag = xml.Attribute("CClr") != null; if (flag) { this.drawingGannFann_1054 = ColorHelper.ColorFromString(xml.Attribute("CClr").Value); } } protected override void AddToXml(XElement xml, List args) { xml.Add(new XAttribute("CClr", this.drawingGannFann_1054.ToString())); } protected override void AddFromInfo(DrawingToolInfo info) { base.AddFromInfo(info); try { XElement xElement = XElement.Parse(info.XML); bool flag = xElement.Name == "Root"; if (flag) { bool flag2 = xElement.Attribute("Color1") != null; if (flag2) { this.drawingGannFann_1054 = ColorHelper.ColorFromInt(int.Parse(xElement.Attribute("Color1").Value)); } } } catch (Exception expr_A1) { ProjectData.SetProjectError(expr_A1); ProjectData.ClearProjectError(); } } protected override void AddToInfo(DrawingToolInfo info) { base.AddToInfo(info); XElement xElement = new XElement("Root"); xElement.Add(new XAttribute("Color1", ColorHelper.ColorToInt(this.drawingGannFann_1054))); info.XML = xElement.ToString(); } public override ImageSource Icon() { ImageSource result; try { result = ImageHelper.GetImage("FibFan.png"); } catch (Exception expr_3A) { ProjectData.SetProjectError(expr_3A); result = null; ProjectData.ClearProjectError(); } return result; } protected override bool CanExtendLeft() { return false; } protected override bool CanExtendRight() { return false; } } }