예제 #1
0
 private static void notebookCreated(NotebookEntity obj)
 {
     lock (SyncObj)
     {
         NotebookCollection.Add(obj);
     }
 }
예제 #2
0
 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);
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
 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);
 }
예제 #10
0
 private void RestoreState()
 {
     if (State.ContainsKey("_notebookPath"))
     {
         _notebookPath = (string)State["_notebookPath"];
     }
     if (State.ContainsKey("Notebook"))
     {
         Notebook = (NotebookEntity)State["Notebook"];
     }
 }
예제 #11
0
 private void SetNotebookForeColor(NotebookEntity entity, Color foreColor)
 {
     if (null == entity)
     {
         return;
     }
     entity.ForeColor = foreColor;
 }
예제 #12
0
 private void getNoteCollectionAndPopulateListUsingTimer(NotebookEntity notebookEntity)
 {
     Debug.WriteLine("getNoteCollectionAndPopulateListUsingTimer tid:{0}", Thread.CurrentThread.ManagedThreadId);
     NoteListControl.ItemsSource.Clear();
     var notes = NoteListCache.GetNoteCollection(notebookEntity.Path);
     populateListUsingTimer(notes);
 }
예제 #13
0
        private void bindNoteList(NotebookEntity notebookEntity)
        {
            if (null == notebookEntity)
            {
                return;
            }

            if (!Deployment.Current.Dispatcher.CheckAccess())
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    getNoteCollectionAndPopulateListUsingTimer(notebookEntity);
                });
            }
            else
            {
                getNoteCollectionAndPopulateListUsingTimer(notebookEntity);
            }
        }
예제 #14
0
파일: Util.cs 프로젝트: ciker/WPYoudaonNote
 internal static void SaveLastSelectedNotebook(NotebookEntity notebookEntity)
 {
     if (System.ComponentModel.DesignerProperties.IsInDesignTool) return;
     IsolatedStorageSettings.ApplicationSettings[ConstantPool.LastSelectedNotebookKey] = notebookEntity;
     IsolatedStorageSettings.ApplicationSettings.Save();
 }