| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- 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<Line> 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<Line>();
- 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<FrameworkElement> 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<FrameworkElement> list = new List<FrameworkElement>();
- 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<ControlPair> GetPropertyEditors()
- {
- List<ControlPair> list = new List<ControlPair>();
- 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<Line>.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<Line>.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<int>(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<object> 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;
- }
- }
- }
|