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 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(); this.InitFibs(); } public abstract override IDrawingTool Clone(); protected abstract override void ColorChanged(); public abstract override string Description(); protected abstract override List 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.Enumerator enumerator = this.FibLevels.GetEnumerator(); while (enumerator.MoveNext()) { DrawingFibBase.FibLevel current = enumerator.Current; current.IsOn = true; } } finally { //List.Enumerator enumerator; //enumerator.Dispose(); } } protected void TurnOffOn() { try { List.Enumerator enumerator = this.FibLevels.GetEnumerator(); while (enumerator.MoveNext()) { DrawingFibBase.FibLevel current = enumerator.Current; current.IsOn = false; } } finally { //List.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 AdditionalEditors() { List list = new List(); int num = 0; checked { try { List.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.Enumerator enumerator; //enumerator.Dispose(); } return list; } } protected override void AddFromXml(XElement xml) { bool flag = false; try { IEnumerator 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 enumerator; //bool flag3 = enumerator != null; //if (flag3) //{ // enumerator.Dispose(); //} } } protected override void AddToXml(XElement xml, List args) { try { List.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.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.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.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.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.Enumerator enumerator; //enumerator.Dispose(); } info.XML = xElement.ToString(); } } } }