Skip to content

Commit

Permalink
[Regular Commit]
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
SebastianDotNet authored and jozefizso committed Apr 13, 2016
1 parent d67f498 commit e97c165
Show file tree
Hide file tree
Showing 16 changed files with 787 additions and 679 deletions.
6 changes: 3 additions & 3 deletions Toolbox/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions Toolbox/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public MainForm(string[] args)
{
InitializeComponent();
Singleton = this;
CommandLineArgs = args;
LoadLanguages();
LoadRuntimeControls();
LoadConfiguration();
CommandLineArgs = args;
}

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

#region IToolboxHost

public event EventHandler LanguageEditorVisibleChanged;

private void RaiseLanguageEditorVisibleChanged()
{
if (null != LanguageEditorVisibleChanged)
LanguageEditorVisibleChanged(this, EventArgs.Empty);
}

public event EventHandler Minimized;

private void RaiseMinimized()
{
if (null != Minimized)
Minimized(this, EventArgs.Empty);
}

public ToolLanguages Languages { get; private set; }

public bool SupportsLanguageEditor { get { return true; } }
Expand Down Expand Up @@ -120,14 +136,6 @@ public bool LanguageEditorVisible
}
}

public event EventHandler LanguageEditorVisibleChanged;

private void RaiseLanguageEditorVisibleChanged()
{
if (null != LanguageEditorVisibleChanged)
LanguageEditorVisibleChanged(this, EventArgs.Empty);
}

public int CurrentLanguageID
{
get
Expand Down Expand Up @@ -167,14 +175,6 @@ public void MinimizeMainWindow(bool showInTaskbar)
ShowInTaskbar = showInTaskbar;
}

public event EventHandler Minimized;

private void RaiseMinimized()
{
if (null != Minimized)
Minimized(this, EventArgs.Empty);
}

public void SwitchTo(string controlName)
{
foreach (TabPage item in tabControlMain.TabPages)
Expand Down Expand Up @@ -308,7 +308,7 @@ private void SaveConfiguration()

#region UI Trigger

private void translationEditor_LanguageChanged(object sender, int lcid)
private void TranslationEditor_LanguageChanged(object sender, int lcid)
{
try
{
Expand Down Expand Up @@ -390,7 +390,7 @@ private void MainForm_KeyDown(object sender, KeyEventArgs e)
}
}

private void tabControlMain_Deselecting(object sender, TabControlCancelEventArgs e)
private void TabControlMain_Deselecting(object sender, TabControlCancelEventArgs e)
{
try
{
Expand Down Expand Up @@ -503,7 +503,7 @@ private void MainForm_Shown(object sender, EventArgs e)
}
}

private void translationEditor_UserTranslationAbout(object sender, EventArgs e)
private void TranslationEditor_UserTranslationAbout(object sender, EventArgs e)
{
try
{
Expand Down
43 changes: 34 additions & 9 deletions Toolbox/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reflection;
using System.IO;
using System.Windows.Forms;
using System.Security.Principal;
Expand All @@ -22,7 +23,7 @@ internal static class Program
private static bool _isShutDown;

/// <summary>
/// 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.
/// 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
/// </summary>
[STAThread]
public static void Main(string[] args)
Expand Down Expand Up @@ -135,7 +136,7 @@ internal static bool IsDesign
internal static bool SelfElevation { get; set; }

/// <summary>
/// Find the local root folder in debug mode. The method use the Application.Startup method path and returns the folder 3x upward.
/// Find the local root folder in debug mode. The method use the Application.Startup path and returns the folder 3x upward.
/// </summary>
/// <returns>The current related debug root folder</returns>
private static string GetInternalRelativeDebugPath()
Expand All @@ -159,6 +160,7 @@ private static void ProceedCommandLineElevationArguments(string[] args)
SelfElevation = true;
}
}

/// <summary>
/// Perform self elevation if necessary and wanted
/// </summary>
Expand Down Expand Up @@ -186,13 +188,33 @@ private static bool PerformSelfElevation()
return false;
}

/// <summary>
/// Try to load an assembly with given file path
/// </summary>
/// <param name="assemblyFullPath">full qualified assembly path</param>
/// <returns>Loaded assembly instance</returns>
private static Assembly LoadFile(string assemblyFullPath)
{
try
{
return Assembly.UnsafeLoadFrom(assemblyFullPath);
}
catch (Exception exception)
{
throw new FileLoadException(String.Format("Failed to load {0}", assemblyFullPath), exception);
}
}

/// <summary>
/// display unhandled exception(s)
/// </summary>
/// <param name="sender">source(ignored)</param>
/// <param name="e">args</param>
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (_isShutDown)
return;

try
{
Forms.ErrorForm.ShowError(null, e.ExceptionObject as Exception, ErrorCategory.Penalty);
Expand All @@ -212,6 +234,9 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
/// <returns>Resolved assembly or null</returns>
private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (_isShutDown)
return null;

try
{
string assemblyName = args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";
Expand All @@ -238,13 +263,13 @@ private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object s
case "VisioApi.dll":
case "WordApi.dll":
case "MSFormsApi.dll":
{
assemblyFullPath = Path.Combine(Program.DependencySubFolder, assemblyName);
if (File.Exists(assemblyFullPath))
return System.Reflection.Assembly.LoadFile(assemblyFullPath);
else
throw new FileNotFoundException(String.Format("Failed to load {0}", assemblyName));
}
{
assemblyFullPath = Path.Combine(Program.DependencySubFolder, assemblyName);
if (File.Exists(assemblyFullPath))
return LoadFile(assemblyFullPath);
else
throw new FileNotFoundException(String.Format("Failed to load {0}", assemblyName));
}
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Toolbox/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.2.1")]
[assembly: AssemblyFileVersion("1.4.2.1")]
[assembly: AssemblyVersion("1.4.2.2")]
[assembly: AssemblyFileVersion("1.4.2.2")]
32 changes: 16 additions & 16 deletions Toolbox/ToolboxControls/About/AboutControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,18 @@ private void checkBoxShowQuestion_CheckedChanged(object sender, EventArgs e)
}
}

private void listViewProcess_Resize(object sender, EventArgs e)
{
try
{
listViewProcess.Columns[2].Width = (listViewProcess.Width - (listViewProcess.Columns[1].Width + listViewProcess.Columns[0].Width)) - 32;
}
catch (Exception exception)
{
Forms.ErrorForm.ShowError(exception, ErrorCategory.NonCritical, Host.CurrentLanguageID);
}
}

#endregion
}
}
Loading

0 comments on commit e97c165

Please sign in to comment.