Exemplo n.º 1
0
 private static void notebookCreated(NotebookEntity obj)
 {
     lock (SyncObj)
     {
         NotebookCollection.Add(obj);
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 private void SetNotebookForeColor(NotebookEntity entity, Color foreColor)
 {
     if (null == entity)
     {
         return;
     }
     entity.ForeColor = foreColor;
 }
Exemplo n.º 4
0
 internal static void SaveLastSelectedNotebook(NotebookEntity notebookEntity)
 {
     if (System.ComponentModel.DesignerProperties.IsInDesignTool)
     {
         return;
     }
     IsolatedStorageSettings.ApplicationSettings[ConstantPool.LastSelectedNotebookKey] = notebookEntity;
     IsolatedStorageSettings.ApplicationSettings.Save();
 }
        void NotebookList_NotebookTapped()
        {
            _notebookPath = NotebookList.SelectedNotebook.Path;
            Notebook      = NotebookList.SelectedNotebook;

            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }
 private void RestoreState()
 {
     if (State.ContainsKey("_notebookPath"))
     {
         _notebookPath = (string)State["_notebookPath"];
     }
     if (State.ContainsKey("Notebook"))
     {
         Notebook = (NotebookEntity)State["Notebook"];
     }
 }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
     }
 }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
0
        private void bindNoteList(NotebookEntity notebookEntity)
        {
            if (null == notebookEntity)
            {
                return;
            }

            if (!Deployment.Current.Dispatcher.CheckAccess())
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    getNoteCollectionAndPopulateListUsingTimer(notebookEntity);
                });
            }
            else
            {
                getNoteCollectionAndPopulateListUsingTimer(notebookEntity);
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public async Task <JsonResult> NewNotebookAsync(string notebookName)
        {
            if (String.IsNullOrEmpty(notebookName))
            {
                throw new ArgumentNullException("[notebookName] is null or empty.");
            }

            var userId = userManager.GetUserId(this.User);
            var entity = new NotebookEntity()
            {
                Id          = Guid.NewGuid(),
                UserId      = new Guid(userId),
                Name        = notebookName,
                DateCreated = DateTime.UtcNow,
                DateUpdated = DateTime.UtcNow
            };

            var result = await notebookRepository.AddAsync(entity);

            return(Json(new { success = true, responseText = result.Id.ToString() }));
        }
Exemplo n.º 13
0
        private NotebookViewModel MapNotebookEntityToNotebookViewModel(NotebookEntity entity, Guid?selectedPage = null)
        {
            var pages = new List <PageViewModel>();

            if (entity.Pages != null && entity.Pages.Count() > 0)
            {
                foreach (var pageEntity in entity.Pages)
                {
                    pages.Add(MapPageEntityToPageViewModel(pageEntity));
                }
            }

            var vm = new NotebookViewModel
            {
                Id           = entity.Id,
                Name         = entity.Name,
                Pages        = pages,
                SelectedPage = selectedPage ?? pages.FirstOrDefault()?.Id
            };

            return(vm);
        }
Exemplo n.º 14
0
 private void NotebookList_Loaded(object sender, RoutedEventArgs e)
 {
     Notebook = NotebookList.FindNotebookEntity(_notebookPath);
     NotebookList.SetSelectedNotebook(Notebook);
 }