コード例 #1
0
ファイル: FrmMain.cs プロジェクト: hhqqnu/CloudNotes
 private void ClearWorkspace()
 {
     if (this.workspace != null)
     {
         this.workspace.PropertyChanged -= this.workspace_PropertyChanged;
         this.workspace = null;
     }
 }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: hhqqnu/CloudNotes
 private async Task LoadNoteAsync(Guid id)
 {
     using (var dataAccessProxy = this.CreateDataAccessProxy())
     {
         this.currentNote = await dataAccessProxy.GetNoteAsync(id);
     }
     this.ClearWorkspace();
     this.workspace = new Workspace(this.currentNote);
     this.workspace.PropertyChanged += this.workspace_PropertyChanged;
     this.lblTitle.Text = this.workspace.Title;
     var datePublished = this.workspace.DatePublished;
     this.lblDatePublished.Text = datePublished.ToLocalTime()
         .ToString("F", new CultureInfo(this.settings.General.Language));
     this.htmlEditor.Html = this.workspace.Content;
     this.htmlEditor.Enabled = true;
     this.tbtnSave.Enabled = false;
     this.mnuSave.Enabled = false;
     this.mnuPrint.Enabled = true;
     if (this.mnuSaveAs != null)
     {
         this.mnuSaveAs.Enabled = true;
     }
 }
コード例 #3
0
ファイル: FrmMain.cs プロジェクト: hhqqnu/CloudNotes
        public async Task ImportNote(Note note, bool rethrow = false)
        {
            Type[] exceptionTypes = null;
            if (rethrow)
            {
                exceptionTypes = new[] {typeof (NoteAlreadyExistsException)};
            }
            await SafeExecutionContext.ExecuteAsync(this, async () =>
            {
                var existingNoteTitles = this.ExistingNotesTitle;
                if (existingNoteTitles.Contains(note.Title))
                {
                    throw new NoteAlreadyExistsException(Resources.TitleExists);
                }

                var canceled = await this.SaveWorkspaceAsync();
                if (!canceled)
                {
                    this.ClearWorkspace();
                    note.Content = string.IsNullOrEmpty(note.Content) ? string.Empty : crypto.Encrypt(note.Content);
                    this.workspace = new Workspace(note);
                    this.workspace.PropertyChanged += this.workspace_PropertyChanged;
                    await this.SaveWorkspaceSlientlyAsync();
                    await this.LoadNotesAsync();
                }
            },
                () =>
                {
                    this.slblStatus.Text = Resources.Importing;
                    this.sp.Visible = true;
                },
                () => this.sp.Visible = false, exceptionTypes);
        }