| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- using MuchInfo.Chart.Data;
- using MuchInfo.Chart.Infrastructure.Controls;
- using MuchInfo.Chart.Infrastructure.Helpers;
- using MuchInfo.Chart.Infrastructure.Utilities;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using System.Collections.Generic;
- using System.Runtime.CompilerServices;
- using System.Windows;
- using System.Xml.Linq;
- using Xceed.Wpf.Toolkit;
- namespace MuchInfo.Chart.WPF.Primitives.Drawing
- {
- public abstract class DrawingFibBase : Drawing2PointBase
- {
- protected class FibLevel
- {
- public float Value;
- public bool IsOn;
- public FibLevel(float aVal, bool drawingOn)
- {
- this.Value = 0f;
- this.IsOn = false;
- this.Value = aVal;
- this.IsOn = drawingOn;
- }
- }
- protected List<DrawingFibBase.FibLevel> FibLevels;
- public float get_LevelValue(int aIndex)
- {
- bool flag = aIndex >= 0 && aIndex < this.FibLevels.Count;
- float value = 0f;
- if (flag)
- {
- value = this.FibLevels[aIndex].Value;
- }
- return value;
- }
- public void set_LevelValue(int aIndex, float value)
- {
- bool flag = aIndex >= 0 && aIndex < this.FibLevels.Count;
- if (flag)
- {
- this.FibLevels[aIndex].Value = value;
- this.MoveDrawingToNewLocations(this.mLastRect);
- this.PropertyChanged();
- }
- }
- //public float this[int aIndex]
- //{
- // get
- // {
- // }
- // set
- // {
- // }
- //}
- public bool get_LevelOn(int aIndex)
- {
- bool flag = aIndex >= 0 && aIndex < this.FibLevels.Count;
- bool isOn = false;
- if (flag)
- {
- isOn = this.FibLevels[aIndex].IsOn;
- }
- return isOn;
- }
- public void set_LevelOn(int aIndex, bool value)
- {
- bool flag = aIndex >= 0 && aIndex < this.FibLevels.Count;
- if (flag)
- {
- this.FibLevels[aIndex].IsOn = value;
- this.MoveDrawingToNewLocations(this.mLastRect);
- this.PropertyChanged();
- }
- }
- public DrawingFibBase()
- {
- this.FibLevels = new List<DrawingFibBase.FibLevel>();
- this.InitFibs();
- }
- public abstract override IDrawingTool Clone();
- protected abstract override void ColorChanged();
- public abstract override string Description();
- protected abstract override List<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect);
- public abstract override string MenuDescription();
- protected abstract override void MoveDrawingToNewLocations(Rect aRect);
- protected void InitFibs()
- {
- this.FibLevels.Add(new DrawingFibBase.FibLevel(23.6f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(38.2f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(50f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(61.8f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(100f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(161.8f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(261.8f, false));
- this.FibLevels.Add(new DrawingFibBase.FibLevel(423.6f, false));
- }
- protected void TurnAllOn()
- {
- try
- {
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel current = enumerator.Current;
- current.IsOn = true;
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- }
- protected void TurnOffOn()
- {
- try
- {
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel current = enumerator.Current;
- current.IsOn = false;
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- }
- protected void TurnOnForArc()
- {
- this.TurnOffOn();
- this.FibLevels[1].IsOn = true;
- this.FibLevels[2].IsOn = true;
- this.FibLevels[3].IsOn = true;
- }
- protected void TurnOnForArc2()
- {
- this.TurnOffOn();
- this.FibLevels[1].IsOn = true;
- this.FibLevels[2].IsOn = true;
- //this.FibLevels[3].IsOn = true;
- }
- public override List<ControlPair> AdditionalEditors()
- {
- List<ControlPair> list = new List<ControlPair>();
- int num = 0;
- checked
- {
- try
- {
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel arg_8A_0 = enumerator.Current;
- ControlPair controlPair = new ControlPair();
- ChartSingleUpDown controlRight = new ChartSingleUpDown(this, "LevelValue", num, "LevelOn", 0, 1000, 1f);
- controlPair.ControlRight = controlRight;
- list.Add(controlPair);
- num++;
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- return list;
- }
- }
- protected override void AddFromXml(XElement xml)
- {
- bool flag = false;
- try
- {
- IEnumerator<XElement> enumerator = xml.Elements().GetEnumerator();
- while (enumerator.MoveNext())
- {
- XElement current = enumerator.Current;
- bool flag2 = current.Name == "Fibs";
- if (flag2)
- {
- bool flag3 = !flag;
- if (flag3)
- {
- this.FibLevels.Clear();
- flag = true;
- }
- DrawingFibBase.FibLevel fibLevel = new DrawingFibBase.FibLevel(23.6f, true);
- flag3 = (current.Attribute("On") != null);
- if (flag3)
- {
- fibLevel.IsOn = bool.Parse(current.Attribute("On").Value);
- }
- flag3 = (current.Attribute("Val") != null);
- if (flag3)
- {
- fibLevel.Value = XMLHelp.ParseSingle(current.Attribute("Val").Value);
- }
- this.FibLevels.Add(fibLevel);
- }
- }
- }
- finally
- {
- //IEnumerator<XElement> enumerator;
- //bool flag3 = enumerator != null;
- //if (flag3)
- //{
- // enumerator.Dispose();
- //}
- }
- }
- protected override void AddToXml(XElement xml, List<object> args)
- {
- try
- {
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel current = enumerator.Current;
- XElement xElement = new XElement("Fibs");
- xElement.Add(new XAttribute("On", current.IsOn.ToString()));
- xElement.Add(new XAttribute("Val", XMLHelp.NumToString(current.Value)));
- xml.Add(xElement);
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- }
- protected override void AddFromInfo(DrawingToolInfo info)
- {
- base.AddFromInfo(info);
- bool flag = false;
- checked
- {
- try
- {
- XElement xElement = XElement.Parse(info.XML);
- bool flag2 = xElement.Name == "Root";
- if (flag2)
- {
- for (int i = 1; i < 100; i++)
- {
- flag2 = (xElement.Attribute("IntValue" + i.ToString()) == null);
- if (flag2)
- {
- break;
- }
- flag2 = !flag;
- if (flag2)
- {
- this.FibLevels.Clear();
- flag = true;
- }
- DrawingFibBase.FibLevel fibLevel = new DrawingFibBase.FibLevel(23.6f, true);
- fibLevel.IsOn = (int.Parse(xElement.Attribute("IntValue" + i.ToString()).Value) > 0);
- fibLevel.Value = XMLHelp.ParseSingle(xElement.Attribute("Value" + i.ToString()).Value);
- bool flag3 = false;
- try
- {
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel current = enumerator.Current;
- flag2 = (current.Value == fibLevel.Value);
- if (flag2)
- {
- flag3 = true;
- break;
- }
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- flag2 = !flag3;
- if (flag2)
- {
- this.FibLevels.Add(fibLevel);
- }
- }
- }
- }
- catch (Exception expr_1C8)
- {
- ProjectData.SetProjectError(expr_1C8);
- ProjectData.ClearProjectError();
- }
- }
- }
- protected override void AddToInfo(DrawingToolInfo info)
- {
- base.AddToInfo(info);
- XElement xElement = new XElement("Root");
- int num = 1;
- checked
- {
- try
- {
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel current = enumerator.Current;
- xElement.Add(new XAttribute("IntValue" + num.ToString(), RuntimeHelpers.GetObjectValue(Interaction.IIf(current.IsOn, "1", "0"))));
- xElement.Add(new XAttribute("Value" + num.ToString(), XMLHelp.NumToString(current.Value)));
- num++;
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- info.XML = xElement.ToString();
- }
- }
- }
- }
|