├── .gitignore
├── .nuget
├── NuGet.Config
└── NuGet.targets
├── AuthManager.cs
├── AutoCADDlls
├── AcCoreMgd.dll
├── AcCui.dll
├── AcDbMgd.dll
├── AcMgd.dll
├── AcWindows.dll
└── AdWindows.dll
├── AutoCADManager.cs
├── AutoCADNote.sln
├── Fonts
└── LiveSymbol.ttf
├── LICENSE
├── Manager.cs
├── MyUserControl.Designer.cs
├── MyUserControl.cs
├── MyUserControl.resx
├── OneNoteForAutoCAD.csproj
├── OneNoteManager.cs
├── PaletteManager.cs
├── Properties
└── AssemblyInfo.cs
├── README.md
├── Screenshot.png
├── app.config
├── myCommands.Designer.cs
├── myCommands.cs
├── myCommands.resx
├── myPlugin.cs
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 |
198 | # Allow AutoCAD Dlls to be checked in
199 | !AutoCADDlls/*
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 "$(NuGetExePath)"
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir) "
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/AuthManager.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Live;
2 | using System;
3 | using System.Threading.Tasks;
4 |
5 | namespace AutoCADNote
6 | {
7 | public class AuthManager
8 | {
9 | private static readonly string ClientId = "ENTER_YOUR_MICROSOFT_LIVE_APPLICATION_CLIENT_ID";
10 |
11 | // Define the permission scopes
12 | private static readonly string[] scopes = new string[] { "wl.signin", "wl.offline_access", "office.onenote_update_by_app" };
13 |
14 | // Set up the Live variables
15 | private static LiveAuthClient authClient;
16 |
17 | public static string Token { get; private set; }
18 | public static string Code { get; private set; }
19 |
20 | internal static async Task GetLoginUrl()
21 | {
22 | // Create authClient
23 | if (authClient == null)
24 | {
25 | await Initialize();
26 | }
27 |
28 | // Get the login url with the right scopes
29 | return authClient.GetLoginUrl(scopes);
30 | }
31 |
32 | private static async Task Initialize()
33 | {
34 | authClient = new LiveAuthClient(ClientId);
35 | LiveLoginResult loginResult = await authClient.InitializeAsync(scopes);
36 | }
37 |
38 | internal static async Task GetToken(Uri url)
39 | {
40 | // store the token and the code
41 | Code = url.Query.Split('&', '=')[1];
42 | var session = await authClient.ExchangeAuthCodeAsync(Code);
43 | Token = session.AccessToken;
44 | return Token;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AutoCADDlls/AcCoreMgd.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/AutoCADDlls/AcCoreMgd.dll
--------------------------------------------------------------------------------
/AutoCADDlls/AcCui.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/AutoCADDlls/AcCui.dll
--------------------------------------------------------------------------------
/AutoCADDlls/AcDbMgd.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/AutoCADDlls/AcDbMgd.dll
--------------------------------------------------------------------------------
/AutoCADDlls/AcMgd.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/AutoCADDlls/AcMgd.dll
--------------------------------------------------------------------------------
/AutoCADDlls/AcWindows.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/AutoCADDlls/AcWindows.dll
--------------------------------------------------------------------------------
/AutoCADDlls/AdWindows.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/AutoCADDlls/AdWindows.dll
--------------------------------------------------------------------------------
/AutoCADManager.cs:
--------------------------------------------------------------------------------
1 | using Autodesk.AutoCAD.ApplicationServices;
2 | using Autodesk.AutoCAD.DatabaseServices;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace AutoCADNote
8 | {
9 | public class AutoCADManager
10 | {
11 | public static event EventHandler DocumentChanged;
12 | public static string currentDocument;
13 |
14 | public static string GetDrawingName()
15 | {
16 | Document doc = Application.DocumentManager.MdiActiveDocument;
17 | return doc.Name.Split('\\').Last(); // Wire up renames
18 | }
19 | public static void WireUpDocumentReloadEvent()
20 | {
21 | Application.DocumentManager.DocumentBecameCurrent += DocumentManager_DocumentBecameCurrent;
22 | }
23 |
24 | public static void UnWireUpDocumentReloadEvent()
25 | {
26 | Application.DocumentManager.DocumentBecameCurrent -= DocumentManager_DocumentBecameCurrent;
27 | }
28 |
29 | static void DocumentManager_DocumentBecameCurrent(object sender, DocumentCollectionEventArgs e)
30 | {
31 | // DocumentBecameCurrent event fires multiple times for a document switch, it fires first with the new document with isActive = true,
32 | // then fires with the old document with isActive false and then once again with the new document with isActive = true.
33 | // Hence we put this double check below of processing only if active and different from the document stored in memory.
34 | // The world outside the AutoCADManager will only see one event bubbled correctly.
35 | if (e.Document != null)
36 | {
37 | var isActive = e.Document.IsActive;
38 | if (isActive)
39 | {
40 | var documentThatJustBecameCurrent = e.Document == null ? null : e.Document.Name;
41 |
42 | if (!String.Equals(documentThatJustBecameCurrent, currentDocument)) //currentDocument is saved from last time around.
43 | {
44 | currentDocument = documentThatJustBecameCurrent;
45 | DocumentChanged(sender, e);
46 | }
47 | }
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/AutoCADNote.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneNoteForAutoCAD", "OneNoteForAutoCAD.csproj", "{91E22D7E-A7E8-419A-AF7F-870A13484BFC}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CA6916D5-F922-4FE4-8D4F-ECAEF10A1364}"
9 | ProjectSection(SolutionItems) = preProject
10 | .nuget\NuGet.Config = .nuget\NuGet.Config
11 | .nuget\NuGet.exe = .nuget\NuGet.exe
12 | .nuget\NuGet.targets = .nuget\NuGet.targets
13 | EndProjectSection
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {91E22D7E-A7E8-419A-AF7F-870A13484BFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {91E22D7E-A7E8-419A-AF7F-870A13484BFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {91E22D7E-A7E8-419A-AF7F-870A13484BFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {91E22D7E-A7E8-419A-AF7F-870A13484BFC}.Release|Any CPU.Build.0 = Release|Any CPU
25 | EndGlobalSection
26 | GlobalSection(SolutionProperties) = preSolution
27 | HideSolutionNode = FALSE
28 | EndGlobalSection
29 | GlobalSection(TeamFoundationVersionControl) = preSolution
30 | SccNumberOfProjects = 2
31 | SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
32 | SccTeamFoundationServer = https://moutfs.visualstudio.com/defaultcollection
33 | SccLocalPath0 = .
34 | SccProjectUniqueName1 = OneNoteForAutoCAD.csproj
35 | SccLocalPath1 = .
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/Fonts/LiveSymbol.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/Fonts/LiveSymbol.ttf
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 OneNoteDev
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 |
23 |
--------------------------------------------------------------------------------
/Manager.cs:
--------------------------------------------------------------------------------
1 | using Autodesk.AutoCAD.Windows;
2 | using System;
3 | using System.Threading.Tasks;
4 | using System.Windows.Forms;
5 |
6 | namespace AutoCADNote
7 | {
8 | public class Manager
9 | {
10 | public static PaletteSet myPaletteSet;
11 | public static MyUserControl userControl;
12 | private static bool initialized;
13 |
14 | public static async Task Init()
15 | {
16 | // if not initialized, then initialize
17 | if (!initialized)
18 | {
19 | await Initialize();
20 | }
21 |
22 | // Open palette -- now there is already a page that is created.
23 | myPaletteSet.Visible = true;
24 | }
25 |
26 | private static async Task Initialize()
27 | {
28 | // Create paletteSet
29 | myPaletteSet = PaletteManager.CreatePaletteSet();
30 |
31 | // Create usercontrol
32 | userControl = new MyUserControl();
33 |
34 | // Wire up palette to user control
35 | myPaletteSet.Add("Palette1", userControl);
36 |
37 | // Wire up events
38 | userControl.WebBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;
39 | AutoCADManager.WireUpDocumentReloadEvent();
40 | AutoCADManager.DocumentChanged += AutoCADManager_DocumentChanged;
41 |
42 | // login and store code and token
43 | var loginUrl = await AuthManager.GetLoginUrl();
44 |
45 | // Ask user to login, and eventually accept permissions
46 | userControl.SetLoginUrl(loginUrl);
47 |
48 | // Show the palette
49 | myPaletteSet.Visible = true;
50 | myPaletteSet.Dock = DockSides.Right; // This needs to be set here due to a bug in AutoCad 2016 that Dock should be set after visible.
51 |
52 | // Set initialized
53 | initialized = true;
54 | }
55 |
56 | private static async Task ShowPageAsPerDocument()
57 | {
58 | var autoCadName = AutoCADManager.GetDrawingName();
59 | if (!String.IsNullOrEmpty(OneNoteManager.PageName)
60 | && !String.Equals(autoCadName, OneNoteManager.PageName))
61 | {
62 | await ShowPage(autoCadName);
63 | }
64 | }
65 |
66 | private static async void AutoCADManager_DocumentChanged(object sender, EventArgs e)
67 | {
68 | await ShowPageAsPerDocument();
69 | }
70 |
71 | private static async void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
72 | {
73 | // Check if the url incoming has a code, if so pass on to the AuthManager to get token
74 | if (e.Url.Query.Contains("code="))
75 | {
76 | var token = await AuthManager.GetToken(e.Url);
77 | await ShowPage(AutoCADManager.GetDrawingName());
78 | }
79 | else if (e.Url.ToString().StartsWith("https://onedrive.live.com"))
80 | {
81 | userControl.ShowLoadingLabel(false);
82 | }
83 | else if (e.Url.OriginalString.Contains("error=access_denied"))
84 | {
85 | // User refused to accept the permission scopes
86 | myPaletteSet.Visible = false;
87 | initialized = false; // Set initialize to false so that it tries to create again if opened next time.
88 |
89 | // Remove the wire-ups of events else they will happen twice
90 | AutoCADManager.UnWireUpDocumentReloadEvent();
91 | AutoCADManager.DocumentChanged -= AutoCADManager_DocumentChanged;
92 | }
93 | }
94 |
95 | private static async Task ShowPage(string autoCadName)
96 | {
97 | userControl.ShowLoadingLabel(true);
98 |
99 | // create page if not already created.
100 | await OneNoteManager.CreatePageIfNotExists(autoCadName);
101 |
102 | userControl.SetBrowserContent(OneNoteManager.PageEditUrl);
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/MyUserControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace AutoCADNote
2 | {
3 | partial class MyUserControl
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 Component 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.webBrowser1 = new System.Windows.Forms.WebBrowser();
32 | this.LoadingLabel = new System.Windows.Forms.Label();
33 | this.SuspendLayout();
34 | //
35 | // webBrowser1
36 | //
37 | this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
38 | this.webBrowser1.Location = new System.Drawing.Point(0, 0);
39 | this.webBrowser1.Margin = new System.Windows.Forms.Padding(2);
40 | this.webBrowser1.MinimumSize = new System.Drawing.Size(15, 16);
41 | this.webBrowser1.Name = "webBrowser1";
42 | this.webBrowser1.Size = new System.Drawing.Size(266, 652);
43 | this.webBrowser1.TabIndex = 0;
44 | //
45 | // LoadingLabel
46 | //
47 | this.LoadingLabel.AutoSize = true;
48 | this.LoadingLabel.BackColor = System.Drawing.SystemColors.Window;
49 | this.LoadingLabel.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
50 | this.LoadingLabel.Location = new System.Drawing.Point(25, 148);
51 | this.LoadingLabel.Name = "LoadingLabel";
52 | this.LoadingLabel.Size = new System.Drawing.Size(75, 19);
53 | this.LoadingLabel.TabIndex = 1;
54 | this.LoadingLabel.Text = "Loading...";
55 | this.LoadingLabel.Visible = false;
56 | //
57 | // MyUserControl
58 | //
59 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
60 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
61 | this.Controls.Add(this.LoadingLabel);
62 | this.Controls.Add(this.webBrowser1);
63 | this.Margin = new System.Windows.Forms.Padding(2);
64 | this.Name = "MyUserControl";
65 | this.Size = new System.Drawing.Size(266, 652);
66 | this.ResumeLayout(false);
67 | this.PerformLayout();
68 |
69 | }
70 |
71 | #endregion
72 |
73 | private System.Windows.Forms.WebBrowser webBrowser1;
74 | private System.Windows.Forms.Label LoadingLabel;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/MyUserControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace AutoCADNote
5 | {
6 | public partial class MyUserControl : UserControl
7 | {
8 | public MyUserControl()
9 | {
10 | InitializeComponent();
11 | this.webBrowser1.ScrollBarsEnabled = false;
12 | }
13 |
14 | public WebBrowser WebBrowser
15 | {
16 | get { return this.webBrowser1; }
17 | }
18 |
19 | public void SetLoginUrl(string loginUrl)
20 | {
21 | webBrowser1.Navigate(loginUrl, "_self", null, "User-Agent: " + "OneNoteForAutoCAD");
22 | }
23 |
24 | internal void SetBrowserContent(string editUrl)
25 | {
26 | webBrowser1.Navigate(editUrl, "_self", null, "User-Agent: " + "OneNoteForAutoCAD");
27 | }
28 |
29 | internal void ShowLoadingLabel(bool show)
30 | {
31 | this.LoadingLabel.Visible = show;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/MyUserControl.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 |
--------------------------------------------------------------------------------
/OneNoteForAutoCAD.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 |
7 |
8 |
9 |
10 | {91E22D7E-A7E8-419A-AF7F-870A13484BFC}
11 | Library
12 | Properties
13 | OneNoteForAutoCAD
14 | OneNoteForAutoCAD
15 | v4.5
16 | 512
17 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
18 |
19 |
20 |
21 | publish\
22 | true
23 | Disk
24 | false
25 | Foreground
26 | 7
27 | Days
28 | false
29 | false
30 | true
31 | 0
32 | 1.0.0.%2a
33 | false
34 | false
35 | true
36 | SAK
37 | SAK
38 | SAK
39 | SAK
40 | .\
41 | true
42 |
43 |
44 | true
45 | full
46 | false
47 | bin\Debug\
48 | DEBUG;TRACE
49 | prompt
50 | 4
51 | AllRules.ruleset
52 |
53 |
54 | pdbonly
55 | true
56 | bin\Release\
57 | TRACE
58 | prompt
59 | 4
60 | AllRules.ruleset
61 |
62 |
63 |
64 | False
65 | False
66 |
67 |
68 | False
69 | False
70 |
71 |
72 | False
73 | False
74 |
75 |
76 | False
77 | False
78 |
79 |
80 | False
81 | False
82 |
83 |
84 | False
85 | False
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | packages\LiveSDK.5.6.2\lib\net45\Microsoft.Live.dll
94 |
95 |
96 | False
97 | packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll
98 |
99 |
100 |
101 | 4.5
102 |
103 |
104 |
105 |
106 |
107 |
108 | 4.5
109 |
110 |
111 | 4.5
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | True
125 | True
126 | myCommands.resx
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | UserControl
135 |
136 |
137 | MyUserControl.cs
138 |
139 |
140 |
141 |
142 | myCommands.cs
143 | ResXFileCodeGenerator
144 | myCommands.Designer.cs
145 |
146 |
147 | MyUserControl.cs
148 |
149 |
150 |
151 |
152 | False
153 | Microsoft .NET Framework 4 %28x86 and x64%29
154 | true
155 |
156 |
157 | False
158 | .NET Framework 3.5 SP1 Client Profile
159 | false
160 |
161 |
162 | False
163 | .NET Framework 3.5 SP1
164 | false
165 |
166 |
167 | False
168 | Windows Installer 3.1
169 | true
170 |
171 |
172 |
173 |
174 |
175 |
176 | Designer
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
197 |
198 |
199 |
200 |
207 |
--------------------------------------------------------------------------------
/OneNoteManager.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Linq;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Net.Http;
7 | using System.Net.Http.Headers;
8 | using System.Threading.Tasks;
9 |
10 | namespace AutoCADNote
11 | {
12 | public static class OneNoteManager
13 | {
14 | private static readonly Uri NotebookEndPoint = new Uri("https://www.onenote.com/api/v1.0/notebooks");
15 |
16 | private static string pageName;
17 | private static string pageEditUrl;
18 | private static string AutoCADNotebook = "AutoCAD_OneNote";
19 | private static string AutoCADNotebookSection = "Drawings";
20 |
21 | public static string SectionsEndPoint { get; set; }
22 |
23 | public static string PagesEndPoint { get; set; }
24 |
25 | public static string PageEditUrl { get { return pageEditUrl; } }
26 |
27 | public static string PageName { get { return pageName; } }
28 |
29 | private static Dictionary PageNameToEditUrls = new Dictionary();
30 |
31 | public static async Task CreatePageIfNotExists(string name)
32 | {
33 | // Check if a page with this name exists in the AutoCAD notebook, if not create it.
34 | // Store the sectionsUrl and pagesurl of created notebook and section for the page
35 | name = SanitizeName(name);
36 |
37 | if (String.IsNullOrEmpty(SectionsEndPoint) || String.IsNullOrEmpty(PagesEndPoint)) // We dont have context of section yet, create or get if it exists
38 | {
39 | // Check if notebook exists, if not create it
40 | await CreateNotebookIfNotExists();
41 |
42 | // Check if section exists, if not create it
43 | await CreateSectionIfNotExists();
44 |
45 | // Now SectionsUrl and PagesUrl are populated
46 | }
47 |
48 | if (!String.IsNullOrEmpty(PageName) && PageName == name)
49 | {
50 | // This page is the one in context, so no need to create anything, PageEditUrl in context is the right one.
51 | }
52 | else // First time run when there is not PageName populated, or if the page name is different
53 | {
54 | // Notebook and section are created and verified, just the pagename is different, do only page level processing
55 |
56 | // Check if page exists, if not create it
57 | // First check if in-memory dictionary has this page, if so use it from there
58 | if (PageNameToEditUrls.ContainsKey(name))
59 | {
60 | pageEditUrl = PageNameToEditUrls[name];
61 | pageName = name;
62 | }
63 | else
64 | {
65 | List existingPages = await GetPagesInSection(AuthManager.Token);
66 | var sameNamedPages = existingPages.Where(e => e.Title == name);
67 | if (sameNamedPages.Any())
68 | {
69 | pageEditUrl = sameNamedPages.First().EditUrl;
70 | }
71 | else
72 | {
73 | pageEditUrl = await CreatePageInOneNote(name, AuthManager.Token);
74 | }
75 |
76 | pageName = name; // Set the name so that we can detect when it changed(new file opened),
77 | //and decide to open that page, or create a new page
78 |
79 | // Add to in-memory dictionary for faster retrieval in case of switching between open documents.
80 | if (!PageNameToEditUrls.ContainsKey(pageName))
81 | {
82 | PageNameToEditUrls.Add(pageName, pageEditUrl);
83 | }
84 | }
85 | }
86 | }
87 |
88 | // Create a simple HTML page and send it to the OneNote API
89 | private static async Task CreatePageInOneNote(string name, string token)
90 | {
91 | var client = new HttpClient();
92 |
93 | // Note: API only supports JSON return type.
94 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
95 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
96 |
97 | string date = DateTime.Now.ToString("o");
98 | string simpleHtml = "" +
99 | "" +
100 | "" + name + "" +
101 | "" +
102 | "" +
103 | "";
104 |
105 | var createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndPoint)
106 | {
107 | Content = new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html")
108 | };
109 |
110 | HttpResponseMessage response = await client.SendAsync(createMessage);
111 |
112 | dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
113 |
114 | var editUrl = responseObject["links"]["oneNoteWebUrl"]["href"].ToString();
115 |
116 | return editUrl;
117 | }
118 |
119 | private static string SanitizeName(string name)
120 | {
121 | name = name.Replace("&", String.Empty); // Strip unsafe html characters.
122 | var parts = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
123 | return String.Join(" ", parts);
124 | }
125 |
126 | private static async Task> GetPagesInSection(string token)
127 | {
128 | var pages = new List();
129 | var client = new HttpClient();
130 |
131 | // Note: API only supports JSON return type.
132 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
133 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
134 |
135 | HttpResponseMessage response = await client.GetAsync(PagesEndPoint);
136 | dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
137 |
138 | foreach (var pageObject in responseObject.value)
139 | {
140 | pages.Add(new PageObject()
141 | {
142 | Id = (string)pageObject["id"],
143 | Title = (string)pageObject["title"],
144 | EditUrl = (string)pageObject["links"]["oneNoteWebUrl"]["href"]
145 | });
146 | }
147 |
148 | return pages;
149 | }
150 |
151 | private static async Task CreateNotebookIfNotExists()
152 | {
153 | string autoCadNotebookSectionsUrl = await GetAutoCadNotebookSectionsUrlForUser(AuthManager.Token);
154 | if (autoCadNotebookSectionsUrl != null)
155 | {
156 | SectionsEndPoint = autoCadNotebookSectionsUrl;
157 | }
158 | else
159 | {
160 | string createdNotebookSectionsUrl = await CreateNotebookInOneNote(AuthManager.Token);
161 | if (!string.IsNullOrEmpty(createdNotebookSectionsUrl))
162 | {
163 | SectionsEndPoint = createdNotebookSectionsUrl;
164 | }
165 | }
166 | }
167 |
168 | private static async Task CreateNotebookInOneNote(string token)
169 | {
170 | var client = new HttpClient();
171 |
172 | // Note: API only supports JSON return type.
173 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
174 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
175 |
176 | var body = String.Format("{{ name: \"{0}\"}}", AutoCADNotebook);
177 | var createMessage = new HttpRequestMessage(HttpMethod.Post, NotebookEndPoint)
178 | {
179 | Content = new StringContent(body, System.Text.Encoding.UTF8, "application/json")
180 | };
181 |
182 | HttpResponseMessage response = await client.SendAsync(createMessage);
183 |
184 | var notebookResponseJson = JToken.Parse(await response.Content.ReadAsStringAsync());
185 |
186 | // Get the SectionsUrl property of created notebook that has notebook id within it.
187 | return (string)notebookResponseJson["sectionsUrl"];
188 | }
189 |
190 | private static async Task GetAutoCadNotebookSectionsUrlForUser(string token)
191 | {
192 | var client = new HttpClient();
193 |
194 | // Note: API only supports JSON return type.
195 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
196 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
197 |
198 | HttpResponseMessage response = await client.GetAsync(NotebookEndPoint);
199 | dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
200 |
201 | string autoCadNotebookSectionsUrl = null;
202 | foreach (var notebookObject in responseObject.value)
203 | {
204 | if (((string)notebookObject["name"]).Equals(AutoCADNotebook, StringComparison.InvariantCultureIgnoreCase))
205 | {
206 | autoCadNotebookSectionsUrl = (string)notebookObject["sectionsUrl"];
207 | }
208 | }
209 |
210 | return autoCadNotebookSectionsUrl;
211 | }
212 |
213 | public static async Task CreateSectionIfNotExists()
214 | {
215 | string autocadSectionPagesUrl = await GetAutoCadSectionPagesUrlForNotebook(AuthManager.Token);
216 | if (!string.IsNullOrEmpty(autocadSectionPagesUrl))
217 | {
218 | PagesEndPoint = autocadSectionPagesUrl;
219 | }
220 | else
221 | {
222 | string createdSectionPagesUrl = await CreateSectionInOneNote(AuthManager.Token);
223 | if (!string.IsNullOrEmpty(createdSectionPagesUrl))
224 | {
225 | PagesEndPoint = createdSectionPagesUrl;
226 | }
227 | }
228 | }
229 |
230 | private static async Task CreateSectionInOneNote(string token)
231 | {
232 | var client = new HttpClient();
233 |
234 | // Note: API only supports JSON return type.
235 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
236 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
237 |
238 | var body = String.Format("{{ name: \"{0}\"}}", AutoCADNotebookSection);
239 | var createMessage = new HttpRequestMessage(HttpMethod.Post, SectionsEndPoint)
240 | {
241 | Content = new StringContent(body, System.Text.Encoding.UTF8, "application/json")
242 | };
243 |
244 | HttpResponseMessage response = await client.SendAsync(createMessage);
245 |
246 | var notebookResponseJson = JToken.Parse(await response.Content.ReadAsStringAsync());
247 |
248 | // Get the PagesUrl property of created section that has section id within it.
249 | return (string)notebookResponseJson["pagesUrl"];
250 | }
251 |
252 | public static async Task GetAutoCadSectionPagesUrlForNotebook(string token)
253 | {
254 | var client = new HttpClient();
255 |
256 | // Note: API only supports JSON return type.
257 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
258 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
259 |
260 | HttpResponseMessage response = await client.GetAsync(SectionsEndPoint);
261 | dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
262 |
263 | string autoCadSectionPagesUrl = null;
264 | foreach (var sectionObject in responseObject.value)
265 | {
266 | if (((string)sectionObject["name"]).Equals(AutoCADNotebookSection, StringComparison.InvariantCultureIgnoreCase))
267 | {
268 | autoCadSectionPagesUrl = (string)sectionObject["pagesUrl"];
269 | }
270 | }
271 |
272 | return autoCadSectionPagesUrl;
273 | }
274 | }
275 |
276 | public class PageObject
277 | {
278 | public string Id { get; set; }
279 | public string Title { get; set; }
280 |
281 | public string EditUrl { get; set; }
282 | }
283 | }
284 |
--------------------------------------------------------------------------------
/PaletteManager.cs:
--------------------------------------------------------------------------------
1 | using Autodesk.AutoCAD.Windows;
2 | using System;
3 | using System.Windows;
4 |
5 | namespace AutoCADNote
6 | {
7 | public class PaletteManager
8 | {
9 | private static readonly string paletteGuid = "4CF60816-6954-430B-A0EC-6A1EB23E2907";
10 | public static PaletteSet CreatePaletteSet()
11 | {
12 | var myPaletteSet = new PaletteSet("OneNote", new Guid(paletteGuid));
13 |
14 | myPaletteSet.Size = new System.Drawing.Size(600, 900);
15 | myPaletteSet.Dock = DockSides.Right;
16 |
17 | return myPaletteSet;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // (C) Copyright 2015 by
2 |
3 | //
4 | using System.Reflection;
5 | using System.Runtime.CompilerServices;
6 | using System.Runtime.InteropServices;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("AutoCADNote")]
12 | [assembly: AssemblyDescription("")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCompany("")]
15 | [assembly: AssemblyProduct("AutoCADNote")]
16 | [assembly: AssemblyCopyright("Copyright © 2015")]
17 | [assembly: AssemblyTrademark("")]
18 | [assembly: AssemblyCulture("")]
19 |
20 | // Version information for an assembly consists of the following four values:
21 | //
22 | // Major Version
23 | // Minor Version
24 | // Build Number
25 | // Revision
26 | //
27 | // You can specify all the values or you can default the Build and Revision Numbers
28 | // by using the '*' as shown below:
29 | // [assembly: AssemblyVersion("1.0.*")]
30 | [assembly: AssemblyVersion("1.0.*")]
31 | [assembly: AssemblyFileVersion("1.0.0.0")]
32 |
33 | // In order to sign your assembly you must specify a key to use. Refer to the
34 | // Microsoft .NET Framework documentation for more information on assembly signing.
35 | //
36 | // Use the attributes below to control which key is used for signing.
37 | //
38 | // Notes:
39 | // (*) If no key is specified, the assembly is not signed.
40 | // (*) KeyName refers to a key that has been installed in the Crypto Service
41 | // Provider (CSP) on your machine. KeyFile refers to a file which contains
42 | // a key.
43 | // (*) If the KeyFile and the KeyName values are both specified, the
44 | // following processing occurs:
45 | // (1) If the KeyName can be found in the CSP, that key is used.
46 | // (2) If the KeyName does not exist and the KeyFile does exist, the key
47 | // in the KeyFile is installed into the CSP and used.
48 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
49 | // When specifying the KeyFile, the location of the KeyFile should be
50 | // relative to the project output directory which is
51 | // %Project Directory%\obj\. For example, if your KeyFile is
52 | // located in the project directory, you would specify the AssemblyKeyFile
53 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
54 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
55 | // documentation for more information on this.
56 | [assembly: AssemblyDelaySign(false)]
57 | [assembly: AssemblyKeyFile("")]
58 | [assembly: AssemblyKeyName("")]
59 |
60 | // Setting ComVisible to false makes the types in this assembly not visible
61 | // to COM components. If you need to access a type in this assembly from
62 | // COM, set the ComVisible attribute to true on that type.
63 | [assembly: ComVisible(false)]
64 |
65 | // The following GUID is for the ID of the typelib if this project is exposed to COM
66 | [assembly: Guid("09ecf05f-4ec6-4203-baec-791b7b2276ec")]
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | README: OneNote-For-AutoCAD
2 | OneNote add-in for AutoCAD that uses OneNote APIs
3 | ===================
4 | 1 - Overview
5 | ===================
6 | OneNote for AutoCAD® is an add-in for AutoCAD that allows users to take notes alongside their drawings from within AutoCAD. These notes are backed up to the cloud and can be accessed anytime. Users can see these notes the next time they open the drawing in AutoCAD.
7 |
8 | OneNote-For-AutoCAD is being shared as sample code to demonstrate a real world example of how to leverage the [OneNote REST APIs](http://dev.onenote.com) across various integration points. Developers can use this code sample to bootstrap their own OneNote related projects.
9 |
10 | ===================
11 | 2 - Shipped Product
12 | ===================
13 | OneNote for AutoCAD is now shipped to the AutoDesk app store!
14 |
15 | You can download the add-in OneNote for AutoCAD [here] (https://apps.autodesk.com/ACD/en/Detail/Index?id=appstore.exchange.autodesk.com%3aonenote_windows32and64%3aen)
16 |
17 |
18 | ===================
19 | 3 - Dependencies
20 | ===================
21 | The project is written in C# and requires .NET 4.5 or above.
22 | A Visual Studio 2013 or above compatible solution is provided and the project has the following dependencies:
23 | - Nuget packages:
24 | - LiveSDK
25 | - Newtonsoft.Json
26 | - Microsoft.AspNet.WebApi.Client
27 | - AutoCAD .NET APIs. Learn more [here](http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-C3F3C736-40CF-44A0-9210-55F6A939B6F2)
28 |
29 | ==================
30 | 4 - Building
31 | ==================
32 | Open Visual Studio as an administrator.
33 | Provided that you have all of the indicated dependencies, then you should be able to build this project directly
34 | from the VS interface.
35 |
36 | To run the app you need to have following pre-requisites:
37 | - 1. Trial or Full version of AutoCAD installed
38 | - 2. You will need to obtain a Microsoft Live Application ClientId as described [here] (https://msdn.microsoft.com/en-us/library/office/dn575426.aspx)
39 | - 3. In AuthManager.cs set the ClientId as your Microsoft Live Application ClientId.
40 | - 4. In the Project properties, ensure that the option to Start External Program on Debug is selected and supply it the path to the acad.exe executable on your machine. Generally this is present in Program Files where AutoCAD is installed. Then on running the project, the AutoCAD IDE will start up with the add-in installed.
41 | - 5. Once you make any changes to the project, build it and load the new dll using netload in the AutoCAD IDE.
42 |
43 | ==================
44 | 5 - Demo
45 | ==================
46 | [](https://screencast.autodesk.com/Embed/4126e149-e5f2-4597-a9e8-6fa9ccfb6d75)
47 |
48 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
49 |
--------------------------------------------------------------------------------
/Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNote-For-AutoCAD/06c76297dba5fa41bd5d72ad9c839d240b052e25/Screenshot.png
--------------------------------------------------------------------------------
/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/myCommands.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 OneNoteForAutoCAD {
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", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class myCommands {
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 myCommands() {
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("OneNoteForAutoCAD.myCommands", typeof(myCommands).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 | /// Looks up a localized string similar to MyCommand.
65 | ///
66 | internal static string MyCommandLocal {
67 | get {
68 | return ResourceManager.GetString("MyCommandLocal", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to MyLispFunction.
74 | ///
75 | internal static string MyLispFunctionLocal {
76 | get {
77 | return ResourceManager.GetString("MyLispFunctionLocal", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Looks up a localized string similar to MyPickFirst.
83 | ///
84 | internal static string MyPickFirstLocal {
85 | get {
86 | return ResourceManager.GetString("MyPickFirstLocal", resourceCulture);
87 | }
88 | }
89 |
90 | ///
91 | /// Looks up a localized string similar to MySessionCmd.
92 | ///
93 | internal static string MySessionCmdLocal {
94 | get {
95 | return ResourceManager.GetString("MySessionCmdLocal", resourceCulture);
96 | }
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/myCommands.cs:
--------------------------------------------------------------------------------
1 | // (C) Copyright 2015 by
2 | //
3 | using Autodesk.AutoCAD.Runtime;
4 |
5 | // This line is not mandatory, but improves loading performances
6 | [assembly: CommandClass(typeof(AutoCADNote.MyCommands))]
7 |
8 | namespace AutoCADNote
9 | {
10 |
11 | // This class is instantiated by AutoCAD for each document when
12 | // a command is called by the user the first time in the context
13 | // of a given document. In other words, non static data in this class
14 | // is implicitly per-document!
15 | public class MyCommands
16 | {
17 | // The CommandMethod attribute can be applied to any public member
18 | // function of any public class.
19 | // The function should take no arguments and return nothing.
20 | // If the method is an intance member then the enclosing class is
21 | // intantiated for each document. If the member is a static member then
22 | // the enclosing class is NOT intantiated.
23 | //
24 | // NOTE: CommandMethod has overloads where you can provide helpid and
25 | // context menu.
26 |
27 | [CommandMethod("OneNoteGroup", "Show", "Show", CommandFlags.Modal)]
28 | public async void Show() // This method can have any name
29 | {
30 | await Manager.Init();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/myCommands.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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | MyCommand
122 |
123 |
124 | MyLispFunction
125 |
126 |
127 | MyPickFirst
128 |
129 |
130 | MySessionCmd
131 |
132 |
--------------------------------------------------------------------------------
/myPlugin.cs:
--------------------------------------------------------------------------------
1 | // (C) Copyright 2015 by
2 | //
3 | using Autodesk.AutoCAD.Runtime;
4 |
5 | // This line is not mandatory, but improves loading performances
6 | [assembly: ExtensionApplication(typeof(AutoCADNote.MyPlugin))]
7 |
8 | namespace AutoCADNote
9 | {
10 |
11 | // This class is instantiated by AutoCAD once and kept alive for the
12 | // duration of the session. If you don't do any one time initialization
13 | // then you should remove this class.
14 | public class MyPlugin : IExtensionApplication
15 | {
16 |
17 | void IExtensionApplication.Initialize()
18 | {
19 | // Add one time initialization here
20 | // One common scenario is to setup a callback function here that
21 | // unmanaged code can call.
22 | // To do this:
23 | // 1. Export a function from unmanaged code that takes a function
24 | // pointer and stores the passed in value in a global variable.
25 | // 2. Call this exported function in this function passing delegate.
26 | // 3. When unmanaged code needs the services of this managed module
27 | // you simply call acrxLoadApp() and by the time acrxLoadApp
28 | // returns global function pointer is initialized to point to
29 | // the C# delegate.
30 | // For more info see:
31 | // http://msdn2.microsoft.com/en-US/library/5zwkzwf4(VS.80).aspx
32 | // http://msdn2.microsoft.com/en-us/library/44ey4b32(VS.80).aspx
33 | // http://msdn2.microsoft.com/en-US/library/7esfatk4.aspx
34 | // as well as some of the existing AutoCAD managed apps.
35 |
36 | // Initialize your plug-in application here
37 | }
38 |
39 | void IExtensionApplication.Terminate()
40 | {
41 | // Do plug-in application clean up here
42 | }
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------