Skip to content

Commit e97c165

Browse files
SebastianDotNetjozefizso
authored andcommitted
[Regular Commit]
- improve Office->ColorUtils - add Word->ApplicationUtils (get main wnd handle from document) - improve toolbox assembly loader (load from unsafe locations) - improve toolbox ui - add LoadAssembliesUnsafe option (NetOffice.Core.Settings) - update assemblies Imported from NetOffice 113578 https://netoffice.codeplex.com/SourceControl/changeset/113578 Legacy NetOffice Git repository commit 307080aeb5f09893bb3f2997bab04e60f55f3fe2
1 parent d67f498 commit e97c165

File tree

16 files changed

+787
-679
lines changed

16 files changed

+787
-679
lines changed

Toolbox/Forms/MainForm.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Toolbox/Forms/MainForm.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ public MainForm(string[] args)
6363
{
6464
InitializeComponent();
6565
Singleton = this;
66+
CommandLineArgs = args;
6667
LoadLanguages();
6768
LoadRuntimeControls();
6869
LoadConfiguration();
69-
CommandLineArgs = args;
7070
}
7171

7272
#endregion
@@ -87,6 +87,22 @@ public MainForm(string[] args)
8787

8888
#region IToolboxHost
8989

90+
public event EventHandler LanguageEditorVisibleChanged;
91+
92+
private void RaiseLanguageEditorVisibleChanged()
93+
{
94+
if (null != LanguageEditorVisibleChanged)
95+
LanguageEditorVisibleChanged(this, EventArgs.Empty);
96+
}
97+
98+
public event EventHandler Minimized;
99+
100+
private void RaiseMinimized()
101+
{
102+
if (null != Minimized)
103+
Minimized(this, EventArgs.Empty);
104+
}
105+
90106
public ToolLanguages Languages { get; private set; }
91107

92108
public bool SupportsLanguageEditor { get { return true; } }
@@ -120,14 +136,6 @@ public bool LanguageEditorVisible
120136
}
121137
}
122138

123-
public event EventHandler LanguageEditorVisibleChanged;
124-
125-
private void RaiseLanguageEditorVisibleChanged()
126-
{
127-
if (null != LanguageEditorVisibleChanged)
128-
LanguageEditorVisibleChanged(this, EventArgs.Empty);
129-
}
130-
131139
public int CurrentLanguageID
132140
{
133141
get
@@ -167,14 +175,6 @@ public void MinimizeMainWindow(bool showInTaskbar)
167175
ShowInTaskbar = showInTaskbar;
168176
}
169177

170-
public event EventHandler Minimized;
171-
172-
private void RaiseMinimized()
173-
{
174-
if (null != Minimized)
175-
Minimized(this, EventArgs.Empty);
176-
}
177-
178178
public void SwitchTo(string controlName)
179179
{
180180
foreach (TabPage item in tabControlMain.TabPages)
@@ -308,7 +308,7 @@ private void SaveConfiguration()
308308

309309
#region UI Trigger
310310

311-
private void translationEditor_LanguageChanged(object sender, int lcid)
311+
private void TranslationEditor_LanguageChanged(object sender, int lcid)
312312
{
313313
try
314314
{
@@ -390,7 +390,7 @@ private void MainForm_KeyDown(object sender, KeyEventArgs e)
390390
}
391391
}
392392

393-
private void tabControlMain_Deselecting(object sender, TabControlCancelEventArgs e)
393+
private void TabControlMain_Deselecting(object sender, TabControlCancelEventArgs e)
394394
{
395395
try
396396
{
@@ -503,7 +503,7 @@ private void MainForm_Shown(object sender, EventArgs e)
503503
}
504504
}
505505

506-
private void translationEditor_UserTranslationAbout(object sender, EventArgs e)
506+
private void TranslationEditor_UserTranslationAbout(object sender, EventArgs e)
507507
{
508508
try
509509
{

Toolbox/Program.cs

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.IO;
34
using System.Windows.Forms;
45
using System.Security.Principal;
@@ -22,7 +23,7 @@ internal static class Program
2223
private static bool _isShutDown;
2324

2425
/// <summary>
25-
/// The main entry point for the component-based application. No need for a service architecture here so far. May this want be changed to CAB in the future.
26+
/// The main entry point for the component-based application. No need for a service architecture here so far. May this want be changed to CAB in the future
2627
/// </summary>
2728
[STAThread]
2829
public static void Main(string[] args)
@@ -135,7 +136,7 @@ internal static bool IsDesign
135136
internal static bool SelfElevation { get; set; }
136137

137138
/// <summary>
138-
/// Find the local root folder in debug mode. The method use the Application.Startup method path and returns the folder 3x upward.
139+
/// Find the local root folder in debug mode. The method use the Application.Startup path and returns the folder 3x upward.
139140
/// </summary>
140141
/// <returns>The current related debug root folder</returns>
141142
private static string GetInternalRelativeDebugPath()
@@ -159,6 +160,7 @@ private static void ProceedCommandLineElevationArguments(string[] args)
159160
SelfElevation = true;
160161
}
161162
}
163+
162164
/// <summary>
163165
/// Perform self elevation if necessary and wanted
164166
/// </summary>
@@ -186,13 +188,33 @@ private static bool PerformSelfElevation()
186188
return false;
187189
}
188190

191+
/// <summary>
192+
/// Try to load an assembly with given file path
193+
/// </summary>
194+
/// <param name="assemblyFullPath">full qualified assembly path</param>
195+
/// <returns>Loaded assembly instance</returns>
196+
private static Assembly LoadFile(string assemblyFullPath)
197+
{
198+
try
199+
{
200+
return Assembly.UnsafeLoadFrom(assemblyFullPath);
201+
}
202+
catch (Exception exception)
203+
{
204+
throw new FileLoadException(String.Format("Failed to load {0}", assemblyFullPath), exception);
205+
}
206+
}
207+
189208
/// <summary>
190209
/// display unhandled exception(s)
191210
/// </summary>
192211
/// <param name="sender">source(ignored)</param>
193212
/// <param name="e">args</param>
194213
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
195214
{
215+
if (_isShutDown)
216+
return;
217+
196218
try
197219
{
198220
Forms.ErrorForm.ShowError(null, e.ExceptionObject as Exception, ErrorCategory.Penalty);
@@ -212,6 +234,9 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
212234
/// <returns>Resolved assembly or null</returns>
213235
private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
214236
{
237+
if (_isShutDown)
238+
return null;
239+
215240
try
216241
{
217242
string assemblyName = args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";
@@ -238,13 +263,13 @@ private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object s
238263
case "VisioApi.dll":
239264
case "WordApi.dll":
240265
case "MSFormsApi.dll":
241-
{
242-
assemblyFullPath = Path.Combine(Program.DependencySubFolder, assemblyName);
243-
if (File.Exists(assemblyFullPath))
244-
return System.Reflection.Assembly.LoadFile(assemblyFullPath);
245-
else
246-
throw new FileNotFoundException(String.Format("Failed to load {0}", assemblyName));
247-
}
266+
{
267+
assemblyFullPath = Path.Combine(Program.DependencySubFolder, assemblyName);
268+
if (File.Exists(assemblyFullPath))
269+
return LoadFile(assemblyFullPath);
270+
else
271+
throw new FileNotFoundException(String.Format("Failed to load {0}", assemblyName));
272+
}
248273
default:
249274
break;
250275
}

Toolbox/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.4.2.1")]
36-
[assembly: AssemblyFileVersion("1.4.2.1")]
35+
[assembly: AssemblyVersion("1.4.2.2")]
36+
[assembly: AssemblyFileVersion("1.4.2.2")]

Toolbox/ToolboxControls/About/AboutControl.Designer.cs

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Toolbox/ToolboxControls/ApplicationObserver/ApplicationObserverControl.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Toolbox/ToolboxControls/ApplicationObserver/ApplicationObserverControl.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,18 @@ private void checkBoxShowQuestion_CheckedChanged(object sender, EventArgs e)
481481
}
482482
}
483483

484+
private void listViewProcess_Resize(object sender, EventArgs e)
485+
{
486+
try
487+
{
488+
listViewProcess.Columns[2].Width = (listViewProcess.Width - (listViewProcess.Columns[1].Width + listViewProcess.Columns[0].Width)) - 32;
489+
}
490+
catch (Exception exception)
491+
{
492+
Forms.ErrorForm.ShowError(exception, ErrorCategory.NonCritical, Host.CurrentLanguageID);
493+
}
494+
}
495+
484496
#endregion
485497
}
486498
}

0 commit comments

Comments
 (0)