LoadAsm() public method

public LoadAsm ( string f ) : void
f string
return void
Exemplo n.º 1
0
 void loadFile()
 {
     bool eSave = false;
     pwner.SetStatus(string.Empty);
     img.Source = null;
     txtEditor.Visibility = Visibility.Collapsed;
     binEditor.Visibility = Visibility.Collapsed;
     imgPane.Visibility = Visibility.Collapsed;
     disasm.Visibility = Visibility.Collapsed;
     compi.Visibility = Visibility.Collapsed;
     iledit.Visibility = Visibility.Collapsed;
     resedit.Visibility = Visibility.Collapsed;
     nd = null;
     List<string> viewAsText = new List<string>() { "xaml", "xml" };
     List<string> viewAsImage = new List<string>() { "png", "bmp", "jpg", "ico" };
     long fl = new System.IO.FileInfo(sourcefile).Length;
     pwner.SetStatus(sourcefile, true);
     string stat = string.Format("{0:0} {1}", (fl > 1024 ? (fl / 1024) : fl), (fl > 1024 ? "Kb" : "bytes"));
     if (et == EditorType.Default)
     {
         string e = Path.GetExtension(sourcefile).Substring(1);
         if (viewAsText.Contains(e)) et = EditorType.Text;
         else if (viewAsImage.Contains(e)) et = EditorType.Image;
         else if (e == "dll") et = EditorType.Assembly;
         else et = EditorType.Binary;
     }
     switch (et)
     {
         case EditorType.Text:
             eSave = true;
             try
             {
                 tbEdit.Text = System.IO.File.ReadAllText(sourcefile, Encoding.UTF8);
             }
             catch (Exception e) { MessageBox.Show(e.Message); }
             txtEditor.Visibility = Visibility.Visible;
             break;
         case EditorType.Compiler:
             eSave = true;
             compilerCode.Text = System.IO.File.ReadAllText(sourcefile, Encoding.UTF8);
             compi.Visibility = Visibility.Visible;
             break;
         case EditorType.Image:
             BitmapImage bi = StaticBitmap.Read(sourcefile);
             img.Source = bi;
             stat = string.Format("{0:0}x{1:0}px | {2}", bi.Width, bi.Height, stat);
             imgPane.Visibility = Visibility.Visible;
             break;
         case EditorType.Assembly:
             nd = new NetDasm(this);
             nd.LoadAsm(sourcefile);
             disasm.Visibility = Visibility.Visible;
             Disassemble();
             eSave = true;
             break;
         case EditorType.Binary:
             Be.Windows.Forms.HexBox hb = new Be.Windows.Forms.HexBox() { ByteProvider = new Be.Windows.Forms.FileByteProvider(sourcefile), ByteCharConverter = new Be.Windows.Forms.DefaultByteCharConverter(), BytesPerLine = 16, UseFixedBytesPerLine = true, StringViewVisible = true, VScrollBarVisible = true };
             hb.TextChanged += delegate(object sender, EventArgs ev) { NeedsSave = true; };
             binHost.Child = hb;
             binEditor.Visibility = Visibility.Visible;
             break;
         case EditorType.Resource:
             resedit.Visibility = Visibility.Visible;
             break;
     }
     pwner.SetStatus(stat);
     CanSave = eSave;
     pwner.menu_save.IsEnabled = CanSave;
     OnFileLoaded();
 }
Exemplo n.º 2
0
 public void loadasm(string fn)
 {
     nd = new NetDasm(this);
     nd.LoadAsm(fn);
 }
Exemplo n.º 3
0
 public void loadasm(string fn)
 {
     nd = new NetDasm(this);
     nd.LoadAsm(fn);
 }
Exemplo n.º 4
0
        void loadFile()
        {
            bool eSave = false;

            pwner.SetStatus(string.Empty);
            img.Source           = null;
            txtEditor.Visibility = Visibility.Collapsed;
            binEditor.Visibility = Visibility.Collapsed;
            imgPane.Visibility   = Visibility.Collapsed;
            disasm.Visibility    = Visibility.Collapsed;
            compi.Visibility     = Visibility.Collapsed;
            iledit.Visibility    = Visibility.Collapsed;
            resedit.Visibility   = Visibility.Collapsed;
            nd = null;
            List <string> viewAsText = new List <string>()
            {
                "xaml", "xml"
            };
            List <string> viewAsImage = new List <string>()
            {
                "png", "bmp", "jpg", "ico"
            };
            long fl = new System.IO.FileInfo(sourcefile).Length;

            pwner.SetStatus(sourcefile, true);
            string stat = string.Format("{0:0} {1}", (fl > 1024 ? (fl / 1024) : fl), (fl > 1024 ? "Kb" : "bytes"));

            if (et == EditorType.Default)
            {
                string e = Path.GetExtension(sourcefile).Substring(1);
                if (viewAsText.Contains(e))
                {
                    et = EditorType.Text;
                }
                else if (viewAsImage.Contains(e))
                {
                    et = EditorType.Image;
                }
                else if (e == "dll")
                {
                    et = EditorType.Assembly;
                }
                else
                {
                    et = EditorType.Binary;
                }
            }
            switch (et)
            {
            case EditorType.Text:
                eSave = true;
                try
                {
                    tbEdit.Text = System.IO.File.ReadAllText(sourcefile, Encoding.UTF8);
                }
                catch (Exception e) { MessageBox.Show(e.Message); }
                txtEditor.Visibility = Visibility.Visible;
                break;

            case EditorType.Compiler:
                eSave             = true;
                compilerCode.Text = System.IO.File.ReadAllText(sourcefile, Encoding.UTF8);
                compi.Visibility  = Visibility.Visible;
                break;

            case EditorType.Image:
                BitmapImage bi = StaticBitmap.Read(sourcefile);
                img.Source         = bi;
                stat               = string.Format("{0:0}x{1:0}px | {2}", bi.Width, bi.Height, stat);
                imgPane.Visibility = Visibility.Visible;
                break;

            case EditorType.Assembly:
                nd = new NetDasm(this);
                nd.LoadAsm(sourcefile);
                disasm.Visibility = Visibility.Visible;
                Disassemble();
                eSave = true;
                break;

            case EditorType.Binary:
                Be.Windows.Forms.HexBox hb = new Be.Windows.Forms.HexBox()
                {
                    ByteProvider = new Be.Windows.Forms.FileByteProvider(sourcefile), ByteCharConverter = new Be.Windows.Forms.DefaultByteCharConverter(), BytesPerLine = 16, UseFixedBytesPerLine = true, StringViewVisible = true, VScrollBarVisible = true
                };
                hb.TextChanged      += delegate(object sender, EventArgs ev) { NeedsSave = true; };
                binHost.Child        = hb;
                binEditor.Visibility = Visibility.Visible;
                break;

            case EditorType.Resource:
                resedit.Visibility = Visibility.Visible;
                break;
            }
            pwner.SetStatus(stat);
            CanSave = eSave;
            pwner.menu_save.IsEnabled = CanSave;
            OnFileLoaded();
        }