public void OpenMemo(MemoInfo info, bool background, bool enabled) { if (_content != null && info == _content.MemoInfo) { return; } _content = CreateMemoPageContent(info); _content.SetCompact(true); var canvas = _content.EditorCanvas; MemoSerializeUtil.LoadEditor(canvas, info.MementoId); _content.Memo.AccessedDate = DateTime.Now; _content.Enabled = enabled; Controls.Add(_content); var caret = canvas.Caret; caret.Position = MemopadConsts.DefaultCaretPosition; caret.Show(); canvas.RootEditor.Content.RequestSelect(SelectKind.True, true); canvas.Select(); var app = MemopadApplication.Instance; var memo = app.Container.Find <Memo>(_MemoInfo.MemoId); var bytes = app.Container.LoadExtendedBinaryData(memo, "FusenBounds"); var bounds = Rectangle.Empty; if (bytes != null) { StartPosition = FormStartPosition.Manual; bounds = (Rectangle)BinaryFormatterUtil.FromBytes(bytes); Bounds = bounds; } Text = _content.Title; Show(); if (bytes != null) { /// なぜかShow()でHeightが+2されてしまうのでもう一度設定 Bounds = bounds; } if (background) { User32PI.SetActiveWindow(MemopadApplication.Instance.MainForm.Handle); } InitToolStripForm(!background); }
private void DoProccessAsync(object sender, DoWorkEventArgs dwe) { var app = MemopadApplication.Instance; lock (app._Lock) { var worker = (BackgroundWorker)sender; try { var action = (Action <EditorCanvas, Memo, MemoInfo>)dwe.Argument; var infos = app.MemoInfos; var count = app.MemoInfoCount; var i = 0; foreach (var info in infos) { if (worker.CancellationPending) { dwe.Cancel = true; break; } var memo = app.Container.Find <Memo>(info.MemoId); if (memo == null) { continue; } Action a = () => { using (var canvas = new EditorCanvas()) { Application.DoEvents(); MemoSerializeUtil.LoadEditor(canvas, info.MementoId); Application.DoEvents(); action(canvas, memo, info); Application.DoEvents(); } }; app.MainForm.Invoke(a); worker.ReportProgress(i * 100 / count); ++i; } } catch (Exception e) { Logger.Warn("Export failed", e); throw; } } }