<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                Windows下沒有比較好的Markdown編輯器 我就自己寫一個 csdn的Markdown很好,就是我需要截圖保存有麻煩 需要把我的截圖保存在本地,然后上傳 這個過程比較麻煩 csdn的圖沒法外鏈 我想把自己的博客放到github,發現都沒有圖片 我自己寫了的,可以把截圖保存為圖片,放到用戶位置 然后插入`![](image/file.png)` 拖入圖片也插入`![](image/file.png)` ![](https://box.kancloud.cn/2016-04-08_5707636e37eec.png) 界面有編輯和設置 編輯由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; } ~~~ ![](https://box.kancloud.cn/2016-04-08_5707636e608fa.png) 在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; ![](https://box.kancloud.cn/2016-04-08_5707636e828de.png) 這樣是在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 = $"![這里寫圖片描述](image/{file.Name})"; } } //文件 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 = $"![這里寫圖片描述](image/{file.Name})"; 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 selectchange; 在MainPage.xaml.cs ~~~ private void selectchange(int select, int selecti) { text.SelectionStart = select; text.SelectionLength = selecti; } ~~~ 因為選擇可以把`![這里寫圖片描述](image/{file.Name})` ![](https://box.kancloud.cn/2016-04-08_5707636e9b4ba.png) 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; } } } ~~~ ![](https://box.kancloud.cn/2016-04-08_5707636ead98c.png) ### [](https://github.com/lindexi/lindexi_gd/blob/master/%E5%8D%9A%E5%AE%A2/win10%20UWP%20Markdown%20%E5%90%AB%E6%BA%90%E4%BB%A3%E7%A0%81.md#發布)發布 [https://dev.windows.com/zh-cn](https://dev.windows.com/zh-cn) 登錄 ![](https://box.kancloud.cn/2016-04-08_5707636ec8b9e.png) 在我的應用 ![](https://box.kancloud.cn/2016-04-08_5707636edc01f.png) 填名字 ![](https://box.kancloud.cn/2016-04-08_5707636ef142c.png) 本來想寫Markdown 不過自己做的不是很好,不敢,就寫win 有人發了Markdown應用 ![](https://box.kancloud.cn/2016-04-08_5707636f20659.png) 點擊開始提交 ![](https://box.kancloud.cn/2016-04-08_5707636f30a78.png) 價格免費 ![](https://box.kancloud.cn/2016-04-08_5707636f4a180.png) 在visual studio ![](https://box.kancloud.cn/2016-04-08_5707636f5c820.png) 關聯 ![](https://box.kancloud.cn/2016-04-08_5707636f788e8.png) ![](https://box.kancloud.cn/2016-04-08_5707636f9f8ad.png) ![](https://box.kancloud.cn/2016-04-08_5707636fb7f45.png) 選擇創建的Markdown ![](https://box.kancloud.cn/2016-04-08_5707636fc8d93.png) 得到 produproperty_StoreKey.pfx 在屬性 ![](https://box.kancloud.cn/2016-04-08_5707636fdd321.png) 沒有密碼 ![](https://box.kancloud.cn/2016-04-08_57076370022df.png) ![](https://box.kancloud.cn/2016-04-08_5707637012d36.png) ![](https://box.kancloud.cn/2016-04-08_570763702cff7.png) ![](https://box.kancloud.cn/2016-04-08_57076370493cf.png) 配置 ![](https://box.kancloud.cn/2016-04-08_570763706067a.png) ![](https://box.kancloud.cn/2016-04-08_570763707caf6.png) 把produproperty_1.1.0.0_x86_x64_arm_bundle.appxupload上傳 ![](https://box.kancloud.cn/2016-04-08_570763709c5fb.png) ![](https://box.kancloud.cn/2016-04-08_57076370bf591.png) ![](https://box.kancloud.cn/2016-04-08_57076370ddb27.png) https://code.csdn.net/lindexi_gd/lindexi_gd/tree/master/%E5%8D%9A%E5%AE%A2/win10%20UWP%20Markdown%20%E5%90%AB%E6%BA%90%E4%BB%A3%E7%A0%81.md 源代碼 https://github.com/lindexi/Markdown
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看