本文整理汇总了C#中ICSharpCode.ILSpy.TextView.DecompilerTextView类的典型用法代码示例。如果您正苦于以下问题:C# DecompilerTextView类的具体用法?C# DecompilerTextView怎么用?C# DecompilerTextView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DecompilerTextView类属于ICSharpCode.ILSpy.TextView命名空间,在下文中一共展示了DecompilerTextView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetViewObject
public sealed override object GetViewObject(DecompilerTextView textView) {
var obj = uiObjRef == null ? null : (FrameworkElement)uiObjRef.Target;
// The element is cached but could be opened in two different tab groups. Only return
// the cached one if it's not in use.
if (obj != null && obj.Parent == null)
return obj;
FrameworkElement newObj;
if (IsVirtualizingCollectionVM)
newObj = new ContentPresenter() { Content = ViewObject, Focusable = true };
else {
newObj = new ScrollViewer {
CanContentScroll = true,
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Content = ViewObject,
Focusable = true,
};
};
if (uiObjRef == null)
uiObjRef = new WeakReference(newObj);
else
uiObjRef.Target = newObj;
return newObj;
}
示例2: View
public override bool View(DecompilerTextView textView)
{
AvalonEditTextOutput output = new AvalonEditTextOutput();
IHighlightingDefinition highlighting = null;
textView.RunWithCancellation(
token => Task.Factory.StartNew(
() => {
try {
// cache read XAML because stream will be closed after first read
if (xml == null) {
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();
return true;
}
示例3: View
public override bool View(DecompilerTextView textView)
{
try
{
AvalonEditTextOutput output = new AvalonEditTextOutput();
Data.Position = 0;
IconBitmapDecoder decoder = new IconBitmapDecoder(Data, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
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, "Save", delegate
{
Save(null);
});
textView.ShowNode(output, this);
return true;
}
catch (Exception)
{
return false;
}
}
示例4: JumpToStatement
static bool JumpToStatement(MethodDef method, uint ilOffset, DecompilerTextView textView) {
if (method == null)
return false;
var serMod = method.Module.ToSerializedDnSpyModule();
var key = new SerializedDnSpyToken(serMod, method.MDToken);
if (textView == null)
textView = MainWindow.Instance.SafeActiveTextView;
bool found = MainWindow.Instance.DnSpyFileListTreeNode.FindModuleNode(method.Module) != null;
if (found) {
return MainWindow.Instance.JumpToReference(textView, method, (success, hasMovedCaret) => {
if (success)
return MoveCaretTo(textView, key, ilOffset);
return false;
});
}
MainWindow.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
MainWindow.Instance.JumpToReference(textView, method, (success, hasMovedCaret) => {
if (success)
return MoveCaretTo(textView, key, ilOffset);
return false;
});
}));
return true;
}
示例5: Save
// yuehan start: 保存 baml 到 xaml 文件
public override bool Save(DecompilerTextView textView)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(base.Text as string));
dlg.FileName = Regex.Replace(dlg.FileName, @"\.baml$", ".xaml", RegexOptions.IgnoreCase);
if (dlg.ShowDialog() == true)
{
// 反编译 baml 文件
var baml = this.Data;
var asm = this.Ancestors().OfType<AssemblyTreeNode>().FirstOrDefault().LoadedAssembly;
baml.Position = 0;
var doc = LoadIntoDocument(asm.GetAssemblyResolver(), asm.AssemblyDefinition, baml);
var xaml = doc.ToString();
// 保存 xaml
FileInfo fi = new FileInfo(dlg.FileName);
if (fi.Exists) fi.Delete();
using (var fs = fi.OpenWrite())
using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
{
sw.BaseStream.Seek(0, SeekOrigin.Begin);
sw.Write(xaml);
sw.Flush();
sw.Close();
}
}
return true;
}
示例6: View
public override bool View(DecompilerTextView textView)
{
try {
AvalonEditTextOutput output = new AvalonEditTextOutput();
Data.Position = 0;
BitmapImage image = new BitmapImage();
//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...
byte[] curData = ((MemoryStream)Data).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, "Save", delegate {
Save(null);
});
textView.ShowNode(output, this, null);
return true;
}
catch (Exception) {
return false;
}
}
示例7: GetLineNumber
public static int GetLineNumber(IBookmark b, DecompilerTextView textView)
{
var bm = b as BookmarkBase;
if (bm != null)
return bm.GetLineNumber(textView);
return b.LineNumber;
}
示例8: GetMemberRef
static IMemberRef GetMemberRef(DecompilerTextView textView)
{
if (textView == null)
return null;
var refSeg = textView.GetCurrentReferenceSegment();
return refSeg == null ? null : refSeg.Reference as IMemberRef;
}
示例9: JumpTo
public static bool JumpTo(DecompilerTextView textView, IMemberRef mr, MethodKey key, int ilOffset)
{
return MainWindow.Instance.JumpToReference(textView, mr, (success, hasMovedCaret) => {
if (success)
return MoveCaretTo(textView, key, ilOffset);
return false;
});
}
示例10: CreateMarker
public ITextMarker CreateMarker(DecompilerTextView textView, ITextMarkerService markerService) {
var marker = CreateMarkerInternal(markerService, textView);
var cm = textView == null ? null : textView.CodeMappings;
marker.ZOrder = ZOrder;
marker.IsVisible = b => cm != null && cm.ContainsKey(MethodKey);
marker.TextMarkerObject = this;
Initialize(textView, markerService, marker);
return marker;
}
示例11: IsVisible
public override bool IsVisible(DecompilerTextView textView) {
TextLocation location, endLocation;
var cm = textView == null ? null : textView.CodeMappings;
if (cm == null || !cm.ContainsKey(MethodKey))
return false;
if (!cm[MethodKey].GetInstructionByTokenAndOffset(ILOffset, out location, out endLocation))
return false;
return true;
}
示例12: JumpToReference
public static bool JumpToReference(DecompilerTextView textView, IMemberRef mr, Func<TextLocation> getLocation)
{
bool retVal = MainWindow.Instance.JumpToReference(textView, mr, getLocation);
if (!retVal) {
MainWindow.Instance.ShowMessageBox(
string.Format("Could not find {0}\n" +
"Make sure that it's visible in the treeview and not a hidden method or part of a hidden class. You could also try to debug the method in IL mode.", mr));
}
return retVal;
}
示例13: Create
public static TextViewContext Create(SharpTreeView treeView = null, DecompilerTextView textView = null)
{
var reference = textView != null ? textView.GetReferenceSegmentAtMousePosition() : null;
var selectedTreeNodes = treeView != null ? treeView.GetTopLevelSelection().ToArray() : null;
return new TextViewContext {
TreeView = treeView,
SelectedTreeNodes = selectedTreeNodes,
TextView = textView,
Reference = reference
};
}
示例14: Save
public override bool Save(DecompilerTextView textView)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(key));
if (dlg.ShowDialog() == true) {
data.Position = 0;
using (var fs = dlg.OpenFile()) {
data.CopyTo(fs);
}
}
return true;
}
示例15: TextMarkerService
public TextMarkerService(DecompilerTextView textView) {
if (textView == null)
throw new ArgumentNullException("textView");
this.textView = textView;
TextView.DocumentChanged += OnDocumentChanged;
TextLineObjectManager.Instance.OnListModified += TextLineObjectManager_OnListModified;
MainWindow.Instance.ExecuteWhenLoaded(() => {
MainWindow.Instance.OnTabStateRemoved += OnTabStateRemoved;
this.textView.OnShowOutput += textView_OnShowOutput;
RecreateMarkers();
});
OnDocumentChanged(null, null);
}