private void SaveAsFile() { TabPageModel tabPage = MainWindow.tabControl.SelectedContent as TabPageModel; if (index != 0) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "XML files (*.xml)|*.xml"; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == true) { fileName = saveFileDialog1.FileName; if (Path.GetExtension(fileName) != ".xml") { MessageBox.Show("This is not xml file!", "Save error!"); return; } tabPage.FullPath = saveFileDialog1.FileName; tabPage.Header = Path.GetFileName(saveFileDialog1.FileName); listFileName[MainWindow.tabControl.SelectedIndex] = saveFileDialog1.FileName; BuildXml(); } } else { MessageBox.Show("Open file!"); } }
private void BuildXml() { if (index != 0) { XDocument xmlDoc = new XDocument(); XElement xmlRoot = new XElement("root"); XElement xmlThread; XAttribute attr; TabPageModel tabPage = MainWindow.tabControl.SelectedContent as TabPageModel; if (tabPage.Header[tabPage.Header.Length - 1] == '*') { tabPage.Header = Path.GetFileName(tabPage.FullPath); } foreach (TreeItemModel tim in tabPage.Items) { if (tim.ItemName == "thread") { xmlThread = new XElement(tim.ItemName); attr = new XAttribute("id", tim.Id); xmlThread.Add(attr); attr = new XAttribute("time", tim.Time); xmlThread.Add(attr); addNodeXml(tim, ref xmlThread); xmlRoot.Add(xmlThread); } } xmlDoc.Add(xmlRoot); xmlDoc.Save(tabPage.FullPath); } }
public override bool View(TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; return(false); }
public override bool View(TabPageModel tabPage) { AvalonEditTextOutput output = new AvalonEditTextOutput(); IHighlightingDefinition highlighting = null; tabPage.ShowTextView(textView => textView.RunWithCancellation( token => Task.Factory.StartNew( () => { try { // cache read text because stream will be closed after first read if (text == null) { using (var reader = new StreamReader(Data)) { text = reader.ReadToEnd(); } } output.Write(text); highlighting = null; } catch (Exception ex) { output.Write(ex.ToString()); } return(output); }, token) ).Then(t => textView.ShowNode(t, this, highlighting)) .HandleExceptions()); tabPage.SupportsLanguageSwitching = false; return(true); }
public override bool View(TabPageModel tabPage) { Stream s = Resource.TryOpenStream(); if (s != null && s.Length < DecompilerTextView.DefaultOutputLengthLimit) { s.Position = 0; FileType type = GuessFileType.DetectFileType(s); if (type != FileType.Binary) { s.Position = 0; AvalonEditTextOutput output = new AvalonEditTextOutput(); output.Title = Resource.Name; output.Write(FileReader.OpenStream(s, Encoding.UTF8).ReadToEnd()); string ext; if (type == FileType.Xml) { ext = ".xml"; } else { ext = Path.GetExtension(DecompilerTextView.CleanUpName(Resource.Name)); } tabPage.ShowTextView(textView => textView.ShowNode(output, this, HighlightingManager.Instance.GetDefinitionByExtension(ext))); tabPage.SupportsLanguageSwitching = false; return(true); } } return(false); }
public override bool View(TabPageModel tabPage) { try { AvalonEditTextOutput output = new AvalonEditTextOutput(); BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = OpenStream(); image.EndInit(); output.AddUIElement(() => new Image { Source = image }); output.WriteLine(); output.AddButton(Images.Save, Resources.Save, delegate { Save(null); }); tabPage.ShowTextView(textView => textView.ShowNode(output, this)); tabPage.SupportsLanguageSwitching = false; return(true); } catch (Exception) { return(false); } }
private void ExitProgramm() { if (index > 0) { TabPageModel tabPage = MainWindow.tabControl.SelectedContent as TabPageModel; ObservableCollection <TabPageModel> pageList = MainWindow.tabControl.ItemsSource as ObservableCollection <TabPageModel>; int i = 0; while (pageList.Count != 0) { MainWindow.tabControl.SelectedIndex = i; if (pageList[i].Header[pageList[i].Header.Length - 1] == '*') { var result = MessageBox.Show("Save file " + pageList[i].Header + "?", "Save", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Yes) { BuildXml(); closeTab(); } else if (result == MessageBoxResult.No) { closeTab(); } } else { closeTab(); } } } Application.Current.Shutdown(); }
public override bool View(TabPageModel tabPage) { IHighlightingDefinition highlighting = null; tabPage.SupportsLanguageSwitching = false; tabPage.ShowTextView(textView => textView.RunWithCancellation( token => Task.Factory.StartNew( () => { AvalonEditTextOutput output = new AvalonEditTextOutput(); try { if (LoadBaml(output, token)) { highlighting = HighlightingManager.Instance.GetDefinitionByExtension(".xml"); } } catch (Exception ex) { output.Write(ex.ToString()); } return(output); }, token)) .Then(output => textView.ShowNode(output, this, highlighting)) .HandleExceptions()); return(true); }
public override bool View(TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; var view = Helpers.PrepareDataGrid(tabPage, this); var metadata = module.Metadata; var list = new List <ConstantEntry>(); ConstantEntry scrollTargetEntry = default; for (int row = 1; row <= metadata.GetTableRowCount(TableIndex.Constant); row++) { ConstantEntry entry = new ConstantEntry(module, MetadataTokens.ConstantHandle(row)); if (scrollTarget == row) { scrollTargetEntry = entry; } list.Add(entry); } view.ItemsSource = list; tabPage.Content = view; if (scrollTargetEntry.RID > 0) { ScrollItemIntoView(view, scrollTargetEntry); } return(true); }
public override bool View(TabPageModel tabPage) { try { AvalonEditTextOutput output = new AvalonEditTextOutput(); using var data = OpenStream(); if (data == null) { return(false); } IconBitmapDecoder decoder = new IconBitmapDecoder(data, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); foreach (var frame in decoder.Frames) { output.Write(String.Format("{0}x{1}, {2} bit: ", frame.PixelHeight, frame.PixelWidth, frame.Thumbnail.Format.BitsPerPixel)); AddIcon(output, frame); output.WriteLine(); } output.AddButton(Images.Save, Resources.Save, delegate { Save(null); }); tabPage.ShowTextView(textView => textView.ShowNode(output, this)); tabPage.SupportsLanguageSwitching = false; return(true); } catch (Exception) { return(false); } }
public static Task ShowTextViewAsync(this TabPageModel tabPage, Func <DecompilerTextView, Task> action) { if (!(tabPage.Content is DecompilerTextView textView)) { textView = new DecompilerTextView(); tabPage.Content = textView; } return(action(textView)); }
public static void ShowTextView(this TabPageModel tabPage, Action <DecompilerTextView> action) { if (!(tabPage.Content is DecompilerTextView textView)) { textView = new DecompilerTextView(); tabPage.Content = textView; } action(textView); }
public override bool View(TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; var dataGrid = new DataGrid { Columns = { new DataGridTextColumn { IsReadOnly = true, Header = "Member", Binding = new Binding("Member") }, new DataGridTextColumn { IsReadOnly = true, Header = "Offset", Binding = new Binding("Offset") { StringFormat = "X8" } }, new DataGridTextColumn { IsReadOnly = true, Header = "Size", Binding = new Binding("Size") }, new DataGridTextColumn { IsReadOnly = true, Header = "Value", Binding = new Binding(".") { Converter = ByteWidthConverter.Instance } }, new DataGridTextColumn { IsReadOnly = true, Header = "Meaning", Binding = new Binding("Meaning") }, }, AutoGenerateColumns = false, CanUserAddRows = false, CanUserDeleteRows = false, GridLinesVisibility = DataGridGridLinesVisibility.None, RowDetailsTemplateSelector = new CharacteristicsDataTemplateSelector(), RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Visible }; var headers = module.Reader.PEHeaders; var header = headers.CoffHeader; var entries = new List <Entry>(); entries.Add(new Entry(headers.CoffHeaderStartOffset, (int)header.Machine, 2, "Machine", header.Machine.ToString())); entries.Add(new Entry(headers.CoffHeaderStartOffset + 2, (int)header.NumberOfSections, 2, "Number of Sections", "Number of sections; indicates size of the Section Table, which immediately follows the headers.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 4, header.TimeDateStamp, 4, "Time/Date Stamp", DateTimeOffset.FromUnixTimeSeconds(unchecked ((uint)header.TimeDateStamp)).DateTime + " - Time and date the file was created in seconds since January 1st 1970 00:00:00 or 0.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 8, header.PointerToSymbolTable, 4, "Pointer to Symbol Table", "Always 0 in .NET executables.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 12, header.NumberOfSymbols, 4, "Number of Symbols", "Always 0 in .NET executables.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 16, (int)header.SizeOfOptionalHeader, 2, "Optional Header Size", "Size of the optional header.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 18, (int)header.Characteristics, 2, "Characteristics", "Flags indicating attributes of the file.")); dataGrid.ItemsSource = entries; tabPage.Content = dataGrid; return(true); }
public override bool View(TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; var dataGrid = Helpers.PrepareDataGrid(tabPage, this); dataGrid.ItemsSource = new[] { new PdbChecksumDebugDirectoryDataEntry(entry) }; tabPage.Content = dataGrid; return(true); }
public override bool Save(TabPageModel tabPage) { Stream s = Resource.TryOpenStream(); if (s == null) { return(false); } SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = Path.GetFileName(WholeProjectDecompiler.SanitizeFileName(Resource.Name)); dlg.Filter = Resources.ResourcesFileFilter; if (dlg.ShowDialog() == true) { s.Position = 0; switch (dlg.FilterIndex) { case 1: using (var fs = dlg.OpenFile()) { s.CopyTo(fs); } break; case 2: try { using (var fs = dlg.OpenFile()) using (var writer = new ResXResourceWriter(fs)) { foreach (var entry in new ResourcesFile(s)) { writer.AddResource(entry.Key, entry.Value); } } } catch (BadImageFormatException) { // ignore errors } catch (EndOfStreamException) { // ignore errors } break; } } return(true); }
public override bool View(TabPageModel tabPage) { try { AvalonEditTextOutput output = new AvalonEditTextOutput(); BitmapImage image = new BitmapImage(); byte[] curData; using (var data = OpenStream()) { if (data == null) { return(false); } //HACK: windows imaging does not understand that .cur files have the same layout as .ico // so load to data, and modify the ResourceType in the header to make look like an icon... MemoryStream s = data as MemoryStream; if (s == null) { // data was stored in another stream type (e.g. PinnedBufferedMemoryStream) s = new MemoryStream(); data.CopyTo(s); } curData = s.ToArray(); } curData[2] = 1; using (Stream stream = new MemoryStream(curData)) { image.BeginInit(); image.StreamSource = stream; image.EndInit(); } output.AddUIElement(() => new Image { Source = image }); output.WriteLine(); output.AddButton(Images.Save, Resources.Save, delegate { Save(null); }); tabPage.ShowTextView(textView => textView.ShowNode(output, this)); tabPage.SupportsLanguageSwitching = false; return(true); } catch (Exception) { return(false); } }
public new ActionResult Profile(int t) { var tab = (ProfileType)t; var user = GetSnsUser(); var tabs = CodeTable.GetCodes(typeof(ProfileType)); var partialView = string.Format("Profiles/{0}", tab); var model = new TabPageModel(user, "账户设置", partialView, tabs); switch (tab) { case ProfileType.Basic: model.Data = CurrentUser; break; } return(View("_TabPage", model)); }
public ActionResult Content(int t) { var tab = (ContentType)t; var user = GetSnsUser(); var partialView = string.Format("Contents/{0}", tab); var tabs = CodeTable.GetCodes(typeof(ContentType)); var model = new TabPageModel(user, "内容管理", partialView, tabs); switch (tab) { case ContentType.Company: model.Data = LoadService <ICompanyService>().GetCompany(CurrentUser.Id); break; } return(View("_TabPage", model)); }
public static DataGrid PrepareDataGrid(TabPageModel tabPage, ILSpyTreeNode selectedNode) { if (!(tabPage.Content is DataGrid view && view.Name == "MetadataView")) { view = new MetaDataGrid() { Name = "MetadataView", GridLinesVisibility = DataGridGridLinesVisibility.None, CanUserAddRows = false, CanUserDeleteRows = false, CanUserReorderColumns = false, RowHeaderWidth = 0, EnableColumnVirtualization = true, EnableRowVirtualization = true, IsReadOnly = true, SelectionMode = DataGridSelectionMode.Single, SelectionUnit = DataGridSelectionUnit.CellOrRowHeader, SelectedTreeNode = selectedNode, CellStyle = new Style { Setters = { new Setter { Property = Control.BorderThicknessProperty, Value = new Thickness(0) } } } }; ContextMenuProvider.Add(view); ScrollViewer.SetIsDeferredScrollingEnabled(view, true); DataGridFilter.SetIsAutoFilterEnabled(view, true); DataGridFilter.SetContentFilterFactory(view, new RegexContentFilterFactory()); } view.RowDetailsTemplateSelector = null; view.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed; ((MetaDataGrid)view).SelectedTreeNode = selectedNode; if (!view.AutoGenerateColumns) { view.Columns.Clear(); } view.AutoGenerateColumns = true; view.AutoGeneratingColumn += View_AutoGeneratingColumn; view.AutoGeneratedColumns += View_AutoGeneratedColumns; return(view); }
public override bool View(TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; var view = Helpers.PrepareDataGrid(tabPage, this); var reader = module.Reader.GetEntireImage().GetReader(0, 64); var entries = new List <Entry>(); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_magic", "Magic Number (MZ)")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_cblp", "Bytes on last page of file")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_cp", "Pages in file")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_crlc", "Relocations")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_cparhdr", "Size of header in paragraphs")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_minalloc", "Minimum extra paragraphs needed")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_maxalloc", "Maximum extra paragraphs needed")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_ss", "Initial (relative) SS value")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_sp", "Initial SP value")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_csum", "Checksum")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_ip", "Initial IP value")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_cs", "Initial (relative) CS value")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_lfarlc", "File address of relocation table")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_ovno", "Overlay number")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res[0]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res[1]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res[2]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res[3]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_oemid", "OEM identifier (for e_oeminfo)")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_oeminfo", "OEM information; e_oemid specific")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[0]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[1]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[2]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[3]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[4]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[5]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[6]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[7]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[8]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadUInt16(), 2, "e_res2[9]", "Reserved words")); entries.Add(new Entry(reader.Offset, reader.ReadInt32(), 4, "e_lfanew", "File address of new exe header")); view.ItemsSource = entries; tabPage.Content = view; return(true); }
public static DataGrid PrepareDataGrid(TabPageModel tabPage, ILSpyTreeNode selectedNode) { if (!(tabPage.Content is DataGrid view && view.Name == "MetadataView")) { view = new MetaDataGrid() { Name = "MetadataView", GridLinesVisibility = DataGridGridLinesVisibility.None, CanUserAddRows = false, CanUserDeleteRows = false, CanUserReorderColumns = false, HeadersVisibility = DataGridHeadersVisibility.Column, EnableColumnVirtualization = true, EnableRowVirtualization = true, RowHeight = 20, IsReadOnly = true, SelectionMode = DataGridSelectionMode.Single, SelectionUnit = DataGridSelectionUnit.FullRow, SelectedTreeNode = selectedNode, CellStyle = (Style)MetadataTableViews.Instance["DataGridCellStyle"], }; ContextMenuProvider.Add(view); DataGridFilter.SetIsAutoFilterEnabled(view, true); DataGridFilter.SetContentFilterFactory(view, new RegexContentFilterFactory()); } DataGridFilter.GetFilter(view).Clear(); view.RowDetailsTemplateSelector = null; view.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed; view.EnableColumnVirtualization = true; view.EnableRowVirtualization = true; ((MetaDataGrid)view).SelectedTreeNode = selectedNode; if (!view.AutoGenerateColumns) { view.Columns.Clear(); } view.AutoGenerateColumns = true; view.AutoGeneratingColumn += View_AutoGeneratingColumn; view.AutoGeneratedColumns += View_AutoGeneratedColumns; return(view); }
public override bool Save(TabPageModel tabPage) { Stream s = Resource.TryOpenStream(); if (s == null) { return(false); } SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = DecompilerTextView.CleanUpName(Resource.Name); if (dlg.ShowDialog() == true) { s.Position = 0; using (var fs = dlg.OpenFile()) { s.CopyTo(fs); } } return(true); }
public override bool Save(TabPageModel tabPage) { Stream s = Resource.TryOpenStream(); if (s == null) { return(false); } SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = Path.GetFileName(WholeProjectDecompiler.SanitizeFileName(Resource.Name)); if (dlg.ShowDialog() == true) { s.Position = 0; using (var fs = dlg.OpenFile()) { s.CopyTo(fs); } } return(true); }
public override bool View(TabPageModel tabPage) { AvalonEditTextOutput output = new AvalonEditTextOutput(); IHighlightingDefinition highlighting = null; tabPage.ShowTextView(textView => textView.RunWithCancellation( token => Task.Factory.StartNew( () => { try { // cache read XAML because stream will be closed after first read if (xml == null) { using var data = OpenStream(); if (data == null) { output.Write("ILSpy: Failed opening resource stream."); output.WriteLine(); return(output); } using (var reader = new StreamReader(data)) { xml = reader.ReadToEnd(); } } output.Write(xml); highlighting = HighlightingManager.Instance.GetDefinitionByExtension(".xml"); } catch (Exception ex) { output.Write(ex.ToString()); } return(output); }, token) ).Then(t => textView.ShowNode(t, this, highlighting)) .HandleExceptions()); tabPage.SupportsLanguageSwitching = false; return(true); }
public override bool Save(TabPageModel tabPage) { Language language = this.Language; if (string.IsNullOrEmpty(language.ProjectFileExtension)) { return(false); } SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = DecompilerTextView.CleanUpName(LoadedAssembly.ShortName) + language.ProjectFileExtension; dlg.Filter = language.Name + " project|*" + language.ProjectFileExtension + "|" + language.Name + " single file|*" + language.FileExtension + "|All files|*.*"; if (dlg.ShowDialog() == true) { DecompilationOptions options = new DecompilationOptions(); options.FullDecompilation = true; if (dlg.FilterIndex == 1) { options.SaveAsProjectDirectory = Path.GetDirectoryName(dlg.FileName); foreach (string entry in Directory.GetFileSystemEntries(options.SaveAsProjectDirectory)) { if (!string.Equals(entry, dlg.FileName, StringComparison.OrdinalIgnoreCase)) { var result = MessageBox.Show( Resources.AssemblySaveCodeDirectoryNotEmpty, Resources.AssemblySaveCodeDirectoryNotEmptyTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.No) { return(true); // don't save, but mark the Save operation as handled } break; } } } tabPage.ShowTextView(textView => textView.SaveToDisk(language, new[] { this }, options, dlg.FileName)); } return(true); }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { try { if ((Int32.Parse(Time.Text) >= 0) && (Int32.Parse(ParamsCount.Text) >= 0)) { int oldTime = item.Time; int newTime = Int32.Parse(Time.Text); TabPageModel currentTab = winTabControl.SelectedItem as TabPageModel; if (currentTab.Header[currentTab.Header.Length - 1] != '*') { foreach (TabPageModel tp in TabsViewModel.Tabs) { if (tp.Equals(currentTab)) { tp.Header += "*"; break; } } } changeDataInItem(list, item); changeTime(list[item.ThreadId], newTime - oldTime); int tempTime = list[item.ThreadId].Time; list[item.ThreadId].Time = tempTime + (newTime - oldTime); } else { throw new InvalidDataException(); } } catch (Exception exc) { MessageBox.Show(exc.Message); Name.Text = item.Name; Time.Text = Convert.ToString(item.Time); Package.Text = item.Package; ParamsCount.Text = Convert.ToString(item.ParamsCount); } }
private void RemoveTabItem() { if (index > 0) { TabPageModel tabPage = MainWindow.tabControl.SelectedContent as TabPageModel; if (tabPage.Header[tabPage.Header.Length - 1] == '*') { var result = MessageBox.Show("Save file " + tabPage.Header + "?", "Save", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Yes) { BuildXml(); closeTab(); } else if (result == MessageBoxResult.No) { closeTab(); } } else { closeTab(); } } }
public override bool View(TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; var dataGrid = Helpers.PrepareDataGrid(tabPage, this); dataGrid.RowDetailsTemplateSelector = new CharacteristicsDataTemplateSelector("Characteristics"); dataGrid.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed; dataGrid.Columns.Clear(); dataGrid.AutoGenerateColumns = false; dataGrid.Columns.AddRange( new[] { new DataGridTextColumn { IsReadOnly = true, Header = "Member", Binding = new Binding("Member") }, new DataGridTextColumn { IsReadOnly = true, Header = "Offset", Binding = new Binding("Offset") { StringFormat = "X8" } }, new DataGridTextColumn { IsReadOnly = true, Header = "Size", Binding = new Binding("Size") }, new DataGridTextColumn { IsReadOnly = true, Header = "Value", Binding = new Binding(".") { Converter = ByteWidthConverter.Instance } }, new DataGridTextColumn { IsReadOnly = true, Header = "Meaning", Binding = new Binding("Meaning") } } ); var headers = module.Reader.PEHeaders; var header = headers.CoffHeader; var entries = new List <Entry>(); entries.Add(new Entry(headers.CoffHeaderStartOffset, (int)header.Machine, 2, "Machine", header.Machine.ToString())); entries.Add(new Entry(headers.CoffHeaderStartOffset + 2, (int)header.NumberOfSections, 2, "Number of Sections", "Number of sections; indicates size of the Section Table, which immediately follows the headers.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 4, header.TimeDateStamp, 4, "Time/Date Stamp", DateTimeOffset.FromUnixTimeSeconds(unchecked ((uint)header.TimeDateStamp)).DateTime + " - Time and date the file was created in seconds since January 1st 1970 00:00:00 or 0.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 8, header.PointerToSymbolTable, 4, "Pointer to Symbol Table", "Always 0 in .NET executables.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 12, header.NumberOfSymbols, 4, "Number of Symbols", "Always 0 in .NET executables.")); entries.Add(new Entry(headers.CoffHeaderStartOffset + 16, (int)header.SizeOfOptionalHeader, 2, "Optional Header Size", "Size of the optional header.")); Entry characteristics; entries.Add(characteristics = new Entry(headers.CoffHeaderStartOffset + 18, (int)header.Characteristics, 2, "Characteristics", "Flags indicating attributes of the file.", new[] { new BitEntry(((int)header.Characteristics & 0x0001) != 0, "<0001> Relocation info stripped from file"), new BitEntry(((int)header.Characteristics & 0x0002) != 0, "<0002> File is executable"), new BitEntry(((int)header.Characteristics & 0x0004) != 0, "<0004> Line numbers stripped from file"), new BitEntry(((int)header.Characteristics & 0x0008) != 0, "<0008> Local symbols stripped from file"), new BitEntry(((int)header.Characteristics & 0x0010) != 0, "<0010> Aggressively trim working set"), new BitEntry(((int)header.Characteristics & 0x0020) != 0, "<0020> Large address aware"), new BitEntry(((int)header.Characteristics & 0x0040) != 0, "<0040> Reserved"), new BitEntry(((int)header.Characteristics & 0x0080) != 0, "<0080> Bytes of machine words are reversed (Low)"), new BitEntry(((int)header.Characteristics & 0x0100) != 0, "<0100> 32-bit word machine"), new BitEntry(((int)header.Characteristics & 0x0200) != 0, "<0200> Debugging info stripped from file in .DBG file"), new BitEntry(((int)header.Characteristics & 0x0400) != 0, "<0400> If image is on removable media, copy and run from the swap file"), new BitEntry(((int)header.Characteristics & 0x0800) != 0, "<0800> If image is on Net, copy and run from the swap file"), new BitEntry(((int)header.Characteristics & 0x1000) != 0, "<1000> System"), new BitEntry(((int)header.Characteristics & 0x2000) != 0, "<2000> DLL"), new BitEntry(((int)header.Characteristics & 0x4000) != 0, "<4000> File should only be run on a UP machine"), new BitEntry(((int)header.Characteristics & 0x8000) != 0, "<8000> Bytes of machine words are reversed (High)"), })); dataGrid.ItemsSource = entries; dataGrid.SetDetailsVisibilityForItem(characteristics, Visibility.Visible); tabPage.Content = dataGrid; return(true); }
public MyTabbedPage(TabPageModel model) : this() { this.SubPage1.BindingContext = model.ModelPg1; this.SubPage2.BindingContext = model.ModelPg2; this.SubPage3.BindingContext = model.ModelPg3; }
public TabPageCommand(TabPageModel model) { this.model = model; }