private void OnCopyData_PageXaml(object sender, RoutedEventArgs e) { var dp = new DataPackage(); if (WireDevice == null) { dp.SetText("No data and therefore no class"); } else { var str = GenerateCSharpClass.GeneratePageXaml(WireDevice); dp.SetText(str); } dp.Properties.Title = "Class to read and write Bluetooth data"; Clipboard.SetContent(dp); }
private void DisplaySelection() { string str; switch (SelectedOutput) { case "JSON": var jsonFormat = Newtonsoft.Json.Formatting.Indented; var jsonSettings = new Newtonsoft.Json.JsonSerializerSettings() { DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ContractResolver = IgnoreEmptyEnumerableResolver.Instance, }; str = Newtonsoft.Json.JsonConvert.SerializeObject(SelectedNameDevice, jsonFormat, jsonSettings); uiJsonText.Text = str; CopyToClipboard(str, "JSON device description"); break; case "Protocol_C#": str = GenerateCSharpClass.GenerateProtocol(SelectedNameDevice); uiJsonText.Text = str; CopyToClipboard(str, "C# device protocol"); break; case "Page_XAML": str = GenerateCSharpClass.GeneratePageXaml(SelectedNameDevice); uiJsonText.Text = str; CopyToClipboard(str, "C# device protocol"); break; case "Page_C#": str = GenerateCSharpClass.GeneratePageCSharp(SelectedNameDevice); uiJsonText.Text = str; CopyToClipboard(str, "C# device protocol"); break; } }