Ejemplo n.º 1
0
 private void IconButton_Click_3(object sender, RoutedEventArgs e)
 {
     try
     {
         var sfd = new SaveFileDialog
         {
             Filter = "Markdown Files (*.md)|*.md"
         };
         if (sfd.ShowDialog() == true)
         {
             //count up null: 25
             //Let's pretend to know a little about markdown 'lite' instead of manipulating string template which will make Team SH real clever
             var result   = StringBuffer.Empty;
             var mdra     = new MarkdownRendererAdapter(null, new InsetSDNSMarkdownRenderer(), null, null);
             var rthToken = new InlineContent(
                 ImmutableArray.Create((IMarkdownToken) new MarkdownTextToken(null, null, null, SourceInfo.Create($"{sfd.SafeFileName} generated by WPF_dnscrypt_proxy_md", null))));
             var rhToken = new MarkdownHeadingBlockToken(null, null, rthToken, null, 1, SourceInfo.Create(null, null));
             result += mdra.Render(rhToken);
             foreach (dynamic item in lv.Items)
             {
                 var thToken = new InlineContent(ImmutableArray.Create((IMarkdownToken) new MarkdownTextToken(null, null, null, SourceInfo.Create(item.Name, null))));
                 var hToken  = new MarkdownHeadingBlockToken(null, null, thToken, null, 2, SourceInfo.Create(null, null));
                 result += mdra.Render(hToken);
                 using (var stamp = GO_WriteStamp(JsonConvert.SerializeObject(item.STAMP)))
                 {
                     var sToken = new SDNSBlockToken(null, null, SourceInfo.Create(null, null), stamp);
                     result += mdra.Render(sToken);
                 }
             }
             File.WriteAllText(sfd.FileName, result);
             if (!GO_CreateSign(sfd.FileName))
             {
                 Xceed.Wpf.Toolkit.MessageBox.Show("Failed to create signature.");
             }
             else
             {
                 Xceed.Wpf.Toolkit.MessageBox.Show("Saved.");
             }
         }
     }
     catch (Exception ex)
     {
         Xceed.Wpf.Toolkit.MessageBox.Show(ex.ToString());
     }
 }