Ejemplo n.º 1
0
 public bool OpenXap(string fp)
 {
     xap = new Xap(fp);
     xap.Open();
     dgXap.ItemsSource = xap.List;
     dAppName.Text     = xap.Meta["Title"];
     try { dImage.Source = StaticBitmap.Read(xap.GetIcon()); }
     catch (Exception) { }
     dAppProp.Text          = string.Format("Version {3} ({4})\rAuthor: {0}\rPublisher: {2}", xap.Meta["Author"], xap.Meta["Genre"], xap.Meta["Publisher"], xap.Meta["Version"], xap.Meta["RuntimeType"], xap.Meta["ProductID"]);
     menu_pack.IsEnabled    = true;
     leftCol.MinWidth       = 5;
     leftCol.Width          = new GridLength(300);
     menu_close.IsEnabled   = true;
     menu_savexap.IsEnabled = true;
     SaveRecent("RecentXap", xap.Source);
     LoadRecent("RecentXap", "menu_recentxap");
     return(true);
 }
Ejemplo n.º 2
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();
        }