2018-2-13-win10-UWP-Markdown-含源代码
| title | author | date | CreateTime | categories |
|---|---|---|---|---|
|
win10 UWP Markdown 含源代码
|
lindexi
|
2018-2-13 17:23:3 +0800
|
2018-2-13 17:23:3 +0800
|
Win10 UWP
|
Windows下没有比较好的Markdown编辑器
我就自己写一个
csdn的Markdown很好,就是我需要截图保存有麻烦
需要把我的截图保存在本地,然后上传
这个过程比较麻烦
csdn的图没法外链
我想把自己的博客放到github,发现都没有图片
我自己写了的,可以把截图保存为图片,放到用户位置
然后插入
拖入图片也插入

界面有编辑和设置
编辑由TopAppBar,TextBox作为输入和TextBlock显示
拖入文件可以使用Drop
在Grid写Drop="{x:Bind view.dropimg}" DragOver="Grid_DragOver"
Grid要AllowDrop="True"
在MainPage.xaml.cs
private void Grid_DragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
e.DragUIOverride.Caption = "打开";
e.Handled = true;
}

在viewModel
public async void dropimg(object sender, Windows.UI.Xaml.DragEventArgs e)
dropimg 处理拖进来的DataPackageView
var defer = e.GetDeferral();
try
{
DataPackageView dataView = e.DataView;
string str = await _m.clipboard(dataView);
tianjia(str);
}
finally
{
defer.Complete();
}
文件有
MainPage.xaml
MainPage.xaml.cs
option.xaml
option.xaml.cs
viewModel.cs
model.cs
notify_property.cs
其中notify_property.cs提供继承通知UI改变值
model包括
正在编辑文件file
保存位置folder
其中folder根据StorageApplicationPermissions.FutureAccessList获得用户位置。
可以访问的路径不多,因为一个程序可以访问文件路径多,不安全。如果每次放在一个不是程序目录的位置,都要用户设置,很麻烦。在用户第一次使用,让用户选择一个位置,然后应用程序可以直接访问用户选择的这个,不用每次都选择。
用户输入text
标题 name
其中text和name都是public string _text;

这样是在viewModel使用,可以OnPropertyChanged();
writetext是用户能输入,在没有设置用户位置,不能输入
_open是否打开
public async Task clipboard(DataPackageView con)
处理剪贴板和拖入内容
本来我是处理剪贴板,因为拖入也是DataPackageView
public async Task<string> clipboard(DataPackageView con)
{
string str = string.Empty;
//文本
if (con.Contains(StandardDataFormats.Text))
{
str = await con.GetTextAsync();
//tianjiatext(str);
return str;
}
//图片
if (con.Contains(StandardDataFormats.Bitmap))
{
RandomAccessStreamReference img = await con.GetBitmapAsync();
var imgstream = await img.OpenReadAsync();
Windows.UI.Xaml.Media.Imaging.BitmapImage bitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
bitmap.SetSource(imgstream);
Windows.UI.Xaml.Media.Imaging.WriteableBitmap src = new Windows.UI.Xaml.Media.Imaging.WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight);
src.SetSource(imgstream);
Windows.Graphics.Imaging.BitmapDecoder decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(imgstream);
Windows.Graphics.Imaging.PixelDataProvider pxprd = await decoder.GetPixelDataAsync(Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8, Windows.Graphics.Imaging.BitmapAlphaMode.Straight, new Windows.Graphics.Imaging.BitmapTransform(), Windows.Graphics.Imaging.ExifOrientationMode.RespectExifOrientation, Windows.Graphics.Imaging.ColorManagementMode.DoNotColorManage);
byte[] buffer = pxprd.DetachPixelData();
str = "image";
StorageFolder folder = await _folder.GetFolderAsync(str);
StorageFile file = await folder.CreateFileAsync(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".png", CreationCollisionOption.GenerateUniqueName);
using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
var encoder = await Windows.Graphics.Imaging.BitmapEncoder.CreateAsync(Windows.Graphics.Imaging.BitmapEncoder.PngEncoderId, fileStream);
encoder.SetPixelData(Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8, Windows.Graphics.Imaging.BitmapAlphaMode.Straight, decoder.PixelWidth, decoder.PixelHeight, decoder.DpiX, decoder.DpiY, buffer);
await encoder.FlushAsync();
str = $"";
}
}
//文件
if (con.Contains(StandardDataFormats.StorageItems))
{
var filelist = await con.GetStorageItemsAsync();
StorageFile file = filelist.OfType<StorageFile>().First();
return await imgfolder(file);
}
return str;
}
返回string是因为要把str插入到text,需要有Textbox光标插入
插入文件
public async Task<string> imgfolder(StorageFile file)
{
string str = "image";
StorageFolder image = null;
try
{
image = await _folder.GetFolderAsync(str);
}
catch
{
}
if (image == null)
{
image = await _folder.CreateFolderAsync(str, CreationCollisionOption.OpenIfExists);
}
file = await file.CopyAsync(image, file.Name, NameCollisionOption.GenerateUniqueName);
if (file.FileType == ".png" || file.FileType == ".jpg")
{
str = $"";
return str;
}
else
{
str = $"[{file.Name}](image/{file.Name})";
return str;
}
}
开始我没有用文件
拖入和剪贴板只用第一个文件
public async void accessfolder(StorageFolder folder)
更改用户位置
public async void storage()
保存
在程序运行
folder = await Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.GetFolderAsync(Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Entries[0].Token);
viewModel.cs
public string text
{
set
{
_m._text = value;
OnPropertyChanged();
}
get
{
return _m._text;
}
}
public string name
{
set
{
_m._name = value;
OnPropertyChanged();
}
get
{
return _m._name;
}
}
本来绑Textbox SelectionStart
SelectionStart错误
要用SelectionStart,只能public Action<int, int> selectchange;
在MainPage.xaml.cs
private void selectchange(int select, int selecti)
{
text.SelectionStart = select;
text.SelectionLength = selecti;
}
因为选择可以把

select Textbox选择的插入
clipboard 保存剪贴板
storage 保存
accessfolder 更改用户位置
public async void accessfolder()
{
FolderPicker pick = new FolderPicker();
pick.FileTypeFilter.Add("*");
StorageFolder folder = await pick.PickSingleFolderAsync();
if (folder != null)
{
_m.accessfolder(folder);
}
addressfolder = string.Empty;
}
model _m
private void tianjia(string str)
把str添加text
MainPage.xaml
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" AllowDrop="True" Drop="{x:Bind view.dropimg}" DragOver="Grid_DragOver">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition />
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBox Text="{x:Bind view.name,Mode=TwoWay}" Grid.Row="0" Margin="10,10,10,10"/>
<TextBox x:Name="text" Text="{Binding Path=text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="10,10,10,10" Grid.Row="1" TextWrapping="Wrap" AcceptsReturn="True" IsReadOnly="{x:Bind view.writetext,Mode=OneWay}" SelectionChanged="text_SelectionChanged"/>
<!--<RichEditBox x:Name="rtext" Margin="10,10,10,10"/>-->
<TextBlock Text="{x:Bind view.reminder,Mode=OneWay}" Grid.Row="2" Margin="10,10,10,10" TextWrapping="Wrap"/>
<!--<Button Content="确定" Click="{x:Bind view.property}" Margin="121,300,0,308"/>-->
</Grid>
<Page.TopAppBar>
<CommandBar>
<!--<AppBarButton Icon="Add" Content="新建" Click="{x:Bind view.fileaddress}"/>-->
<AppBarButton Icon="OpenFile" Content="打开" Click="{x:Bind view.file_open}" />
<AppBarButton Icon="Save" Content="保存" Click="{x:Bind view.storage}"/>
<AppBarButton Icon="Setting" Content="设置" Click="option"/>
</CommandBar>
</Page.TopAppBar>
public sealed partial class MainPage
{
viewModel view;
public MainPage()
{
this.InitializeComponent();
text.Paste += Text_Paste;
}
private void Text_Paste(object sender, TextControlPasteEventArgs e)
{
view.clipboard(e);
}
private void Grid_DragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
e.DragUIOverride.Caption = "打开";
e.Handled = true;
}
private void text_SelectionChanged(object sender, RoutedEventArgs e)
{
view.select = text.SelectionStart;
}
private void selectchange(int select, int selecti)
{
text.SelectionStart = select;
text.SelectionLength = selecti;
}
private bool _ctrl;
private void text_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key.Equals(Windows.System.VirtualKey.Control))
{
_ctrl = true;
}
else if (e.Key == Windows.System.VirtualKey.V && _ctrl)
{
}
if (_ctrl)
{
if (e.Key == Windows.System.VirtualKey.Z)
{
}
}
e.Handled = true;
}
private void text_KeyUp(object sender, KeyRoutedEventArgs e)
{
if (e.Key.Equals(Windows.System.VirtualKey.Control))
{
_ctrl = false;
}
}
private void option(object sender, RoutedEventArgs e)
{
view.storage();
Frame frame = Window.Current.Content as Frame;
frame.Navigate(typeof(option), view);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is viewModel)
{
view = e.Parameter as viewModel;
DataContext = view;
}
else
{
view = new viewModel();
view.selectchange = selectchange;
this.DataContext = view;
}
}
}

发布
登录


在我的应用
.png)
填名字
.png)
本来想写Markdown
不过自己做的不是很好,不敢,就写win
有人发了Markdown应用

点击开始提交

价格免费

在visual studio

关联

.png)

选择创建的Markdown

得到
produproperty_StoreKey.pfx
在属性

没有密码

.png)

.png)
配置


把produproperty_1.1.0.0_x86_x64_arm_bundle.appxupload上传




.png)
2018-2-13-win10-UWP-Markdown-含源代码的更多相关文章
- win10 UWP Markdown 含源代码
Windows下没有比较好的Markdown编辑器 我就自己写一个 csdn的Markdown很好,就是我需要截图保存有麻烦 需要把我的截图保存在本地,然后上传 这个过程比较麻烦 csdn的图没法外链 ...
- win10 UWP Markdown 含源码
Windows下没有比較好的Markdown编辑器 我就自己写一个 csdn的Markdown非常好,就是我须要截图保存有麻烦 须要把我的截图保存在本地,然后上传 这个过程比較麻烦 csdn的图没法外 ...
- 【广告】win10 uwp 水印图床 含代码
本文主要是广告我的软件. 图床可以加速大家写博客上传图片的时间,通过简化我们的操作来得到加速. 在写博客的时候,我们发现,我们需要上传一张图片,需要先打开图片,然后选择本地图片,然后上传. 但是我经常 ...
- win10 uwp 入门
UWP是什么我在这里就不说,本文主要是介绍如何入门UWP,也是合并我写的博客. 关于UWP介绍可以参见:http://lib.csdn.net/article/csharp/32451 首先需要申请一 ...
- 2018-8-9-win10-uwp-装机必备应用-含源代码
title author date CreateTime categories win10 uwp 装机必备应用 含源代码 lindexi 2018-8-9 9:7:31 +0800 2018-8-9 ...
- win10 uwp 使用 Microsoft.Graph 发送邮件
在 2018 年 10 月 13 号参加了 张队长 的 Office 365 训练营 学习如何开发 Office 365 插件和 OAuth 2.0 开发,于是我就使用 UWP 尝试使用 Micros ...
- win10 uwp 列表模板选择器
本文主要讲ListView等列表可以根据内容不同,使用不同模板的列表模板选择器,DataTemplateSelector. 如果在 UWP 需要定义某些列的显示和其他列不同,或者某些行的显示和其他行不 ...
- win10 uwp MVVM 轻量框架
如果在开发过程,遇到多个页面之间,需要传输信息,那么可能遇到设计的问题.如果因为一个页面内包含多个子页面和多个子页面之间的通信问题找不到一个好的解决方法,那么请看本文.如果因为ViewModel代码越 ...
- Win10 UWP版《芒果TV》v2.4.0直播超女,芒果台综艺一网打尽
Win10 UWP版<芒果TV>直播超女,芒果台综艺一网打尽 Win10版UWP<芒果TV>自2015年9月登录商店以来,一直在持续更新,积极改进,拥有芒果台视频的独家点播和直 ...
- win10 uwp 获得Slider拖动结束的值
原文:win10 uwp 获得Slider拖动结束的值 本文讲的是如何获得Slider移动结束的值,也就是触发移动后的值.如果我们监听ValueChanged,在我们鼠标放开之前,只要拖动不放,那么就 ...
随机推荐
- iOS 检测耳机插入/拔出
http://www.verydemo.com/demo_c134_i28481.html 开发过程中录音和播放这块碰到了一些问题,麻烦的主要有三个: 检测是否有声音输入设备 当有多个声音输出设备时, ...
- python 同名变量引用
- PHP Laravel系列之环境搭建( VirtualBox+Vagrant+Homestead+系列网址)
搭建环境从来都是阻挡一门新技能的最致命的硬伤,为了这个环境,我又是花费了半天的时间,各种问题层出不穷,下面基于网上的一些教程(我看到的都多少有些问题) 开始的时候是在实验楼这个平台上开始学习的,不过 ...
- Servlet FilterConfig
FilterConfig的对象由Web容器创建.这个对象可用于获取web.xml文件中Filter的配置信息 文件:index.html <!DOCTYPE html> <html& ...
- 集合--Set&&HashSet和TreeSet
特点:元素无序,不可重复 1.添加元素 set.add("tanlei"); set.addAll(Arrays.asList(44,"磊","磊&q ...
- 在 Linux Mint 19 上安装 zsh 和设置小键盘一步到位
在 Linux Mint 19 上安装 zsh 和设置小键盘 安装 zsh 并设置 zsh 为默认 shell 安装 sudo apt install zsh 设置 zsh 为默认 shell,注意没 ...
- 2016年中国的SaaS服务商企业研究
近年来,随着中国人口红利的消退及移动互联网红利的凸显,让中国的To C创业,尤其是O2O领域的创业经历了一波高潮.2015年末,一场"资本寒冬"让O2O创业趋于理性,但SaaS及T ...
- UVa 679 【思维题】
UVA 679 紫书P148例题. 题目大意:小球从一棵所有叶子深度相同的二叉树的顶点开始向下落,树开始所有节点都为0.若小球落到节点为0的则往左落,否则向右落.并且小球会改变它经过的节点,0变1,1 ...
- Vue电商后台管理系统项目第1天-基本环境搭建&登录功能
基本环境搭建完成 安装npm包:npm -S i vue vue-router axios element-ui 配置Eslint: 打开设置,搜索Eslint拓展,然后将下面代码覆盖进去即可 { , ...
- ORA错误查询手册
ORA-00910: 指定した長さがデータ型に対して長すぎます 原因: データ型CHARまたはRAWに対して指定した長さは.2000を超える値または4000を超える値であるため無効です. 処置: 指定 ...