├── .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 | 
4 | 
5 | [](http://opensource.org/licenses/MIT)
6 | [](http://opensource.org/licenses/MIT)
7 |
8 | [](http://developer.autodesk.com/)
9 | [](http://developer.autodesk.com/)
10 | [](http://developer.autodesk.com/)
11 |
12 | 
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 | 
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 | 
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