├── .gitignore ├── LICENSE ├── README.md ├── bucket.manager ├── App.config ├── Forge │ └── Derivatives.cs ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── HTML │ └── Viewer.html ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Tools │ ├── JSEditor.Designer.cs │ ├── JSEditor.cs │ └── JSEditor.resx ├── Utils │ ├── CustomProgress.cs │ ├── Prompt.cs │ └── Utils.cs ├── bucket.manager.csproj ├── bucket.manager.sln └── packages.config ├── js_run.gif └── thumbnail.png /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | thumbs.db 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | 28 | # Visual Studio 2015 cache/options directory 29 | .vs/ 30 | # Uncomment if you have tasks that create the project's static files in wwwroot 31 | #wwwroot/ 32 | 33 | # MSTest test Results 34 | [Tt]est[Rr]esult*/ 35 | [Bb]uild[Ll]og.* 36 | 37 | # NUNIT 38 | *.VisualState.xml 39 | TestResult.xml 40 | 41 | # Build Results of an ATL Project 42 | [Dd]ebugPS/ 43 | [Rr]eleasePS/ 44 | dlldata.c 45 | 46 | # .NET Core 47 | project.lock.json 48 | project.fragment.lock.json 49 | artifacts/ 50 | **/Properties/launchSettings.json 51 | 52 | *_i.c 53 | *_p.c 54 | *_i.h 55 | *.ilk 56 | *.meta 57 | *.obj 58 | *.pch 59 | *.pdb 60 | *.pgc 61 | *.pgd 62 | *.rsp 63 | *.sbr 64 | *.tlb 65 | *.tli 66 | *.tlh 67 | *.tmp 68 | *.tmp_proj 69 | *.log 70 | *.vspscc 71 | *.vssscc 72 | .builds 73 | *.pidb 74 | *.svclog 75 | *.scc 76 | 77 | # Chutzpah Test files 78 | _Chutzpah* 79 | 80 | # Visual C++ cache files 81 | ipch/ 82 | *.aps 83 | *.ncb 84 | *.opendb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | *.VC.db 89 | *.VC.VC.opendb 90 | 91 | # Visual Studio profiler 92 | *.psess 93 | *.vsp 94 | *.vspx 95 | *.sap 96 | 97 | # TFS 2012 Local Workspace 98 | $tf/ 99 | 100 | # Guidance Automation Toolkit 101 | *.gpState 102 | 103 | # ReSharper is a .NET coding add-in 104 | _ReSharper*/ 105 | *.[Rr]e[Ss]harper 106 | *.DotSettings.user 107 | 108 | # JustCode is a .NET coding add-in 109 | .JustCode 110 | 111 | # TeamCity is a build add-in 112 | _TeamCity* 113 | 114 | # DotCover is a Code Coverage Tool 115 | *.dotCover 116 | 117 | # Visual Studio code coverage results 118 | *.coverage 119 | *.coveragexml 120 | 121 | # NCrunch 122 | _NCrunch_* 123 | .*crunch*.local.xml 124 | nCrunchTemp_* 125 | 126 | # MightyMoose 127 | *.mm.* 128 | AutoTest.Net/ 129 | 130 | # Web workbench (sass) 131 | .sass-cache/ 132 | 133 | # Installshield output folder 134 | [Ee]xpress/ 135 | 136 | # DocProject is a documentation generator add-in 137 | DocProject/buildhelp/ 138 | DocProject/Help/*.HxT 139 | DocProject/Help/*.HxC 140 | DocProject/Help/*.hhc 141 | DocProject/Help/*.hhk 142 | DocProject/Help/*.hhp 143 | DocProject/Help/Html2 144 | DocProject/Help/html 145 | 146 | # Click-Once directory 147 | publish/ 148 | 149 | # Publish Web Output 150 | *.[Pp]ublish.xml 151 | *.azurePubxml 152 | # TODO: Comment the next line if you want to checkin your web deploy settings 153 | # but database connection strings (with potential passwords) will be unencrypted 154 | *.pubxml 155 | *.publishproj 156 | 157 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 158 | # checkin your Azure Web App publish settings, but sensitive information contained 159 | # in these scripts will be unencrypted 160 | PublishScripts/ 161 | 162 | # NuGet Packages 163 | *.nupkg 164 | # The packages folder can be ignored because of Package Restore 165 | **/packages/* 166 | # except build/, which is used as an MSBuild target. 167 | !**/packages/build/ 168 | # Uncomment if necessary however generally it will be regenerated when needed 169 | #!**/packages/repositories.config 170 | # NuGet v3's project.json files produces more ignorable files 171 | *.nuget.props 172 | *.nuget.targets 173 | 174 | # Microsoft Azure Build Output 175 | csx/ 176 | *.build.csdef 177 | 178 | # Microsoft Azure Emulator 179 | ecf/ 180 | rcf/ 181 | 182 | # Windows Store app package directories and files 183 | AppPackages/ 184 | BundleArtifacts/ 185 | Package.StoreAssociation.xml 186 | _pkginfo.txt 187 | 188 | # Visual Studio cache files 189 | # files ending in .cache can be ignored 190 | *.[Cc]ache 191 | # but keep track of directories ending in .cache 192 | !*.[Cc]ache/ 193 | 194 | # Others 195 | ClientBin/ 196 | ~$* 197 | *~ 198 | *.dbmdl 199 | *.dbproj.schemaview 200 | *.jfm 201 | *.pfx 202 | *.publishsettings 203 | orleans.codegen.cs 204 | 205 | # Since there are multiple workflows, uncomment next line to ignore bower_components 206 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 207 | #bower_components/ 208 | 209 | # RIA/Silverlight projects 210 | Generated_Code/ 211 | 212 | # Backup & report files from converting an old project file 213 | # to a newer Visual Studio version. Backup files are not needed, 214 | # because we have git ;-) 215 | _UpgradeReport_Files/ 216 | Backup*/ 217 | UpgradeLog*.XML 218 | UpgradeLog*.htm 219 | 220 | # SQL Server files 221 | *.mdf 222 | *.ldf 223 | *.ndf 224 | 225 | # Business Intelligence projects 226 | *.rdl.data 227 | *.bim.layout 228 | *.bim_*.settings 229 | 230 | # Microsoft Fakes 231 | FakesAssemblies/ 232 | 233 | # GhostDoc plugin setting file 234 | *.GhostDoc.xml 235 | 236 | # Node.js Tools for Visual Studio 237 | .ntvs_analysis.dat 238 | node_modules/ 239 | 240 | # Typescript v1 declaration files 241 | typings/ 242 | 243 | # Visual Studio 6 build log 244 | *.plg 245 | 246 | # Visual Studio 6 workspace options file 247 | *.opt 248 | 249 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 250 | *.vbw 251 | 252 | # Visual Studio LightSwitch build output 253 | **/*.HTMLClient/GeneratedArtifacts 254 | **/*.DesktopClient/GeneratedArtifacts 255 | **/*.DesktopClient/ModelManifest.xml 256 | **/*.Server/GeneratedArtifacts 257 | **/*.Server/ModelManifest.xml 258 | _Pvt_Extensions 259 | 260 | # Paket dependency manager 261 | .paket/paket.exe 262 | paket-files/ 263 | 264 | # FAKE - F# Make 265 | .fake/ 266 | 267 | # JetBrains Rider 268 | .idea/ 269 | *.sln.iml 270 | 271 | # CodeRush 272 | .cr/ 273 | 274 | # Python Tools for Visual Studio (PTVS) 275 | __pycache__/ 276 | *.pyc 277 | 278 | # Cake - Uncomment if you are using it 279 | # tools/** 280 | # !tools/packages.config 281 | 282 | # Telerik's JustMock configuration file 283 | *.jmconfig 284 | 285 | # BizTalk build output 286 | *.btp.cs 287 | *.btm.cs 288 | *.odx.cs 289 | *.xsd.cs 290 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Autodesk Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Desktop tool to manage buckets and objects 2 | 3 | ![Platforms](https://img.shields.io/badge/platform-Windows-lightgray.svg) 4 | ![.NET](https://img.shields.io/badge/.NET-4.6-blue.svg) 5 | [![CefSharp](http://img.shields.io/badge/CefSharp-57.0.0-blue.svg)](http://opensource.org/licenses/MIT) 6 | [![License](http://img.shields.io/:license-mit-blue.svg)](http://opensource.org/licenses/MIT) 7 | 8 | [![Data-Management](https://img.shields.io/badge/Data%20Management-v2-green.svg)](http://developer.autodesk.com/) 9 | [![Model-Derivative](https://img.shields.io/badge/Model%20Derivative-v2-green.svg)](http://developer.autodesk.com/) 10 | [![Viewer](https://img.shields.io/badge/Viewer-v6-green.svg)](http://developer.autodesk.com/) 11 | 12 | ![Advanced](https://img.shields.io/badge/Level-Advanced-red.svg) 13 | 14 | 15 | # Demonstration 16 | 17 | This sample is a Windows desktop application that lists all buckets for a given Forge Client ID & Secret, allow creating new buckets, upload new files, translate and delete. Allow download of SVF for offline viewing. Simple JavaScript for testing code. It is intended as tool for developers. 18 | 19 | ## Thumbnail 20 | 21 | 22 | ![thumbnail](/thumbnail.png) 23 | 24 | # Setup 25 | 26 | ## Prerequisites 27 | 28 | 1. **Visual Studio**: Either Community (Windows) or Code (Windows, MacOS). 29 | 2. **CefSharp**: Chromium based browser control for .NET apps 30 | 3. **.NET Framework** basic knowledge with C# 31 | 32 | ## Running locally 33 | 34 | For using this sample, you need an Autodesk developer credentials. Visit the [Forge Developer Portal](https://developer.autodesk.com), sign up for an account, then [create an app](https://developer.autodesk.com/myapps/create). 35 | 36 | Download the repository, open `bucket.manager.sln` Solution on Visual Studio. The build process should download the required packages (**Autodesk.Forge** and dependencies). Run the project. At the form, enter your Client ID & Secret, click on **Authenticate** button. The app will obtain a 2-legged token and list buckets and files. After translating, files should be Viewable. 37 | 38 | # Features 39 | 40 | This sample app includes a few features: 41 | 42 | ## Download SVF 43 | 44 | After creating a bucket and uploading an object, translate the file. When finish, open on the Viewer. Click on **Download SVF** button and select a destination folder. The HTML to view the file needs to point to the .svf file, usually a **0.SVF** under a folder with the same name of the viewable. 45 | 46 | ## Running JavaScript code 47 | 48 | The CefSharp control allow **.EvaluateScriptAsync()** for executing JavaScript code, which can be used for quick testing some code. Load a model on the Viewer, then click on **JavaScript** button. Type, paste or open a .js file, then click on **Run** (or `Ctrl+R`) to run, the result will show on the bottom text area and (if applicable) at the DevTools Console). The video demonstrate it: 49 | 50 | ![JavaScript run demo](js_run.gif) 51 | 52 | # Further Reading 53 | 54 | Blog: 55 | 56 | - [Download SVG](https://forge.autodesk.com/blog/forge-svf-extractor-c-net): details on how to download the SVF for offline viewing. 57 | 58 | Samples: 59 | 60 | - [Desktop 3-legged sample](https://github.com/Autodesk-Forge/data.management-csharp-desktop.sample) 61 | 62 | ### Tips & Tricks 63 | 64 | The CEF Sharp library should work on `AnyCPU`, but this sample uses only `x64` version. [This issue](https://github.com/cefsharp/CefSharp/issues/1714) entry explains how to adjust it, if needed. 65 | 66 | ## License 67 | 68 | This sample is licensed under the terms of the [MIT License](http://opensource.org/licenses/MIT). Please see the [LICENSE](LICENSE) file for full details. 69 | 70 | ## Written by 71 | 72 | Augusto Goncalves [@augustomaia](https://twitter.com/augustomaia), [Forge Partner Development](http://forge.autodesk.com) 73 | -------------------------------------------------------------------------------- /bucket.manager/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /bucket.manager/Forge/Derivatives.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | // Forge Extractor 20 | // Based on https://forge.autodesk.com/blog/forge-svf-extractor-nodejs 21 | 22 | using Autodesk.Forge; 23 | using Autodesk.Forge.Model; 24 | using Newtonsoft.Json.Linq; 25 | using RestSharp; 26 | using System; 27 | using System.Collections.Generic; 28 | using System.IO; 29 | using System.IO.Compression; 30 | using System.Linq; 31 | using System.Text.RegularExpressions; 32 | using System.Threading.Tasks; 33 | 34 | namespace bucket.manager.ForgeUtils 35 | { 36 | public static class Derivatives 37 | { 38 | /// 39 | /// Prepare a list of downloadables for a given URN 40 | /// 41 | /// URN of the resource on Autodesk Forge 42 | /// Valid access token to download the resources 43 | /// List of resouces for the given URN 44 | public async static Task> ExtractSVFAsync(string urn, string accessToken) 45 | { 46 | DerivativesApi derivativeApi = new DerivativesApi(); 47 | derivativeApi.Configuration.AccessToken = accessToken; 48 | 49 | // get the manifest for the URN 50 | dynamic manifest = await derivativeApi.GetManifestAsync(urn); 51 | 52 | // list items of the manifest file 53 | List urns = ParseManifest(manifest.derivatives); 54 | 55 | // iterate on what's on the file 56 | foreach (ManifestItem item in urns) 57 | { 58 | switch (item.MIME) 59 | { 60 | case "application/autodesk-svf": 61 | item.Path.Files = await SVFDerivates(item, accessToken); 62 | break; 63 | case "application/autodesk-f2d": 64 | item.Path.Files = await F2DDerivates(item, accessToken); 65 | break; 66 | case "application/autodesk-db": 67 | item.Path.Files = new List() 68 | { 69 | "objects_attrs.json.gz", 70 | "objects_vals.json.gz", 71 | "objects_offs.json.gz", 72 | "objects_ids.json.gz", 73 | "objects_avs.json.gz", 74 | item.Path.RootFileName 75 | }; 76 | break; 77 | default: 78 | item.Path.Files = new List() 79 | { 80 | item.Path.RootFileName 81 | }; 82 | break; 83 | } 84 | } 85 | 86 | // now organize the list for external usage 87 | List resouces = new List(); 88 | foreach (ManifestItem item in urns) 89 | { 90 | foreach (string file in item.Path.Files) 91 | { 92 | Uri myUri = new Uri(new Uri(item.Path.BasePath), file); 93 | resouces.Add(new Resource() 94 | { 95 | FileName = file, 96 | RemotePath = DERIVATIVE_PATH + Uri.UnescapeDataString(myUri.AbsoluteUri), 97 | LocalPath = Path.Combine(item.Path.LocalPath, file) 98 | }); 99 | } 100 | } 101 | 102 | return resouces; 103 | } 104 | 105 | public struct Resource 106 | { 107 | /// 108 | /// File name (no path) 109 | /// 110 | public string FileName { get; set; } 111 | /// 112 | /// Remove path to download (must add developer.api.autodesk.com prefix) 113 | /// 114 | public string RemotePath { get; set; } 115 | /// 116 | /// Path to save file locally 117 | /// 118 | public string LocalPath { get; set; } 119 | } 120 | 121 | public const string BASE_URL = "https://developer.api.autodesk.com/"; 122 | public const string DERIVATIVE_PATH = "derivativeservice/v2/derivatives/"; 123 | 124 | /// 125 | /// Download the manifest and extract it 126 | /// 127 | /// 128 | /// 129 | /// 130 | private static async Task GetDerivativeAsync(string manifest, string accessToken) 131 | { 132 | // prepare to download the file 133 | IRestClient client = new RestClient(BASE_URL); 134 | RestRequest request = new RestRequest(DERIVATIVE_PATH + "{manifest}", Method.GET); 135 | request.AddParameter("manifest", manifest, ParameterType.UrlSegment); 136 | request.AddHeader("Authorization", "Bearer " + accessToken); 137 | request.AddHeader("Accept-Encoding", "gzip, deflate"); 138 | IRestResponse response = await client.ExecuteTaskAsync(request); 139 | 140 | JObject manifestJson = null; 141 | 142 | // unzip it 143 | if (manifest.IndexOf(".gz") > -1) 144 | { 145 | GZipStream gzip = new GZipStream(new MemoryStream(response.RawBytes), CompressionMode.Decompress); 146 | using (var fileStream = new StreamReader(gzip)) 147 | manifestJson = JObject.Parse(fileStream.ReadToEnd()); 148 | } 149 | else 150 | { 151 | ZipArchive zip = new ZipArchive(new MemoryStream(response.RawBytes)); 152 | ZipArchiveEntry manifestData = zip.GetEntry("manifest.json"); 153 | using (var stream = manifestData.Open()) 154 | using (var reader = new StreamReader(stream)) 155 | manifestJson = JObject.Parse(reader.ReadToEnd().ToString()); 156 | } 157 | 158 | return manifestJson; 159 | } 160 | 161 | /// 162 | /// Prepare list of resources for SVF files 163 | /// 164 | /// 165 | /// 166 | /// 167 | private static async Task> SVFDerivates(ManifestItem item, string accessToken) 168 | { 169 | JObject manifest = await GetDerivativeAsync(item.Path.URN, accessToken); 170 | 171 | List files = new List(); 172 | files.Add(item.Path.URN.Substring(item.Path.BasePath.Length)); 173 | 174 | files.AddRange(GetAssets(manifest)); 175 | 176 | return files; 177 | } 178 | 179 | /// 180 | /// Prepare list of resources for f2d files 181 | /// 182 | /// 183 | /// 184 | /// 185 | private static async Task> F2DDerivates(ManifestItem item, string accessToken) 186 | { 187 | JObject manifest = await GetDerivativeAsync(item.Path.BasePath + "manifest.json.gz", accessToken); 188 | 189 | List files = new List(); 190 | files.Add("manifest.json.gz"); 191 | 192 | files.AddRange(GetAssets(manifest)); 193 | 194 | return files; 195 | } 196 | 197 | /// 198 | /// Get asset URIs on the manifest file 199 | /// 200 | /// 201 | /// 202 | private static List GetAssets(JObject manifest) 203 | { 204 | List files = new List(); 205 | 206 | // for each "asset" on the manifest, add to the list of files (skip embed) 207 | foreach (JObject asset in manifest["assets"]) 208 | { 209 | System.Diagnostics.Debug.WriteLine(asset["URI"].Value()); 210 | if (asset["URI"].Value().Contains("embed:/")) continue; 211 | files.Add(asset["URI"].Value()); 212 | } 213 | 214 | return files; 215 | } 216 | 217 | private static readonly string[] ROLES = { 218 | "Autodesk.CloudPlatform.DesignDescription", 219 | "Autodesk.CloudPlatform.PropertyDatabase", 220 | "Autodesk.CloudPlatform.IndexableContent", 221 | "leaflet-zip", 222 | "thumbnail", 223 | "graphics", 224 | "preview", 225 | "raas", 226 | "pdf", 227 | "lod", 228 | }; 229 | 230 | private class ManifestItem 231 | { 232 | public string Guid { get; set; } 233 | public string MIME { get; set; } 234 | public PathInfo Path { get; set; } 235 | } 236 | 237 | /// 238 | /// Download and parse the SVF file 239 | /// 240 | /// 241 | /// 242 | private static List ParseManifest(dynamic manifest) 243 | { 244 | List urns = new List(); 245 | foreach (KeyValuePair item in manifest.Dictionary) 246 | { 247 | DynamicDictionary itemKeys = (DynamicDictionary)item.Value; 248 | if (itemKeys.Dictionary.ContainsKey("role") && ROLES.Contains(itemKeys.Dictionary["role"])) 249 | { 250 | urns.Add(new ManifestItem 251 | { 252 | Guid = (string)itemKeys.Dictionary["guid"], 253 | MIME = (string)itemKeys.Dictionary["mime"], 254 | Path = DecomposeURN((string)itemKeys.Dictionary["urn"]) 255 | }); 256 | } 257 | 258 | if (itemKeys.Dictionary.ContainsKey("children")) 259 | { 260 | urns.AddRange(ParseManifest(itemKeys.Dictionary["children"])); 261 | } 262 | } 263 | return urns; 264 | } 265 | 266 | private class PathInfo 267 | { 268 | public string RootFileName { get; set; } 269 | public string LocalPath { get; set; } 270 | public string BasePath { get; set; } 271 | public string URN { get; set; } 272 | public List Files { get; set; } 273 | } 274 | 275 | private static PathInfo DecomposeURN(string encodedUrn) 276 | { 277 | string urn = Uri.UnescapeDataString(encodedUrn); 278 | 279 | string rootFileName = urn.Substring(urn.LastIndexOf('/') + 1); 280 | string basePath = urn.Substring(0, urn.LastIndexOf('/') + 1); 281 | string localPath = basePath.Substring(basePath.IndexOf('/') + 1); 282 | localPath = Regex.Replace(localPath, "[/]?output/", string.Empty); 283 | 284 | return new PathInfo() 285 | { 286 | RootFileName = rootFileName, 287 | BasePath = basePath, 288 | LocalPath = localPath, 289 | URN = urn 290 | }; 291 | } 292 | } 293 | } 294 | -------------------------------------------------------------------------------- /bucket.manager/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | namespace bucket.manager 20 | { 21 | partial class Form1 22 | { 23 | /// 24 | /// Required designer variable. 25 | /// 26 | private System.ComponentModel.IContainer components = null; 27 | 28 | /// 29 | /// Clean up any resources being used. 30 | /// 31 | /// true if managed resources should be disposed; otherwise, false. 32 | protected override void Dispose(bool disposing) 33 | { 34 | if (disposing && (components != null)) 35 | { 36 | components.Dispose(); 37 | } 38 | base.Dispose(disposing); 39 | } 40 | 41 | #region Windows Form Designer generated code 42 | 43 | /// 44 | /// Required method for Designer support - do not modify 45 | /// the contents of this method with the code editor. 46 | /// 47 | private void InitializeComponent() 48 | { 49 | this.components = new System.ComponentModel.Container(); 50 | this.treeBuckets = new System.Windows.Forms.TreeView(); 51 | this.label1 = new System.Windows.Forms.Label(); 52 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 53 | this.txtTimeout = new System.Windows.Forms.TextBox(); 54 | this.txtAccessToken = new System.Windows.Forms.TextBox(); 55 | this.label4 = new System.Windows.Forms.Label(); 56 | this.btnAuthenticate = new System.Windows.Forms.Button(); 57 | this.txtClientSecret = new System.Windows.Forms.TextBox(); 58 | this.label2 = new System.Windows.Forms.Label(); 59 | this.txtClientId = new System.Windows.Forms.TextBox(); 60 | this.cmbRegion = new System.Windows.Forms.ComboBox(); 61 | this.label3 = new System.Windows.Forms.Label(); 62 | this.btnRefreshToken = new System.Windows.Forms.Button(); 63 | this.btnCreateBucket = new System.Windows.Forms.Button(); 64 | this.btnUpload = new System.Windows.Forms.Button(); 65 | this.btnTranslate = new System.Windows.Forms.Button(); 66 | this.menuTranslate = new System.Windows.Forms.ContextMenuStrip(this.components); 67 | this.btnDeleteObject = new System.Windows.Forms.Button(); 68 | this.panel1 = new System.Windows.Forms.Panel(); 69 | this.btnShowDevTools = new System.Windows.Forms.Button(); 70 | this.btnDownloadSVF = new System.Windows.Forms.Button(); 71 | this.btnJavaScript = new System.Windows.Forms.Button(); 72 | this.progressBar = new bucket.manager.Utils.CustomProgressBar(); 73 | this.groupBox1.SuspendLayout(); 74 | this.SuspendLayout(); 75 | // 76 | // treeBuckets 77 | // 78 | this.treeBuckets.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 79 | | System.Windows.Forms.AnchorStyles.Left))); 80 | this.treeBuckets.Location = new System.Drawing.Point(12, 209); 81 | this.treeBuckets.Name = "treeBuckets"; 82 | this.treeBuckets.Size = new System.Drawing.Size(225, 392); 83 | this.treeBuckets.TabIndex = 0; 84 | this.treeBuckets.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeBuckets_AfterSelect); 85 | // 86 | // label1 87 | // 88 | this.label1.AutoSize = true; 89 | this.label1.Location = new System.Drawing.Point(14, 24); 90 | this.label1.Name = "label1"; 91 | this.label1.Size = new System.Drawing.Size(21, 13); 92 | this.label1.TabIndex = 1; 93 | this.label1.Text = "ID:"; 94 | // 95 | // groupBox1 96 | // 97 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 98 | | System.Windows.Forms.AnchorStyles.Right))); 99 | this.groupBox1.Controls.Add(this.txtTimeout); 100 | this.groupBox1.Controls.Add(this.txtAccessToken); 101 | this.groupBox1.Controls.Add(this.label4); 102 | this.groupBox1.Controls.Add(this.btnAuthenticate); 103 | this.groupBox1.Controls.Add(this.txtClientSecret); 104 | this.groupBox1.Controls.Add(this.label2); 105 | this.groupBox1.Controls.Add(this.txtClientId); 106 | this.groupBox1.Controls.Add(this.label1); 107 | this.groupBox1.Location = new System.Drawing.Point(13, 13); 108 | this.groupBox1.Name = "groupBox1"; 109 | this.groupBox1.Size = new System.Drawing.Size(675, 76); 110 | this.groupBox1.TabIndex = 2; 111 | this.groupBox1.TabStop = false; 112 | this.groupBox1.Text = "Forge Credentials"; 113 | // 114 | // txtTimeout 115 | // 116 | this.txtTimeout.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 117 | this.txtTimeout.Location = new System.Drawing.Point(583, 46); 118 | this.txtTimeout.Name = "txtTimeout"; 119 | this.txtTimeout.ReadOnly = true; 120 | this.txtTimeout.Size = new System.Drawing.Size(86, 20); 121 | this.txtTimeout.TabIndex = 10; 122 | this.txtTimeout.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; 123 | // 124 | // txtAccessToken 125 | // 126 | this.txtAccessToken.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 127 | | System.Windows.Forms.AnchorStyles.Right))); 128 | this.txtAccessToken.Location = new System.Drawing.Point(100, 46); 129 | this.txtAccessToken.Name = "txtAccessToken"; 130 | this.txtAccessToken.ReadOnly = true; 131 | this.txtAccessToken.Size = new System.Drawing.Size(477, 20); 132 | this.txtAccessToken.TabIndex = 9; 133 | // 134 | // label4 135 | // 136 | this.label4.AutoSize = true; 137 | this.label4.Location = new System.Drawing.Point(14, 49); 138 | this.label4.Name = "label4"; 139 | this.label4.Size = new System.Drawing.Size(79, 13); 140 | this.label4.TabIndex = 8; 141 | this.label4.Text = "Access Token:"; 142 | // 143 | // btnAuthenticate 144 | // 145 | this.btnAuthenticate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 146 | this.btnAuthenticate.Location = new System.Drawing.Point(583, 18); 147 | this.btnAuthenticate.Name = "btnAuthenticate"; 148 | this.btnAuthenticate.Size = new System.Drawing.Size(86, 23); 149 | this.btnAuthenticate.TabIndex = 5; 150 | this.btnAuthenticate.Text = "Authenticate"; 151 | this.btnAuthenticate.UseVisualStyleBackColor = true; 152 | this.btnAuthenticate.Click += new System.EventHandler(this.btnAuthenticate_Click); 153 | // 154 | // txtClientSecret 155 | // 156 | this.txtClientSecret.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 157 | this.txtClientSecret.Location = new System.Drawing.Point(384, 20); 158 | this.txtClientSecret.Name = "txtClientSecret"; 159 | this.txtClientSecret.PasswordChar = '*'; 160 | this.txtClientSecret.Size = new System.Drawing.Size(193, 20); 161 | this.txtClientSecret.TabIndex = 4; 162 | // 163 | // label2 164 | // 165 | this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 166 | this.label2.AutoSize = true; 167 | this.label2.Location = new System.Drawing.Point(337, 24); 168 | this.label2.Name = "label2"; 169 | this.label2.Size = new System.Drawing.Size(41, 13); 170 | this.label2.TabIndex = 3; 171 | this.label2.Text = "Secret:"; 172 | // 173 | // txtClientId 174 | // 175 | this.txtClientId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 176 | | System.Windows.Forms.AnchorStyles.Right))); 177 | this.txtClientId.Location = new System.Drawing.Point(35, 20); 178 | this.txtClientId.Name = "txtClientId"; 179 | this.txtClientId.Size = new System.Drawing.Size(296, 20); 180 | this.txtClientId.TabIndex = 2; 181 | // 182 | // cmbRegion 183 | // 184 | this.cmbRegion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 185 | this.cmbRegion.FormattingEnabled = true; 186 | this.cmbRegion.Items.AddRange(new object[] { 187 | "US", 188 | "EMEA"}); 189 | this.cmbRegion.Location = new System.Drawing.Point(62, 95); 190 | this.cmbRegion.Name = "cmbRegion"; 191 | this.cmbRegion.SelectedIndex = 0; 192 | this.cmbRegion.Size = new System.Drawing.Size(174, 21); 193 | this.cmbRegion.TabIndex = 3; 194 | this.cmbRegion.SelectedIndexChanged += new System.EventHandler(this.btnRefreshToken_Click); 195 | // 196 | // label3 197 | // 198 | this.label3.AutoSize = true; 199 | this.label3.Location = new System.Drawing.Point(12, 98); 200 | this.label3.Name = "label3"; 201 | this.label3.Size = new System.Drawing.Size(44, 13); 202 | this.label3.TabIndex = 14; 203 | this.label3.Text = "Region:"; 204 | // 205 | // btnRefreshToken 206 | // 207 | this.btnRefreshToken.Location = new System.Drawing.Point(13, 122); 208 | this.btnRefreshToken.Name = "btnRefreshToken"; 209 | this.btnRefreshToken.Size = new System.Drawing.Size(121, 23); 210 | this.btnRefreshToken.TabIndex = 4; 211 | this.btnRefreshToken.Text = "Refresh buckets"; 212 | this.btnRefreshToken.UseVisualStyleBackColor = true; 213 | this.btnRefreshToken.Click += new System.EventHandler(this.btnRefreshToken_Click); 214 | // 215 | // btnCreateBucket 216 | // 217 | this.btnCreateBucket.Location = new System.Drawing.Point(140, 122); 218 | this.btnCreateBucket.Name = "btnCreateBucket"; 219 | this.btnCreateBucket.Size = new System.Drawing.Size(97, 23); 220 | this.btnCreateBucket.TabIndex = 5; 221 | this.btnCreateBucket.Text = "Create Bucket"; 222 | this.btnCreateBucket.UseVisualStyleBackColor = true; 223 | this.btnCreateBucket.Click += new System.EventHandler(this.btnCreateBucket_Click); 224 | // 225 | // btnUpload 226 | // 227 | this.btnUpload.Location = new System.Drawing.Point(13, 180); 228 | this.btnUpload.Name = "btnUpload"; 229 | this.btnUpload.Size = new System.Drawing.Size(93, 23); 230 | this.btnUpload.TabIndex = 6; 231 | this.btnUpload.Text = "Upload File"; 232 | this.btnUpload.UseVisualStyleBackColor = true; 233 | this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click); 234 | // 235 | // btnTranslate 236 | // 237 | this.btnTranslate.Location = new System.Drawing.Point(113, 180); 238 | this.btnTranslate.Name = "btnTranslate"; 239 | this.btnTranslate.Size = new System.Drawing.Size(124, 23); 240 | this.btnTranslate.TabIndex = 7; 241 | this.btnTranslate.Text = "Translate file"; 242 | this.btnTranslate.UseVisualStyleBackColor = true; 243 | this.btnTranslate.Click += new System.EventHandler(this.btnTranslate_Click); 244 | // 245 | // menuTranslate 246 | // 247 | this.menuTranslate.ImageScalingSize = new System.Drawing.Size(20, 20); 248 | this.menuTranslate.Name = "menuTranslate"; 249 | this.menuTranslate.Size = new System.Drawing.Size(61, 4); 250 | // 251 | // btnDeleteObject 252 | // 253 | this.btnDeleteObject.Location = new System.Drawing.Point(13, 151); 254 | this.btnDeleteObject.Name = "btnDeleteObject"; 255 | this.btnDeleteObject.Size = new System.Drawing.Size(103, 23); 256 | this.btnDeleteObject.TabIndex = 8; 257 | this.btnDeleteObject.Text = "Delete Object"; 258 | this.btnDeleteObject.UseVisualStyleBackColor = true; 259 | this.btnDeleteObject.Click += new System.EventHandler(this.btnDeleteObject_Click); 260 | // 261 | // panel1 262 | // 263 | this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 264 | | System.Windows.Forms.AnchorStyles.Left) 265 | | System.Windows.Forms.AnchorStyles.Right))); 266 | this.panel1.Location = new System.Drawing.Point(242, 95); 267 | this.panel1.Margin = new System.Windows.Forms.Padding(2); 268 | this.panel1.Name = "panel1"; 269 | this.panel1.Size = new System.Drawing.Size(446, 477); 270 | this.panel1.TabIndex = 9; 271 | // 272 | // btnShowDevTools 273 | // 274 | this.btnShowDevTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 275 | this.btnShowDevTools.Location = new System.Drawing.Point(613, 577); 276 | this.btnShowDevTools.Name = "btnShowDevTools"; 277 | this.btnShowDevTools.Size = new System.Drawing.Size(75, 23); 278 | this.btnShowDevTools.TabIndex = 10; 279 | this.btnShowDevTools.Text = "DevTools"; 280 | this.btnShowDevTools.UseVisualStyleBackColor = true; 281 | this.btnShowDevTools.Click += new System.EventHandler(this.btnShowDevTools_Click); 282 | // 283 | // btnDownloadSVF 284 | // 285 | this.btnDownloadSVF.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 286 | this.btnDownloadSVF.Location = new System.Drawing.Point(492, 577); 287 | this.btnDownloadSVF.Name = "btnDownloadSVF"; 288 | this.btnDownloadSVF.Size = new System.Drawing.Size(115, 23); 289 | this.btnDownloadSVF.TabIndex = 11; 290 | this.btnDownloadSVF.Text = "Download SVF"; 291 | this.btnDownloadSVF.UseVisualStyleBackColor = true; 292 | this.btnDownloadSVF.Click += new System.EventHandler(this.btnDownloadSVF_Click); 293 | // 294 | // btnJavaScript 295 | // 296 | this.btnJavaScript.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 297 | this.btnJavaScript.Location = new System.Drawing.Point(411, 577); 298 | this.btnJavaScript.Name = "btnJavaScript"; 299 | this.btnJavaScript.Size = new System.Drawing.Size(75, 23); 300 | this.btnJavaScript.TabIndex = 12; 301 | this.btnJavaScript.Text = "JavaScript"; 302 | this.btnJavaScript.UseVisualStyleBackColor = true; 303 | this.btnJavaScript.Click += new System.EventHandler(this.btnJavaScript_Click); 304 | // 305 | // progressBar 306 | // 307 | this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 308 | | System.Windows.Forms.AnchorStyles.Right))); 309 | this.progressBar.CustomText = null; 310 | this.progressBar.DisplayStyle = bucket.manager.Utils.ProgressBarDisplayText.Percentage; 311 | this.progressBar.Location = new System.Drawing.Point(12, 607); 312 | this.progressBar.Name = "progressBar"; 313 | this.progressBar.Size = new System.Drawing.Size(676, 23); 314 | this.progressBar.TabIndex = 7; 315 | this.progressBar.Visible = false; 316 | // 317 | // Form1 318 | // 319 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 320 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 321 | this.ClientSize = new System.Drawing.Size(700, 642); 322 | this.Controls.Add(this.btnJavaScript); 323 | this.Controls.Add(this.btnDownloadSVF); 324 | this.Controls.Add(this.btnShowDevTools); 325 | this.Controls.Add(this.panel1); 326 | this.Controls.Add(this.btnDeleteObject); 327 | this.Controls.Add(this.progressBar); 328 | this.Controls.Add(this.btnTranslate); 329 | this.Controls.Add(this.btnUpload); 330 | this.Controls.Add(this.btnCreateBucket); 331 | this.Controls.Add(this.btnRefreshToken); 332 | this.Controls.Add(this.label3); 333 | this.Controls.Add(this.cmbRegion); 334 | this.Controls.Add(this.groupBox1); 335 | this.Controls.Add(this.treeBuckets); 336 | this.Name = "Form1"; 337 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 338 | this.Text = "Bucket Manager"; 339 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); 340 | this.Load += new System.EventHandler(this.Form1_Load); 341 | this.groupBox1.ResumeLayout(false); 342 | this.groupBox1.PerformLayout(); 343 | this.ResumeLayout(false); 344 | 345 | } 346 | 347 | #endregion 348 | 349 | private System.Windows.Forms.TreeView treeBuckets; 350 | private System.Windows.Forms.Label label1; 351 | private System.Windows.Forms.GroupBox groupBox1; 352 | private System.Windows.Forms.TextBox txtAccessToken; 353 | private System.Windows.Forms.Label label4; 354 | private System.Windows.Forms.Button btnAuthenticate; 355 | private System.Windows.Forms.TextBox txtClientSecret; 356 | private System.Windows.Forms.Label label2; 357 | private System.Windows.Forms.TextBox txtClientId; 358 | private System.Windows.Forms.TextBox txtTimeout; 359 | private System.Windows.Forms.ComboBox cmbRegion; 360 | private System.Windows.Forms.Label label3; 361 | private System.Windows.Forms.Button btnRefreshToken; 362 | private System.Windows.Forms.Button btnCreateBucket; 363 | private System.Windows.Forms.Button btnUpload; 364 | private System.Windows.Forms.Button btnTranslate; 365 | private Utils.CustomProgressBar progressBar; 366 | private System.Windows.Forms.ContextMenuStrip menuTranslate; 367 | private System.Windows.Forms.Button btnDeleteObject; 368 | private System.Windows.Forms.Panel panel1; 369 | private System.Windows.Forms.Button btnShowDevTools; 370 | private System.Windows.Forms.Button btnDownloadSVF; 371 | private System.Windows.Forms.Button btnJavaScript; 372 | } 373 | } 374 | 375 | -------------------------------------------------------------------------------- /bucket.manager/Form1.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | using Autodesk.Forge; 20 | using Autodesk.Forge.Model; 21 | using bucket.manager.Utils; 22 | using CefSharp; 23 | using CefSharp.WinForms; 24 | using RestSharp; 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Diagnostics; 28 | using System.Drawing; 29 | using System.IO; 30 | using System.Text.RegularExpressions; 31 | using System.Threading.Tasks; 32 | using System.Windows.Forms; 33 | 34 | namespace bucket.manager 35 | { 36 | public partial class Form1 : Form 37 | { 38 | public Form1() 39 | { 40 | InitializeComponent(); 41 | InitBrowser(); 42 | } 43 | 44 | public ChromiumWebBrowser browser; 45 | 46 | public void InitBrowser() 47 | { 48 | var settings = new CefSettings(); 49 | //settings.CefCommandLineArgs.Add("enable-gpu", "1"); 50 | //settings.CefCommandLineArgs.Add("enable-webgl", "1"); 51 | Cef.Initialize(settings); 52 | browser = new ChromiumWebBrowser("file:///HTML/Viewer.html"); // CefSharp needs a initial page... 53 | 54 | browser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 55 | | System.Windows.Forms.AnchorStyles.Left) 56 | | System.Windows.Forms.AnchorStyles.Right))); 57 | browser.MinimumSize = new System.Drawing.Size(20, 20); 58 | browser.Name = "webBrowser1"; 59 | browser.TabIndex = 1; 60 | browser.Dock = DockStyle.Fill; 61 | panel1.Controls.Add(browser); 62 | } 63 | 64 | private Timer _tokenTimer = new Timer(); 65 | private Timer _translationTimer = new Timer(); 66 | private DateTime _expiresAt; 67 | 68 | private async void btnAuthenticate_Click(object sender, EventArgs e) 69 | { 70 | if (string.IsNullOrWhiteSpace(txtClientId.Text) || string.IsNullOrWhiteSpace(txtClientSecret.Text)) return; 71 | 72 | // get the access token 73 | TwoLeggedApi oAuth = new TwoLeggedApi(); 74 | Bearer token = (await oAuth.AuthenticateAsync( 75 | txtClientId.Text, 76 | txtClientSecret.Text, 77 | oAuthConstants.CLIENT_CREDENTIALS, 78 | new Scope[] { Scope.BucketRead, Scope.BucketCreate, Scope.DataRead, Scope.DataWrite })).ToObject(); 79 | txtAccessToken.Text = token.AccessToken; 80 | _expiresAt = DateTime.Now.AddSeconds(token.ExpiresIn.Value); 81 | 82 | // keep track on time 83 | _tokenTimer.Tick += new EventHandler(tickTokenTimer); 84 | _tokenTimer.Interval = 1000; 85 | _tokenTimer.Enabled = true; 86 | 87 | btnRefreshToken_Click(null, null); 88 | } 89 | 90 | void tickTokenTimer(object sender, EventArgs e) 91 | { 92 | // update the time left on the access token 93 | double secondsLeft = (_expiresAt - DateTime.Now).TotalSeconds; 94 | txtTimeout.Text = secondsLeft.ToString("0"); 95 | txtTimeout.BackColor = (secondsLeft < 60 ? System.Drawing.Color.Red : System.Drawing.SystemColors.Control); 96 | } 97 | 98 | private string AccessToken 99 | { 100 | get 101 | { 102 | return txtAccessToken.Text; 103 | } 104 | } 105 | 106 | private async void btnRefreshToken_Click(object sender, EventArgs e) 107 | { 108 | treeBuckets.Nodes.Clear(); 109 | 110 | BucketsApi bucketApi = new BucketsApi(); 111 | bucketApi.Configuration.AccessToken = AccessToken; 112 | 113 | // control GetBucket pagination 114 | string lastBucket = null; 115 | 116 | Buckets buckets = null; 117 | do 118 | { 119 | buckets = (await bucketApi.GetBucketsAsync(cmbRegion.Text, 100, lastBucket)).ToObject(); 120 | foreach (var bucket in buckets.Items) 121 | { 122 | TreeNode nodeBucket = new TreeNode(bucket.BucketKey); 123 | nodeBucket.Tag = bucket.BucketKey; 124 | treeBuckets.Nodes.Add(nodeBucket); 125 | lastBucket = bucket.BucketKey; // after the loop, this will contain the last bucketKey 126 | } 127 | } while (buckets.Items.Count > 0); 128 | 129 | // for each bucket, show the objects 130 | foreach (TreeNode n in treeBuckets.Nodes) 131 | if (n != null) // async? 132 | await ShowBucketObjects(n); 133 | } 134 | 135 | private async Task ShowBucketObjects(TreeNode nodeBucket) 136 | { 137 | nodeBucket.Nodes.Clear(); 138 | 139 | ObjectsApi objects = new ObjectsApi(); 140 | objects.Configuration.AccessToken = AccessToken; 141 | 142 | // show objects on the given TreeNode 143 | BucketObjects objectsList = (await objects.GetObjectsAsync((string)nodeBucket.Tag)).ToObject(); 144 | foreach (var objInfo in objectsList.Items) 145 | { 146 | TreeNode nodeObject = new TreeNode(objInfo.ObjectKey); 147 | nodeObject.Tag = ((string)objInfo.ObjectId).Base64Encode(); 148 | nodeBucket.Nodes.Add(nodeObject); 149 | } 150 | } 151 | 152 | private const int UPLOAD_CHUNK_SIZE = 2; // Mb 153 | 154 | private async void btnUpload_Click(object sender, EventArgs e) 155 | { 156 | if (treeBuckets.SelectedNode == null || treeBuckets.SelectedNode.Level != 0) 157 | { 158 | MessageBox.Show("Please select a bucket", "Bucket required", MessageBoxButtons.OK, MessageBoxIcon.Error); 159 | return; 160 | } 161 | string bucketKey = treeBuckets.SelectedNode.Text; 162 | 163 | // ask user to select file 164 | OpenFileDialog formSelectFile = new OpenFileDialog(); 165 | formSelectFile.Multiselect = false; 166 | if (formSelectFile.ShowDialog() != DialogResult.OK) return; 167 | string filePath = formSelectFile.FileName; 168 | string objectKey = Path.GetFileName(filePath); 169 | 170 | ObjectsApi objects = new ObjectsApi(); 171 | objects.Configuration.AccessToken = AccessToken; 172 | 173 | // get file size 174 | long fileSize = (new FileInfo(filePath)).Length; 175 | 176 | // show progress bar for upload 177 | progressBar.DisplayStyle = ProgressBarDisplayText.CustomText; 178 | progressBar.Show(); 179 | progressBar.Value = 0; 180 | progressBar.Minimum = 0; 181 | progressBar.CustomText = "Preparing to upload file..."; 182 | 183 | // decide if upload direct or resumable (by chunks) 184 | if (fileSize > UPLOAD_CHUNK_SIZE * 1024 * 1024) // upload in chunks 185 | { 186 | long chunkSize = 2 * 1024 * 1024; // 2 Mb 187 | long numberOfChunks = (long)Math.Round((double)(fileSize / chunkSize)) + 1; 188 | 189 | progressBar.Maximum = (int)numberOfChunks; 190 | 191 | long start = 0; 192 | chunkSize = (numberOfChunks > 1 ? chunkSize : fileSize); 193 | long end = chunkSize; 194 | string sessionId = Guid.NewGuid().ToString(); 195 | 196 | // upload one chunk at a time 197 | using (BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open))) 198 | { 199 | for (int chunkIndex = 0; chunkIndex < numberOfChunks; chunkIndex++) 200 | { 201 | string range = string.Format("bytes {0}-{1}/{2}", start, end, fileSize); 202 | 203 | long numberOfBytes = chunkSize + 1; 204 | byte[] fileBytes = new byte[numberOfBytes]; 205 | MemoryStream memoryStream = new MemoryStream(fileBytes); 206 | reader.BaseStream.Seek((int)start, SeekOrigin.Begin); 207 | int count = reader.Read(fileBytes, 0, (int)numberOfBytes); 208 | memoryStream.Write(fileBytes, 0, (int)numberOfBytes); 209 | memoryStream.Position = 0; 210 | 211 | dynamic chunkUploadResponse = await objects.UploadChunkAsync(bucketKey, objectKey, (int)numberOfBytes, range, sessionId, memoryStream); 212 | 213 | start = end + 1; 214 | chunkSize = ((start + chunkSize > fileSize) ? fileSize - start - 1 : chunkSize); 215 | end = start + chunkSize; 216 | 217 | progressBar.CustomText = string.Format("{0} Mb uploaded...", (chunkIndex * chunkSize) / 1024 / 1024); 218 | progressBar.Value = chunkIndex; 219 | } 220 | } 221 | } 222 | else // upload in a single call 223 | { 224 | using (StreamReader streamReader = new StreamReader(filePath)) 225 | { 226 | progressBar.Value = 50; // random... 227 | progressBar.Maximum = 100; 228 | dynamic uploadedObj = await objects.UploadObjectAsync(bucketKey, 229 | objectKey, (int)streamReader.BaseStream.Length, streamReader.BaseStream, 230 | "application/octet-stream"); 231 | } 232 | 233 | } 234 | 235 | progressBar.Hide(); 236 | await ShowBucketObjects(treeBuckets.SelectedNode); 237 | treeBuckets.SelectedNode.Expand(); 238 | } 239 | 240 | private void Form1_Load(object sender, EventArgs e) 241 | { 242 | // authenticate when starts 243 | btnAuthenticate_Click(null, null); 244 | } 245 | 246 | private void btnTranslate_Click(object sender, EventArgs e) 247 | { 248 | // show menu with translation options 249 | // ToDo: include other translation formats 250 | menuTranslate.Items.Clear(); 251 | menuTranslate.Items.Add("Viewer (SVF)", null, onClickTranslate); 252 | menuTranslate.Show(btnTranslate, new Point(0, btnTranslate.Height)); 253 | } 254 | 255 | private async void onClickTranslate(object sender, EventArgs e) 256 | { 257 | // for now, just one translation at a time 258 | if (_translationTimer.Enabled) return; 259 | 260 | // check level 1 of objects 261 | if (treeBuckets.SelectedNode == null || treeBuckets.SelectedNode.Level != 1) 262 | { 263 | MessageBox.Show("Please select an object", "Objects required", MessageBoxButtons.OK, MessageBoxIcon.Error); 264 | return; 265 | } 266 | string urn = (string)treeBuckets.SelectedNode.Tag; 267 | 268 | // prepare a SVF translation 269 | List outputs = new List() 270 | { 271 | new JobPayloadItem( 272 | JobPayloadItem.TypeEnum.Svf, 273 | new List() 274 | { 275 | JobPayloadItem.ViewsEnum._2d, 276 | JobPayloadItem.ViewsEnum._3d 277 | }) 278 | }; 279 | JobPayload job; 280 | //if (string.IsNullOrEmpty(objModel.rootFilename)) 281 | job = new JobPayload(new JobPayloadInput(urn), new JobPayloadOutput(outputs)); 282 | //else 283 | // job = new JobPayload(new JobPayloadInput(objModel.objectKey, true, objModel.rootFilename), new JobPayloadOutput(outputs)); 284 | 285 | // start progress bar for translation 286 | progressBar.Show(); 287 | progressBar.Value = 0; 288 | progressBar.Minimum = 0; 289 | progressBar.Maximum = 100; 290 | progressBar.CustomText = "Starting translation job..."; 291 | 292 | // start translation job 293 | DerivativesApi derivative = new DerivativesApi(); 294 | derivative.Configuration.AccessToken = AccessToken; 295 | dynamic jobPosted = await derivative.TranslateAsync(job, true); 296 | 297 | // start a monitor job to follow the translation 298 | _translationTimer.Tick += new EventHandler(isTranslationReady); 299 | _translationTimer.Tag = urn; 300 | _translationTimer.Interval = 5000; 301 | _translationTimer.Enabled = true; 302 | } 303 | 304 | private async void isTranslationReady(object sender, EventArgs e) 305 | { 306 | DerivativesApi derivative = new DerivativesApi(); 307 | derivative.Configuration.AccessToken = AccessToken; 308 | 309 | // get the translation manifest 310 | dynamic manifest = await derivative.GetManifestAsync((string)_translationTimer.Tag); 311 | int progress = (string.IsNullOrWhiteSpace(Regex.Match(manifest.progress, @"\d+").Value) ? 100 : Int32.Parse(Regex.Match(manifest.progress, @"\d+").Value)); 312 | 313 | // for better UX, show a small number of progress (instead zero) 314 | progressBar.Value = (progress == 0 ? 10 : progress); 315 | progressBar.CustomText = string.Format("Translation in progress: {0}", progress); 316 | Debug.WriteLine(progress); 317 | 318 | // if ready, hide everything 319 | if (progress >= 100) 320 | { 321 | progressBar.Hide(); 322 | _translationTimer.Enabled = false; 323 | } 324 | } 325 | 326 | private async void btnDeleteObject_Click(object sender, EventArgs e) 327 | { 328 | // treeBuckets level 1 are for Objects 329 | if (treeBuckets.SelectedNode == null || treeBuckets.SelectedNode.Level != 1) 330 | { 331 | MessageBox.Show("Please select an object", "Objects required", MessageBoxButtons.OK, MessageBoxIcon.Error); 332 | return; 333 | } 334 | 335 | if (MessageBox.Show("This objects will be permantly delete, confirm?", "Are you sure?", 336 | MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) 337 | return; 338 | 339 | // call API to delete object on the bucket 340 | ObjectsApi objects = new ObjectsApi(); 341 | objects.Configuration.AccessToken = AccessToken; 342 | await objects.DeleteObjectAsync((string)treeBuckets.SelectedNode.Parent.Tag, (string)treeBuckets.SelectedNode.Text); 343 | await ShowBucketObjects(treeBuckets.SelectedNode.Parent); 344 | } 345 | 346 | private void Form1_FormClosing(object sender, FormClosingEventArgs e) 347 | { 348 | // required by CefSharp Browser 349 | Cef.Shutdown(); 350 | } 351 | 352 | private void treeBuckets_AfterSelect(object sender, TreeViewEventArgs e) 353 | { 354 | if (treeBuckets.SelectedNode == null || treeBuckets.SelectedNode.Level != 1) return; 355 | 356 | // this basic HTML page to show the model passing URN & Access Token 357 | browser.Load(string.Format("file:///HTML/Viewer.html?URN={0}&Token={1}", treeBuckets.SelectedNode.Tag, AccessToken)); 358 | } 359 | 360 | private async void btnCreateBucket_Click(object sender, EventArgs e) 361 | { 362 | string bucketKey = string.Empty; 363 | if (Prompt.ShowDialog("Enter bucket name: ", "Create new bucket", txtClientId.Text.ToLower() + DateTime.Now.Ticks.ToString(), out bucketKey) == DialogResult.OK) 364 | { 365 | BucketsApi buckets = new BucketsApi(); 366 | buckets.Configuration.AccessToken = AccessToken; 367 | PostBucketsPayload bucketPayload = new PostBucketsPayload(bucketKey.ToLower(), null, PostBucketsPayload.PolicyKeyEnum.Transient); 368 | await buckets.CreateBucketAsync(bucketPayload, cmbRegion.Text); 369 | 370 | btnRefreshToken_Click(null, null); 371 | } 372 | } 373 | 374 | private void btnShowDevTools_Click(object sender, EventArgs e) 375 | { 376 | browser.ShowDevTools(); 377 | } 378 | 379 | private async void btnDownloadSVF_Click(object sender, EventArgs e) 380 | { 381 | // ensure the selected node is an object and get its URN 382 | if (treeBuckets.SelectedNode == null || treeBuckets.SelectedNode.Level != 1) 383 | { 384 | MessageBox.Show("Please select an object", "Objects required", MessageBoxButtons.OK, MessageBoxIcon.Error); 385 | return; 386 | } 387 | string urn = (string)treeBuckets.SelectedNode.Tag; 388 | 389 | // select a folder to download the files 390 | string folderPath = string.Empty; 391 | using (var fbd = new FolderBrowserDialog()) 392 | { 393 | if (fbd.ShowDialog() != DialogResult.OK || string.IsNullOrWhiteSpace(fbd.SelectedPath)) return; 394 | folderPath = fbd.SelectedPath; 395 | folderPath = Path.Combine(folderPath, treeBuckets.SelectedNode.Text); 396 | if (Directory.Exists(folderPath)) Directory.Delete(folderPath, true); 397 | Directory.CreateDirectory(folderPath); 398 | } 399 | 400 | // prepare the UI 401 | progressBar.Show(); 402 | progressBar.DisplayStyle = ProgressBarDisplayText.CustomText; 403 | progressBar.Value = 0; 404 | progressBar.CustomText = "Starting extraction..."; 405 | 406 | // get the list of resources to download 407 | List resourcesToDownload = await ForgeUtils.Derivatives.ExtractSVFAsync(urn, AccessToken); 408 | 409 | // update the UI 410 | progressBar.Minimum = 0; 411 | progressBar.Maximum = resourcesToDownload.Count; 412 | progressBar.Step = 1; 413 | 414 | IRestClient client = new RestClient("https://developer.api.autodesk.com/"); 415 | foreach (ForgeUtils.Derivatives.Resource resource in resourcesToDownload) 416 | { 417 | progressBar.PerformStep(); 418 | progressBar.CustomText = "Downloading " + resource.FileName; 419 | 420 | // prepare the GET to download the file 421 | RestRequest request = new RestRequest(resource.RemotePath, Method.GET); 422 | request.AddHeader("Authorization", "Bearer " + AccessToken); 423 | request.AddHeader("Accept-Encoding", "gzip, deflate"); 424 | IRestResponse response = await client.ExecuteTaskAsync(request); 425 | 426 | if (response.StatusCode != System.Net.HttpStatusCode.OK) 427 | { 428 | // something went wrong with this file... 429 | MessageBox.Show(string.Format("Error downloading {0}: {1}", 430 | resource.FileName, response.StatusCode.ToString())); 431 | 432 | // any other action? 433 | } 434 | else 435 | { 436 | // combine with selected local path 437 | string pathToSave = Path.Combine(folderPath, resource.LocalPath); 438 | // ensure local dir exists 439 | Directory.CreateDirectory(Path.GetDirectoryName(pathToSave)); 440 | // save file 441 | File.WriteAllBytes(pathToSave, response.RawBytes); 442 | } 443 | } 444 | 445 | progressBar.Hide(); 446 | } 447 | 448 | private void btnJavaScript_Click(object sender, EventArgs e) 449 | { 450 | Tools.JSEditor editor = new Tools.JSEditor(this.browser); 451 | editor.Show(); 452 | } 453 | } 454 | } 455 | -------------------------------------------------------------------------------- /bucket.manager/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /bucket.manager/HTML/Viewer.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 77 | -------------------------------------------------------------------------------- /bucket.manager/Program.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | using System; 20 | ///////////////////////////////////////////////////////////////////// 21 | // Copyright (c) Autodesk, Inc. All rights reserved 22 | // Written by Forge Partner Development 23 | // 24 | // Permission to use, copy, modify, and distribute this software in 25 | // object code form for any purpose and without fee is hereby granted, 26 | // provided that the above copyright notice appears in all copies and 27 | // that both that copyright notice and the limited warranty and 28 | // restricted rights notice below appear in all supporting 29 | // documentation. 30 | // 31 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 32 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 33 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 34 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 35 | // UNINTERRUPTED OR ERROR FREE. 36 | ///////////////////////////////////////////////////////////////////// 37 | 38 | using System.Windows.Forms; 39 | 40 | namespace bucket.manager 41 | { 42 | static class Program 43 | { 44 | /// 45 | /// The main entry point for the application. 46 | /// 47 | [STAThread] 48 | static void Main() 49 | { 50 | Application.EnableVisualStyles(); 51 | Application.SetCompatibleTextRenderingDefault(false); 52 | Application.Run(new Form1()); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /bucket.manager/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | using System.Reflection; 20 | using System.Runtime.CompilerServices; 21 | using System.Runtime.InteropServices; 22 | 23 | // General Information about an assembly is controlled through the following 24 | // set of attributes. Change these attribute values to modify the information 25 | // associated with an assembly. 26 | [assembly: AssemblyTitle("bucket.manager")] 27 | [assembly: AssemblyDescription("")] 28 | [assembly: AssemblyConfiguration("")] 29 | [assembly: AssemblyCompany("")] 30 | [assembly: AssemblyProduct("bucket.manager")] 31 | [assembly: AssemblyCopyright("Copyright Autodesk © 2017")] 32 | [assembly: AssemblyTrademark("")] 33 | [assembly: AssemblyCulture("")] 34 | 35 | // Setting ComVisible to false makes the types in this assembly not visible 36 | // to COM components. If you need to access a type in this assembly from 37 | // COM, set the ComVisible attribute to true on that type. 38 | [assembly: ComVisible(false)] 39 | 40 | // The following GUID is for the ID of the typelib if this project is exposed to COM 41 | [assembly: Guid("09a7d975-d2f9-4ff4-8536-815dcf98ca97")] 42 | 43 | // Version information for an assembly consists of the following four values: 44 | // 45 | // Major Version 46 | // Minor Version 47 | // Build Number 48 | // Revision 49 | // 50 | // You can specify all the values or you can default the Build and Revision Numbers 51 | // by using the '*' as shown below: 52 | // [assembly: AssemblyVersion("1.0.*")] 53 | [assembly: AssemblyVersion("1.0.0.0")] 54 | [assembly: AssemblyFileVersion("1.0.0.0")] 55 | -------------------------------------------------------------------------------- /bucket.manager/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace bucket.manager.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("bucket.manager.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /bucket.manager/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /bucket.manager/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace bucket.manager.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bucket.manager/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bucket.manager/Tools/JSEditor.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace bucket.manager.Tools 2 | { 3 | partial class JSEditor 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.TextPanel = new System.Windows.Forms.Panel(); 32 | this.FileName = new System.Windows.Forms.Label(); 33 | this.menuStrip1 = new System.Windows.Forms.MenuStrip(); 34 | this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 40 | this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); 41 | this.selectLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 42 | this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.clearSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 44 | this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); 45 | this.indentSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 46 | this.outdentSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 47 | this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); 48 | this.uppercaseSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 49 | this.lowercaseSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 50 | this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 | this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 52 | this.findDialogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 53 | this.findAndReplaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 54 | this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); 55 | this.goToLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 56 | this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 57 | this.wordWrapItem = new System.Windows.Forms.ToolStripMenuItem(); 58 | this.indentGuidesItem = new System.Windows.Forms.ToolStripMenuItem(); 59 | this.hiddenCharactersItem = new System.Windows.Forms.ToolStripMenuItem(); 60 | this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); 61 | this.zoomInToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 62 | this.zoomOutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 63 | this.zoom100ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 64 | this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); 65 | this.collapseAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 66 | this.expandAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 67 | this.PanelSearch = new System.Windows.Forms.Panel(); 68 | this.BtnNextSearch = new System.Windows.Forms.Button(); 69 | this.BtnPrevSearch = new System.Windows.Forms.Button(); 70 | this.BtnCloseSearch = new System.Windows.Forms.Button(); 71 | this.TxtSearch = new System.Windows.Forms.TextBox(); 72 | this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 73 | this.txtConsole = new System.Windows.Forms.TextBox(); 74 | this.brnRun = new System.Windows.Forms.Button(); 75 | this.menuStrip1.SuspendLayout(); 76 | this.PanelSearch.SuspendLayout(); 77 | this.SuspendLayout(); 78 | // 79 | // TextPanel 80 | // 81 | this.TextPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 82 | | System.Windows.Forms.AnchorStyles.Left) 83 | | System.Windows.Forms.AnchorStyles.Right))); 84 | this.TextPanel.Location = new System.Drawing.Point(8, 95); 85 | this.TextPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 86 | this.TextPanel.Name = "TextPanel"; 87 | this.TextPanel.Size = new System.Drawing.Size(744, 478); 88 | this.TextPanel.TabIndex = 0; 89 | // 90 | // FileName 91 | // 92 | this.FileName.AutoSize = true; 93 | this.FileName.Font = new System.Drawing.Font("Segoe UI Light", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 94 | this.FileName.ForeColor = System.Drawing.SystemColors.HotTrack; 95 | this.FileName.Location = new System.Drawing.Point(12, 45); 96 | this.FileName.Name = "FileName"; 97 | this.FileName.Size = new System.Drawing.Size(52, 30); 98 | this.FileName.TabIndex = 1; 99 | this.FileName.Text = "Title"; 100 | // 101 | // menuStrip1 102 | // 103 | this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); 104 | this.menuStrip1.Font = new System.Drawing.Font("Segoe UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 105 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 106 | this.fileToolStripMenuItem, 107 | this.editToolStripMenuItem, 108 | this.searchToolStripMenuItem, 109 | this.viewToolStripMenuItem}); 110 | this.menuStrip1.Location = new System.Drawing.Point(0, 0); 111 | this.menuStrip1.Name = "menuStrip1"; 112 | this.menuStrip1.Size = new System.Drawing.Size(769, 27); 113 | this.menuStrip1.TabIndex = 2; 114 | this.menuStrip1.Text = "menuStrip1"; 115 | // 116 | // fileToolStripMenuItem 117 | // 118 | this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 119 | this.openToolStripMenuItem}); 120 | this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; 121 | this.fileToolStripMenuItem.Size = new System.Drawing.Size(41, 23); 122 | this.fileToolStripMenuItem.Text = "File"; 123 | // 124 | // openToolStripMenuItem 125 | // 126 | this.openToolStripMenuItem.Name = "openToolStripMenuItem"; 127 | this.openToolStripMenuItem.Size = new System.Drawing.Size(121, 24); 128 | this.openToolStripMenuItem.Text = "Open..."; 129 | this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); 130 | // 131 | // editToolStripMenuItem 132 | // 133 | this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 134 | this.cutToolStripMenuItem, 135 | this.copyToolStripMenuItem, 136 | this.pasteToolStripMenuItem, 137 | this.toolStripSeparator1, 138 | this.selectLineToolStripMenuItem, 139 | this.selectAllToolStripMenuItem, 140 | this.clearSelectionToolStripMenuItem, 141 | this.toolStripSeparator2, 142 | this.indentSelectionToolStripMenuItem, 143 | this.outdentSelectionToolStripMenuItem, 144 | this.toolStripSeparator3, 145 | this.uppercaseSelectionToolStripMenuItem, 146 | this.lowercaseSelectionToolStripMenuItem}); 147 | this.editToolStripMenuItem.Name = "editToolStripMenuItem"; 148 | this.editToolStripMenuItem.Size = new System.Drawing.Size(44, 23); 149 | this.editToolStripMenuItem.Text = "Edit"; 150 | // 151 | // cutToolStripMenuItem 152 | // 153 | this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; 154 | this.cutToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+X"; 155 | this.cutToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 156 | this.cutToolStripMenuItem.Text = "Cut"; 157 | this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); 158 | // 159 | // copyToolStripMenuItem 160 | // 161 | this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; 162 | this.copyToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+C"; 163 | this.copyToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 164 | this.copyToolStripMenuItem.Text = "Copy"; 165 | this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); 166 | // 167 | // pasteToolStripMenuItem 168 | // 169 | this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; 170 | this.pasteToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+V"; 171 | this.pasteToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 172 | this.pasteToolStripMenuItem.Text = "Paste"; 173 | this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click); 174 | // 175 | // toolStripSeparator1 176 | // 177 | this.toolStripSeparator1.Name = "toolStripSeparator1"; 178 | this.toolStripSeparator1.Size = new System.Drawing.Size(193, 6); 179 | // 180 | // selectLineToolStripMenuItem 181 | // 182 | this.selectLineToolStripMenuItem.Name = "selectLineToolStripMenuItem"; 183 | this.selectLineToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 184 | this.selectLineToolStripMenuItem.Text = "Select Line"; 185 | this.selectLineToolStripMenuItem.Click += new System.EventHandler(this.selectLineToolStripMenuItem_Click); 186 | // 187 | // selectAllToolStripMenuItem 188 | // 189 | this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; 190 | this.selectAllToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+A"; 191 | this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 192 | this.selectAllToolStripMenuItem.Text = "Select All"; 193 | this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); 194 | // 195 | // clearSelectionToolStripMenuItem 196 | // 197 | this.clearSelectionToolStripMenuItem.Name = "clearSelectionToolStripMenuItem"; 198 | this.clearSelectionToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 199 | this.clearSelectionToolStripMenuItem.Text = "Clear Selection"; 200 | this.clearSelectionToolStripMenuItem.Click += new System.EventHandler(this.clearSelectionToolStripMenuItem_Click); 201 | // 202 | // toolStripSeparator2 203 | // 204 | this.toolStripSeparator2.Name = "toolStripSeparator2"; 205 | this.toolStripSeparator2.Size = new System.Drawing.Size(193, 6); 206 | // 207 | // indentSelectionToolStripMenuItem 208 | // 209 | this.indentSelectionToolStripMenuItem.Name = "indentSelectionToolStripMenuItem"; 210 | this.indentSelectionToolStripMenuItem.ShortcutKeyDisplayString = "Tab"; 211 | this.indentSelectionToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 212 | this.indentSelectionToolStripMenuItem.Text = "Indent"; 213 | this.indentSelectionToolStripMenuItem.Click += new System.EventHandler(this.indentSelectionToolStripMenuItem_Click); 214 | // 215 | // outdentSelectionToolStripMenuItem 216 | // 217 | this.outdentSelectionToolStripMenuItem.Name = "outdentSelectionToolStripMenuItem"; 218 | this.outdentSelectionToolStripMenuItem.ShortcutKeyDisplayString = "Shift+Tab"; 219 | this.outdentSelectionToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 220 | this.outdentSelectionToolStripMenuItem.Text = "Outdent"; 221 | this.outdentSelectionToolStripMenuItem.Click += new System.EventHandler(this.outdentSelectionToolStripMenuItem_Click); 222 | // 223 | // toolStripSeparator3 224 | // 225 | this.toolStripSeparator3.Name = "toolStripSeparator3"; 226 | this.toolStripSeparator3.Size = new System.Drawing.Size(193, 6); 227 | // 228 | // uppercaseSelectionToolStripMenuItem 229 | // 230 | this.uppercaseSelectionToolStripMenuItem.Name = "uppercaseSelectionToolStripMenuItem"; 231 | this.uppercaseSelectionToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+U"; 232 | this.uppercaseSelectionToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 233 | this.uppercaseSelectionToolStripMenuItem.Text = "Uppercase"; 234 | this.uppercaseSelectionToolStripMenuItem.Click += new System.EventHandler(this.uppercaseSelectionToolStripMenuItem_Click); 235 | // 236 | // lowercaseSelectionToolStripMenuItem 237 | // 238 | this.lowercaseSelectionToolStripMenuItem.Name = "lowercaseSelectionToolStripMenuItem"; 239 | this.lowercaseSelectionToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+L"; 240 | this.lowercaseSelectionToolStripMenuItem.Size = new System.Drawing.Size(196, 24); 241 | this.lowercaseSelectionToolStripMenuItem.Text = "Lowercase"; 242 | this.lowercaseSelectionToolStripMenuItem.Click += new System.EventHandler(this.lowercaseSelectionToolStripMenuItem_Click); 243 | // 244 | // searchToolStripMenuItem 245 | // 246 | this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 247 | this.findToolStripMenuItem, 248 | this.findDialogToolStripMenuItem, 249 | this.findAndReplaceToolStripMenuItem, 250 | this.toolStripSeparator7, 251 | this.goToLineToolStripMenuItem}); 252 | this.searchToolStripMenuItem.Name = "searchToolStripMenuItem"; 253 | this.searchToolStripMenuItem.Size = new System.Drawing.Size(61, 23); 254 | this.searchToolStripMenuItem.Text = "Search"; 255 | // 256 | // findToolStripMenuItem 257 | // 258 | this.findToolStripMenuItem.Name = "findToolStripMenuItem"; 259 | this.findToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+F"; 260 | this.findToolStripMenuItem.Size = new System.Drawing.Size(241, 24); 261 | this.findToolStripMenuItem.Text = "Quick Find..."; 262 | this.findToolStripMenuItem.Click += new System.EventHandler(this.findToolStripMenuItem_Click); 263 | // 264 | // findDialogToolStripMenuItem 265 | // 266 | this.findDialogToolStripMenuItem.Name = "findDialogToolStripMenuItem"; 267 | this.findDialogToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Alt+F"; 268 | this.findDialogToolStripMenuItem.Size = new System.Drawing.Size(241, 24); 269 | this.findDialogToolStripMenuItem.Text = "Find..."; 270 | this.findDialogToolStripMenuItem.Click += new System.EventHandler(this.findDialogToolStripMenuItem_Click); 271 | // 272 | // findAndReplaceToolStripMenuItem 273 | // 274 | this.findAndReplaceToolStripMenuItem.Name = "findAndReplaceToolStripMenuItem"; 275 | this.findAndReplaceToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+H"; 276 | this.findAndReplaceToolStripMenuItem.Size = new System.Drawing.Size(241, 24); 277 | this.findAndReplaceToolStripMenuItem.Text = "Find and Replace..."; 278 | this.findAndReplaceToolStripMenuItem.Click += new System.EventHandler(this.findAndReplaceToolStripMenuItem_Click); 279 | // 280 | // toolStripSeparator7 281 | // 282 | this.toolStripSeparator7.Name = "toolStripSeparator7"; 283 | this.toolStripSeparator7.Size = new System.Drawing.Size(238, 6); 284 | // 285 | // goToLineToolStripMenuItem 286 | // 287 | this.goToLineToolStripMenuItem.Name = "goToLineToolStripMenuItem"; 288 | this.goToLineToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+G"; 289 | this.goToLineToolStripMenuItem.Size = new System.Drawing.Size(241, 24); 290 | this.goToLineToolStripMenuItem.Text = "Go To Line..."; 291 | // 292 | // viewToolStripMenuItem 293 | // 294 | this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 295 | this.wordWrapItem, 296 | this.indentGuidesItem, 297 | this.hiddenCharactersItem, 298 | this.toolStripSeparator4, 299 | this.zoomInToolStripMenuItem, 300 | this.zoomOutToolStripMenuItem, 301 | this.zoom100ToolStripMenuItem, 302 | this.toolStripSeparator5, 303 | this.collapseAllToolStripMenuItem, 304 | this.expandAllToolStripMenuItem}); 305 | this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; 306 | this.viewToolStripMenuItem.Size = new System.Drawing.Size(50, 23); 307 | this.viewToolStripMenuItem.Text = "View"; 308 | // 309 | // wordWrapItem 310 | // 311 | this.wordWrapItem.Name = "wordWrapItem"; 312 | this.wordWrapItem.Size = new System.Drawing.Size(221, 24); 313 | this.wordWrapItem.Text = "Word Wrap"; 314 | this.wordWrapItem.Click += new System.EventHandler(this.wordWrapToolStripMenuItem1_Click); 315 | // 316 | // indentGuidesItem 317 | // 318 | this.indentGuidesItem.Checked = true; 319 | this.indentGuidesItem.CheckState = System.Windows.Forms.CheckState.Checked; 320 | this.indentGuidesItem.Name = "indentGuidesItem"; 321 | this.indentGuidesItem.Size = new System.Drawing.Size(221, 24); 322 | this.indentGuidesItem.Text = "Show Indent Guides"; 323 | this.indentGuidesItem.Click += new System.EventHandler(this.indentGuidesToolStripMenuItem_Click); 324 | // 325 | // hiddenCharactersItem 326 | // 327 | this.hiddenCharactersItem.Name = "hiddenCharactersItem"; 328 | this.hiddenCharactersItem.Size = new System.Drawing.Size(221, 24); 329 | this.hiddenCharactersItem.Text = "Show Whitespace"; 330 | this.hiddenCharactersItem.Click += new System.EventHandler(this.hiddenCharactersToolStripMenuItem_Click); 331 | // 332 | // toolStripSeparator4 333 | // 334 | this.toolStripSeparator4.Name = "toolStripSeparator4"; 335 | this.toolStripSeparator4.Size = new System.Drawing.Size(218, 6); 336 | // 337 | // zoomInToolStripMenuItem 338 | // 339 | this.zoomInToolStripMenuItem.Name = "zoomInToolStripMenuItem"; 340 | this.zoomInToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Plus"; 341 | this.zoomInToolStripMenuItem.Size = new System.Drawing.Size(221, 24); 342 | this.zoomInToolStripMenuItem.Text = "Zoom In"; 343 | this.zoomInToolStripMenuItem.Click += new System.EventHandler(this.zoomInToolStripMenuItem_Click); 344 | // 345 | // zoomOutToolStripMenuItem 346 | // 347 | this.zoomOutToolStripMenuItem.Name = "zoomOutToolStripMenuItem"; 348 | this.zoomOutToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+Minus"; 349 | this.zoomOutToolStripMenuItem.Size = new System.Drawing.Size(221, 24); 350 | this.zoomOutToolStripMenuItem.Text = "Zoom Out"; 351 | this.zoomOutToolStripMenuItem.Click += new System.EventHandler(this.zoomOutToolStripMenuItem_Click); 352 | // 353 | // zoom100ToolStripMenuItem 354 | // 355 | this.zoom100ToolStripMenuItem.Name = "zoom100ToolStripMenuItem"; 356 | this.zoom100ToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+0"; 357 | this.zoom100ToolStripMenuItem.Size = new System.Drawing.Size(221, 24); 358 | this.zoom100ToolStripMenuItem.Text = "Zoom 100%"; 359 | this.zoom100ToolStripMenuItem.Click += new System.EventHandler(this.zoom100ToolStripMenuItem_Click); 360 | // 361 | // toolStripSeparator5 362 | // 363 | this.toolStripSeparator5.Name = "toolStripSeparator5"; 364 | this.toolStripSeparator5.Size = new System.Drawing.Size(218, 6); 365 | // 366 | // collapseAllToolStripMenuItem 367 | // 368 | this.collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; 369 | this.collapseAllToolStripMenuItem.Size = new System.Drawing.Size(221, 24); 370 | this.collapseAllToolStripMenuItem.Text = "Collapse All"; 371 | this.collapseAllToolStripMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click); 372 | // 373 | // expandAllToolStripMenuItem 374 | // 375 | this.expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; 376 | this.expandAllToolStripMenuItem.Size = new System.Drawing.Size(221, 24); 377 | this.expandAllToolStripMenuItem.Text = "Expand All"; 378 | this.expandAllToolStripMenuItem.Click += new System.EventHandler(this.expandAllToolStripMenuItem_Click); 379 | // 380 | // PanelSearch 381 | // 382 | this.PanelSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 383 | this.PanelSearch.BackColor = System.Drawing.Color.White; 384 | this.PanelSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 385 | this.PanelSearch.Controls.Add(this.BtnNextSearch); 386 | this.PanelSearch.Controls.Add(this.BtnPrevSearch); 387 | this.PanelSearch.Controls.Add(this.BtnCloseSearch); 388 | this.PanelSearch.Controls.Add(this.TxtSearch); 389 | this.PanelSearch.Location = new System.Drawing.Point(462, 93); 390 | this.PanelSearch.Name = "PanelSearch"; 391 | this.PanelSearch.Size = new System.Drawing.Size(292, 40); 392 | this.PanelSearch.TabIndex = 10; 393 | this.PanelSearch.Visible = false; 394 | // 395 | // BtnNextSearch 396 | // 397 | this.BtnNextSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 398 | this.BtnNextSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 399 | this.BtnNextSearch.ForeColor = System.Drawing.Color.White; 400 | this.BtnNextSearch.Location = new System.Drawing.Point(233, 4); 401 | this.BtnNextSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 402 | this.BtnNextSearch.Name = "BtnNextSearch"; 403 | this.BtnNextSearch.Size = new System.Drawing.Size(25, 30); 404 | this.BtnNextSearch.TabIndex = 9; 405 | this.BtnNextSearch.Tag = "Find next (Enter)"; 406 | this.BtnNextSearch.UseVisualStyleBackColor = true; 407 | this.BtnNextSearch.Click += new System.EventHandler(this.BtnNextSearch_Click); 408 | // 409 | // BtnPrevSearch 410 | // 411 | this.BtnPrevSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 412 | this.BtnPrevSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 413 | this.BtnPrevSearch.ForeColor = System.Drawing.Color.White; 414 | this.BtnPrevSearch.Location = new System.Drawing.Point(205, 4); 415 | this.BtnPrevSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 416 | this.BtnPrevSearch.Name = "BtnPrevSearch"; 417 | this.BtnPrevSearch.Size = new System.Drawing.Size(25, 30); 418 | this.BtnPrevSearch.TabIndex = 8; 419 | this.BtnPrevSearch.Tag = "Find previous (Shift+Enter)"; 420 | this.BtnPrevSearch.UseVisualStyleBackColor = true; 421 | this.BtnPrevSearch.Click += new System.EventHandler(this.BtnPrevSearch_Click); 422 | // 423 | // BtnCloseSearch 424 | // 425 | this.BtnCloseSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 426 | this.BtnCloseSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 427 | this.BtnCloseSearch.ForeColor = System.Drawing.Color.White; 428 | this.BtnCloseSearch.Location = new System.Drawing.Point(261, 4); 429 | this.BtnCloseSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 430 | this.BtnCloseSearch.Name = "BtnCloseSearch"; 431 | this.BtnCloseSearch.Size = new System.Drawing.Size(25, 30); 432 | this.BtnCloseSearch.TabIndex = 7; 433 | this.BtnCloseSearch.Tag = "Close (Esc)"; 434 | this.BtnCloseSearch.UseVisualStyleBackColor = true; 435 | this.BtnCloseSearch.Click += new System.EventHandler(this.BtnClearSearch_Click); 436 | // 437 | // TxtSearch 438 | // 439 | this.TxtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 440 | | System.Windows.Forms.AnchorStyles.Right))); 441 | this.TxtSearch.BorderStyle = System.Windows.Forms.BorderStyle.None; 442 | this.TxtSearch.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 443 | this.TxtSearch.Location = new System.Drawing.Point(10, 6); 444 | this.TxtSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 445 | this.TxtSearch.Name = "TxtSearch"; 446 | this.TxtSearch.Size = new System.Drawing.Size(189, 25); 447 | this.TxtSearch.TabIndex = 6; 448 | this.TxtSearch.TextChanged += new System.EventHandler(this.TxtSearch_TextChanged); 449 | this.TxtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtSearch_KeyDown); 450 | // 451 | // openFileDialog 452 | // 453 | this.openFileDialog.DefaultExt = "txt"; 454 | this.openFileDialog.FileName = "New File"; 455 | this.openFileDialog.Filter = "All files|*.*"; 456 | // 457 | // txtConsole 458 | // 459 | this.txtConsole.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 460 | | System.Windows.Forms.AnchorStyles.Right))); 461 | this.txtConsole.Location = new System.Drawing.Point(70, 581); 462 | this.txtConsole.Multiline = true; 463 | this.txtConsole.Name = "txtConsole"; 464 | this.txtConsole.Size = new System.Drawing.Size(682, 35); 465 | this.txtConsole.TabIndex = 11; 466 | // 467 | // brnRun 468 | // 469 | this.brnRun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 470 | this.brnRun.Location = new System.Drawing.Point(8, 581); 471 | this.brnRun.Name = "brnRun"; 472 | this.brnRun.Size = new System.Drawing.Size(56, 35); 473 | this.brnRun.TabIndex = 12; 474 | this.brnRun.Text = "Run!"; 475 | this.brnRun.UseVisualStyleBackColor = true; 476 | this.brnRun.Click += new System.EventHandler(this.brnRun_Click); 477 | // 478 | // JSEditor 479 | // 480 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); 481 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 482 | this.BackColor = System.Drawing.Color.White; 483 | this.ClientSize = new System.Drawing.Size(769, 628); 484 | this.Controls.Add(this.brnRun); 485 | this.Controls.Add(this.txtConsole); 486 | this.Controls.Add(this.PanelSearch); 487 | this.Controls.Add(this.FileName); 488 | this.Controls.Add(this.TextPanel); 489 | this.Controls.Add(this.menuStrip1); 490 | this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 491 | this.MainMenuStrip = this.menuStrip1; 492 | this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); 493 | this.Name = "JSEditor"; 494 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 495 | this.Text = "JavaScript for Viewer"; 496 | this.Load += new System.EventHandler(this.MainForm_Load); 497 | this.menuStrip1.ResumeLayout(false); 498 | this.menuStrip1.PerformLayout(); 499 | this.PanelSearch.ResumeLayout(false); 500 | this.PanelSearch.PerformLayout(); 501 | this.ResumeLayout(false); 502 | this.PerformLayout(); 503 | 504 | } 505 | 506 | #endregion 507 | 508 | private System.Windows.Forms.Panel TextPanel; 509 | private System.Windows.Forms.Label FileName; 510 | private System.Windows.Forms.MenuStrip menuStrip1; 511 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; 512 | private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; 513 | private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; 514 | private System.Windows.Forms.ToolStripMenuItem wordWrapItem; 515 | private System.Windows.Forms.ToolStripMenuItem hiddenCharactersItem; 516 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; 517 | private System.Windows.Forms.ToolStripMenuItem zoomInToolStripMenuItem; 518 | private System.Windows.Forms.ToolStripMenuItem zoomOutToolStripMenuItem; 519 | private System.Windows.Forms.ToolStripMenuItem zoom100ToolStripMenuItem; 520 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; 521 | private System.Windows.Forms.ToolStripMenuItem collapseAllToolStripMenuItem; 522 | private System.Windows.Forms.ToolStripMenuItem expandAllToolStripMenuItem; 523 | private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; 524 | private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem; 525 | private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; 526 | private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; 527 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; 528 | private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; 529 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; 530 | private System.Windows.Forms.ToolStripMenuItem indentSelectionToolStripMenuItem; 531 | private System.Windows.Forms.ToolStripMenuItem outdentSelectionToolStripMenuItem; 532 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; 533 | private System.Windows.Forms.ToolStripMenuItem uppercaseSelectionToolStripMenuItem; 534 | private System.Windows.Forms.ToolStripMenuItem lowercaseSelectionToolStripMenuItem; 535 | private System.Windows.Forms.Panel PanelSearch; 536 | private System.Windows.Forms.Button BtnNextSearch; 537 | private System.Windows.Forms.Button BtnPrevSearch; 538 | private System.Windows.Forms.Button BtnCloseSearch; 539 | private System.Windows.Forms.TextBox TxtSearch; 540 | private System.Windows.Forms.OpenFileDialog openFileDialog; 541 | private System.Windows.Forms.ToolStripMenuItem selectLineToolStripMenuItem; 542 | private System.Windows.Forms.ToolStripMenuItem clearSelectionToolStripMenuItem; 543 | private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem; 544 | private System.Windows.Forms.ToolStripMenuItem goToLineToolStripMenuItem; 545 | private System.Windows.Forms.ToolStripMenuItem findToolStripMenuItem; 546 | private System.Windows.Forms.ToolStripMenuItem findAndReplaceToolStripMenuItem; 547 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; 548 | private System.Windows.Forms.ToolStripMenuItem findDialogToolStripMenuItem; 549 | private System.Windows.Forms.ToolStripMenuItem indentGuidesItem; 550 | private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; 551 | private System.Windows.Forms.TextBox txtConsole; 552 | private System.Windows.Forms.Button brnRun; 553 | } 554 | } -------------------------------------------------------------------------------- /bucket.manager/Tools/JSEditor.cs: -------------------------------------------------------------------------------- 1 | using CefSharp; 2 | using CefSharp.WinForms; 3 | using ScintillaNET; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.ComponentModel; 7 | using System.Data; 8 | using System.Drawing; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using System.Windows.Forms; 14 | 15 | namespace bucket.manager.Tools 16 | { 17 | public partial class JSEditor : Form 18 | { 19 | ChromiumWebBrowser _browser; 20 | 21 | public JSEditor(ChromiumWebBrowser browser) 22 | { 23 | _browser = browser; 24 | _browser.ConsoleMessage += Browser_ConsoleMessage; 25 | InitializeComponent(); 26 | } 27 | 28 | private void Browser_ConsoleMessage(object sender, ConsoleMessageEventArgs e) 29 | { 30 | SetText(e.Message); 31 | } 32 | 33 | // https://stackoverflow.com/a/10775421 34 | delegate void SetTextCallback(string text); 35 | private void SetText(string text) 36 | { 37 | // InvokeRequired required compares the thread ID of the 38 | // calling thread to the thread ID of the creating thread. 39 | // If these threads are different, it returns true. 40 | if (this.txtConsole.InvokeRequired) 41 | { 42 | SetTextCallback d = new SetTextCallback(SetText); 43 | this.Invoke(d, new object[] { text }); 44 | } 45 | else 46 | { 47 | this.txtConsole.Text = text; 48 | } 49 | } 50 | 51 | // https://github.com/cefsharp/CefSharp/issues/983 52 | public async Task EvaluateScript(string script, object defaultValue, TimeSpan timeout) 53 | { 54 | object result = defaultValue; 55 | if (_browser.IsBrowserInitialized && !_browser.IsDisposed && !_browser.Disposing) 56 | { 57 | try 58 | { 59 | var task = _browser.EvaluateScriptAsync(script, timeout); 60 | await task.ContinueWith(res => { 61 | if (!res.IsFaulted && !res.IsCanceled) 62 | { 63 | var response = res.Result; 64 | result = response.Success ? (response.Result ?? "null") : response.Message; 65 | } 66 | }).ConfigureAwait(false); // <-- This makes the task to synchronize on a different context 67 | } 68 | catch (Exception e) 69 | { 70 | Console.WriteLine(e.InnerException.Message); 71 | } 72 | } 73 | return result; 74 | } 75 | 76 | private void brnRun_Click(object sender, EventArgs e) 77 | { 78 | RunJavaScript(); 79 | } 80 | 81 | private void RunJavaScript() 82 | { 83 | object result = EvaluateScript(TextArea.Text, 0, TimeSpan.FromSeconds(1)).GetAwaiter().GetResult(); 84 | SetText(result.ToString()); 85 | } 86 | 87 | // ******* 88 | // Sample code from https://github.com/robinrodricks/ScintillaNET.Demo 89 | // ******* 90 | ScintillaNET.Scintilla TextArea; 91 | 92 | private void MainForm_Load(object sender, EventArgs e) 93 | { 94 | 95 | // CREATE CONTROL 96 | TextArea = new ScintillaNET.Scintilla(); 97 | TextPanel.Controls.Add(TextArea); 98 | 99 | // BASIC CONFIG 100 | TextArea.Dock = System.Windows.Forms.DockStyle.Fill; 101 | TextArea.TextChanged += (this.OnTextChanged); 102 | 103 | // INITIAL VIEW CONFIG 104 | TextArea.WrapMode = WrapMode.None; 105 | TextArea.IndentationGuides = IndentView.LookBoth; 106 | 107 | // STYLING 108 | InitColors(); 109 | InitSyntaxColoring(); 110 | 111 | // NUMBER MARGIN 112 | InitNumberMargin(); 113 | 114 | // BOOKMARK MARGIN 115 | InitBookmarkMargin(); 116 | 117 | // CODE FOLDING MARGIN 118 | InitCodeFolding(); 119 | 120 | // DRAG DROP 121 | InitDragDropFile(); 122 | 123 | // INIT HOTKEYS 124 | InitHotkeys(); 125 | 126 | } 127 | 128 | private void InitColors() 129 | { 130 | 131 | TextArea.SetSelectionBackColor(true, IntToColor(0x114D9C)); 132 | 133 | } 134 | 135 | private void InitHotkeys() 136 | { 137 | 138 | // register the hotkeys with the form 139 | HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true); 140 | HotKeyManager.AddHotKey(this, OpenFindDialog, Keys.F, true, false, true); 141 | HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true); 142 | HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.H, true); 143 | HotKeyManager.AddHotKey(this, Uppercase, Keys.U, true); 144 | HotKeyManager.AddHotKey(this, Lowercase, Keys.L, true); 145 | HotKeyManager.AddHotKey(this, ZoomIn, Keys.Oemplus, true); 146 | HotKeyManager.AddHotKey(this, ZoomOut, Keys.OemMinus, true); 147 | HotKeyManager.AddHotKey(this, ZoomDefault, Keys.D0, true); 148 | HotKeyManager.AddHotKey(this, CloseSearch, Keys.Escape); 149 | HotKeyManager.AddHotKey(this, RunJavaScript, Keys.R, true); 150 | 151 | // remove conflicting hotkeys from scintilla 152 | TextArea.ClearCmdKey(Keys.Control | Keys.F); 153 | TextArea.ClearCmdKey(Keys.Control | Keys.R); 154 | TextArea.ClearCmdKey(Keys.Control | Keys.H); 155 | TextArea.ClearCmdKey(Keys.Control | Keys.L); 156 | TextArea.ClearCmdKey(Keys.Control | Keys.U); 157 | TextArea.ClearCmdKey(Keys.Control | Keys.R); 158 | 159 | } 160 | 161 | private void InitSyntaxColoring() 162 | { 163 | 164 | // Configure the default style 165 | TextArea.StyleResetDefault(); 166 | TextArea.Styles[Style.Default].Font = "Consolas"; 167 | TextArea.Styles[Style.Default].Size = 10; 168 | TextArea.Styles[Style.Default].BackColor = IntToColor(0x212121); 169 | TextArea.Styles[Style.Default].ForeColor = IntToColor(0xFFFFFF); 170 | TextArea.StyleClearAll(); 171 | 172 | // Configure the CPP (C#) lexer styles 173 | TextArea.Styles[Style.Cpp.Identifier].ForeColor = IntToColor(0xD0DAE2); 174 | TextArea.Styles[Style.Cpp.Comment].ForeColor = IntToColor(0xBD758B); 175 | TextArea.Styles[Style.Cpp.CommentLine].ForeColor = IntToColor(0x40BF57); 176 | TextArea.Styles[Style.Cpp.CommentDoc].ForeColor = IntToColor(0x2FAE35); 177 | TextArea.Styles[Style.Cpp.Number].ForeColor = IntToColor(0xFFFF00); 178 | TextArea.Styles[Style.Cpp.String].ForeColor = IntToColor(0xFFFF00); 179 | TextArea.Styles[Style.Cpp.Character].ForeColor = IntToColor(0xE95454); 180 | TextArea.Styles[Style.Cpp.Preprocessor].ForeColor = IntToColor(0x8AAFEE); 181 | TextArea.Styles[Style.Cpp.Operator].ForeColor = IntToColor(0xE0E0E0); 182 | TextArea.Styles[Style.Cpp.Regex].ForeColor = IntToColor(0xff00ff); 183 | TextArea.Styles[Style.Cpp.CommentLineDoc].ForeColor = IntToColor(0x77A7DB); 184 | TextArea.Styles[Style.Cpp.Word].ForeColor = IntToColor(0x48A8EE); 185 | TextArea.Styles[Style.Cpp.Word2].ForeColor = IntToColor(0xF98906); 186 | TextArea.Styles[Style.Cpp.CommentDocKeyword].ForeColor = IntToColor(0xB3D991); 187 | TextArea.Styles[Style.Cpp.CommentDocKeywordError].ForeColor = IntToColor(0xFF0000); 188 | TextArea.Styles[Style.Cpp.GlobalClass].ForeColor = IntToColor(0x48A8EE); 189 | 190 | TextArea.Lexer = Lexer.Cpp; // closest to JavaScript :-) 191 | 192 | TextArea.SetKeywords(0, "abstract break char debugger double finally goto in null public throw try arguments byte default else float if instanceof long package return switch throws typeof while case const delete false for implements int native private short synchonized transient var with boolean catch continue do eval final function interface new proptected static this true void yield"); 193 | TextArea.SetKeywords(1, "export let class extends enum await import"); 194 | 195 | } 196 | 197 | private void OnTextChanged(object sender, EventArgs e) 198 | { 199 | 200 | } 201 | 202 | 203 | #region Numbers, Bookmarks, Code Folding 204 | 205 | /// 206 | /// the background color of the text area 207 | /// 208 | private const int BACK_COLOR = 0x2A211C; 209 | 210 | /// 211 | /// default text color of the text area 212 | /// 213 | private const int FORE_COLOR = 0xB7B7B7; 214 | 215 | /// 216 | /// change this to whatever margin you want the line numbers to show in 217 | /// 218 | private const int NUMBER_MARGIN = 1; 219 | 220 | /// 221 | /// change this to whatever margin you want the bookmarks/breakpoints to show in 222 | /// 223 | private const int BOOKMARK_MARGIN = 2; 224 | private const int BOOKMARK_MARKER = 2; 225 | 226 | /// 227 | /// change this to whatever margin you want the code folding tree (+/-) to show in 228 | /// 229 | private const int FOLDING_MARGIN = 3; 230 | 231 | /// 232 | /// set this true to show circular buttons for code folding (the [+] and [-] buttons on the margin) 233 | /// 234 | private const bool CODEFOLDING_CIRCULAR = true; 235 | 236 | private void InitNumberMargin() 237 | { 238 | 239 | TextArea.Styles[Style.LineNumber].BackColor = IntToColor(BACK_COLOR); 240 | TextArea.Styles[Style.LineNumber].ForeColor = IntToColor(FORE_COLOR); 241 | TextArea.Styles[Style.IndentGuide].ForeColor = IntToColor(FORE_COLOR); 242 | TextArea.Styles[Style.IndentGuide].BackColor = IntToColor(BACK_COLOR); 243 | 244 | var nums = TextArea.Margins[NUMBER_MARGIN]; 245 | nums.Width = 30; 246 | nums.Type = MarginType.Number; 247 | nums.Sensitive = true; 248 | nums.Mask = 0; 249 | 250 | TextArea.MarginClick += TextArea_MarginClick; 251 | } 252 | 253 | private void InitBookmarkMargin() 254 | { 255 | 256 | //TextArea.SetFoldMarginColor(true, IntToColor(BACK_COLOR)); 257 | 258 | var margin = TextArea.Margins[BOOKMARK_MARGIN]; 259 | margin.Width = 20; 260 | margin.Sensitive = true; 261 | margin.Type = MarginType.Symbol; 262 | margin.Mask = (1 << BOOKMARK_MARKER); 263 | //margin.Cursor = MarginCursor.Arrow; 264 | 265 | var marker = TextArea.Markers[BOOKMARK_MARKER]; 266 | marker.Symbol = MarkerSymbol.Circle; 267 | marker.SetBackColor(IntToColor(0xFF003B)); 268 | marker.SetForeColor(IntToColor(0x000000)); 269 | marker.SetAlpha(100); 270 | 271 | } 272 | 273 | private void InitCodeFolding() 274 | { 275 | 276 | TextArea.SetFoldMarginColor(true, IntToColor(BACK_COLOR)); 277 | TextArea.SetFoldMarginHighlightColor(true, IntToColor(BACK_COLOR)); 278 | 279 | // Enable code folding 280 | TextArea.SetProperty("fold", "1"); 281 | TextArea.SetProperty("fold.compact", "1"); 282 | 283 | // Configure a margin to display folding symbols 284 | TextArea.Margins[FOLDING_MARGIN].Type = MarginType.Symbol; 285 | TextArea.Margins[FOLDING_MARGIN].Mask = Marker.MaskFolders; 286 | TextArea.Margins[FOLDING_MARGIN].Sensitive = true; 287 | TextArea.Margins[FOLDING_MARGIN].Width = 20; 288 | 289 | // Set colors for all folding markers 290 | for (int i = 25; i <= 31; i++) 291 | { 292 | TextArea.Markers[i].SetForeColor(IntToColor(BACK_COLOR)); // styles for [+] and [-] 293 | TextArea.Markers[i].SetBackColor(IntToColor(FORE_COLOR)); // styles for [+] and [-] 294 | } 295 | 296 | // Configure folding markers with respective symbols 297 | TextArea.Markers[Marker.Folder].Symbol = CODEFOLDING_CIRCULAR ? MarkerSymbol.CirclePlus : MarkerSymbol.BoxPlus; 298 | TextArea.Markers[Marker.FolderOpen].Symbol = CODEFOLDING_CIRCULAR ? MarkerSymbol.CircleMinus : MarkerSymbol.BoxMinus; 299 | TextArea.Markers[Marker.FolderEnd].Symbol = CODEFOLDING_CIRCULAR ? MarkerSymbol.CirclePlusConnected : MarkerSymbol.BoxPlusConnected; 300 | TextArea.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner; 301 | TextArea.Markers[Marker.FolderOpenMid].Symbol = CODEFOLDING_CIRCULAR ? MarkerSymbol.CircleMinusConnected : MarkerSymbol.BoxMinusConnected; 302 | TextArea.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine; 303 | TextArea.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner; 304 | 305 | // Enable automatic folding 306 | TextArea.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change); 307 | 308 | } 309 | 310 | private void TextArea_MarginClick(object sender, MarginClickEventArgs e) 311 | { 312 | if (e.Margin == BOOKMARK_MARGIN) 313 | { 314 | // Do we have a marker for this line? 315 | const uint mask = (1 << BOOKMARK_MARKER); 316 | var line = TextArea.Lines[TextArea.LineFromPosition(e.Position)]; 317 | if ((line.MarkerGet() & mask) > 0) 318 | { 319 | // Remove existing bookmark 320 | line.MarkerDelete(BOOKMARK_MARKER); 321 | } 322 | else 323 | { 324 | // Add bookmark 325 | line.MarkerAdd(BOOKMARK_MARKER); 326 | } 327 | } 328 | } 329 | 330 | #endregion 331 | 332 | #region Drag & Drop File 333 | 334 | public void InitDragDropFile() 335 | { 336 | 337 | TextArea.AllowDrop = true; 338 | TextArea.DragEnter += delegate (object sender, DragEventArgs e) { 339 | if (e.Data.GetDataPresent(DataFormats.FileDrop)) 340 | e.Effect = DragDropEffects.Copy; 341 | else 342 | e.Effect = DragDropEffects.None; 343 | }; 344 | TextArea.DragDrop += delegate (object sender, DragEventArgs e) { 345 | 346 | // get file drop 347 | if (e.Data.GetDataPresent(DataFormats.FileDrop)) 348 | { 349 | 350 | Array a = (Array)e.Data.GetData(DataFormats.FileDrop); 351 | if (a != null) 352 | { 353 | 354 | string path = a.GetValue(0).ToString(); 355 | 356 | LoadDataFromFile(path); 357 | 358 | } 359 | } 360 | }; 361 | 362 | } 363 | 364 | private void LoadDataFromFile(string path) 365 | { 366 | if (File.Exists(path)) 367 | { 368 | FileName.Text = Path.GetFileName(path); 369 | TextArea.Text = File.ReadAllText(path); 370 | } 371 | } 372 | 373 | #endregion 374 | 375 | #region Main Menu Commands 376 | 377 | private void openToolStripMenuItem_Click(object sender, EventArgs e) 378 | { 379 | if (openFileDialog.ShowDialog() == DialogResult.OK) 380 | { 381 | LoadDataFromFile(openFileDialog.FileName); 382 | } 383 | } 384 | 385 | private void findToolStripMenuItem_Click(object sender, EventArgs e) 386 | { 387 | OpenSearch(); 388 | } 389 | 390 | private void findDialogToolStripMenuItem_Click(object sender, EventArgs e) 391 | { 392 | OpenFindDialog(); 393 | } 394 | 395 | private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e) 396 | { 397 | OpenReplaceDialog(); 398 | } 399 | 400 | private void cutToolStripMenuItem_Click(object sender, EventArgs e) 401 | { 402 | TextArea.Cut(); 403 | } 404 | 405 | private void copyToolStripMenuItem_Click(object sender, EventArgs e) 406 | { 407 | TextArea.Copy(); 408 | } 409 | 410 | private void pasteToolStripMenuItem_Click(object sender, EventArgs e) 411 | { 412 | TextArea.Paste(); 413 | } 414 | 415 | private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) 416 | { 417 | TextArea.SelectAll(); 418 | } 419 | 420 | private void selectLineToolStripMenuItem_Click(object sender, EventArgs e) 421 | { 422 | Line line = TextArea.Lines[TextArea.CurrentLine]; 423 | TextArea.SetSelection(line.Position + line.Length, line.Position); 424 | } 425 | 426 | private void clearSelectionToolStripMenuItem_Click(object sender, EventArgs e) 427 | { 428 | TextArea.SetEmptySelection(0); 429 | } 430 | 431 | private void indentSelectionToolStripMenuItem_Click(object sender, EventArgs e) 432 | { 433 | Indent(); 434 | } 435 | 436 | private void outdentSelectionToolStripMenuItem_Click(object sender, EventArgs e) 437 | { 438 | Outdent(); 439 | } 440 | 441 | private void uppercaseSelectionToolStripMenuItem_Click(object sender, EventArgs e) 442 | { 443 | Uppercase(); 444 | } 445 | 446 | private void lowercaseSelectionToolStripMenuItem_Click(object sender, EventArgs e) 447 | { 448 | Lowercase(); 449 | } 450 | 451 | private void wordWrapToolStripMenuItem1_Click(object sender, EventArgs e) 452 | { 453 | 454 | // toggle word wrap 455 | wordWrapItem.Checked = !wordWrapItem.Checked; 456 | TextArea.WrapMode = wordWrapItem.Checked ? WrapMode.Word : WrapMode.None; 457 | } 458 | 459 | private void indentGuidesToolStripMenuItem_Click(object sender, EventArgs e) 460 | { 461 | 462 | // toggle indent guides 463 | indentGuidesItem.Checked = !indentGuidesItem.Checked; 464 | TextArea.IndentationGuides = indentGuidesItem.Checked ? IndentView.LookBoth : IndentView.None; 465 | } 466 | 467 | private void hiddenCharactersToolStripMenuItem_Click(object sender, EventArgs e) 468 | { 469 | 470 | // toggle view whitespace 471 | hiddenCharactersItem.Checked = !hiddenCharactersItem.Checked; 472 | TextArea.ViewWhitespace = hiddenCharactersItem.Checked ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible; 473 | } 474 | 475 | private void zoomInToolStripMenuItem_Click(object sender, EventArgs e) 476 | { 477 | ZoomIn(); 478 | } 479 | 480 | private void zoomOutToolStripMenuItem_Click(object sender, EventArgs e) 481 | { 482 | ZoomOut(); 483 | } 484 | 485 | private void zoom100ToolStripMenuItem_Click(object sender, EventArgs e) 486 | { 487 | ZoomDefault(); 488 | } 489 | 490 | private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) 491 | { 492 | TextArea.FoldAll(FoldAction.Contract); 493 | } 494 | 495 | private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) 496 | { 497 | TextArea.FoldAll(FoldAction.Expand); 498 | } 499 | 500 | 501 | #endregion 502 | 503 | #region Uppercase / Lowercase 504 | 505 | private void Lowercase() 506 | { 507 | 508 | // save the selection 509 | int start = TextArea.SelectionStart; 510 | int end = TextArea.SelectionEnd; 511 | 512 | // modify the selected text 513 | TextArea.ReplaceSelection(TextArea.GetTextRange(start, end - start).ToLower()); 514 | 515 | // preserve the original selection 516 | TextArea.SetSelection(start, end); 517 | } 518 | 519 | private void Uppercase() 520 | { 521 | 522 | // save the selection 523 | int start = TextArea.SelectionStart; 524 | int end = TextArea.SelectionEnd; 525 | 526 | // modify the selected text 527 | TextArea.ReplaceSelection(TextArea.GetTextRange(start, end - start).ToUpper()); 528 | 529 | // preserve the original selection 530 | TextArea.SetSelection(start, end); 531 | } 532 | 533 | #endregion 534 | 535 | #region Indent / Outdent 536 | 537 | private void Indent() 538 | { 539 | // we use this hack to send "Shift+Tab" to scintilla, since there is no known API to indent, 540 | // although the indentation function exists. Pressing TAB with the editor focused confirms this. 541 | GenerateKeystrokes("{TAB}"); 542 | } 543 | 544 | private void Outdent() 545 | { 546 | // we use this hack to send "Shift+Tab" to scintilla, since there is no known API to outdent, 547 | // although the indentation function exists. Pressing Shift+Tab with the editor focused confirms this. 548 | GenerateKeystrokes("+{TAB}"); 549 | } 550 | 551 | private void GenerateKeystrokes(string keys) 552 | { 553 | HotKeyManager.Enable = false; 554 | TextArea.Focus(); 555 | SendKeys.Send(keys); 556 | HotKeyManager.Enable = true; 557 | } 558 | 559 | #endregion 560 | 561 | #region Zoom 562 | 563 | private void ZoomIn() 564 | { 565 | TextArea.ZoomIn(); 566 | } 567 | 568 | private void ZoomOut() 569 | { 570 | TextArea.ZoomOut(); 571 | } 572 | 573 | private void ZoomDefault() 574 | { 575 | TextArea.Zoom = 0; 576 | } 577 | 578 | 579 | #endregion 580 | 581 | #region Quick Search Bar 582 | 583 | bool SearchIsOpen = false; 584 | 585 | private void OpenSearch() 586 | { 587 | 588 | SearchManager.SearchBox = TxtSearch; 589 | SearchManager.TextArea = TextArea; 590 | 591 | if (!SearchIsOpen) 592 | { 593 | SearchIsOpen = true; 594 | InvokeIfNeeded(delegate () { 595 | PanelSearch.Visible = true; 596 | TxtSearch.Text = SearchManager.LastSearch; 597 | TxtSearch.Focus(); 598 | TxtSearch.SelectAll(); 599 | }); 600 | } 601 | else 602 | { 603 | InvokeIfNeeded(delegate () { 604 | TxtSearch.Focus(); 605 | TxtSearch.SelectAll(); 606 | }); 607 | } 608 | } 609 | private void CloseSearch() 610 | { 611 | if (SearchIsOpen) 612 | { 613 | SearchIsOpen = false; 614 | InvokeIfNeeded(delegate () { 615 | PanelSearch.Visible = false; 616 | //CurBrowser.GetBrowser().StopFinding(true); 617 | }); 618 | } 619 | } 620 | 621 | private void BtnClearSearch_Click(object sender, EventArgs e) 622 | { 623 | CloseSearch(); 624 | } 625 | 626 | private void BtnPrevSearch_Click(object sender, EventArgs e) 627 | { 628 | SearchManager.Find(false, false); 629 | } 630 | private void BtnNextSearch_Click(object sender, EventArgs e) 631 | { 632 | SearchManager.Find(true, false); 633 | } 634 | private void TxtSearch_TextChanged(object sender, EventArgs e) 635 | { 636 | SearchManager.Find(true, true); 637 | } 638 | 639 | private void TxtSearch_KeyDown(object sender, KeyEventArgs e) 640 | { 641 | if (HotKeyManager.IsHotkey(e, Keys.Enter)) 642 | { 643 | SearchManager.Find(true, false); 644 | } 645 | if (HotKeyManager.IsHotkey(e, Keys.Enter, true) || HotKeyManager.IsHotkey(e, Keys.Enter, false, true)) 646 | { 647 | SearchManager.Find(false, false); 648 | } 649 | } 650 | 651 | #endregion 652 | 653 | #region Find & Replace Dialog 654 | 655 | private void OpenFindDialog() 656 | { 657 | 658 | } 659 | private void OpenReplaceDialog() 660 | { 661 | 662 | 663 | } 664 | 665 | #endregion 666 | 667 | #region Utils 668 | 669 | public static Color IntToColor(int rgb) 670 | { 671 | return Color.FromArgb(255, (byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb); 672 | } 673 | 674 | public void InvokeIfNeeded(Action action) 675 | { 676 | if (this.InvokeRequired) 677 | { 678 | this.BeginInvoke(action); 679 | } 680 | else 681 | { 682 | action.Invoke(); 683 | } 684 | } 685 | 686 | internal class HotKeyManager 687 | { 688 | 689 | public static bool Enable = true; 690 | 691 | public static void AddHotKey(Form form, Action function, Keys key, bool ctrl = false, bool shift = false, bool alt = false) 692 | { 693 | form.KeyPreview = true; 694 | 695 | form.KeyDown += delegate (object sender, KeyEventArgs e) { 696 | if (IsHotkey(e, key, ctrl, shift, alt)) 697 | { 698 | function(); 699 | } 700 | }; 701 | } 702 | 703 | public static bool IsHotkey(KeyEventArgs eventData, Keys key, bool ctrl = false, bool shift = false, bool alt = false) 704 | { 705 | return eventData.KeyCode == key && eventData.Control == ctrl && eventData.Shift == shift && eventData.Alt == alt; 706 | } 707 | 708 | 709 | } 710 | 711 | internal class SearchManager 712 | { 713 | 714 | public static ScintillaNET.Scintilla TextArea; 715 | public static TextBox SearchBox; 716 | 717 | public static string LastSearch = ""; 718 | 719 | public static int LastSearchIndex; 720 | 721 | public static void Find(bool next, bool incremental) 722 | { 723 | bool first = LastSearch != SearchBox.Text; 724 | 725 | LastSearch = SearchBox.Text; 726 | if (LastSearch.Length > 0) 727 | { 728 | 729 | if (next) 730 | { 731 | 732 | // SEARCH FOR THE NEXT OCCURANCE 733 | 734 | // Search the document at the last search index 735 | TextArea.TargetStart = LastSearchIndex - 1; 736 | TextArea.TargetEnd = LastSearchIndex + (LastSearch.Length + 1); 737 | TextArea.SearchFlags = SearchFlags.None; 738 | 739 | // Search, and if not found.. 740 | if (!incremental || TextArea.SearchInTarget(LastSearch) == -1) 741 | { 742 | 743 | // Search the document from the caret onwards 744 | TextArea.TargetStart = TextArea.CurrentPosition; 745 | TextArea.TargetEnd = TextArea.TextLength; 746 | TextArea.SearchFlags = SearchFlags.None; 747 | 748 | // Search, and if not found.. 749 | if (TextArea.SearchInTarget(LastSearch) == -1) 750 | { 751 | 752 | // Search again from top 753 | TextArea.TargetStart = 0; 754 | TextArea.TargetEnd = TextArea.TextLength; 755 | 756 | // Search, and if not found.. 757 | if (TextArea.SearchInTarget(LastSearch) == -1) 758 | { 759 | 760 | // clear selection and exit 761 | TextArea.ClearSelections(); 762 | return; 763 | } 764 | } 765 | 766 | } 767 | 768 | } 769 | else 770 | { 771 | 772 | // SEARCH FOR THE PREVIOUS OCCURANCE 773 | 774 | // Search the document from the beginning to the caret 775 | TextArea.TargetStart = 0; 776 | TextArea.TargetEnd = TextArea.CurrentPosition; 777 | TextArea.SearchFlags = SearchFlags.None; 778 | 779 | // Search, and if not found.. 780 | if (TextArea.SearchInTarget(LastSearch) == -1) 781 | { 782 | 783 | // Search again from the caret onwards 784 | TextArea.TargetStart = TextArea.CurrentPosition; 785 | TextArea.TargetEnd = TextArea.TextLength; 786 | 787 | // Search, and if not found.. 788 | if (TextArea.SearchInTarget(LastSearch) == -1) 789 | { 790 | 791 | // clear selection and exit 792 | TextArea.ClearSelections(); 793 | return; 794 | } 795 | } 796 | 797 | } 798 | 799 | // Select the occurance 800 | LastSearchIndex = TextArea.TargetStart; 801 | TextArea.SetSelection(TextArea.TargetEnd, TextArea.TargetStart); 802 | TextArea.ScrollCaret(); 803 | 804 | } 805 | 806 | SearchBox.Focus(); 807 | } 808 | 809 | 810 | } 811 | 812 | #endregion 813 | } 814 | } 815 | -------------------------------------------------------------------------------- /bucket.manager/Tools/JSEditor.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 132, 17 125 | 126 | -------------------------------------------------------------------------------- /bucket.manager/Utils/CustomProgress.cs: -------------------------------------------------------------------------------- 1 | // From https://stackoverflow.com/a/3529945 2 | 3 | using System; 4 | using System.Drawing; 5 | using System.Windows.Forms; 6 | 7 | namespace bucket.manager.Utils 8 | { 9 | public enum ProgressBarDisplayText 10 | { 11 | Percentage, 12 | CustomText 13 | } 14 | 15 | class CustomProgressBar : ProgressBar 16 | { 17 | //Property to set to decide whether to print a % or Text 18 | public ProgressBarDisplayText DisplayStyle { get; set; } 19 | 20 | //Property to hold the custom text 21 | public String CustomText { get; set; } 22 | 23 | public CustomProgressBar() 24 | { 25 | // Modify the ControlStyles flags 26 | //http://msdn.microsoft.com/en-us/library/system.windows.forms.controlstyles.aspx 27 | SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); 28 | } 29 | 30 | protected override void OnPaint(PaintEventArgs e) 31 | { 32 | Rectangle rect = ClientRectangle; 33 | Graphics g = e.Graphics; 34 | 35 | ProgressBarRenderer.DrawHorizontalBar(g, rect); 36 | rect.Inflate(-3, -3); 37 | if (Value > 0) 38 | { 39 | // As we doing this ourselves we need to draw the chunks on the progress bar 40 | Rectangle clip = new Rectangle(rect.X, rect.Y, (int)Math.Round(((float)Value / Maximum) * rect.Width), rect.Height); 41 | ProgressBarRenderer.DrawHorizontalChunks(g, clip); 42 | } 43 | 44 | // Set the Display text (Either a % amount or our custom text 45 | string text = DisplayStyle == ProgressBarDisplayText.Percentage ? Value.ToString() + '%' : CustomText; 46 | 47 | 48 | using (Font f = new Font(FontFamily.GenericSerif, 10)) 49 | { 50 | 51 | SizeF len = g.MeasureString(text, f); 52 | // Calculate the location of the text (the middle of progress bar) 53 | // Point location = new Point(Convert.ToInt32((rect.Width / 2) - (len.Width / 2)), Convert.ToInt32((rect.Height / 2) - (len.Height / 2))); 54 | Point location = new Point(Convert.ToInt32((Width / 2) - len.Width / 2), Convert.ToInt32((Height / 2) - len.Height / 2)); 55 | // The commented-out code will centre the text into the highlighted area only. This will centre the text regardless of the highlighted area. 56 | // Draw the custom text 57 | g.DrawString(text, f, Brushes.Red, location); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /bucket.manager/Utils/Prompt.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | // Based on https://stackoverflow.com/a/5427121/4838205 20 | 21 | using System.Windows.Forms; 22 | 23 | namespace bucket.manager.Utils 24 | { 25 | public static class Prompt 26 | { 27 | public static DialogResult ShowDialog(string label, string caption, string defaultValue, out string text) 28 | { 29 | Form prompt = new Form() 30 | { 31 | Width = 500, 32 | Height = 150, 33 | FormBorderStyle = FormBorderStyle.FixedDialog, 34 | Text = caption, 35 | StartPosition = FormStartPosition.CenterScreen 36 | }; 37 | Label textLabel = new Label() { Left = 50, Top = 20, Text = label }; 38 | TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 , Text = defaultValue}; 39 | Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK }; 40 | confirmation.Click += (sender, e) => { prompt.Close(); }; 41 | prompt.Controls.Add(textBox); 42 | prompt.Controls.Add(confirmation); 43 | prompt.Controls.Add(textLabel); 44 | prompt.AcceptButton = confirmation; 45 | 46 | DialogResult ret = prompt.ShowDialog(); 47 | text = textBox.Text; 48 | return ret; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /bucket.manager/Utils/Utils.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Autodesk, Inc. All rights reserved 3 | // Written by Forge Partner Development 4 | // 5 | // Permission to use, copy, modify, and distribute this software in 6 | // object code form for any purpose and without fee is hereby granted, 7 | // provided that the above copyright notice appears in all copies and 8 | // that both that copyright notice and the limited warranty and 9 | // restricted rights notice below appear in all supporting 10 | // documentation. 11 | // 12 | // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 13 | // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 14 | // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 15 | // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 16 | // UNINTERRUPTED OR ERROR FREE. 17 | ///////////////////////////////////////////////////////////////////// 18 | 19 | namespace bucket.manager.Utils 20 | { 21 | public static class Utils 22 | { 23 | public static string Base64Encode(this string plainText) 24 | { 25 | var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); 26 | return System.Convert.ToBase64String(plainTextBytes); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /bucket.manager/bucket.manager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Debug 10 | AnyCPU 11 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97} 12 | WinExe 13 | bucket.manager 14 | bucket.manager 15 | v4.6 16 | 512 17 | true 18 | 19 | 20 | 21 | 22 | 23 | AnyCPU 24 | true 25 | full 26 | false 27 | bin\Debug\ 28 | DEBUG;TRACE 29 | prompt 30 | 4 31 | 32 | 33 | AnyCPU 34 | pdbonly 35 | true 36 | bin\Release\ 37 | TRACE 38 | prompt 39 | 4 40 | 41 | 42 | true 43 | bin\x64\Debug\ 44 | DEBUG;TRACE 45 | full 46 | x64 47 | prompt 48 | MinimumRecommendedRules.ruleset 49 | true 50 | 51 | 52 | bin\x64\Release\ 53 | TRACE 54 | true 55 | pdbonly 56 | x64 57 | prompt 58 | MinimumRecommendedRules.ruleset 59 | true 60 | 61 | 62 | true 63 | bin\x86\Debug\ 64 | DEBUG;TRACE 65 | full 66 | x86 67 | prompt 68 | MinimumRecommendedRules.ruleset 69 | true 70 | 71 | 72 | bin\x86\Release\ 73 | TRACE 74 | true 75 | pdbonly 76 | x86 77 | prompt 78 | MinimumRecommendedRules.ruleset 79 | true 80 | 81 | 82 | 83 | packages\Autodesk.Forge.1.7.0\lib\net452\Autodesk.Forge.dll 84 | 85 | 86 | packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll 87 | 88 | 89 | packages\RestSharp.106.3.1\lib\net452\RestSharp.dll 90 | 91 | 92 | packages\jacobslusser.ScintillaNET.3.6.3\lib\net40\ScintillaNET.dll 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Form 112 | 113 | 114 | Form1.cs 115 | 116 | 117 | Form 118 | 119 | 120 | JSEditor.cs 121 | 122 | 123 | 124 | 125 | 126 | 127 | Component 128 | 129 | 130 | Form1.cs 131 | 132 | 133 | JSEditor.cs 134 | 135 | 136 | ResXFileCodeGenerator 137 | Resources.Designer.cs 138 | Designer 139 | 140 | 141 | True 142 | Resources.resx 143 | True 144 | 145 | 146 | Designer 147 | 148 | 149 | SettingsSingleFileGenerator 150 | Settings.Designer.cs 151 | 152 | 153 | True 154 | Settings.settings 155 | True 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | Always 164 | 165 | 166 | 167 | 168 | 169 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /bucket.manager/bucket.manager.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2010 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bucket.manager", "bucket.manager.csproj", "{09A7D975-D2F9-4FF4-8536-815DCF98CA97}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Debug|x64.ActiveCfg = Debug|x64 21 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Debug|x64.Build.0 = Debug|x64 22 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Debug|x86.ActiveCfg = Debug|x86 23 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Debug|x86.Build.0 = Debug|x86 24 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Release|x64.ActiveCfg = Release|x64 27 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Release|x64.Build.0 = Release|x64 28 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Release|x86.ActiveCfg = Release|x86 29 | {09A7D975-D2F9-4FF4-8536-815DCF98CA97}.Release|x86.Build.0 = Release|x86 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {02CFA0DD-3C2D-43C3-A155-5B5866878283} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /bucket.manager/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /js_run.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk-Forge/forge-bucketsmanager-desktop/3d2d8d564d645a0c0fa44ff1a013a159242e8883/js_run.gif -------------------------------------------------------------------------------- /thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk-Forge/forge-bucketsmanager-desktop/3d2d8d564d645a0c0fa44ff1a013a159242e8883/thumbnail.png --------------------------------------------------------------------------------