private void ThisAddIn_Startup(object sender, System.EventArgs e) { Globals.Ribbons.Ribbon.keepUpdateBtn.Checked = true; Globals.Ribbons.Ribbon.showTaskPaneBtn.Checked = true; GetCurrentUser(); ShortcutContainer shortcut = new ShortcutContainer(); _msgorillaTaskPane = this.CustomTaskPanes.Add(shortcut, "MSGorilla"); _msgorillaTaskPane.Visible = Globals.Ribbons.Ribbon.showTaskPaneBtn.Checked; _msgorillaTaskPane.VisibleChanged += taskPaneValue_VisibleChanged; }
/// <summary> /// Parses lines of strings to a shortcut object by splitting the entries with the delimiters comma and semicolon. /// </summary> /// <param name="lines">String array that contains shortcut information seperated by a delimiter.</param> /// <returns>Parsed shortcut object.</returns> public static ShortcutContainer Parse(string[] lines) { var shortcutContainer = new ShortcutContainer(); foreach (var line in lines) { //TODO: Testen auf Fehler string[] shortcutInfo = line.Split(',', ';'); shortcutContainer.ShortcutInformation.Add(new ShortcutDetails(0, shortcutInfo[0], shortcutInfo[1], shortcutInfo[2])); } return(shortcutContainer); }
public void SerializeToXml(ShortcutContainer listOfShortcutInformation, string xmlPath) { try { var serializer = new XmlSerializer(typeof(ShortcutContainer)); using (var writer = File.Open(xmlPath, FileMode.OpenOrCreate, FileAccess.Write)) { serializer.Serialize(writer, listOfShortcutInformation); } } catch (InvalidOperationException invalidOperationException) { Console.WriteLine(invalidOperationException.Message); } catch (ArgumentNullException argumentNullException) { Console.WriteLine(argumentNullException.Message); } catch (ArgumentOutOfRangeException argumentOutOfRangeException) { Console.WriteLine(argumentOutOfRangeException.Message); } catch (ArgumentException argumentException) { Console.WriteLine(argumentException.Message); } catch (PathTooLongException pathTooLongException) { Console.WriteLine(pathTooLongException.Message); } catch (DirectoryNotFoundException directoryNotFoundException) { Console.WriteLine(directoryNotFoundException.Message); } catch (FileNotFoundException fileNotFoundException) { Console.WriteLine(fileNotFoundException.Message); } catch (IOException ioException) { Console.WriteLine(ioException.Message); } catch (UnauthorizedAccessException unauthorizedAccessException) { Console.WriteLine(unauthorizedAccessException.Message); } catch (NotSupportedException notSupportedException) { Console.WriteLine(notSupportedException.Message); } }
public void Add(ShortcutDetails create) { ShortcutContainer shortcuts = null; if (File.Exists(Properties.Resources.ShortcutInformationFile)) { shortcuts = JsonParser.DeserializeFromJson <ShortcutContainer>(Properties.Resources.ShortcutInformationFile); } else { shortcuts = new ShortcutContainer(); } shortcuts.ShortcutInformation.Add(create); JsonParser.SerializeToJson(shortcuts, Properties.Resources.ShortcutInformationFile); }
/// <summary> /// /// </summary> /// <param name="xmlPath"></param> /// <returns></returns> public ShortcutContainer DeserializeFromXml(string xmlPath) { ShortcutContainer listOfShortcutInformation = null; try { var deserializer = new XmlSerializer(typeof(ShortcutContainer)); using (TextReader reader = new StreamReader(xmlPath)) { object obj = deserializer.Deserialize(reader); ShortcutContainer xmlData = (ShortcutContainer)obj; listOfShortcutInformation = xmlData; } } catch (InvalidOperationException invalidOperationException) { Console.WriteLine(invalidOperationException.Message); } return(listOfShortcutInformation); }