Beispiel #1
0
        /// <summary>
        /// 导出笔记
        /// </summary>
        /// <param name="parameter"></param>
        private void Export(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            byte b;

            if (!byte.TryParse(parameter.ToString(), out b))
            {
                return;
            }

            Logic.Enums.ExportTypes type = (Logic.Enums.ExportTypes)b;


            var fileConfig = new Framework.Common.Dialog.FileConfig
            {
                FileName = this.GetFileName(type),
                Filter   = this.GetFileFilter(type),
                Title    = "导出路径"
            };

            this.DialogService.SaveFile(fileConfig, stream =>
            {
                using (var writer = new StreamWriter(stream))
                {
                    switch (type)
                    {
                    case Logic.Enums.ExportTypes.PlainText:
                        writer.Write(this.Summary);
                        break;

                    case Logic.Enums.ExportTypes.Word:
                        writer.Write(this.Content);
                        break;

                    case Logic.Enums.ExportTypes.Html:
                        var converter = new MarkupConverter.MarkupConverter();
                        writer.Write(converter.ConvertRtfToHtml(this.Content));
                        break;
                    }
                }
            });
        }