Exemplo n.º 1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(ConstantPool.AccessToken))
            {
                NavigationService.Navigate(new Uri("/Views/AuthorizeView.xaml", UriKind.Relative));
                return;
            }

            if (_isNewPage == false)
            {
                // 从新建页面返回
                var savedNotebook = Util.ReadLastSelectedNotebook();
                if (null != savedNotebook && null != NotebookList.SelectedNotebook)
                {
                    if (savedNotebook.Path != NotebookList.SelectedNotebook.Path)
                    {
                        NotebookList.SetSelectedNotebook(savedNotebook);
                    }
                }
                return;
            }

            InitNotebookList();

            if (ConstantPool.AutoSendErrorReport)
            {
                Util.SendErrorReportAsync();
            }

            _isNewPage = false;
        }
Exemplo n.º 2
0
        private void OnModifyNotebook()
        {
            Console.WriteLine("请输入NotebookId");
            int id = 0;

            if (int.TryParse(Console.ReadLine().Trim(), out id) && NotebookList.Contains(id))
            {
                SceneManager.Instance.PushScene(new NotebookPasswordScene(Username, Password, id));
            }
            else
            {
                Console.WriteLine("NotebookId 错误");
                Console.ReadKey();
            }
        }
Exemplo n.º 3
0
        public void UpdatePage(object sender, EventArgs e)
        {
            string userID = HandleLoginUserID.Value;
            Note   note;

            if (IsEdit)
            {
                note = GoogleFirestoreConnectionManager.GetNote(NoteID);
                if (HandleLoginUserID.Value != note.UserID)
                {
                    Response.Redirect("./Notebooks.aspx");
                }
                NoteText.Text = HttpUtility.UrlDecode(note.Text);
                NotebookID    = note.NotebookID;
                ExtractTextUpdatePanel.Update();
            }

            Notebooks = GoogleFirestoreConnectionManager.GetNotebooks(userID);
            string unfiledId = null;

            foreach (Notebook notebook in Notebooks)
            {
                NotebookList.Items.Add(new ListItem(HttpUtility.UrlDecode(notebook.Title), notebook.ID));
                if (HttpUtility.UrlDecode(notebook.Title) == "Unfiled Notes")
                {
                    unfiledId = notebook.ID;
                }
            }
            NotebookList.DataBind();
            if (NotebookID != null)
            {
                NotebookList.SelectedValue = NotebookID;
            }
            else if (unfiledId != null)
            {
                NotebookList.SelectedValue = unfiledId;
            }
            DropdownUpdatePanel.Update();
        }
Exemplo n.º 4
0
        private void InitNotebookList()
        {
            NotebookList.NotebookSelectionChanged += () =>
            {
                if (null == NotebookList.SelectedNotebook)
                {
                    return;
                }
                NoteList.UpdateBind(NotebookList.SelectedNotebook);
                NoteListPivotItem.Header = new TextBlock
                {
                    Text       = NotebookList.SelectedNotebook.Name,
                    FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei"),
                    FontSize   = 40,
                    Margin     = new Thickness(0, 10, 0, 0),
                    Foreground = new SolidColorBrush(Colors.Black)
                };
                MainPivot.SelectedItem = NoteListPivotItem;
            };

            NotebookList.SetSelectedNotebook(NotebookList.GetDefaultSelectedNotebook());
        }
        /// <summary>
        /// 加载日记本页
        /// </summary>
        private void LoadNotebookPage()
        {
            if (GlobalVar.notebook_id <= 0)
            {
                MessageBox.Show("请选择日记本!");
            }

            if (isEnd)
            {
                return;
            }

            IDictionary <string, string> parameters = Request.getParameters();

            parameters.Add("notebook_id", GlobalVar.notebook_id.ToString());
            parameters.Add("start", start.ToString());
            parameters.Add("end", (start + limit).ToString());

            string resultStr = Http.Send(Request.baseUrl + Request.notebookList, "GET", parameters);

            NotebookList result = JsonConvert.DeserializeObject <NotebookList>(resultStr);

            foreach (NotebookList.Notebook noteBook in result.data)
            {
                this.list.Items.Add(noteBook);
                start++;
            }

            // 已经结束了
            if (result.data.Count == 0)
            {
                isEnd = true;
            }

            this.list.Items.Refresh();
        }
Exemplo n.º 6
0
        private async void OnSyncAppbarButtonClicked(object sender, EventArgs e)
        {
            try
            {
                var pivotItem = MainPivot.SelectedItem as PivotItem;
                if (null == pivotItem)
                {
                    return;
                }
                if (pivotItem.Name == null)
                {
                    return;
                }
                switch ((pivotItem.Name))
                {
                case "NoteListPivotItem":
                    using (var waitPopup = new WaitPopup("正在同步笔记中", this))
                    {
                        if (NotebookList.SelectedNotebook != null)
                        {
                            SyncCore.GetInst().SyncNoteChanged += (noteSyncEventArgs) =>
                            {
                                OnSyncNoteChanged(waitPopup, noteSyncEventArgs);
                            };
                            await SyncCore.GetInst().SyncNotebookNotesAsync(NotebookList.SelectedNotebook.Name,
                                                                            NotebookList.SelectedNotebook.Path, (type, msg) =>
                            {
                                switch (type)
                                {
                                case SyncCompletedType.All:
                                    Toast.Prompt("笔记同步完成");
                                    break;

                                case SyncCompletedType.AddedNote:
                                    waitPopup.SafeInvoke(() => waitPopup.SetTip(msg.ToString()));
                                    break;

                                case SyncCompletedType.Failed:
                                    Toast.Prompt("额,同步笔记失败,请稍后重试!");
                                    LoggerFactory.GetLogger().Error("同步笔记失败", (Exception)msg);
                                    break;
                                }
                            });

                            // 取消事件订阅
                            SyncCore.GetInst().SyncNoteChanged -= (noteSyncEventArgs) =>
                            {
                                OnSyncNoteChanged(waitPopup, noteSyncEventArgs);
                            };
                        }
                        else
                        {
                            Toast.Prompt("额,没有选择任何笔记本欸!");
                        }
                    }
                    break;

                case "NotebookPivotItem":
                    using (new WaitPopup("正在同步笔记本列表", this))
                    {
                        await NotebookList.SycnNotebooksAsync();

                        NotebookList.SetSelectedNotebook(NotebookList.GetDefaultSelectedNotebook());
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                LoggerFactory.GetLogger().Error("同步发生错误", ex);
                Toast.Prompt("额,发生不可预知的错误,请稍后重试!");
            }
        }
 private void NotebookList_Loaded(object sender, RoutedEventArgs e)
 {
     Notebook = NotebookList.FindNotebookEntity(_notebookPath);
     NotebookList.SetSelectedNotebook(Notebook);
 }