diff --git a/Indicators/.samples.json b/Indicators/.samples.json index 4550c97..8acd222 100644 --- a/Indicators/.samples.json +++ b/Indicators/.samples.json @@ -302,6 +302,12 @@ { "name": "Notifications Sample" }, + { + "name": "OpenFileDialog Sample" + }, + { + "name": "OpenFolderDialog Sample" + }, { "name": "Orientation Sample" }, @@ -344,6 +350,9 @@ { "name": "Rectangle Shape Sample" }, + { + "name": "SaveFileDialog Sample" + }, { "name": "ScrollBarVisibility Sample" }, diff --git a/Indicators/OpenFileDialog Sample/OpenFileDialog Sample.sln b/Indicators/OpenFileDialog Sample/OpenFileDialog Sample.sln new file mode 100644 index 0000000..832f54f --- /dev/null +++ b/Indicators/OpenFileDialog Sample/OpenFileDialog Sample.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFileDialog Sample", "OpenFileDialog Sample\OpenFileDialog Sample.csproj", "{3040baa2-c3e6-46b2-a167-5594d4036ef0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3040baa2-c3e6-46b2-a167-5594d4036ef0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3040baa2-c3e6-46b2-a167-5594d4036ef0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3040baa2-c3e6-46b2-a167-5594d4036ef0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3040baa2-c3e6-46b2-a167-5594d4036ef0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Indicators/OpenFileDialog Sample/OpenFileDialog Sample/OpenFileDialog Sample.cs b/Indicators/OpenFileDialog Sample/OpenFileDialog Sample/OpenFileDialog Sample.cs new file mode 100644 index 0000000..3a367ab --- /dev/null +++ b/Indicators/OpenFileDialog Sample/OpenFileDialog Sample/OpenFileDialog Sample.cs @@ -0,0 +1,45 @@ +using System; +using cAlgo.API; +using System.Text; + +namespace cAlgo +{ + [Indicator(AccessRights = AccessRights.None, IsOverlay = true)] + public class OpenFileDialogSample : Indicator + { + private OpenFileDialog _openFileDialog; + + protected override void Initialize() + { + _openFileDialog = new OpenFileDialog() + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), + Multiselect = true, + Title = "My Open File Dialog Title" + }; + + var showOpenFileDialog = new Button { Text = "Show Open File Dialog" }; + showOpenFileDialog.Click += showOpenFileDialog_Click; + + var panel = new StackPanel + { + Orientation = Orientation.Vertical, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center + }; + + panel.AddChild(showOpenFileDialog); + Chart.AddControl(panel); + } + + private void showOpenFileDialog_Click(ButtonClickEventArgs obj) + { + var result = _openFileDialog.ShowDialog(); + Print($"Result: {result} | FileName: {_openFileDialog.FileName} | FileNames: {string.Join(',', _openFileDialog.FileNames)}"); + } + + public override void Calculate(int index) + { + } + } +} \ No newline at end of file diff --git a/Indicators/OpenFileDialog Sample/OpenFileDialog Sample/OpenFileDialog Sample.csproj b/Indicators/OpenFileDialog Sample/OpenFileDialog Sample/OpenFileDialog Sample.csproj new file mode 100644 index 0000000..51ac844 --- /dev/null +++ b/Indicators/OpenFileDialog Sample/OpenFileDialog Sample/OpenFileDialog Sample.csproj @@ -0,0 +1,9 @@ + + + net6.0 + + + + + + diff --git a/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample.sln b/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample.sln new file mode 100644 index 0000000..b8cf161 --- /dev/null +++ b/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFolderDialog Sample", "OpenFolderDialog Sample\OpenFolderDialog Sample.csproj", "{96cc103a-7c47-4eb7-bfbd-0749bd22e097}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {96cc103a-7c47-4eb7-bfbd-0749bd22e097}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96cc103a-7c47-4eb7-bfbd-0749bd22e097}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96cc103a-7c47-4eb7-bfbd-0749bd22e097}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96cc103a-7c47-4eb7-bfbd-0749bd22e097}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample/OpenFolderDialog Sample.cs b/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample/OpenFolderDialog Sample.cs new file mode 100644 index 0000000..6427f10 --- /dev/null +++ b/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample/OpenFolderDialog Sample.cs @@ -0,0 +1,43 @@ +using System; +using cAlgo.API; + +namespace cAlgo +{ + [Indicator(AccessRights = AccessRights.None, IsOverlay = true)] + public class OpenFolderDialogSample : Indicator + { + private OpenFolderDialog _openFolderDialog; + + protected override void Initialize() + { + _openFolderDialog = new OpenFolderDialog() + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), + Title = "My Open Folder Dialog Title" + }; + + var showOpenFolderDialog = new Button { Text = "Show Open Folder Dialog" }; + showOpenFolderDialog.Click += showOpenFolderDialog_Click; + + var panel = new StackPanel + { + Orientation = Orientation.Vertical, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center + }; + + panel.AddChild(showOpenFolderDialog); + Chart.AddControl(panel); + } + + private void showOpenFolderDialog_Click(ButtonClickEventArgs obj) + { + var result = _openFolderDialog.ShowDialog(); + Print($"Result: {result} | FolderName: {_openFolderDialog.FolderName}"); + } + + public override void Calculate(int index) + { + } + } +} \ No newline at end of file diff --git a/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample/OpenFolderDialog Sample.csproj b/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample/OpenFolderDialog Sample.csproj new file mode 100644 index 0000000..51ac844 --- /dev/null +++ b/Indicators/OpenFolderDialog Sample/OpenFolderDialog Sample/OpenFolderDialog Sample.csproj @@ -0,0 +1,9 @@ + + + net6.0 + + + + + + diff --git a/Indicators/SaveFileDialog Sample/SaveFileDialog Sample.sln b/Indicators/SaveFileDialog Sample/SaveFileDialog Sample.sln new file mode 100644 index 0000000..6e931e7 --- /dev/null +++ b/Indicators/SaveFileDialog Sample/SaveFileDialog Sample.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaveFileDialog Sample", "SaveFileDialog Sample\SaveFileDialog Sample.csproj", "{5ec3ab32-b5ab-493c-8747-46eb9ec16b0e}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5ec3ab32-b5ab-493c-8747-46eb9ec16b0e}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5ec3ab32-b5ab-493c-8747-46eb9ec16b0e}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5ec3ab32-b5ab-493c-8747-46eb9ec16b0e}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5ec3ab32-b5ab-493c-8747-46eb9ec16b0e}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Indicators/SaveFileDialog Sample/SaveFileDialog Sample/SaveFileDialog Sample.cs b/Indicators/SaveFileDialog Sample/SaveFileDialog Sample/SaveFileDialog Sample.cs new file mode 100644 index 0000000..fffafa2 --- /dev/null +++ b/Indicators/SaveFileDialog Sample/SaveFileDialog Sample/SaveFileDialog Sample.cs @@ -0,0 +1,61 @@ +using System; +using cAlgo.API; +using System.Text; + +namespace cAlgo +{ + [Indicator(AccessRights = AccessRights.None, IsOverlay = true)] + public class SaveFileDialogSample : Indicator + { + private SaveFileDialog _saveFileDialog; + + protected override void Initialize() + { + _saveFileDialog = new SaveFileDialog() + { + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), + Title = "My Save File Dialog Title" + }; + + var showSaveFileDialogText = new Button { Text = "Show Save File Dialog (Set Content as text)" }; + var showSaveFileDialogBytes = new Button { Text = "Show Save File Dialog (Set Content as bytes)" }; + + showSaveFileDialogText.Click += showSaveFileDialogText_Click; + showSaveFileDialogBytes.Click += showSaveFileDialogBytes_Click; + + var panel = new StackPanel + { + Orientation = Orientation.Vertical, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center + }; + panel.AddChild(showSaveFileDialogText); + panel.AddChild(showSaveFileDialogBytes); + Chart.AddControl(panel); + } + + private void showSaveFileDialogText_Click(ButtonClickEventArgs obj) + { + var result = _saveFileDialog.ShowDialog(); + Print($"Result: {result}"); + if (result != FileDialogResult.Cancel) + { + _saveFileDialog.WriteToFile("Test in text"); + } + } + + private void showSaveFileDialogBytes_Click(ButtonClickEventArgs obj) + { + var result = _saveFileDialog.ShowDialog(); + Print($"Result: {result}"); + if (result != FileDialogResult.Cancel) + { + _saveFileDialog.WriteToFile(Encoding.UTF8.GetBytes("Test in bytes")); + } + } + + public override void Calculate(int index) + { + } + } +} \ No newline at end of file diff --git a/Indicators/SaveFileDialog Sample/SaveFileDialog Sample/SaveFileDialog Sample.csproj b/Indicators/SaveFileDialog Sample/SaveFileDialog Sample/SaveFileDialog Sample.csproj new file mode 100644 index 0000000..51ac844 --- /dev/null +++ b/Indicators/SaveFileDialog Sample/SaveFileDialog Sample/SaveFileDialog Sample.csproj @@ -0,0 +1,9 @@ + + + net6.0 + + + + + +