add ProxyJump function
This commit is contained in:
1 parent
56e20e5464
commit
7f0e0fdb23
48 files changed
+3875
-44
No files matched your search
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using BulkArchiveMailer.AddIn.UI;
|
||||
using BulkArchiveMailer.Core;
|
||||
using Office = Microsoft.Office.Core;
|
||||
|
||||
namespace BulkArchiveMailer.AddIn
|
||||
{
|
||||
/// <summary>
|
||||
/// Backs the single "Массовая рассылка" ribbon button declared in
|
||||
/// Ribbon.xml (raw Ribbon XML + callbacks approach, not the Ribbon
|
||||
/// Designer visual item - keeps everything in one small readable
|
||||
/// file). Wired up via ThisAddIn.CreateRibbonExtensibilityObject().
|
||||
/// </summary>
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public class RibbonController : Office.IRibbonExtensibility
|
||||
{
|
||||
private Office.IRibbonUI ribbon;
|
||||
|
||||
public string GetCustomUI(string ribbonId)
|
||||
{
|
||||
return GetEmbeddedResourceText("BulkArchiveMailer.AddIn.Ribbon.xml");
|
||||
}
|
||||
|
||||
public void Ribbon_Load(Office.IRibbonUI ribbonUi)
|
||||
{
|
||||
ribbon = ribbonUi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The button's onAction callback. Opens SettingsForm first if the
|
||||
/// archive folder is not configured yet (or does not exist);
|
||||
/// otherwise jumps straight to PreviewForm. Kept deliberately
|
||||
/// simple - see README.md for the reasoning.
|
||||
/// </summary>
|
||||
public void OnOpenBulkSenderButtonClick(Office.IRibbonControl control)
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = AppSettings.Load();
|
||||
var outlookApplication = Globals.ThisAddIn.OutlookApplication;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(settings.ArchiveFolder) || !Directory.Exists(settings.ArchiveFolder))
|
||||
{
|
||||
using (var settingsForm = new SettingsForm(outlookApplication))
|
||||
{
|
||||
settingsForm.ShowDialog();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
using (var previewForm = new PreviewForm(outlookApplication))
|
||||
{
|
||||
previewForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не удалось открыть окно массовой рассылки: " + ex.Message,
|
||||
"BulkArchiveMailer",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetEmbeddedResourceText(string resourceName)
|
||||
{
|
||||
var asm = Assembly.GetExecutingAssembly();
|
||||
foreach (var name in asm.GetManifestResourceNames())
|
||||
{
|
||||
if (string.Equals(name, resourceName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using (var stream = asm.GetManifestResourceStream(name))
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user