AshFile
Inheritance: System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector
コード例 #1
0
        public void LocateInCode(string g)
        {
            AshFile af = (disasmFile.Child as AshFile);

            if (af == null)
            {
                af = this;
            }
            if (af == null)
            {
                return;
            }
            if (codeSearchOffset < 0)
            {
                codeSearchOffset = 0;
            }
            if (g.Length > 0 && af.compilerCode.Text.Contains(g))
            {
                codeSearchOffset = af.compilerCode.Text.IndexOf(g, (codeSearchOffset > 0 ? (codeSearchOffset + 1) : 0));
                af.compilerCode.Select(codeSearchOffset, g.Length);
                int l = -1;
                foreach (string s in af.compilerCode.Text.Split('\r'))
                {
                    l++;
                    if (s.Contains(g))
                    {
                        break;
                    }
                }
                if (l >= 0)
                {
                    af.compilerCode.ScrollToLine(l);
                }
            }
        }
コード例 #2
0
        public AshFile OpenFile(string fp, AshFile.EditorType viewas = AshFile.EditorType.Default, bool addToRecent = true)
        {
            if (Path.GetExtension(fp) == ".xap")
            {
                OpenXap(fp);
                return null;
            }

            int iOpen = CheckIfOpen(fp);
            if (iOpen >= 0)
            {
                if (CheckIfNeedsSave(iOpen))
                {
                    filez.SelectedIndex = iOpen;
                    return null;
                }
                else CloseFile(filez.Items[iOpen]);
            }
            AshFile af = new AshFile(this, fp, viewas);
            TabItem ti = new TabItem() { Content = af, Style = (App.Current.Resources["AshTabItem"] as Style) };

            TextBlock tb = new TextBlock();
            tb.SetBinding(TextBlock.TextProperty, new Binding("TabTitle") { Source = ti.Content, Mode = BindingMode.OneWay });
            tb.SetBinding(TextBlock.FontWeightProperty, new Binding("TabWeight") { Source = ti.Content, Mode = BindingMode.OneWay });
            ti.Header = tb;

            filez.Items.Add(ti);
            filez.SelectedIndex = filez.Items.Count - 1;
            if (addToRecent)
            {
                SaveRecent("RecentFiles", fp);
                LoadRecent("RecentFiles", "menu_recent");
            }
            return af;
        }
コード例 #3
0
        public bool CheckIfNeedsSave(int i)
        {
            AshFile ashi = ToAshFile(filez.Items[i]);

            if (ashi != null)
            {
                return(ashi.NeedsSave);
            }
            return(true);
        }
コード例 #4
0
 private void disasmTree_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if ((sender as TreeView).SelectedItem != null)
     {
         // scroll to member logic
         TreeViewItem  si = ((sender as TreeView).SelectedItem as TreeViewItem);
         List <string> tp = new List <string> {
             "TypeDefinition", "MethodDefinition", "PropertyDefinition", "FieldDefinition", "EventDefinition"
         };
         if (tp.Contains(si.Tag.GetType().Name))
         {
             AshFile  af = (disasmFile.Child as AshFile);
             string   g  = string.Empty;
             string[] td = nd.Decompile(si.Tag).Text.Split('\r');
             if (si.Tag.GetType().Name == tp[0])
             {
                 g = td[2].Trim();
             }
             else
             {
                 if (!td[0].Contains("[CompilerGenerated]"))
                 {
                     g = td[0].Trim();
                     if (g.Contains(";"))
                     {
                         g = g.Substring(0, g.IndexOf(';'));
                     }
                 }
                 else
                 {
                     MessageBox.Show("This member is compiler generated.");
                 }
             }
             LocateInCode(g);
         }
         else if (si.Tag.GetType().Name == "EmbeddedResource" && si.Items.Count == 0)
         {
             //if (NeedsSave && MessageBoxResult.Yes == MessageBox.Show("Save current changes?", "Save changes", MessageBoxButton.YesNo)) Save();
             XapEditor.decompiler.ResourceDecompiler rdec = new decompiler.ResourceDecompiler(si.Tag as Mono.Cecil.EmbeddedResource);
             string tmp = Path.GetTempFileName();
             //AshFile af = new AshFile(this.pwner, tmp, EditorType.Resource);
             foreach (KeyValuePair <string, string> kv in rdec.Entries)
             {
                 //af.reEntries.Items.Add(new ComboBoxItem() { Content = kv.Key, Tag = kv.Value });
                 si.Items.Add(nd.GetTreeItem(XapEntry.GetIconForExtension(Path.GetExtension(kv.Key)), kv.Key, kv.Key, kv.Key, string.Format("{0} bytes", new FileInfo(kv.Value).Length)));
                 bool iF = kv.Key.Replace('\\', '/').Contains("/");
             }
             //disasmFile.Child = af;
         }
     }
 }
コード例 #5
0
        public AshFile OpenFile(string fp, AshFile.EditorType viewas = AshFile.EditorType.Default, bool addToRecent = true)
        {
            if (Path.GetExtension(fp) == ".xap")
            {
                OpenXap(fp);
                return(null);
            }

            int iOpen = CheckIfOpen(fp);

            if (iOpen >= 0)
            {
                if (CheckIfNeedsSave(iOpen))
                {
                    filez.SelectedIndex = iOpen;
                    return(null);
                }
                else
                {
                    CloseFile(filez.Items[iOpen]);
                }
            }
            AshFile af = new AshFile(this, fp, viewas);
            TabItem ti = new TabItem()
            {
                Content = af, Style = (App.Current.Resources["AshTabItem"] as Style)
            };

            TextBlock tb = new TextBlock();

            tb.SetBinding(TextBlock.TextProperty, new Binding("TabTitle")
            {
                Source = ti.Content, Mode = BindingMode.OneWay
            });
            tb.SetBinding(TextBlock.FontWeightProperty, new Binding("TabWeight")
            {
                Source = ti.Content, Mode = BindingMode.OneWay
            });
            ti.Header = tb;

            filez.Items.Add(ti);
            filez.SelectedIndex = filez.Items.Count - 1;
            if (addToRecent)
            {
                SaveRecent("RecentFiles", fp);
                LoadRecent("RecentFiles", "menu_recent");
            }
            return(af);
        }
コード例 #6
0
 public int CheckIfOpen(string fp)
 {
     for (int i = 0; i < filez.Items.Count; i++)
     {
         AshFile ashi = ToAshFile(filez.Items[i]);
         if (ashi != null)
         {
             if (ashi.SourceFile == fp)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
コード例 #7
0
        void OpenDecompiledCode(string segment = null)
        {
            AshFile af = new AshFile(pwner, decompilationResult, EditorType.Compiler);

            af.Tag = new CodeEditorParameters()
            {
                File = SourceFile, References = nd.ResolvedReferences.ToArray()
            };
            disasmFile.Child     = af;
            af.NeedsSaveChanged += delegate(bool ns) { NeedsSave = ns; };
            this.FileSaved      += delegate(AshFile f)
            {
                NetDasm.CompileFromCs(af.compilerCode.Text, SourceFile, (af.Tag as CodeEditorParameters).References);
            };
        }
コード例 #8
0
        bool CloseAllFiles(bool onlyXapEntries)
        {
            bool           ok     = true;
            List <TabItem> remove = new List <TabItem>();

            foreach (TabItem item in filez.Items)
            {
                AshFile af = ToAshFile(item);
                bool    sc = true;
                if (onlyXapEntries)
                {
                    sc = false;
                    if (xap != null)
                    {
                        foreach (XapEntry xe in xap.List)
                        {
                            if (xe.FullPath == af.SourceFile)
                            {
                                sc = true;
                                break;
                            }
                        }
                    }
                }
                if (af != null && sc)
                {
                    remove.Add(item);
                }
            }
            foreach (TabItem item in remove)
            {
                if (!CloseFile(item))
                {
                    ok = false;
                    break;
                }
            }
            return(ok);
        }
コード例 #9
0
        private void reEntries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem cbi = ((sender as ComboBox).SelectedItem as ComboBoxItem);

            if (cbi != null)
            {
                EditorType et = EditorType.Binary;
                switch (Path.GetExtension(cbi.Content as string))
                {
                case ".jpg":
                case ".jpeg":
                case ".png":
                    et = EditorType.Image;
                    break;

                case ".xaml":
                    et = EditorType.Text;
                    break;
                }
                AshFile af = new AshFile(this.pwner, cbi.Tag as string, et);
                reContent.Child = af;
            }
            reSaveAs.IsEnabled = (cbi != null);
        }
コード例 #10
0
ファイル: NetDasm.cs プロジェクト: Prashant-Jonny/dotnetrain
 public NetDasm(AshFile mw)
 {
     w = mw;
 }
コード例 #11
0
 private void reEntries_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ComboBoxItem cbi = ((sender as ComboBox).SelectedItem as ComboBoxItem);
     if (cbi != null)
     {
         EditorType et = EditorType.Binary;
         switch (Path.GetExtension(cbi.Content as string))
         {
             case ".jpg":
             case ".jpeg":
             case ".png":
                 et = EditorType.Image;
                 break;
             case ".xaml":
                 et = EditorType.Text;
                 break;
         }
         AshFile af = new AshFile(this.pwner, cbi.Tag as string, et);
         reContent.Child = af;
     }
     reSaveAs.IsEnabled = (cbi != null);
 }
コード例 #12
0
 void OpenDecompiledCode(string segment = null)
 {
     AshFile af = new AshFile(pwner, decompilationResult, EditorType.Compiler);
     af.Tag = new CodeEditorParameters() { File = SourceFile, References = nd.ResolvedReferences.ToArray() };
     disasmFile.Child = af;
     af.NeedsSaveChanged += delegate(bool ns) { NeedsSave = ns; };
     this.FileSaved += delegate(AshFile f)
     {
         NetDasm.CompileFromCs(af.compilerCode.Text, SourceFile, (af.Tag as CodeEditorParameters).References);
     };
 }
コード例 #13
0
ファイル: NetDasm.cs プロジェクト: net-shell/quantum-vaginer
 public NetDasm(AshFile mw)
 {
     w = mw;
 }