private static void notebookCreated(NotebookEntity obj) { lock (SyncObj) { NotebookCollection.Add(obj); } }
public void UpdateBind(NotebookEntity notebookEntity) { Debug.WriteLine("UpdateBind occured,tid:{0}", Thread.CurrentThread.ManagedThreadId); if (null == notebookEntity) { Debug.WriteLine("NoteList.xaml.cs::UpdateBind notebookEntity 为空"); return; } _currentNotebookEntity = notebookEntity; bindNoteList(_currentNotebookEntity); }
static void NotebookListCache_NotebookCreated(NotebookEntity obj) { Debug.WriteLine("NotebookListCache::笔记本创建事件触发"); Debug.Assert(obj != null); if (!Deployment.Current.Dispatcher.CheckAccess()) { Deployment.Current.Dispatcher.BeginInvoke(() => { notebookCreated(obj); }); } else { notebookCreated(obj); } }
public void ModifyOrAddIfNotExistsAll(List <Notebook> notebooks) { if (null == notebooks) { throw new ArgumentNullException("notebooks"); } using (var dc = new MyDataContext()) { foreach (var nb in notebooks) { var notebookEntity = dc.NotebookTable.FirstOrDefault(n => n.Path == nb.Path); if (null == notebookEntity) { var entity = new NotebookEntity(nb); dc.NotebookTable.InsertOnSubmit(entity); if (NotebookCreated != null) { NotebookCreated(entity); } } else { if (notebookEntity.Name == nb.Name && notebookEntity.Path == nb.Path && notebookEntity.NotesNum == nb.NotesNum && notebookEntity.CreateTime == nb.CreateTime && notebookEntity.ModifyTime == nb.ModifyTime) { continue; } notebookEntity.Name = nb.Name; notebookEntity.Path = nb.Path; notebookEntity.NotesNum = nb.NotesNum; notebookEntity.CreateTime = nb.CreateTime; notebookEntity.ModifyTime = nb.ModifyTime; if (NotebookModified != null) { NotebookModified(notebookEntity); } } } dc.SafeSubmitChanges(); } }
public void SetSelectedNotebook(NotebookEntity notebookEntity) { if (null == notebookEntity) { lbNotebook.SelectedItem = null; Debug.WriteLine("NotebookList.xaml.cs::SetSelectedNotebook notebookEntity 为空"); return; } var findNotebook = _notebookSource.FirstOrDefault(entity => entity.Path.Equals(notebookEntity.Path)); if (null == findNotebook) { LoggerFactory.GetLogger().Warn("NotebookList.xaml.cs::SetSelectedNotebook 未能找到笔记名称为:" + notebookEntity.Name +" 的笔记实例"); return; } lbNotebook.SelectedItem = findNotebook; //lbNotebook_SelectionChanged(null, null); }
public void ModifyOrAddIfNotExistsAll(List<Notebook> notebooks) { if (null == notebooks) { throw new ArgumentNullException("notebooks"); } using (var dc = new MyDataContext()) { foreach (var nb in notebooks) { var notebookEntity = dc.NotebookTable.FirstOrDefault(n => n.Path == nb.Path); if (null == notebookEntity) { var entity = new NotebookEntity(nb); dc.NotebookTable.InsertOnSubmit(entity); if (NotebookCreated != null) { NotebookCreated(entity); } } else { if (notebookEntity.Name == nb.Name && notebookEntity.Path == nb.Path && notebookEntity.NotesNum == nb.NotesNum && notebookEntity.CreateTime == nb.CreateTime && notebookEntity.ModifyTime == nb.ModifyTime) continue; notebookEntity.Name = nb.Name; notebookEntity.Path = nb.Path; notebookEntity.NotesNum = nb.NotesNum; notebookEntity.CreateTime = nb.CreateTime; notebookEntity.ModifyTime = nb.ModifyTime; if (NotebookModified != null) { NotebookModified(notebookEntity); } } } dc.SafeSubmitChanges(); } }
private static void notebookModified(NotebookEntity obj) { lock (SyncObj) { var findNotebook = NotebookCollection.FirstOrDefault(nb => nb.Id == obj.Id); if (null == findNotebook) { return; } NotebookCollection.Remove(findNotebook); NotebookCollection.Add(obj); } }
void NotebookList_NotebookTapped() { _notebookPath = NotebookList.SelectedNotebook.Path; Notebook = NotebookList.SelectedNotebook; if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }
private void NotebookList_Loaded(object sender, RoutedEventArgs e) { Notebook = NotebookList.FindNotebookEntity(_notebookPath); NotebookList.SetSelectedNotebook(Notebook); }
private void RestoreState() { if (State.ContainsKey("_notebookPath")) { _notebookPath = (string)State["_notebookPath"]; } if (State.ContainsKey("Notebook")) { Notebook = (NotebookEntity)State["Notebook"]; } }
private void SetNotebookForeColor(NotebookEntity entity, Color foreColor) { if (null == entity) { return; } entity.ForeColor = foreColor; }
private void getNoteCollectionAndPopulateListUsingTimer(NotebookEntity notebookEntity) { Debug.WriteLine("getNoteCollectionAndPopulateListUsingTimer tid:{0}", Thread.CurrentThread.ManagedThreadId); NoteListControl.ItemsSource.Clear(); var notes = NoteListCache.GetNoteCollection(notebookEntity.Path); populateListUsingTimer(notes); }
private void bindNoteList(NotebookEntity notebookEntity) { if (null == notebookEntity) { return; } if (!Deployment.Current.Dispatcher.CheckAccess()) { Deployment.Current.Dispatcher.BeginInvoke(() => { getNoteCollectionAndPopulateListUsingTimer(notebookEntity); }); } else { getNoteCollectionAndPopulateListUsingTimer(notebookEntity); } }
internal static void SaveLastSelectedNotebook(NotebookEntity notebookEntity) { if (System.ComponentModel.DesignerProperties.IsInDesignTool) return; IsolatedStorageSettings.ApplicationSettings[ConstantPool.LastSelectedNotebookKey] = notebookEntity; IsolatedStorageSettings.ApplicationSettings.Save(); }