private void RibbonCommandRefresh_Executed(object sender, ExecutedRoutedEventArgs e) { LogEventAccess lea = LogEventAccess.Ribbon; if (sender is TextBox) { lea = LogEventAccess.Hotkey; } else { if (e.Source is Microsoft.Windows.Controls.Ribbon.RibbonButton) { lea = LogEventAccess.QuickAccessToolbar; } else if (e.Source is Microsoft.Windows.Controls.Ribbon.RibbonGroup) { lea = LogEventAccess.Ribbon; } } try { StartLoadingUI(); if (elementControl.CurrentElement != null) { elementControl.UpdateElement(elementControl.CurrentElement); elementControl.UpdateStatusChangedElementList(); Properties.Settings.Default.LastFocusedElementGuid = elementControl.CurrentElement.ID.ToString(); Properties.Settings.Default.Save(); } this.Plan.ItemsSource = null; this.NavigationTabList.ItemsSource = null; GC.Collect(); elementControl = new ElementControl(startPath); elementControl.fsSyncReporter += new FSSyncReporter(ElementControl_fsSyncReporter); elementControl.hasOpenFileDelegate += new HasOpenFileDelegate(ElementControl_hasOpenFileDelegate); elementControl.generalOperationErrorDelegate += new GeneralOperationErrorDelegate(ElementControl_generalOperationError); this.Plan.ItemsSource = elementControl.Root.Elements; LoadNavigationTab(); LogControl.Write( elementControl.Root, lea, LogEventType.Refresh, LogEventStatus.NULL, null); } catch (Exception ex) { MessageBox.Show("Oops!\nSomething unexpected happened, please close this Planz window and reopen."); //MessageBox.Show("RibbonCommandRefresh_Executed\n" + ex.Message); LogControl.Write( elementControl.Root, lea, LogEventType.Refresh, LogEventStatus.Error, LogEventInfo.ErrorMessage + LogControl.COMMA + ex.Message); } }
public MainWindow() { InitializeComponent(); // Show UI Loading StartLoadingUI(); this.PlanzMainWindow.Title = "Planz - " + this.startPath; // Setup StartProcess.CheckFirstTimeRunning(); elementControl = new ElementControl(startPath); elementControl.fsSyncReporter += new FSSyncReporter(ElementControl_fsSyncReporter); elementControl.hasOpenFileDelegate += new HasOpenFileDelegate(ElementControl_hasOpenFileDelegate); elementControl.generalOperationErrorDelegate += new GeneralOperationErrorDelegate(ElementControl_generalOperationError); // Load Plan this.Plan.ItemsSource = elementControl.Root.Elements; // Load Navigation Tab LoadNavigationTab(); // Load QC LoadQuickCapture(); }
public MainWindow(string startPath) { InitializeComponent(); // Window Text this.PlanzMainWindow.Title = "Planz - " + startPath; // Show UI Loading StartLoadingUI(); // Setup this.startPath = startPath; elementControl = new ElementControl(startPath); elementControl.fsSyncReporter += new FSSyncReporter(ElementControl_fsSyncReporter); elementControl.hasOpenFileDelegate += new HasOpenFileDelegate(ElementControl_hasOpenFileDelegate); elementControl.generalOperationErrorDelegate += new GeneralOperationErrorDelegate(ElementControl_generalOperationError); // Load Plan this.Plan.ItemsSource = elementControl.Root.Elements; // Load Navigation Tab LoadNavigationTab(); }
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 ArrayList GetOpenFileList(Element element) { ArrayList openFileList = new ArrayList(); switch (element.Type) { case ElementType.Heading: if (element.IsLocalHeading) { ElementControl temp_eleControl = new ElementControl(element.Path); foreach (Element ele in temp_eleControl.Root.Elements) { openFileList.AddRange(GetOpenFileList(ele)); } } break; case ElementType.Note: if (element.AssociationType == ElementAssociationType.File) { if (System.IO.File.Exists(element.AssociationURIFullPath)) { try { FileStream fs = System.IO.File.Open(element.AssociationURIFullPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read, System.IO.FileShare.None); fs.Close(); } catch (System.IO.IOException ex) { openFileList.Add(element.AssociationURIFullPath); } } } break; }; return openFileList; }
//Update the Today+ heading when the planz runs the first tiem at each day //Move deferred notes from date folder to Today+ public void UpdateToday() { Element todayPlus = GetTodayElement(); string todayJournalPath = JournalControl.GetJournalPath(DateTime.Now); ElementControl eleControl = new ElementControl(todayJournalPath + "\\"); Element today = eleControl.root; List<Element> eleList = new List<Element>(); foreach (Element ele in today.Elements) { if(ele.IsNote && ele.PowerDStatus==PowerDStatus.Deferred) eleList.Add(ele); } int index = 0; foreach (Element element in eleList) { element.PowerDStatus = PowerDStatus.None; eleControl.MoveElement(FindElementByGuid(today,element.ID), todayPlus, index); index++; } }
public void LabelWith(Element element, string path) { ElementControl temp_eleControl = new ElementControl(path); Element ele = new Element { ID = Guid.NewGuid(), ParentElement = temp_eleControl.Root, HeadImageSource = String.Empty, TailImageSource = String.Empty, NoteText = element.NoteText, Path = path, Type = ElementType.Note, Status = ElementStatus.New, FontColor = ElementColor.Blue.ToString(), Position = 0, }; string shortcutName = ShortcutNameConverter.GenerateShortcutNameFromFileName(element.AssociationURI, path); string shortcutPath = path + shortcutName; ele.AssociationType = ElementAssociationType.FolderShortcut; ele.AssociationURI = shortcutName; CreateShortcut(ele, element.Path, shortcutPath); temp_eleControl.Root.Elements.Insert(0, ele); DatabaseControl temp_dbControl = new DatabaseControl(path); temp_dbControl.OpenConnection(); temp_dbControl.InsertElementIntoXML(ele); temp_dbControl.CloseConnection(); temp_eleControl.UpdateElement(ele); string folderName, parentName, tempPath; int pos; char[] ds = { '\\' }; tempPath = path.TrimEnd(ds); pos = tempPath.LastIndexOfAny(ds); folderName = tempPath.Substring(pos + 1); tempPath = tempPath.Remove(pos); pos = tempPath.LastIndexOfAny(ds); parentName = tempPath.Substring(pos + 1); //string notifyText = "Labeled with \"" + System.IO.Path.GetFileName(targetPath) + "\" under \"" + System.IO.Path.Path.GetFileName(parent) + "\""; string notifyText = "Labeled with \"" + folderName + "\" under \"" + parentName + "\""; //add an note for notification Element notifyEle = new Element { ID = Guid.NewGuid(), ParentElement = element, NoteText = notifyText, Path = element.Path, Type = ElementType.Note, Status = ElementStatus.New, FontColor = ElementColor.SpringGreen.ToString(), Position = 0, }; /* shortcutName = ShortcutNameConverter.GenerateShortcutNameFromFileName(folderName, element.Path); shortcutPath = element.Path + shortcutName; notifyEle.AssociationType = ElementAssociationType.FolderShortcut; notifyEle.AssociationURI = shortcutName; CreateShortcut(notifyEle, path, shortcutPath); notifyEle.TailImageSource = FileTypeHandler.GetIcon(ElementAssociationType.FolderShortcut, notifyEle.AssociationURIFullPath); */ notifyEle.PowerDStatus = PowerDStatus.Done; notifyEle.PowerDTimeStamp = DateTime.Now; InsertElement(notifyEle, element, 0); UpdateElement(element); }