From 3993d5ce06bcc596ed549b3b7c8737c93860c9b0 Mon Sep 17 00:00:00 2001 From: Kevin Hill Date: Tue, 29 Jun 2021 10:42:54 -0700 Subject: [PATCH] initial import --- .editorconfig | 4 + .gitignore | 6 ++ .npmignore | 10 +++ LICENSE | 21 +++++ Properties/Resources.Designer.cs | 84 +++++++++++++++++++ Properties/Resources.resx | 124 ++++++++++++++++++++++++++++ README.md | 62 ++++++++++++++ bin/Release/sspm.dll | Bin 0 -> 9216 bytes bin/Release/sspm.pdb | Bin 0 -> 19968 bytes sppm.csproj | 74 +++++++++++++++++ sppm.sln | 25 ++++++ src/sppm.cs | 22 +++++ src/sppm.js | 133 +++++++++++++++++++++++++++++++ 13 files changed, 565 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 LICENSE create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 README.md create mode 100644 bin/Release/sspm.dll create mode 100644 bin/Release/sspm.pdb create mode 100644 sppm.csproj create mode 100644 sppm.sln create mode 100644 src/sppm.cs create mode 100644 src/sppm.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c5412fa --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*] +tab_width = 4 +indent_size = 4 +trim_trailing_whitespace = true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f760286 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.vs/ +.vscode/ +.cache/ +obj/ +node_modules/ +System Volume Information/ \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..affc1fa --- /dev/null +++ b/.npmignore @@ -0,0 +1,10 @@ +.vs/ +.vscode/ +tools/ + +.editorconfig +.eslintignore +.eslintrc.json +.gitignore +.prettierrc.json +.babelrc.json \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..174ac3b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Kevin Hill + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6cc827f --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,84 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SSPM.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SSPM.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to (function(spGlobal) { + /// const notify = (message, title) => { + /// const textInfo = new StrokesPlus.Types.Internal.DisplayTextInfo(); + /// + /// textInfo.UsePrimaryScreen = true; + /// textInfo.Message = message; + /// textInfo.Title = title; + /// textInfo.TitleFont = new Font("Segoe UI", 18, host.flags(FontStyle.Bold)); + /// textInfo.TitleAlignment = "Right"; + /// textInfo.MessageFont = new Font("Segoe UI Semibold", 14); + /// textInfo.MessageAlignment = "Right"; + /// textInfo.Padding = 10; + /// textInfo. [rest of string was truncated]";. + /// + public static string sppm { + get { + return ResourceManager.GetString("sppm", resourceCulture); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..f94ec78 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\src\sppm.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ef0062 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +## ScriptsPlus, a StrokesPlus.net Plugin + +### Enhance the scripting capabilities of S+ with a rich module library. +Inspired by the simplicity of jQuery, there are 40+ modules that extend and enhance the scripting capabilities within action scripts. +Many common `sp.xxxx` methods are wrapped to simplify their use and some wrapped together to create new tools. + +# Install +Download `ScriptsPlusPlugin.dll` from here and place it in `C:\Program Files\StrokesPlus.net\Plug-Ins` to be automatically picked up by S+ +You can also add it manually, or place it in your own plugins folder and add that path. + +# Loading + - Head to `Global Actions` + - Open the `Load/Unload` tab + - Check the box to enable the load script + - Paste in this snippet: `var $ = ScriptsPlus();` + - Profit! + +# Examples + +### Wrapped Methods +```javascript +// wraps `sp.MessageBox()` +$.alert("Hello World!"); + +// wraps `new DisplayTextInfo()` +$.toast("Hello World!"); + +// wraps `sp.sp.ShowBalloonTip()` +$.balloon("Hello World!"); +``` + +### Dialogs +```javascript +function getUserInput() { + var modal = $.dialog.create("Text Input Demo"); + + modal.show(input => $.alert(input, "Input")); +} + +getUserInput(); +``` + +### Popup Menus +```javascript +var { addToMenu, addToSubMenu, menuItem, show } = $.popup; + +var popup = $.popup.create(); +var addToMainMenu = $.popup.addToMenu(popup); + +var mastercam = menuItem("Mastercam"); +var addToDemo = $.popup.addToSubMenu(mastercam); + +addToDemo(menuItem("Hello World", `$.alert('Hello World')`)); +addToDemo(menuItem("Taco Bell", `$.alert('Taco Bell')`)); +addToDemo(menuItem("Is Good", `$.alert('Is Good')`)); + +addToMainMenu(mastercam); +addToMainMenu($.popup.spacer); +addToMainMenu($.popup.cancel); + +show(popup); +``` \ No newline at end of file diff --git a/bin/Release/sspm.dll b/bin/Release/sspm.dll new file mode 100644 index 0000000000000000000000000000000000000000..29a59aab5c1074ec659806128d49360d32c5f45a GIT binary patch literal 9216 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 literal 0 HcmV?d00001 diff --git a/bin/Release/sspm.pdb b/bin/Release/sspm.pdb new file mode 100644 index 0000000000000000000000000000000000000000..85e5652551739cafc95f4ef91526fc3301b3ac70 GIT binary patch literal 19968 zcmeHOU2Igx6`ozFV?%Ac*l`m>%0f)B0k3!0#@HzZ8!s*>IB~L0Nh3>Ty}mY!?cL?x zH9t}wEYviXB1KM{C`E!QQ6K6mkjr?;DI(z2MIdkUBnVB=^&NW@JsGcwq11WDuL&uga-mY+`ce~H;FI`a` z3JZW+2p7mE;3S^`U$cnwyBIw1@XywbO*ybsJ9+b$U8@#ZaJ%u7aNALh+MX)hO+XlfD1W*5akjkrC}!LLb`tEjT@v zh=1c~ldr|sZW!7~-|&g{R7#KajixZ197n+pb=4szZXn&^QG16G*-E!1>}J>fA+gB+wA2m&jxryPy}SV`(;C}l3E~jzxc$f z-#mme`RzdRG@t^m9wi&UTKObpxtb_To?Vu!QORDr^w%FymMf65?~p_1epY}bVLqBmV^B+d=dckr&sYe!!RnN4%jMcpF@Wve zXscp_2wOQsH*$!5@mMOHilkyuJPpR;l&uoWJZ+$iMbx3%Rf`(WV_oWx6nq^xJ@s%@ zk0nz=n7r@_Bc+Y_4#eX9iDQPZGog?0vYEC8#q#C9+4YZ0KmYaz`_6AHai4qT>_M2vwn{7#J~^h891~AM1&DV=b$BpYzGyU+&>?>t{h+~@(T+Z$ZT~{K zMk;kdoANpJ-XrU=C&%hUy(!y+I?E@nbe#PX>h?<6GRV@-RiLGyt3kb>6`&hHD?vSC zqbL<+!XpwUEfFiyc35L_2{qQ4b_B(P={P|iLD{($ zGdb{!IJf4U`^@ET?p3yX97tKkU%|a`|KDUPL1kjx{*&`AIiS${zkcI zSoLLKe0la2l)elxzya>Ii1~~7Qp8x99v5He@SMw-7|;AbYc06aZv*VM21xKC2GOtU zK}*DaLd74(Fl$a->AB|mQs)t3(-?h(KS3Dtf?_?4Z3L|c^@v><(<{JQ#I>4qJhSF2 zdt7ZX+tr$~wAu1^cAH_BX)|m=Uv*~ORI%Igoh$8A`ccKiZc{!JGf#p?s0B^}&ja5B zUI+5*WbPFL9t0i-P5|!&@LOMXNyD`<>8jNgSo7HI@*>$cGd*wk_3x!#AWj>s$R%e|>BJKqTM~ z3cqWj?dftc31oHUKuHM(}eDV+m(>b{6gEA~L z*H-UTGkMILl`S)QJag5%%1j<};k$tZJI{@XSZY?dFsGKs$01WJ=TFsbLh>T7|AYnX#tf+M5#yqDz2IieCEN5WCy&eDvrOg2{oX;UST@#HH&o;eQ8jR)4ujaodn@Pu*Y1t^U*`UI?tik~TP=07LeD>tJsX%bjx&OPt|9Mzs_kWX^ z`$FCS@jj^r$os$b!25yr`@gT^nSV>ddqSqKyzR_(|F;hHUf>3xbN>e?%n|VKs2o_j G9{4}$$Pz;U literal 0 HcmV?d00001 diff --git a/sppm.csproj b/sppm.csproj new file mode 100644 index 0000000..f6dc6a9 --- /dev/null +++ b/sppm.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {0000CF33-0000-0000-0000-000000000000} + Library + SSPM + sspm + v4.8 + 512 + true + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + prompt + 4 + false + + + + False + C:\Program Files\StrokesPlus.net\ClearScript.Core.dll + False + + + C:\Program Files\StrokesPlus.net\ClearScript.V8.dll + False + + + + + + + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + + \ No newline at end of file diff --git a/sppm.sln b/sppm.sln new file mode 100644 index 0000000..d01b1a2 --- /dev/null +++ b/sppm.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31321.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sppm", "sppm.csproj", "{0000CF33-0000-0000-0000-000000000000}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0000CF33-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0000CF33-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0000CF33-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0000CF33-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EDD7BDD0-0D99-4905-B067-282AFA10DD39} + EndGlobalSection +EndGlobal diff --git a/src/sppm.cs b/src/sppm.cs new file mode 100644 index 0000000..d3c95c8 --- /dev/null +++ b/src/sppm.cs @@ -0,0 +1,22 @@ +using Microsoft.ClearScript; +using System.Windows.Forms; + +namespace SSPM +{ + public static class SSPM + { + public static string jsSource { get; } = Properties.Resources.sppm; + + public static void StrokesPlusInitStaticPlugin(ScriptEngine e) + { + try + { + e.Execute(jsSource); + } + catch (System.Exception err) + { + MessageBox.Show(err.Message, "SSPM Plugin Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/src/sppm.js b/src/sppm.js new file mode 100644 index 0000000..bb6b72d --- /dev/null +++ b/src/sppm.js @@ -0,0 +1,133 @@ +(function(spGlobal) { + const notify = (message, title) => { + const textInfo = new StrokesPlus.Types.Internal.DisplayTextInfo(); + + textInfo.UsePrimaryScreen = true; + textInfo.Message = message; + textInfo.Title = title; + textInfo.TitleFont = new Font("Segoe UI", 18, host.flags(FontStyle.Bold)); + textInfo.TitleAlignment = "Right"; + textInfo.MessageFont = new Font("Segoe UI Semibold", 14); + textInfo.MessageAlignment = "Right"; + textInfo.Padding = 10; + textInfo.Duration = 2000; + textInfo.Location = "bottomright"; + textInfo.Opacity = 0.9; + textInfo.ForeColor = "white"; + textInfo.BackColor = "SteelBlue"; + + return StrokesPlus.UI.TextOverlay.Show(textInfo); + } + + const alert = StrokesPlus.UI.Alert; + + const APPDATA = StrokesPlus.OS.Shell.ExpandEnvironmentVariables('%APPDATA%'); + const SP_APPDATA = System.IO.Path.Combine(APPDATA, 'StrokesPlus.net'); + const NODE_MODULES = System.IO.Path.Combine(SP_APPDATA, 'node_modules'); + const PKG_JSON = "package.json"; + + function npm(input) { + const NPM = 'C:\\Program Files\\nodejs\\npm.cmd'; + const CMD = `cd "${SP_APPDATA}" && "${NPM}" ${input}`; + + try { + StrokesPlus.OS.Shell.RunProgram('cmd.exe', '/C ' + CMD, '', 'hidden', true, true, true); + } catch (err) { + alert(err.toString(), "Error"); + } + } + + function resolve(id) { + const pkgPath = System.IO.Path.Combine(NODE_MODULES, id, PKG_JSON); + + if (System.IO.File.Exists(pkgPath)) { + return pkgPath; + } else { + alert(`${pkgPath} was not found`, "Error"); + } + } + + function readPackage(abspath) { + try { + return JSON.parse(System.IO.File.ReadAllText(abspath)); + } catch (error) { + alert(error, "error"); + } + } + + class Plugin { + static load(id) { + const pkgPath = resolve(id); + const plugin = new Plugin(pkgPath); + const src = plugin.source; + __spEngineWrapper.Engine.Evaluate(src); + } + static fromNpm(id) { + if (typeof id === "string") { + notify(id, `Installing from npm...`); + npm(`install --save ${id}`); + } else { + npm(`install`); + } + } + constructor(abspath) { + this.abspath = abspath; + this.resolvedPkg = this.abspath.replace("/", "\\").replace("\\\\", "\\"); + } + get pkgExists() { + return System.IO.File.Exists(this.resolvedPkg); + } + get pkg() { + const contents = System.IO.File.ReadAllText(this.resolvedPkg); + try { + return JSON.parse(contents); + } catch (error) { + return {}; + } + } + get mainEntry() { + const path = this.resolvedPkg.replace(PKG_JSON, ""); + return System.IO.Path.Combine(path, this.pkg.main); + } + get source() { + try { + return System.IO.File.ReadAllText(this.mainEntry); + } catch (error) { + return alert(abspath, 'File Read Error'); + } + } + } + + const SSPM = class { + constructor() { + // + } + + install(id) { + if (typeof id === "string") { + notify(`Installing "${id}" from npmjs`, "StrokesPlus Package Manager"); + npm(`install --save ${id}`); + } else { + npm(`install`); + } + } + } + + function once(fn) { + if (__spEngineWrapper.Engine.Name == StrokesPlus.ScriptEngine.List.Last().Engine.Name) { + fn(); + } + } + + spGlobal["SPPM"] = SPPM; + spGlobal["Plugin"] = Plugin; + spGlobal["sppm"] = new spGlobal["SPPM"](); +})(this); +// +//////////////////////////////////////////////////////////////////// +// +//sppm.install('@spcsp/explore-settings-json'); +//Plugin.load('@spcsp/explore-settings-json'); + +//Plugin.load('@spcsp/osd-toast'); +//toast("hi");