Пример #1
0
 /// <summary>
 /// Get the recipient dialog and allow the user to chose a recipient
 /// </summary>
 /// <param name="PstrRecipient"></param>
 public static ExtendedRecipientList GetRecipients(string PstrRecipient = "")
 {
     try
     {
         Outlook.SelectNamesDialog LobjSnd = Globals.ThisAddIn.Application.Session.GetSelectNamesDialog();
         if (PstrRecipient != string.Empty)
         {
             LobjSnd.Recipients.Add(PstrRecipient);
         }
         LobjSnd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo;
         LobjSnd.AllowMultipleSelection     = false;
         LobjSnd.Display();
         if (!LobjSnd.Recipients.ResolveAll())
         {
             return(null);
         }
         else
         {
             return(LobjSnd.Recipients.ToListOfExtendedRecipient());
         }
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "There was an error selecting the recipient.");
         return(null);
     }
 }
Пример #2
0
 /// <summary>
 /// The user wants to setup display options for multiple recipients
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonDisplayOptions_Click(object sender, EventArgs e)
 {
     try
     {
         RecipientOptions LobjForm = new RecipientOptions(Settings.Recipients);
         if (LobjForm.ShowDialog() == DialogResult.OK)
         {
             Settings.Recipients = LobjForm.GetRecipients();
             txtName.Text        = Settings.Recipients.ToStringOfNames();
             if (Settings.Recipients.Count == 1)
             {
                 radioButtonShared.Enabled = false;
                 if (radioButtonShared.Checked)
                 {
                     radioButtonMeetings.Checked = true;
                 }
             }
             else
             {
                 radioButtonShared.Enabled = true;
             }
         }
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Something happened while working with the recipients form.");
     }
 }
Пример #3
0
        /// <summary>
        /// Load recipient list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            try
            {
                // we load a different list from file...
                OpenFileDialog LobjDlg = new OpenFileDialog();
                LobjDlg.InitialDirectory = Common.GetUserAppDataPath(Common.APPNAME);
                LobjDlg.Filter           = "Outlook Calendar Export - User List (*.oceul)|*.oceul";
                if (LobjDlg.ShowDialog() == DialogResult.OK)
                {
                    // cleanup
                    MobjRecipients = new Dictionary <string, ExtendedRecipient>();
                    listBox1.Items.Clear();

                    // load
                    ExtendedRecipientList LobjList = new ExtendedRecipientList();
                    LobjList.Import(LobjDlg.FileName);
                    foreach (ExtendedRecipient LobjItem in LobjList)
                    {
                        MobjRecipients.Add(LobjItem.RecipientName, LobjItem);
                        listBox1.Items.Add(LobjItem.RecipientName);
                    }

                    uiVerify();
                }
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log(true, "Unable to load the recipient list.");
            }
        }
Пример #4
0
 /// <summary>
 /// The user wants to add a new item to the list
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Outlook.SelectNamesDialog LobjDialog;
         LobjDialog = Globals.ThisAddIn.Application.Session.GetSelectNamesDialog();
         LobjDialog.NumberOfRecipientSelectors = Microsoft.Office.Interop.Outlook.OlRecipientSelectors.olShowNone;
         if (LobjDialog.Display())
         {
             // verify the recipient first
             try
             {
                 Outlook.MAPIFolder LobjFolder = Common.IsRecipientValid(LobjDialog.Recipients[1]);
                 Outlook.Items      LobjItems  = LobjFolder.Items;
                 LobjItems.Sort("[Start]");
             }
             catch
             {
                 MessageBox.Show("Unable to add the recipient. This might be becuase you do not have " +
                                 "permission/access to their calendar or it has not been setup as a shared " +
                                 "calendar in your Outlook Calendar.",
                                 Common.APPNAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             listBox1.Items.Add(LobjDialog.Recipients[1].Name);
             MobjRecipients.Add(LobjDialog.Recipients[1].Name, new ExtendedRecipient(LobjDialog.Recipients[1]));
             uiVerify();
         }
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "An error occurred when adding the name.");
     }
 }
Пример #5
0
        /// <summary>
        /// Opens Word, loads the provided template "PrintWhat" and then
        /// fills in the data based on whether the result is a:
        ///  - Day
        ///  - Work week
        ///  - Full week
        ///  - Month
        ///  The type of item to print is based on the Name of the template
        ///  provided in PrintWhat.
        /// </summary>
        public void Export()
        {
            try
            {
                // first we need to get the template type
                switch (MobjSettings.GetTemplateType())
                {
                case AddinSettings.TemplateType.Day:
                    exportDays();
                    break;

                case AddinSettings.TemplateType.FullWeek:
                    exportDays();
                    break;

                case AddinSettings.TemplateType.Month:
                    // if the first day of the month is a Friday, then we start
                    // off with a count of 5, so that we start replacing the
                    // day fields on the proper day on a monthly calendar
                    DateTime LobjDate = MobjSettings.Date.GetFirstOfMonth();
                    exportDays(LobjDate.GetDayOfWeekInt());
                    break;

                case AddinSettings.TemplateType.WorkWeek:
                    exportDays();
                    break;
                }
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log(true, "The export to Microsoft Word failed.");
            }
        }
Пример #6
0
 /// <summary>
 /// The user clicked the about button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         FileInfo LobjFile    = new FileInfo(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "").Replace("/", "\\"));
         Assembly LobjAssm    = Assembly.LoadFrom(LobjFile.FullName);
         Version  LobjVersion = LobjAssm.GetName().Version;
         MessageBox.Show(Common.APPNAME + "\n\n" +
                         "This add-in is provided to give you more printing options " +
                         "in Outlook. The templates provided are fully customizable " +
                         "and new templates can be developed.\n\n" +
                         "This has been developed by:\n\n\t" +
                         " - Microsoft Premier Field Engineering\n\t" +
                         " - Date:     \t" + LobjFile.CreationTime.ToShortDateString() + "\n\t" +
                         " - Version:  \t" + LobjVersion.ToString() + "\n\n" +
                         "THIS SOFTWARE IS PROVIDED 'AS IS' AND ANY EXPRESSED OR " +
                         "IMPLIED WARRANTIES ARE DISCLAIMED. PLEASE CONTACT YOUR " +
                         "HELP DESK FOR ASSISTANCE.",
                         Common.APPNAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
     }
 }
Пример #7
0
 /// <summary>
 /// Replaces all the symbols with the proper coloring
 /// </summary>
 /// <param name="PobjDoc"></param>
 private void colorCode(Word.Document PobjDoc)
 {
     try
     {
         // now find all the symbols and color code them
         foreach (ExtendedRecipient LobjRecipient in MobjSettings.Recipients)
         {
             Word.Find LobjFind = PobjDoc.Range().Find;
             // Clear all previously set formatting for Find dialog box.
             LobjFind.ClearFormatting();
             // Clear all previously set formatting for Replace dialog box.
             LobjFind.Replacement.ClearFormatting();
             // Set font to Replace found font.
             LobjFind.Text                   = LobjRecipient.Symbol;
             LobjFind.Forward                = true;
             LobjFind.Wrap                   = Word.WdFindWrap.wdFindContinue;
             LobjFind.Format                 = true;
             LobjFind.MatchCase              = true;
             LobjFind.MatchWholeWord         = false;
             LobjFind.MatchWildcards         = false;
             LobjFind.MatchSoundsLike        = false;
             LobjFind.MatchAllWordForms      = false;
             LobjFind.Replacement.Text       = LobjRecipient.Symbol;
             LobjFind.Replacement.Font.Color = LobjRecipient.HighlightColor.FromRGBColorString().ConvertToWordColor();
             LobjFind.Execute(Replace: Word.WdReplace.wdReplaceAll);
         }
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Unable to update the coloring on the symbols.");
     }
 }
Пример #8
0
 /// <summary>
 /// Load and initialize the progress form or set it to
 /// a new value to reset it to zero
 /// </summary>
 /// <param name="PintMax"></param>
 /// <param name="PstrValue"></param>
 public static void LoadProgress(int PintMax, string PstrValue)
 {
     try
     {
         IntPtr LintHwnd = Process.GetProcessesByName("Outlook")[0].MainWindowHandle;
         if (GobjProgress == null)
         {
             GobjProgress = new ProgressForm(PintMax, PstrValue);
             GobjProgress.Show(new ArbitraryWindow(LintHwnd));
         }
         else
         {
             GobjProgress.SetLabel(PstrValue);
             GobjProgress.SetProgressBarMax(PintMax);
             if (!GobjProgress.Visible)
             {
                 GobjProgress.Show(new ArbitraryWindow(LintHwnd));
             }
         }
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Unable to load the progress form.");
     }
 }
Пример #9
0
 /// <summary>
 /// EVENT
 /// This event fires when Outlook starts, but after ALL other
 /// add-ins have been loaded.
 /// </summary>
 private void Application_Startup()
 {
     try
     {
         // PRIMARY PURPOSE:
         // start a thread, wait a second and then load the
         // add-in. We do this because we want to give Outlook
         // a chance to fully connect to the server before
         // specific add-ins load and interfere with the
         // connection to the Exchange Server
         new Thread(() =>
         {
             try
             {
                 Thread.Sleep(1000);    // wait one second
                 loadDelayedAddins();
             }
             catch (Exception PobjEx)
             {
                 PobjEx.Log("Thread failed.");
             }
         }).Start();
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log("Application_Startup(): Unable to start thread.");
     }
 }
Пример #10
0
        /// <summary>
        /// Updates the header of the document
        /// </summary>
        /// <param name="PobjDoc"></param>
        private void updateHeader(Word.Document PobjDoc)
        {
            try
            {
                switch (MobjSettings.GetTemplateType())
                {
                case AddinSettings.TemplateType.FullWeek:
                case AddinSettings.TemplateType.WorkWeek:
                    PobjDoc.FindReplace("<<header>>", "Calendar for Week of " + MobjStart.Day.GetOrdinal() + " to " + MobjEnd.Day.GetOrdinal());
                    break;

                case AddinSettings.TemplateType.Month:
                    PobjDoc.FindReplace("<<header>>", "Calendar for Month of " + MobjStart.Month.GetMonthName() + ", " + MobjEnd.Year.ToString());
                    break;

                case AddinSettings.TemplateType.Day:
                    PobjDoc.FindReplace("<<header>>", "Day of " + MobjStart.Month.GetMonthName() + " the " + MobjStart.Day.GetOrdinal());
                    break;
                }

                if (MobjSettings.ShowHeader)
                {
                    if (MobjSettings.Recipients.Count == 1)
                    {
                        if (MobjSettings.Recipients[0].ShowName)
                        {
                            PobjDoc.FindReplace("<<name>>", "Calendar of " +
                                                MobjSettings.Recipients[0].RecipientName);
                        }
                        else
                        {
                            PobjDoc.FindReplace("<<name>>", "Calendar of " +
                                                MobjSettings.Recipients[0].DisplayName);
                        }
                    }
                    else
                    {
                        PobjDoc.FindReplace("<<name>>", "Calendars of " +
                                            MobjSettings.Recipients.ToStringOfNamesWithSymbols());
                    }
                }
                else
                {
                    // delete the header row and lead paragraph
                    // this is the ONLY troubling part, we have to select
                    // the range and type a backspace
                    Word.Range LobjRange = PobjDoc.FindReplace("<<name>>", "");
                    LobjRange.Select();
                    LobjRange.Application.Selection.TypeBackspace();
                }
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log(true, "Unable to update the header.");
            }
        }
Пример #11
0
 public ExportToWord(AddinSettings PobjSettings)
 {
     try
     {
         MobjSettings = PobjSettings;
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
     }
 }
Пример #12
0
 /// <summary>
 /// EXTENSION METHOD
 /// Converts a System Color object to a Word Color Object
 /// </summary>
 /// <param name="PobjColor"></param>
 /// <returns></returns>
 public static Word.WdColor ConvertToWordColor(this Color PobjColor)
 {
     try
     {
         return((Microsoft.Office.Interop.Word.WdColor)(PobjColor.R + 0x100 * PobjColor.G + 0x10000 * PobjColor.B));
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(Word.WdColor.wdColorBlack);
     }
 }
Пример #13
0
 /// <summary>
 /// Used for .Contains() to assist with easy list actions
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(ExtendedAppointment PobjOther)
 {
     try
     {
         return(PobjOther.Guid == this.Guid);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(false);
     }
 }
Пример #14
0
 /// <summary>
 /// Gets the path to the current DLL install location
 /// </summary>
 /// <returns></returns>
 public static string GetCurrentPath()
 {
     try
     {
         return(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "").Replace("/", "\\"));
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return("");
     }
 }
Пример #15
0
 /// <summary>
 /// Returns the first day of the month
 /// </summary>
 /// <param name="PobjDate"></param>
 /// <returns></returns>
 public static DateTime GetFirstOfMonth(this DateTime PobjDate)
 {
     try
     {
         return(new DateTime(PobjDate.Year, PobjDate.Month, 1));
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(PobjDate);
     }
 }
Пример #16
0
 /// <summary>
 /// Returns the last day of the month
 /// </summary>
 /// <param name="PobjDate"></param>
 /// <returns></returns>
 public static DateTime GetEndOfMonth(this DateTime PobjDate)
 {
     try
     {
         DateTime LobjNextMonth = new DateTime(PobjDate.Year, PobjDate.Month + 1, 1);
         return(LobjNextMonth.AddDays(-1));
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(PobjDate);
     }
 }
Пример #17
0
 /// <summary>
 /// STARTUP
 /// On startup we connect to the startup event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     try
     {
         // hook to the startup event. It will only fire after all
         // the add-ins have been loaded.
         Application.Startup += Application_Startup;
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log("ThisAddin_Startup() failed.");
     }
 }
Пример #18
0
 /// <summary>
 /// Returns the first day of the work week (Monday)
 /// </summary>
 /// <param name="PobjDate"></param>
 /// <returns></returns>
 public static DateTime GetMonday(this DateTime PobjDate)
 {
     try
     {
         double LintDoW = (double)PobjDate.DayOfWeek;
         return(PobjDate.AddDays((-1 * LintDoW) + 1));
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(PobjDate);
     }
 }
Пример #19
0
 /// <summary>
 /// Load form - set Outlook application
 /// </summary>
 public PrintWhatForm(AddinSettings PobjSettings)
 {
     try
     {
         InitializeComponent();
         MobjOutlook = Globals.ThisAddIn.Application;
         Settings    = PobjSettings;
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Could not load print options form.");
         this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     }
 }
Пример #20
0
        private bool getAllAppointments()
        {
            try
            {
                // first we need to figure out the start and end dates
                // for all the calendar entries we will be collecting
                switch (MobjSettings.GetTemplateType())
                {
                case AddinSettings.TemplateType.Day:
                    MobjStart = new DateTime(MobjSettings.Date.Year,
                                             MobjSettings.Date.Month,
                                             MobjSettings.Date.Day,
                                             00, 00, 00);
                    MobjEnd = new DateTime(MobjSettings.Date.Year,
                                           MobjSettings.Date.Month,
                                           MobjSettings.Date.Day,
                                           23, 59, 59);
                    break;

                case AddinSettings.TemplateType.FullWeek:
                    MobjStart = MobjSettings.Date.GetSunday();
                    MobjEnd   = MobjStart.AddDays(6);
                    break;

                case AddinSettings.TemplateType.WorkWeek:
                    MobjStart = MobjSettings.Date.GetMonday();
                    MobjEnd   = MobjStart.AddDays(5);
                    break;

                case AddinSettings.TemplateType.Month:
                    MobjStart = new DateTime(MobjSettings.Date.Year,
                                             MobjSettings.Date.Month,
                                             1);
                    MobjEnd = MobjStart.GetEndOfMonth();
                    break;
                }

                // do it
                MobjAppointments = new DailyAppointmentsList();
                bool LbolMeetingsOnly = (MobjSettings.ExportWhat != AddinSettings.ExportType.All);
                return(MobjAppointments.Load(MobjSettings.Recipients, MobjStart, MobjEnd, LbolMeetingsOnly, MobjSettings.ExcludePrivate));
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log();
                return(false);
            }
        }
Пример #21
0
 /// <summary>
 /// Exports a serialized list to file
 /// </summary>
 /// <param name="PstrFilename"></param>
 /// <returns></returns>
 public bool Export(string PstrFilename)
 {
     try
     {
         StreamWriter  LobjSw  = new StreamWriter(PstrFilename);
         XmlSerializer LobjSer = new XmlSerializer(this.GetType());
         LobjSer.Serialize(LobjSw, this);
         LobjSw.Close();
         return(true);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Unable to export the users.");
         return(false);
     }
 }
Пример #22
0
 /// <summary>
 /// Returns a List of strings with recipient names.
 /// </summary>
 /// <returns></returns>
 public List <string> GetRecipientList()
 {
     try
     {
         List <string> LobjReturn = new List <string>();
         foreach (ExtendedRecipient LobjItem in Recipients)
         {
             LobjReturn.Add(LobjItem.RecipientName);
         }
         return(LobjReturn);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(null);
     }
 }
Пример #23
0
 /// <summary>
 /// Imports a serialized list from file
 /// </summary>
 /// <param name="PstrFileName"></param>
 /// <returns></returns>
 public bool Import(string PstrFileName)
 {
     try
     {
         StreamReader  LobjReader = new StreamReader(PstrFileName);
         XmlSerializer LobjSer    = new XmlSerializer(this.GetType());
         this.Clear();
         this.AddRange((ExtendedRecipientList)LobjSer.Deserialize(LobjReader));
         LobjReader.Close();
         return(true);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Unable to import the user list.");
         return(false);
     }
 }
Пример #24
0
        /// <summary>
        /// User change the show to limit the template types
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboBoxShow_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                // load all again
                listBoxTemplates.Items.Clear();
                listBoxTemplates.Items.AddRange(Common.LoadTemplates().ToArray());
                List <string> LobjKeep = new List <string>();
                foreach (string LstrItem in listBoxTemplates.Items)
                {
                    if (LstrItem.ToUpper().StartsWith("[MONTH]") &&
                        (comboBoxShow.Text.ToUpper().Contains("MONTH") ||
                         comboBoxShow.Text.ToUpper().Contains("ALL")))
                    {
                        LobjKeep.Add(LstrItem);
                    }
                    if (LstrItem.ToUpper().StartsWith("[WORKWEEK]") &&
                        (comboBoxShow.Text.ToUpper().Contains("WORK") ||
                         comboBoxShow.Text.ToUpper().Contains("ALL")))
                    {
                        LobjKeep.Add(LstrItem);
                    }
                    if (LstrItem.ToUpper().StartsWith("[FULLWEEK]") &&
                        (comboBoxShow.Text.ToUpper().Contains("FULL") ||
                         comboBoxShow.Text.ToUpper().Contains("ALL")))
                    {
                        LobjKeep.Add(LstrItem);
                    }
                    if (LstrItem.ToUpper().StartsWith("[DAY]") &&
                        (comboBoxShow.Text.ToUpper().Contains("DAILY") ||
                         comboBoxShow.Text.ToUpper().Contains("ALL")))
                    {
                        LobjKeep.Add(LstrItem);
                    }
                }

                // now clear again and add them
                listBoxTemplates.Items.Clear();
                listBoxTemplates.Items.AddRange(LobjKeep.ToArray());
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log(true);
            }
        }
Пример #25
0
 /// <summary>
 /// Returns a full path to the specified folder in the AppData
 /// </summary>
 /// <param name="PstrFolder"></param>
 /// <returns></returns>
 public static string GetUserAppDataPath(string PstrFolder)
 {
     try
     {
         string LstrPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
         LstrPath = Path.Combine(LstrPath, PstrFolder);
         if (!new DirectoryInfo(LstrPath).Exists)
         {
             new DirectoryInfo(LstrPath).Create();
         }
         return(LstrPath);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Unable to get AppData path.");
         return("");
     }
 }
 /// <summary>
 /// Figures the days, by providing a list of dates from start ot end date
 /// </summary>
 /// <param name="PobjStart"></param>
 /// <param name="PobjEnd"></param>
 /// <returns></returns>
 private List <DateTime> figureDays(DateTime PobjStart, DateTime PobjEnd)
 {
     try
     {
         double          LintTotal = (PobjEnd - PobjStart).TotalDays;
         List <DateTime> LobjDays  = new List <DateTime>();
         for (int LintDay = 0; LintDay < LintTotal; LintDay++)
         {
             LobjDays.Add(PobjStart.AddDays(LintDay));
         }
         return(LobjDays);
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log();
         return(null);
     }
 }
Пример #27
0
 /// <summary>
 /// The user wants to save the current list to a file
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSave_Click(object sender, EventArgs e)
 {
     try
     {
         // we save the current list to file...
         SaveFileDialog LobjDlg = new SaveFileDialog();
         LobjDlg.InitialDirectory = Common.GetUserAppDataPath(Common.APPNAME);
         LobjDlg.Filter           = "Outlook Calendar Export - User List (*.oceul)|*.oceul";
         if (LobjDlg.ShowDialog() == DialogResult.OK)
         {
             GetRecipients().Export(LobjDlg.FileName);
             uiVerify();
         }
     }
     catch (Exception PobjEx)
     {
         PobjEx.Log(true, "Unable to load the recipient list.");
     }
 }
Пример #28
0
        /// <summary>
        /// Ask the user for the date they want to print with Today
        /// Selected by default. Then open Word, set the sheet size to 5x3,
        /// insert a table 2 columns a merged header (2 rows) and then
        /// proceed to fill it with the information from the calendar.
        /// Then open the Print Dialog for Word...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonExport_Click(object PobjSender, RibbonControlEventArgs PobjEventArgs)
        {
            PrintWhatForm LobjDlg = null;

            try
            {
                AddinSettings LobjSettings = new AddinSettings();
                LobjSettings.LoadSettings();

                // show dialog
                LobjDlg = new PrintWhatForm(LobjSettings);
                if (LobjDlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return; // done
                }
                LobjSettings = LobjDlg.Settings;

                // save the settings
                LobjSettings.SaveSettings();

                // DO IT
                ExportToWord LobjExport = new ExportToWord(LobjSettings);
                if (LobjExport.Load())
                {
                    // load of items successful - export
                    LobjExport.Export();
                    // done
                    MessageBox.Show("Completed!", Common.APPNAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log(true, "There was an error exporting to Word.");
            }
            finally
            {
                if (MobjProgress != null)
                {
                    MobjProgress.Close();
                    MobjProgress = null;
                }
            }
        }
Пример #29
0
        /// <summary>
        /// HELPER
        /// When the new explorer event first, we load the add-ins listed in
        /// Delayed load registry key
        /// </summary>
        /// <param name="Explorer"></param>
        private void loadDelayedAddins()
        {
            try
            {
                if (!readDelayedAddins()) // load names
                {
                    return;               // failed - exception in load
                }
                // next verify we have values
                if (MobjAddinNames.Count == 0)
                {
                    return; // no add-ins were in the delayed add-in list
                }
                // so we exit and do nothing more

                // sleep more if specified
                if (MintDelay > 0)
                {
                    Thread.Sleep(MintDelay * 1000);
                }

                // loop through each add-in from the COMAddins list
                // and if we find it from the delayed list, enable it
                foreach (Office.COMAddIn LobjAddin in Application.COMAddIns)
                {
                    if (MobjAddinNames.Contains(LobjAddin.ProgId))
                    {
                        try
                        {
                            LobjAddin.Connect = true; // load it
                        }
                        catch (Exception PobjEx)
                        {
                            PobjEx.Log("Unable to load: " + LobjAddin.ProgId);
                        }
                    }
                }
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log("loadDelayedAddins() failed.");
            }
        }
Пример #30
0
        /// <summary>
        /// HELPER
        /// Reads the list of add-ins from the delayed registry key
        /// </summary>
        /// <returns>True is successful</returns>
        private bool readDelayedAddins()
        {
            try
            {
                RegistryKey LobjKey = null;
                try
                {
                    LobjKey = Registry.CurrentUser.OpenSubKey(MCstrREGKEY);
                    if (LobjKey == null)
                    {
                        LobjKey = Registry.LocalMachine.OpenSubKey(MCstrREGKEY);
                    }
                }
                catch { } // ignore a failure here
                if (LobjKey != null)
                {
                    try
                    {
                        MintDelay = int.Parse(LobjKey.GetValue("").ToString());
                    }
                    catch { } // fail quietely - value likely was not set
                              // and that is OK, we just do not want to fail

                    // load the values
                    foreach (string LstrValue in LobjKey.GetValueNames())
                    {
                        MobjAddinNames.Add(LstrValue);
                    }

                    return(true); // tell the caller success
                }
                else
                {
                    throw new Exception("Registry cannot be accessed or DelayedAddins key is missing.");
                }
            }
            catch (Exception PobjEx)
            {
                PobjEx.Log("readDelayedAddins() failed.");
                return(false); // tell caller we failed
            }
        }