0% found this document useful (0 votes)
59 views18 pages

Message

Uploaded by

nourchip95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views18 pages

Message

Uploaded by

nourchip95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

/*

* PAT$ ToolBar Indicator made with ♡ by beo


* Last edit 03/03/2021
* [Link]
drawing-tools-why-this-is-better/
*/

#region Using declarations


using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using WindowsInput;
#endregion

public enum ArrowIconStyleEnum { ColorFilled, ColorOutlined, Monochrome }

namespace [Link]
{

[TypeConverter("[Link]
nverter")]
public class PATSToolBar : Indicator
{
private const string assembly = "[Link]";
//private const string assembly = "Toolbar";
private List<object> toolBarItems;
private bool isToolBarAdded;
private ArrowIconStyleEnum arrowIconStyle =
[Link];
private [Link] cw; //chartWindow
private [Link] myTimer;
private ATR myATR;
private string path = [Link] + @"bin\
Custom\DrawingTools\[Link]";
private StreamReader sr;
private Style systemMenuStyle =
[Link]("SystemMenuStyle") as Style;
private Style mainMenuItem =
[Link]("MainMenuItem") as Style;
private Brush textBrush =
[Link]("FontActionBrush") as Brush ?? [Link];
private Label atrLabel, lagLabel;
private double lastPrice;
private InputSimulator inputSimulator;
private bool simulatingPanning;
private TimeZoneInfo marketTimeZone;

protected override void OnStateChange()


{
if (State == [Link])
{
Name = "PATS ToolBar";
Description = @"Drawing tools
horizontal toolbar showing selected tools only";
IsOverlay = true;
IsChartOnly = true;
DisplayInDataBox = false;
PaintPriceMarkers = false;
IsSuspendedWhileInactive = true;
EnablePanning = true;
EnableZooming = true;
SelectedTypes = new
XElement("SelectedTypes");
LeftMargin = 32;
GroupArrows = true;
ShowPlotExecutions = true;
ShowDrawnObjects = true;
ShowRemoveAll = true;
ShowATR = true;
ATRPeriod = 21;
ATRInTicks = false;
ShowClock = true;
ShowMarketTimeZone = false;
ShowLag = true;
LagWarning = 0.3;
LagAlert = 1.0;
ShowAngledLine = true;
ShowChannel = true;
ShowRange = true;
ShowSupportLine = true;
ShowMeasuredMove = true;
ShowArrows = true;
ShowNote = true;
ShowMeasure = true;
ShowHelp = true;
Annotation = "";
}
else if (State == [Link])
{
isToolBarAdded = false;
simulatingPanning = false;
}
else if (State == [Link])
{
Name = "";
marketTimeZone = [Link];
if (ChartControl != null)
[Link]((Action)(() => addToolBar()));
}
else if (State == [Link])
{
myATR = ATR(ATRPeriod);
}
else if(State == [Link])
{
if (ChartControl != null)
[Link]((Action)(() => removeToolBar()));
}
}

private Button createButton(object tooltip, object icon, Style style,


FontFamily fontFamily)
{
return new Button() {
ToolTip = tooltip,
Content = icon,
Cursor = [Link],
Style = style,
FontFamily = fontFamily,
FontSize = 16,
FontStyle = [Link],
VerticalAlignment = [Link]
};
}

private NTMenuItem createNTMenuItem(object icon, string header, Style


style, string toolTip)
{
NTMenuItem item = new NTMenuItem(){ VerticalAlignment =
[Link] };
if (icon != null) [Link] = icon;
if (header != null) [Link] = header;
if (style != null) [Link] = style;
if (toolTip != null) [Link] = toolTip;
return item;
}

private Label createLabel(string content)


{
return new Label() {
Foreground = textBrush,
Content = content,
VerticalAlignment = [Link],
Margin = new Thickness(24, 0, 0, 0)
};
}

private bool addDrawingToolToToolBar(string name, string assembly,


Style style, FontFamily fontFamily)
{
[Link] dt =
[Link][assembly].CreateInstance(name) as
[Link];
if (dt == null) return false;
string dtName = [Link];
if (GroupArrows && (dtName == "Arrow up" || dtName == "Arrow
down")) return true;
Button b = createButton(dtName, [Link] ??
[Link], style, fontFamily);
[Link] += (sender, args) => { if (ChartControl != null)
[Link]([Link]().FullName); };
if (dtName == "Arrow Up Green" || dtName == "Arrow Down Green" ||
dtName == "Arrow Up Blue" || dtName == "Arrow Down Red") [Link] =
getArrowIcon(dtName, arrowIconStyle);
[Link](b);
return true;
}

private Object getArrowIcon(string name, ArrowIconStyleEnum style)


{
Grid icon = new Grid { Height = 16, Width = 16 };
[Link] p = new [Link]();
Brush b = name == "Arrow Up Blue" ? [Link] : name == "Arrow
Down Red" ? [Link] : [Link];
[Link] = style == [Link] ? b : (style ==
[Link] && ![Link]("Green")) ? textBrush :
[Link];
[Link] = style == [Link] ? textBrush :
b;
[Link] =
[Link]([Link]("Down") ? "M 5.5 2 L 5.5 8 L 2 8
L 7.5 14 L 13 8 L 9.5 8 L 9.5 2 Z" : "M 7.5 2 L 2 8 L 5.5 8 L 5.5 14 L 9.5 14 L 9.5
8 L 13 8 Z");
[Link](p);
return icon;
}

private void addRemoveSelectedDrawingTool(bool add, string name)


{
string toolName = "[Link]." + name;
XElement e = [Link](toolName);
if (add && e == null)
{
XElement el = new XElement(toolName);
[Link](new XAttribute("Assembly", assembly));
[Link](el);
}
if (!add && e != null) [Link]();
}

private Grid getToggleDrawingsIcon(bool hide)


{
Grid icon = new Grid { Height = 16, Width = 16 };
[Link] p1 = new [Link]();
[Link] p2 = new [Link]();
[Link] p3 = new [Link]();
[Link] = [Link] = [Link] = textBrush;
[Link] = [Link]("m7.873 1.968c-
3.519 0-6.672 2.309-7.847 5.746-.035.103-.035.215 0 .318 1.174 3.437 4.328 5.746
7.847 5.746s6.672-2.309 7.847-5.746c.035-.103.035-.215 0-.318-1.174-3.437-4.328-
5.746-7.847-5.746zm0 10.826c-3.044 0-5.78-1.971-6.859-4.921 1.08-2.95 3.816-4.921
6.859-4.921 3.044 0 5.78 1.971 6.859 4.921-1.08 2.95-3.816 4.921-6.859 4.921z");
[Link] = [Link]("m7.873 5.275c-
1.433 0-2.599 1.166-2.599 2.599 0 1.433 1.166 2.599 2.599 2.599 1.433 0 2.599-1.166
2.599-2.599 0-1.433-1.166-2.599-2.599-2.599z");
[Link] = [Link]("M 0 15 L 15 1 L 16
1 L 1 15 Z");
[Link](p1);
[Link](p2);
if (hide) [Link](p3);
return icon;
}

private Grid getPanningIcon(bool enabled)


{
Grid icon = new Grid { Height = 16, Width = 16 };
[Link] p = new [Link]();
[Link] = enabled ? [Link] : textBrush;
[Link] = [Link]("M 5 3 L 8 0 L 11 3
Z M 13 5 L 16 8 L 13 11 Z M 11 13 L 8 16 L 5 13 Z M 3 5 L 0 8 L 3 11 Z M 7.5 3 L
8.5 3 L 8.5 13 L 7.5 13 Z M 3 7.5 L 13 7.5 L 13 8.5 L 3 8.5 Z");
[Link](p);
return icon;
}

private void drawNote(string note)


{
Annotation = note;
[Link] dt =
[Link][assembly].CreateInstance("[Link]
[Link]") as [Link];
if (dt == null || ChartControl == null) return;
[Link]([Link]().FullName);
}

protected void MouseRightButtonUp(object sender, MouseButtonEventArgs


e)
{
if (simulatingPanning)
{
[Link]([Link]);
[Link]();
simulatingPanning = false;
[Link] = true;
}
}
protected void MouseMove(object sender, MouseEventArgs e)
{
if (!simulatingPanning && [Link] ==
[Link])
{
simulatingPanning = true;
[Link]([Link]);
[Link]();
}
}

protected void MouseLeave(object sender, MouseEventArgs e)


{
if (simulatingPanning)
{
[Link]([Link]);
[Link]();
simulatingPanning = false;
}
}

protected void PreviewMouseWheel(object sender, MouseWheelEventArgs e)


{
if ([Link]([Link]) ||
[Link]([Link]) || [Link]([Link]) ||
[Link]([Link])) return;
[Link]([Link],
[Link] > 0 ? [Link] : [Link]);
[Link] = true;
}

private void addToolBar()


{
if (isToolBarAdded) return;
cw = [Link]([Link]) as Chart; if (cw ==
null) return;
toolBarItems = new List<object>();
FontFamily fontFamily =
[Link]["IconsFamily"] as FontFamily;
Style style = [Link]["LinkButtonStyle"] as
Style;

if (EnablePanning || EnableZooming) inputSimulator = new


InputSimulator();
if (EnablePanning)
{
[Link] += MouseRightButtonUp;
[Link] += MouseMove;
[Link] += MouseLeave;
}
if (EnableZooming) [Link] +=
PreviewMouseWheel;

#region drawing tools


addRemoveSelectedDrawingTool(ShowAngledLine, "AngledLine");
addRemoveSelectedDrawingTool(ShowChannel, "Channel");
addRemoveSelectedDrawingTool(ShowSupportLine, "SupportLine");
addRemoveSelectedDrawingTool(ShowRange, "Range");
addRemoveSelectedDrawingTool(ShowMeasuredMove, "MeasuredMove");
addRemoveSelectedDrawingTool(ShowMeasure, "Measure");
addRemoveSelectedDrawingTool(ShowArrows && !GroupArrows,
"ArrowUpGreen");
addRemoveSelectedDrawingTool(ShowArrows && !GroupArrows,
"ArrowDownGreen");
addRemoveSelectedDrawingTool(ShowArrows && !GroupArrows,
"ArrowUpBlue");
addRemoveSelectedDrawingTool(ShowArrows && !GroupArrows,
"ArrowDownRed");

List<XElement> elements = new List<XElement>();


foreach (XElement element in
[Link]([Link]()).Elements()) [Link](element);
int count = 0;

Button empty = createButton("", null, style, fontFamily);


[Link] = new Thickness(LeftMargin, 0, 0, 0);
[Link](empty);

while (count < [Link])


{
for (int j = 0; count < [Link]; j++)
{
XElement element = elements[count];
try
{
if
(addDrawingToolToToolBar([Link](),
[Link]("Assembly").Value, style, fontFamily)) count++;
else { [Link](j); j--; }
}
catch (Exception e)
{
[Link](j);
j--;
[Link](typeof([Link]),
"NinjaScriptTileError", new object[] { [Link](), e },
[Link], [Link]);
}
}
}
#endregion

if (ShowArrows && GroupArrows)


{
Menu arrowsMenu = new Menu { VerticalAlignment =
[Link], VerticalContentAlignment = [Link],
Style = systemMenuStyle };
NTMenuItem arrowsMenuItem =
createNTMenuItem(getArrowIcon("Arrow Up Green", [Link]),
null, mainMenuItem, "Arrows");
[Link] = new Thickness(-4, 0, 0, 0);

List<string> arrows = new List<string>(){ "ArrowUpGreen",


"ArrowDownGreen", "ArrowUpBlue", "ArrowDownRed"};
string dtprefix = "[Link].";
if ([Link](x => [Link]() == dtprefix +
"ArrowUp")) [Link]("ArrowUp");
if ([Link](x => [Link]() == dtprefix +
"ArrowDown")) [Link]("ArrowDown");
foreach (string s in arrows)
{
[Link] dt =
[Link][assembly].CreateInstance(dtprefix + s) as
[Link];
if (dt == null) break;
string dtName = [Link];
NTMenuItem arrowItem = createNTMenuItem([Link],
dtName, mainMenuItem, null);
if (dtName == "Arrow Up Blue" || dtName == "Arrow
Down Red" || dtName == "Arrow Up Green" || dtName == "Arrow Down Green")
[Link] = getArrowIcon(dtName, arrowIconStyle);
[Link] += (sender, args) => { if
(ChartControl != null) [Link]([Link]().FullName); };
[Link](arrowItem);
}
[Link](arrowsMenuItem);
[Link](arrowsMenu);
}

if (ShowNote)
{
Menu theMenu = new Menu { VerticalAlignment =
[Link], VerticalContentAlignment = [Link],

NTMenuItem topMenuItem = createNTMenuItem("𝐓", null,


Style = systemMenuStyle };

mainMenuItem, "Note");
[Link] = new Thickness(-4, 0, 0, 0);
NTMenuItem textItem =
createNTMenuItem([Link], "Note", mainMenuItem, null);
[Link] += (o, args) => drawNote("");
[Link](textItem);
if (![Link](path))
{
foreach (string s in new[] { "2EL", "2ES", "F2EL",
"F2ES"})
{
NTMenuItem subItem = createNTMenuItem(null, s,
mainMenuItem, null);
[Link] += (o, args) => drawNote(s);
[Link](subItem);
}
}
else
{
try
{
sr = new [Link](path);
string line;
while ((line = [Link]()) != null)
{
string trimmed = [Link]();
if ([Link] == 0) continue;
NTMenuItem subItem =
createNTMenuItem(null, trimmed, mainMenuItem, null);
[Link] += (o, args) =>
drawNote(trimmed);
[Link](subItem);
}
[Link](); sr = null;
}
catch (Exception e)
{
Log("You cannot write and read from the same
file at the same time.", [Link]);
}
}
[Link](topMenuItem);
[Link](theMenu);
}

if (ShowPlotExecutions)
{
Grid icon = new Grid { Height = 16, Width = 16 };
[Link] p = new
[Link]();
[Link] = textBrush;
[Link] = [Link]("M 6 1 L 6 15
L 7 15 L 7 1 Z M 6 1 L 10 1 L 10 2 L 6 2 Z M 10 1 L 10 15 L 9 15 L 9 1 Z M 6 15 L
10 15 L 10 14 L 6 14 Z M 2 8 L 5 11 L 2 14 Z M 14 2 L 11 5 L 14 8 Z");
[Link](p);
Button b = createButton("Plot Executions", icon, style,
fontFamily);
[Link] += (o, args) =>
[Link]("^e");
[Link](b);
}

if (ShowDrawnObjects)
{
Button b = createButton("Hide Drawings",
getToggleDrawingsIcon(true), style, fontFamily);
[Link] += (o, args) => {
Button bb = o as Button;
[Link] = [Link] == "Hide Drawings" ? "Show
Drawings" : "Hide Drawings";
[Link] = getToggleDrawingsIcon([Link] ==
"Hide Drawings");
foreach (var obj in
[Link])
{
var draw = obj as
[Link];
if (draw == null || ![Link])
continue;
[Link] = ![Link];
}
ForceRefresh();
};
[Link](b);
}

if (ShowRemoveAll)
{
NTMenuItem ntDrawingTools = ((Menu)[Link][3]).Items[0]
as NTMenuItem;
foreach (var item in [Link])
{
if (item is NTMenuItem && ((NTMenuItem)item).Header !
= null)
{
NTMenuItem mnItem = item as NTMenuItem;
if ([Link]() == "Remove All
Drawing Objects")
{
Button b = createButton([Link],
[Link], style, fontFamily);
[Link] += (o, args) =>
[Link](o);
[Link](b);
}
}
}
}

if (ShowHelp)
{
Menu helpMenu = new Menu { VerticalAlignment =
[Link], VerticalContentAlignment = [Link],
Style = systemMenuStyle };
NTMenuItem helpMenuItem = createNTMenuItem("?", null,
mainMenuItem, "Help");
[Link] = new Thickness(-4, 0, 0, 0);
NTMenuItem helpLinkItem = createNTMenuItem(null, "Help",
mainMenuItem, null);
NTMenuItem tipLinkItem = createNTMenuItem(null, "Tip Me ♡",
mainMenuItem, null);
NTMenuItem aboutItem = createNTMenuItem(null, "About",
mainMenuItem, null);
[Link](helpLinkItem);
[Link](tipLinkItem);
[Link](aboutItem);
[Link](helpMenuItem);
[Link] += ((o, args) => {
try {
[Link]("[Link] }
catch ([Link] e)
{ [Link]([Link]); }
});
[Link] += ((o, args) => {
try {
[Link]("[Link]
57fcbaa98c46477ba7bcd801f4356e60"); }
catch ([Link] e)
{ [Link]([Link]); }
});
[Link] += (o, args) =>
[Link](new Action(() => new
AboutWindow().Show()));
[Link](helpMenu);
}

if (ShowATR) { atrLabel = createLabel("ATR 0.00");


[Link](atrLabel); }
if (ShowLag) { lagLabel = createLabel("LAG 0.000");
[Link](lagLabel); }

if (ShowClock)
{
myTimer = new [Link]();
[Link] = 1000;
[Link] = true;
Label clockLabel = createLabel(ShowMarketTimeZone ?
[Link]([Link], marketTimeZone).ToString() :
[Link]());
[Link](clockLabel);
[Link] += new EventHandler((o, args) =>
[Link] = ShowMarketTimeZone ?
[Link]([Link], marketTimeZone).ToString() :
[Link]());
}

ShowHideToolBar(TabSelected());
[Link] += TabChangedHandler;
}

private bool TabSelected()


{
return (ChartControl != null && [Link] ==
(([Link]([Link]) as
TabItem).Content as ChartTab));
}

private void ShowHideToolBar(bool show)


{
if (show && !isToolBarAdded)
{
foreach (object toolBarItem in toolBarItems)
[Link](toolBarItem);
isToolBarAdded = true;
}
else if (!show && isToolBarAdded)
{
foreach (object toolBarItem in toolBarItems)
[Link](toolBarItem);
isToolBarAdded = false;
}
}

protected void removeToolBar()


{
if (myTimer != null) { [Link](); [Link](); }
if (sr != null) { [Link](); sr = null; }
[Link] -= MouseRightButtonUp;
[Link] -= MouseMove;
[Link] -= MouseLeave;
[Link] -= PreviewMouseWheel;
if (cw == null) return;
[Link] -= TabChangedHandler;
ShowHideToolBar(false);
}

private void TabChangedHandler(object sender, SelectionChangedEventArgs


e)
{
if ([Link] <= 0) return;
TabItem tabItem = [Link][0] as TabItem; if (tabItem ==
null) return;
ChartTab temp = [Link] as ChartTab; if (temp == null)
return;
ShowHideToolBar(TabSelected());
}

private void updateATR (string atrValue)


{ [Link]((Action)(() => [Link] = "ATR " +
atrValue)); }

private void updateLAG (double price, double lag)


{
[Link]((Action)(() => {
[Link] = "LAG " + [Link]("0.000");
[Link] = (lag < -LagAlert) ? [Link] :
(lag < -LagWarning) ? [Link] : textBrush;
}));
lastPrice = price;
}

protected override void OnBarUpdate() { if (ShowATR)


updateATR([Link](myATR[0] / (ATRInTicks ? TickSize : 1), 2).ToString()); }
protected override void OnMarketData(MarketDataEventArgs e) { if
(ShowLag && [Link] == [Link] && lastPrice != [Link])
updateLAG([Link], ([Link] - [Link]).TotalSeconds); }

public override string DisplayName { get { return "PATS ToolBar"; } }

#region Properties
[Browsable(false)]
public string Annotation { get; set; }

public XElement SelectedTypes { get; set; }

[Range(1, 1000)]
[Display(Name = "Left Margin", Description = "Empty space before first
drawing button", GroupName = "0. General Settings", Order = 0)]
public int LeftMargin { get; set; }

[Display(Name = "Arrows Icons Style", Description = "Color Filled,


Color Outlined or Monochrome arrows icons", GroupName = "0. General Settings",
Order = 1)]
public ArrowIconStyleEnum ArrowIconStyle { get { return arrowIconStyle;
} set { arrowIconStyle = value; } }

[Display(Name = "Arrows Dropdown Menu", Description = "Group all arrows


into dropdown menu", GroupName = "0. General Settings", Order = 2)]
public bool GroupArrows { get; set; }

[Display(Name = "Right Click Panning", Description = "Right Click


Panning", GroupName = "0. General Settings", Order = 3)]
public bool EnablePanning { get; set; }

[Display(Name = "Scroll Wheel Zoom", Description = "Scroll Wheel Zoom",


GroupName = "0. General Settings", Order = 4)]
public bool EnableZooming { get; set; }

[Display(Name = "Plot Executions", Description = "Toggle plot


executions between none, markers only and markers + text", GroupName = "1.
Buttons", Order = 1)]
public bool ShowPlotExecutions { get; set; }

[Display(Name = "Hide Drawings", Description = "Toggle between hide and


show all drawings", GroupName = "1. Buttons", Order = 2)]
public bool ShowDrawnObjects { get; set; }

[Display(Name = "Remove All Drawing Objects", Description = "Remove all


drawing objects", GroupName = "1. Buttons", Order = 3)]
public bool ShowRemoveAll { get; set; }

[Display(Name = "Help", Description = "Show help menu", GroupName = "1.


Buttons", Order = 4)]
public bool ShowHelp { get; set; }

[RefreshProperties([Link])]
[Display(Name = "ATR", Description = "Display ATR value", GroupName =
"2. Labels", Order = 1)]
public bool ShowATR { get; set; }

[Range(1, 1000)]
[Display(Name = "ATR Period", Description = "Set ATR period", GroupName
= "2. Labels", Order = 2)]
public int ATRPeriod { get; set; }

[Display(Name = "ATR Value in Ticks", Description = "Display ATR value


in ticks", GroupName = "2. Labels", Order = 3)]
public bool ATRInTicks { get; set; }

[Display(Name = "Lag", Description = "Display chart lag", GroupName =


"2. Labels", Order = 4)]
public bool ShowLag { get; set; }

[Range(0, 100)]
[Display(Name = "Lag Warning Threshold", Description = "Lag warning
threshold in seconds", GroupName = "2. Labels", Order = 5)]
public double LagWarning
{ get; set; }

[Range(0, 100)]
[Display(Name = "Lag Alert Threshold", Description = "Lag alert threshold
in seconds", GroupName = "2. Labels", Order = 6)]
public double LagAlert
{ get; set; }

[Display(Name = "Clock", Description = "Display date and time",


GroupName = "2. Labels", Order = 7)]
public bool ShowClock { get; set; }

[Display(Name = "Clock With Market Time Zone", Description = "Display


date and time using market trading hours time zone", GroupName = "2. Labels", Order
= 8)]
public bool ShowMarketTimeZone { get; set; }

[Display(Name = "Angled Line", Description = "PATS angled line drawing


tool", GroupName = "3. PATS Drawing Tools", Order = 0)]
public bool ShowAngledLine { get; set; }

[Display(Name = "Channel", Description = "PATS trend channel drawing


tool", GroupName = "3. PATS Drawing Tools", Order = 1)]
public bool ShowChannel { get; set; }

[Display(Name = "Support Line", Description = "PATS support line


drawing tool", GroupName = "3. PATS Drawing Tools", Order = 2)]
public bool ShowSupportLine { get; set; }

[Display(Name = "Range", Description = "PATS trading range drawing


tool", GroupName = "3. PATS Drawing Tools", Order = 3)]
public bool ShowRange { get; set; }

[Display(Name = "Measured Move", Description = "PATS measured move


drawing tool", GroupName = "3. PATS Drawing Tools", Order = 4)]
public bool ShowMeasuredMove { get; set; }

[Display(Name = "Measure", Description = "PATS measure drawing tool",


GroupName = "3. PATS Drawing Tools", Order = 5)]
public bool ShowMeasure { get; set; }

[Display(Name = "Arrows", Description = "PATS arrows drawing tool",


GroupName = "3. PATS Drawing Tools", Order = 6)]
public bool ShowArrows { get; set; }

[Display(Name = "Note", Description = "PATS note drawing tool",


GroupName = "3. PATS Drawing Tools", Order = 7)]
public bool ShowNote { get; set; }
#endregion
}

public class CustomDrawingToolPropertyDescriptor : PropertyDescriptor


{
private readonly string displayName;
private readonly string name;
private readonly int order;
private readonly Type type;

public override AttributeCollection Attributes


{
get
{
Attribute[] attr = new Attribute[1];
attr[0] = new DisplayAttribute { Name
= DisplayName, GroupName = "4. Standard Drawing Tools", Order = order };
return new AttributeCollection(attr);
}
}

public CustomDrawingToolPropertyDescriptor(Type type, string


displayName, int order) : base([Link], null)
{
name = [Link];
[Link] = displayName;
[Link] = order;
[Link] = type;
}

public override Type ComponentType


{ get { return typeof (PATSToolBar); } }
public override string DisplayName
{ get { return displayName; } }
public override bool IsReadOnly
{ get { return false; } }
public override string Name
{ get { return name; } }
public override Type PropertyType
{ get { return typeof (bool); } }

public override bool CanResetValue(object component)


{ return true; }
public override bool ShouldSerializeValue(object component)
{ return true; }

public override object GetValue(object component)


{
PATSToolBar c = component as PATSToolBar;
return c != null && [Link](Name) != null;
}

public override void ResetValue(object component) {}


public override void SetValue(object component, object value)
{
PATSToolBar c = component as PATSToolBar;
if (c == null) return;
bool val = (bool) value;
if (val && [Link](Name) == null)
{
XElement toAdd = new XElement(Name);
[Link](new XAttribute("Assembly",
[Link](type) ?
"[Link]" : [Link]().Name));
[Link](toAdd);
}
else if(!val && [Link](Name) != null)
[Link](Name).Remove();
}
}

public class CustomDrawingToolIndicatorTypeConverter : TypeConverter


{
public override bool GetPropertiesSupported(ITypeDescriptorContext
context) { return true; }

public override PropertyDescriptorCollection


GetProperties(ITypeDescriptorContext context, object component, Attribute[] attrs)
{
TypeConverter tc = component is IndicatorBase ?
[Link](typeof(IndicatorBase)) :
[Link](typeof([Link]));
PropertyDescriptorCollection propertyDescriptorCollection =
[Link](context, component, attrs);
if (propertyDescriptorCollection == null) return null;
PropertyDescriptorCollection properties = new
PropertyDescriptorCollection(null);
foreach (PropertyDescriptor pd in propertyDescriptorCollection)
{
if (![Link] || [Link] || [Link] ==
"IsAutoScale" || [Link] == "DisplayInDataBox" || [Link] == "MaximumBarsLookBack"
|| [Link] == "Calculate"
|| [Link] == "Panel" || [Link] == "IsVisible" ||
[Link] == "PaintPriceMarkers" || [Link] == "Displacement" || [Link] ==
"ScaleJustification" || [Link] == "Name")
continue;

if ([Link] == "SelectedTypes")
{
int i = 1;
foreach (Type type in
[Link](typeof([Link])))
{
[Link] tool =
[Link]([Link]) as [Link];
if (tool == null || ![Link])
continue;
CustomDrawingToolPropertyDescriptor descriptor
= new CustomDrawingToolPropertyDescriptor(type, [Link], i);
[Link](descriptor);
i++;
}
continue;
}
[Link](pd);
}
return properties;
}
}
}

public class AboutWindow : NTWindow


{
public AboutWindow()
{
Caption = "About PATS ToolBar";
Width = 400;
Height = 200;
WindowStartupLocation = [Link];
ScrollViewer viewer = new ScrollViewer();
[Link] = [Link];
Brush textBrush = [Link]("FontActionBrush")
as Brush ?? [Link];
TextBlock textBlock = new TextBlock(); [Link] = "PATS ToolBar
Indicator version 03/03/2021 made with ♡ by beo";
TextBlock linkForum = new TextBlock(); [Link] = "Download
latest version and post any questions/suggestions here";
[Link] += ((o, args) => {
try {
[Link]("[Link]
forum/topic/pats-toolbar-custom-drawing-tools-why-this-is-better/"); }
catch ([Link] e) { [Link]([Link]); }
});
TextBlock tip = new TextBlock(); [Link] = "If you like my work you
can tip me here";
[Link] = [Link] = [Link];
[Link] = [Link] =
[Link];
[Link] += ((o, args) => {
try {
[Link]("[Link] }
catch ([Link] e) { [Link]([Link]); }
});
TextBlock thumb = new TextBlock(); [Link] = "👍"; [Link] = new
Thickness(8, 0, 0, 0);
StackPanel tipPanel = new StackPanel() { Orientation =
[Link] };
[Link](tip);
[Link](thumb);
TextBlock tippers = new TextBlock(); [Link] = "I want to say
thank you to all tippers:\nBen, George, Scott, Alex, Meridee, Michael, Nathan,
Suzu,\nMaria, Jeff and Jacob";
[Link] = [Link] = [Link] =
[Link] = [Link] = textBrush;
StackPanel myStackPanel = new StackPanel() { Orientation =
[Link] };
[Link](textBlock);
[Link](new TextBlock());
[Link](linkForum);
[Link](new TextBlock());
[Link](tipPanel);
[Link](new TextBlock());
[Link](tippers);
Content = myStackPanel;
}
}

#region NinjaScript generated code. Neither change nor remove.

namespace [Link]
{
public partial class Indicator :
[Link]
{
private PATSToolBar[] cachePATSToolBar;
public PATSToolBar PATSToolBar()
{
return PATSToolBar(Input);
}

public PATSToolBar PATSToolBar(ISeries<double> input)


{
if (cachePATSToolBar != null)
for (int idx = 0; idx < [Link]; idx++)
if (cachePATSToolBar[idx] != null &&
cachePATSToolBar[idx].EqualsInput(input))
return cachePATSToolBar[idx];
return CacheIndicator<PATSToolBar>(new PATSToolBar(), input, ref
cachePATSToolBar);
}
}
}

namespace [Link]
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public [Link] PATSToolBar()
{
return [Link](Input);
}

public [Link] PATSToolBar(ISeries<double> input )


{
return [Link](input);
}
}
}

namespace [Link]
{
public partial class Strategy :
[Link]
{
public [Link] PATSToolBar()
{
return [Link](Input);
}

public [Link] PATSToolBar(ISeries<double> input )


{
return [Link](input);
}
}
}

#endregion

You might also like