Beispiel #1
0
        public static string GetSummaryText(MemoInfo info)
        {
            var canvas = new EditorCanvas();

            MemoSerializeUtil.LoadEditor(canvas, info.MementoId);

            try {
                return(GetSummaryText(canvas));
            } finally {
                canvas.Dispose();
            }
        }
        internal static IEnumerable <MemoInfo> RecoverMemoInfosFromMemento(Action <int> reportProgress)
        {
            Contract.Requires(reportProgress != null);

            var ret = new List <MemoInfo>();

            /// mementoの取得
            var mementoIds = MemopadApplication.Instance.MemoAccessor.GetMementoIds();
            var len        = mementoIds.Count();
            var i          = 0;

            foreach (var mementoId in mementoIds)
            {
                var canvas = new EditorCanvas();

                try {
                    LoadEditor(canvas, mementoId);

                    var memo = canvas.EditorContent as Memo;

                    if (memo != null)
                    {
                        var title  = memo.Title;
                        var memoId = MemopadApplication.Instance.Container.GetId(memo);

                        var info = new MemoInfo();
                        info.Title     = title;
                        info.MemoId    = memoId;
                        info.MementoId = mementoId;

                        ret.Add(info);
                    }
                } catch (Exception e) {
                    Logger.Warn("Restore failed mementoId=" + mementoId, e);
                } finally {
                    canvas.Dispose();
                }

                ++i;
                if (reportProgress != null)
                {
                    reportProgress(i * 100 / len);
                }
            }

            reportProgress(100);

            return(ret);
        }