public static string ConvertFromNoteTextToFileName(Element element) { string fileName = element.NoteText.Trim(); if (fileName == String.Empty) { fileName = element.ID.ToString(); } while (fileName.EndsWith(".")) { fileName = fileName.Substring(0, fileName.Length - 1); } fileName = fileName.Replace("/", ""); fileName = fileName.Replace("\\",""); fileName = fileName.Replace("*", ""); fileName = fileName.Replace("?", ""); fileName = fileName.Replace("\"",""); fileName = fileName.Replace("<", ""); fileName = fileName.Replace(">", ""); fileName = fileName.Replace("|", ""); fileName = fileName.Replace(":", ""); return fileName; }
public CheckWindow(Element currentElement) { InitializeComponent(); this.currentElement = currentElement; this.removeFromToday.IsChecked = true; this.headingName.Text = currentElement.NoteText; }
private string GetTextBoxSelectedText(Element element) { TextBox target = null; FindTextBox(this.Plan, element.ID, ref target); return target.SelectedText; }
public FlagWindow(Element currentElement) { InitializeComponent(); this.currentElement = currentElement; this.headingName.Text = currentElement.NoteText; AssignTimeSpan(true); AssignTimeSpan(false); foreach (CustomTimeSpan ts in timeSpanList) { this.startTimePicker.Items.Add(ts); this.dueTimePicker.Items.Add(ts); } AssignDefaultTimeSpanValue(); this.startDatePicker.SelectedDate = DateTime.Now; this.dueDatePicker.SelectedDate = DateTime.Now; this.addReminder.IsEnabled = false; this.startTimePicker.IsEnabled = false; this.dueTimePicker.IsEnabled = false; this.startAllDay.IsChecked = true; this.dueAllDay.IsChecked = true; this.start.IsChecked = false; this.due.IsChecked = false; }
public bool ChangeElementType(ElementType type, ref Element element) { switch (type) { case ElementType.Heading: element.Type = type; element.IsExpanded = false; element.LevelOfSynchronization = 0; string path = element.Path; string associatedURI = element.AssociationURI; if (element.AssociationType != ElementAssociationType.FolderShortcut) { element.Path = element.ParentElement.Path + HeadingNameConverter.ConvertFromHeadingNameToFolderName(element) + System.IO.Path.DirectorySeparatorChar; element.NoteText = element.NoteText.Trim(); if (!CreateFolder(element)) { element.Type = ElementType.Note; element.AssociationURI = associatedURI; element.Path = path; //MessageBox.Show("The heading name is too long, please shorten the name and try again."); return false; } else { element.AssociationURI = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(element.Path)); if (Properties.Settings.Default.ShowOutline) { element.ShowExpander = Visibility.Visible; } return true; } } else { IWshRuntimeLibrary.WshShellClass wshShell = new IWshRuntimeLibrary.WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(element.ParentElement.Path + element.AssociationURI); if (shortcut != null) { element.Path = shortcut.TargetPath + System.IO.Path.DirectorySeparatorChar; } if (Properties.Settings.Default.ShowOutline) { element.ShowExpander = Visibility.Visible; } } break; case ElementType.Note: if (!element.IsRemoteHeading) { RemoveFolder(element); element.AssociationType = ElementAssociationType.None; element.AssociationURI = String.Empty; } else { element.AssociationType = ElementAssociationType.FolderShortcut; } element.Type = type; element.IsExpanded = false; element.LevelOfSynchronization = 0; break; }; return true; }
private void ChangeElementTextFontFamily(Element element) { TextBox tb = GetTextBox(element); if (tb != null) { tb.FontFamily = new FontFamily(element.FontFamily); } }
private void ChangeNoteElementTextFontFamily(Element element, FontFamily ff) { TextBox tb = GetTextBox(element); if (tb != null && element.Type == ElementType.Note) { tb.FontFamily = ff; } switch (element.Type) { case ElementType.Heading: foreach (Element ele in element.Elements) { ChangeNoteElementTextFontFamily(ele, ff); } break; } }
private void ResetPowerDButtons(Element element) { try { Microsoft.Windows.Controls.Ribbon.RibbonCommand pd_done = ((Microsoft.Windows.Controls.Ribbon.RibbonSplitButton)this.RibbonButton_PowerDDone).Command as Microsoft.Windows.Controls.Ribbon.RibbonCommand; Microsoft.Windows.Controls.Ribbon.RibbonCommand pd_defer = ((Microsoft.Windows.Controls.Ribbon.RibbonSplitButton)this.RibbonButton_PowerDDefer).Command as Microsoft.Windows.Controls.Ribbon.RibbonCommand; Microsoft.Windows.Controls.Ribbon.RibbonCommand pd_delegate = ((Microsoft.Windows.Controls.Ribbon.RibbonSplitButton)this.RibbonButton_PowerDDelegate).Command as Microsoft.Windows.Controls.Ribbon.RibbonCommand; Microsoft.Windows.Controls.Ribbon.RibbonCommand pd_delete = ((Microsoft.Windows.Controls.Ribbon.RibbonButton)this.RibbonButton_PowerDDelete).Command as Microsoft.Windows.Controls.Ribbon.RibbonCommand; switch (element.Type) { case ElementType.Heading: if (element.IsExpanded) { RibbonButton_PowerDDone.IsEnabled = false; RibbonButton_PowerDDefer.IsEnabled = false; RibbonButton_PowerDDelegate.IsEnabled = false; RibbonButton_PowerDDelete.IsEnabled = false; } else { RibbonButton_PowerDDone.IsEnabled = true; RibbonButton_PowerDDefer.IsEnabled = true; RibbonButton_PowerDDelegate.IsEnabled = true; RibbonButton_PowerDDelete.IsEnabled = true; } break; case ElementType.Note: if (element.IsCommandNote) { RibbonButton_PowerDDone.IsEnabled = false; RibbonButton_PowerDDefer.IsEnabled = false; RibbonButton_PowerDDelegate.IsEnabled = false; RibbonButton_PowerDDelete.IsEnabled = false; } else { RibbonButton_PowerDDone.IsEnabled = true; RibbonButton_PowerDDefer.IsEnabled = true; RibbonButton_PowerDDelegate.IsEnabled = true; RibbonButton_PowerDDelete.IsEnabled = true; } break; } if (element.PowerDStatus == PowerDStatus.Done && element.FontColor == ElementColor.SpringGreen.ToString()) { RibbonButton_PowerDDone.IsEnabled = false; RibbonButton_PowerDDefer.IsEnabled = false; RibbonButton_PowerDDelegate.IsEnabled = false; RibbonButton_PowerDDelete.IsEnabled = true; pd_delete.LabelTitle = PowerDDeleteType.Undo.ToString(); BitmapImage bi = new BitmapImage(new Uri("Images/powerd_undo.png", UriKind.Relative)); pd_delete.LargeImageSource = bi; } else if (element.PowerDStatus == PowerDStatus.Deferred && element.FontColor == ElementColor.Plum.ToString()) { RibbonButton_PowerDDone.IsEnabled = false; RibbonButton_PowerDDefer.IsEnabled = false; RibbonButton_PowerDDelegate.IsEnabled = false; RibbonButton_PowerDDelete.IsEnabled = true; pd_delete.LabelTitle = PowerDDeleteType.Undo.ToString(); BitmapImage bi = new BitmapImage(new Uri("Images/powerd_undo.png", UriKind.Relative)); pd_delete.LargeImageSource = bi; } else { pd_delete.LabelTitle = PowerDDeleteType.Delete.ToString(); BitmapImage bi = new BitmapImage(new Uri("Images/powerd_delete.png", UriKind.Relative)); pd_delete.LargeImageSource = bi; } SHOW_DONEDEFER_HANDLE = false; RibbonPowerDOption_ShowAssociationMarkedDone.IsChecked = element.ParentElement.ShowAssociationMarkedDone; RibbonPowerDOption_ShowAssociationMarkedDefer.IsChecked = element.ParentElement.ShowAssociationMarkedDefer; SHOW_DONEDEFER_HANDLE = true; } catch (Exception ex) { } }
private void ShowOrHideMarkedAssociation(Element element, PowerDStatus status, bool show) { if (show) { elementControl.ShowOrHidePowerDElement(element, status, show); elementControl.SyncHeadingElement(element); } else { elementControl.ShowOrHidePowerDElement(element, status, show); //elementControl.SyncHeadingElement(element); } }
public Element CreateNewElement(Element element) { Element newElement = CreateNewElement(element.Type, element.NoteText); newElement.AssociationType = element.AssociationType; newElement.AssociationURI = element.AssociationURI; newElement.FlagStatus = element.FlagStatus; newElement.FontColor = element.FontColor; newElement.IsExpanded = element.IsExpanded; newElement.IsVisible = element.IsVisible; newElement.LevelOfSynchronization = element.LevelOfSynchronization; newElement.ModifiedOn = element.ModifiedOn; newElement.PowerDStatus = element.PowerDStatus; newElement.PowerDTimeStamp = element.PowerDTimeStamp; newElement.ShowAssociationMarkedDefer = element.ShowAssociationMarkedDefer; newElement.ShowAssociationMarkedDone = element.ShowAssociationMarkedDone; newElement.StartDate = element.StartDate; newElement.Status = element.Status; newElement.TempData = element.TempData; return newElement; }
public void DeleteElement(Element element) { try { // Note with association AND remote Heading if (element.Status != ElementStatus.MissingAssociation && (element.IsRemoteHeading || (element.IsNote && element.HasAssociation))) { MoveAssociationToRecycleBin(element.AssociationURIFullPath); } if (element.IsLocalHeading) { MoveFolderToRecycleBin(element.Path); } RemoveElement(element, element.ParentElement); } catch (Exception ex) { //string message = "DeleteElement\n" + ex.Message; //OnOperationError(element, new OperationErrorEventArgs{ Message = message }); } finally { } }
public bool CreateFolder(Element element) { bool isFolderCreated = false; if (element.ParentElement.Path != root.Path) { DatabaseControl temp_dbControl = new DatabaseControl(element.ParentElement.Path); temp_dbControl.OpenConnection(); isFolderCreated = temp_dbControl.CreateFolder(element); temp_dbControl.CloseConnection(); } else { isFolderCreated = dbControl.CreateFolder(element); } return isFolderCreated; }
public Element CreateNewElement(ElementType type, string noteText) { Element newElement = new Element { NoteText = noteText, ParentElement = root, }; switch (type) { case ElementType.Heading: newElement.Type = type; newElement.FlagImageSource = String.Format("pack://application:,,,/{0};component/{1}", "Planz", "Images/normal.gif"); newElement.IsExpanded = false; newElement.Path = newElement.ParentElement.Path + HeadingNameConverter.ConvertFromHeadingNameToFolderName(newElement) + System.IO.Path.DirectorySeparatorChar; // Remove while spaces newElement.NoteText = newElement.NoteText.Trim(); if (!CreateFolder(newElement)) { newElement.Type = ElementType.Note; MessageBox.Show("The heading name is too long, please shorten the name and try again."); } else { if (Properties.Settings.Default.ShowOutline) { newElement.ShowExpander = Visibility.Visible; } } break; case ElementType.Note: newElement.Type = type; newElement.FlagImageSource = String.Format("pack://application:,,,/{0};component/{1}", "Planz", "Images/normal.gif"); break; }; return newElement; }
public bool CheckOpenFiles(Element element) { ArrayList openFileList; if (HasOpenFiles(element, out openFileList)) { if (hasOpenFileDelegate != null) { OnFindOpenFiles(openFileList, new EventArgs()); } return true; } return false; }
public void Check(Element element) { element.FlagStatus = FlagStatus.Check; element.FlagImageSource = String.Format("pack://application:,,,/{0};component/{1}", "Planz", "Images/check.gif"); UpdateElement(element); }
public void Check(Element element, bool removeFromToday) { Element today = GetTodayElement(); if (today != null) { Element toberemoved = null; foreach (Element ele in today.Elements) { if (ele.NoteText == element.NoteText && ele.AssociationType == ElementAssociationType.FolderShortcut) { toberemoved = ele; break; } } if (toberemoved != null) { if (removeFromToday) { DeleteElement(toberemoved); } else { Check(toberemoved); } } } Check(element); }
private int GetTextBoxSelectionStart(Element element) { TextBox target = null; FindTextBox(this.Plan, element.ID, ref target); return target.SelectionStart; }
public void Demote(Element element) { if (element.ParentElement.FirstChild == element) { switch (element.Type) { case ElementType.Heading: if (element.IsRemoteHeading) { ChangeElementType(ElementType.Note, ref element); element.Elements.Clear(); GC.Collect(); UpdateElement(element); } else { if (HasChildOrContent(element) == false) { ChangeElementType(ElementType.Note, ref element); UpdateElement(element); } } break; case ElementType.Note: break; }; } else { switch (element.Type) { case ElementType.Heading: if ((HasChildOrContent(element) == false) || (!element.IsLocalHeading && element.IsCollapsed)) { ChangeElementType(ElementType.Note, ref element); UpdateElement(element); } else { Element elementAbove = element.ElementAboveUnderSameParent; if (elementAbove != null) { if (elementAbove.Type == ElementType.Heading) { if (element.IsLocalHeading && (CheckOpenFiles(element) == true)) return; elementAbove.IsExpanded = true; UpdateElement(elementAbove); if (element.IsLocalHeading) { string previousPath = element.Path; element.Path = elementAbove.Path + HeadingNameConverter.ConvertFromHeadingNameToFolderName(element) + System.IO.Path.DirectorySeparatorChar; RemoveElement(element, element.ParentElement); InsertElement(element, elementAbove, elementAbove.Elements.Count); MoveFolder(element, previousPath); UpdateElement(element); } else { MoveElement(element, elementAbove, elementAbove.Elements.Count); } } else { return; } } } break; case ElementType.Note: Element elementAboveUnderSameParent = element.ElementAboveUnderSameParent; if (elementAboveUnderSameParent.Type == ElementType.Heading) { elementAboveUnderSameParent.IsExpanded = true; UpdateElement(elementAboveUnderSameParent); MoveElement(element, elementAboveUnderSameParent, elementAboveUnderSameParent.Elements.Count); } break; }; } }
private void HandleICC(Element element, ICCAssociationType type) { // Note: defaultName does NOT contain file extension string defaultName = String.Empty; bool insertBelow = true; TextBox tb = GetTextBox(element); if (tb.SelectionStart == 0 && tb.Text != String.Empty) { insertBelow = false; } if (tb.SelectedText != String.Empty) { defaultName = tb.SelectedText; insertBelow = true; } else { defaultName = element.NoteText; } if (defaultName.Length > StartProcess.MAX_EXTRACTNAME_LENGTH) defaultName = defaultName.Substring(0, StartProcess.MAX_EXTRACTNAME_LENGTH); while (defaultName.EndsWith(".")) defaultName = defaultName.TrimEnd('.'); switch (type) { case ICCAssociationType.TwitterUpdate: TwitterWindow tw = new TwitterWindow(defaultName); if (tw.ShowDialog().Value == true) { Tweet tweet = new Tweet{ Username = tw.Username, Password = tw.Password, Message = tw.Tweet, }; elementControl.ICC(element, tweet, insertBelow, type); } break; case ICCAssociationType.OutlookEmailMessage: if (defaultName.Trim() == String.Empty) { defaultName = "New Email"; } elementControl.ICC(element, defaultName, insertBelow, type); break; default: string fileFullName = element.Path + ICCFileNameHandler.GenerateFileName(defaultName, type); FileNameWindow fnw = new FileNameWindow(fileFullName, type); if (fnw.ShowDialog().Value == true) { elementControl.ICC(element, fnw.FileName, insertBelow, type); } break; }; GetFocusToElementTextBox(elementControl.CurrentElement, elementControl.CurrentElement.NoteText.Length, false, false); }
private void button_OK_Click(object sender, RoutedEventArgs e) { // return; // Click to save the note //none of URI or note is available, there is nothing to save if (newNoteText.Length == 0 && newInfoItem == null) return; bNoteModified = false; bSkipModifyConfirmation = false; //use the title as note, if only URI is available if (newInfoItem!=null && newNoteText.Length == 0 ) newNoteText = newInfoItem.Title; ComboBoxItem cbi_sel = (ComboBoxItem) comboBox_SaveLoc.SelectedItem; string xmlFileFullPath = cbi_sel.Tag.ToString(); Element parentElement = new Element { ParentElement = null, HeadImageSource = String.Empty, TailImageSource = String.Empty, NoteText = String.Empty, IsExpanded = true, Path = xmlFileFullPath, Type = ElementType.Heading, }; Element newElement = new Element { ParentElement = parentElement, HeadImageSource = String.Empty, TailImageSource = String.Empty, NoteText = newNoteText, IsExpanded = false, Path = xmlFileFullPath, Type = ElementType.Note, FontColor = ElementColor.Blue.ToString(), Status = ElementStatus.New, }; newElement.ParentElement = parentElement; newElement.Position = 0; if ((newInfoItem != null) && (bool)checkBox_URI.IsChecked) { ElementAssociationType newType; switch (newInfoItem.Type) { case InfoItemType.Email: newType = ElementAssociationType.Email; break; case InfoItemType.File: newType = ElementAssociationType.FileShortcut; break; case InfoItemType.Web: newType = ElementAssociationType.Web; break; default: newType = ElementAssociationType.None; break; } newElement.AssociationType = newType; } try { newElement.ParentElement.Elements.Insert(0, newElement); DatabaseControl temp_dbControl = new DatabaseControl(newElement.ParentElement.Path); temp_dbControl.OpenConnection(); temp_dbControl.InsertElementIntoXML(newElement); temp_dbControl.CloseConnection(); ElementControl elementControl = new ElementControl(newElement.ParentElement.Path); elementControl.CurrentElement = newElement; //if URI is available and selected, association will be added together with the note if ((newInfoItem!= null) && (bool)checkBox_URI.IsChecked) { elementControl.AddAssociation(newElement, newInfoItem.Uri, newElement.AssociationType, newNoteText); } string eventInfo = LogEventInfo.NoteText + LogControl.COMMA + newElement.NoteText; if ((bool)checkBox_URI.IsChecked) eventInfo += LogControl.DELIMITER + LogEventInfo.LinkStatus + LogControl.COMMA + "check"; else eventInfo += LogControl.DELIMITER + LogEventInfo.LinkStatus + LogControl.COMMA + "unCheck"; if(newInfoItem!=null && newInfoItem.Uri!=null) eventInfo += LogControl.DELIMITER + LogEventInfo.LinkedFile + LogControl.COMMA + newInfoItem.Uri; eventInfo += LogControl.DELIMITER + LogEventInfo.PutUnder + LogControl.COMMA + newElement.Path; LogControl.Write( elementControl.CurrentElement, LogEventAccess.QuickCapture, LogEventType.CreateNewNote, LogEventStatus.NULL, eventInfo); newInfoItem = null; } catch (Exception ex) { System.Windows.MessageBox.Show("QuickCapture_button_OK_Click\n" + ex.Message); LogControl.Write( newElement, LogEventAccess.QuickCapture, LogEventType.CreateNewNote, LogEventStatus.Error, LogEventInfo.ErrorMessage + LogControl.COMMA + ex.Message); } ReInitilize(); this.Visibility = Visibility.Hidden; this.ShowInTaskbar = true; }
private void ResizeElementTextBox(Element element, Dictionary<int, double> dict) { TextBox tb; Rect textRext; Point p; int level = element.Level; tb = GetTextBox(element); if (tb != null) { if (dict.ContainsKey(level)) { tb.Width = dict[level]; } else { textRext = tb.GetRectFromCharacterIndex(tb.Text.Length); p = tb.TranslatePoint(new Point(0, 0), this.Plan); tb.Width = this.Plan.ActualWidth - textRext.Width - p.X - TEXTBOX_RIGHT_MARGIN; dict.Add(level, tb.Width); } } switch (element.Type) { case ElementType.Heading: foreach (Element ele in element.Elements) { ResizeElementTextBox(ele, dict); } break; } }
private void ElementSelectAll(Element element) { SELECTALL_FOCUS_HANDLE = true; TextBox tb = GetTextBox(element); if (tb != null) { switch (element.Type) { case ElementType.Heading: foreach (Element ele in element.Elements) { ElementSelectAll(ele); } tb.Focus(); tb.SelectAll(); break; case ElementType.Note: tb.Focus(); tb.SelectAll(); break; } } }
private void ShowOutlineIcon(Element element, bool show) { if (show) { element.ShowFlag = Visibility.Visible; if (element.IsHeading) { element.ShowExpander = Visibility.Visible; foreach (Element ele in element.Elements) { ShowOutlineIcon(ele, show); } } else { element.HeadImageSource = HeadImageControl.Note_Unselected; } } else { if (element.FlagStatus == FlagStatus.Normal) { element.ShowFlag = Visibility.Hidden; } else { element.ShowFlag = Visibility.Visible; } if (element.IsHeading) { element.ShowExpander = Visibility.Hidden; foreach (Element ele in element.Elements) { ShowOutlineIcon(ele, show); } } else { element.HeadImageSource = HeadImageControl.Note_Empty; } } }
private void ElementUnselectAll(Element element) { SELECTALL_FOCUS_HANDLE = false; TextBox tb = GetTextBox(element); if (tb != null) { switch (element.Type) { case ElementType.Heading: foreach (Element ele in element.Elements) { ElementUnselectAll(ele); } tb.Focus(); tb.SelectionStart = tb.Text.Length; ElementTextBox_LostFocus(tb, new RoutedEventArgs()); break; case ElementType.Note: tb.Focus(); tb.SelectionStart = tb.Text.Length; ElementTextBox_LostFocus(tb, new RoutedEventArgs()); break; } } }
private void ChangeElementTextFontSize(Element element) { TextBox tb = GetTextBox(element); if (tb != null) { tb.FontSize = element.FontSize; } }
public void AddAssociation(Element element, string fileFullName, ElementAssociationType type, string text) { string noteText = String.Empty; string shortcutName = String.Empty; string folderPath = element.Path; string title = string.Empty; List<Element> emailAttachmentElementList = new List<Element>(); if (text != null) { noteText = text; if (noteText.Length > StartProcess.MAX_EXTRACTTEXT_LENGTH) { noteText = noteText.Substring(0, StartProcess.MAX_EXTRACTTEXT_LENGTH) + "..."; } title = noteText.Replace("/", "").Replace("\\", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "").Replace(":", ""); if (title.Length > StartProcess.MAX_EXTRACTNAME_LENGTH) title = title.Substring(0, StartProcess.MAX_EXTRACTNAME_LENGTH); while (title.EndsWith(".")) title.TrimEnd('.'); } if (type == ElementAssociationType.File) { } else if (type == ElementAssociationType.FileShortcut) { if (text == null) { noteText = noteText = System.IO.Path.GetFileNameWithoutExtension(fileFullName); title = noteText; } string fs_fileName = title + System.IO.Path.GetExtension(fileFullName); shortcutName = ShortcutNameConverter.GenerateShortcutNameFromFileName(fs_fileName, folderPath); } else if (type == ElementAssociationType.FolderShortcut) { if (fileFullName.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { fileFullName = fileFullName.Substring(0, fileFullName.Length - 1); } noteText = System.IO.Path.GetFileName(fileFullName); string fs_fileName = noteText; shortcutName = ShortcutNameConverter.GenerateShortcutNameFromFileName(fs_fileName, folderPath); } else if (type == ElementAssociationType.Web) { if (text == null) { ActiveWindow activeWindow = new ActiveWindow(); title = activeWindow.GetActiveWindowText(activeWindow.GetActiveWindowHandle()); if(title.Contains(" - Windows Internet Explorer")) { // IE int labelIndex1 = title.LastIndexOf(" - Windows Internet Explorer"); if (labelIndex1 != -1) { title = title.Remove(labelIndex1); noteText = title; } }else if(title.Contains(" - Mozilla Firefox")) { // Firefox int labelIndex2 = title.LastIndexOf(" - Mozilla Firefox"); if (labelIndex2 != -1) { title = title.Remove(labelIndex2); noteText = title; } }else { noteText = fileFullName; title = string.Empty; } if (noteText.Length > StartProcess.MAX_EXTRACTTEXT_LENGTH) { noteText = noteText.Substring(0, StartProcess.MAX_EXTRACTTEXT_LENGTH) + "..."; } } shortcutName = ShortcutNameConverter.GenerateShortcutNameFromWebTitle(title, folderPath); } else if (type == ElementAssociationType.Email) { Outlook.Application outlookApp = new Outlook.Application(); Outlook.MailItem mailItem = null; if (outlookApp.ActiveExplorer().Selection.Count > 0) { mailItem = outlookApp.ActiveExplorer().Selection[1] as Outlook.MailItem; if (mailItem == null) return; if (mailItem != null) { Element associatedElement = element; if (element.IsHeading && element.IsCollapsed) { associatedElement = element.ParentElement; } Regex byproduct = new Regex("att[0-9]+[.txt|.c]"); foreach (Outlook.Attachment attachment in mailItem.Attachments) { string attachmentFileName = attachment.FileName; if (!byproduct.IsMatch(attachmentFileName.ToLower())) { string fileNameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(attachmentFileName); string fileNameExt = System.IO.Path.GetExtension(attachmentFileName); string copyPath = associatedElement.Path + attachmentFileName; int index = 2; while (FileNameChecker.Exist(copyPath)) { copyPath = associatedElement.Path + fileNameWithoutExt + " (" + index.ToString() + ")" + fileNameExt; index++; } attachment.SaveAsFile(copyPath); Element attachmentElement = CreateNewElement(ElementType.Note, " --- " + fileNameWithoutExt); attachmentElement.AssociationType = ElementAssociationType.File; attachmentElement.AssociationURI = System.IO.Path.GetFileName(copyPath); attachmentElement.TailImageSource = FileTypeHandler.GetIcon((ElementAssociationType)attachmentElement.AssociationType, copyPath); emailAttachmentElementList.Add(attachmentElement); } } } } if ((fileFullName == null) && (mailItem != null)) { noteText = mailItem.Subject; if (noteText.Length > StartProcess.MAX_EXTRACTTEXT_LENGTH) { noteText = noteText.Substring(0, StartProcess.MAX_EXTRACTTEXT_LENGTH) + "..."; } fileFullName = mailItem.EntryID; shortcutName = ShortcutNameConverter.GenerateShortcutNameFromEmailSubject(mailItem.Subject, folderPath); } else { shortcutName = ShortcutNameConverter.GenerateShortcutNameFromEmailSubject(title, folderPath); } } switch (element.Type) { case ElementType.Heading: if (element.IsExpanded) { Element firstElement = CreateNewElement(ElementType.Note, noteText); InsertElement(firstElement, element, 0); AssignAssociationInfo(firstElement, fileFullName, shortcutName, type); currentElement = firstElement; } else { Element newElement = CreateNewElement(ElementType.Note, noteText); InsertElement(newElement, element.ParentElement, element.Position + 1); AssignAssociationInfo(newElement, fileFullName, shortcutName, type); currentElement = newElement; } break; case ElementType.Note: if (element.HasAssociation == false) { if (element.NoteText.Trim() == String.Empty) { element.NoteText = noteText; } AssignAssociationInfo(element, fileFullName, shortcutName, type); currentElement = element; } else { Element newElement = CreateNewElement(ElementType.Note, noteText); InsertElement(newElement, element.ParentElement, element.Position + 1); AssignAssociationInfo(newElement, fileFullName, shortcutName, type); currentElement = newElement; } break; }; int curr_index = currentElement.Position; foreach (Element emailAttachmentElement in emailAttachmentElementList) { InsertElement(emailAttachmentElement, currentElement.ParentElement, curr_index); curr_index++; } }
private void ChangeNoteElementTextFontSize(Element element, int size, double tailIconHeight) { element.TailImageHeight = tailIconHeight; element.TailImageWidth = tailIconHeight; TextBox tb = GetTextBox(element); if (tb != null && element.Type == ElementType.Note) { tb.FontSize = size; } switch (element.Type) { case ElementType.Heading: foreach (Element ele in element.Elements) { ChangeNoteElementTextFontSize(ele, size, tailIconHeight); } break; } }
private TextBox GetTextBox(Element element) { TextBox target = null; FindTextBox(this.Plan, element.ID, ref target); return target; }
private void GetFocusToElementTextBox( Element element, int cursor_pos, bool highlightChildren, bool bringToView) { if (element == null) { return; } UpdateLayout(); TextBox target = null; FindTextBox(this.Plan, element.ID, ref target); if (target != null) { target.Focus(); //Mouse.Capture(target, CaptureMode.Element); if (cursor_pos != -1) { target.SelectionStart = cursor_pos; } else { if (highlightChildren) { ElementUnselectAll(elementControl.PreviousElement); target.Focus(); ElementSelectAll(element); } else { target.Focus(); target.SelectAll(); } } if (bringToView) { Point p = target.TranslatePoint(new Point(0, 0), this.Plan); double offset = p.Y - this.Plan.ActualHeight; if ((offset <= 0 && Math.Abs(offset) <= this.Plan.ActualHeight / 3) || offset > 0) { ScrollViewer sv = null; FindScrollViewer(this.Plan, ref sv); sv.ScrollToVerticalOffset(sv.VerticalOffset + p.Y - this.Plan.ActualHeight / 3); } } } }
public void AddElement(Element newElement, Element parentElement) { if (FindElementByGuid(parentElement, newElement.ID) == null) { newElement.ParentElement = parentElement; parentElement.Elements.Add(newElement); } }