Beispiel #1
0
        /// <summary>
        /// Prompts the user for a metadata file and adds to the project.
        /// </summary>
        public void AddMetadataFile()
        {
            var fileName = uiSvc.ShowOpenFileDialog(null);

            if (fileName is null)
            {
                return;
            }
            var projectLoader = new ProjectLoader(
                Services,
                loader,
                this.decompilerSvc.Decompiler.Project,
                Services.RequireService <DecompilerEventListener>());
            var metadataUri = ImageLocation.FromUri(fileName);

            try
            {
                var metadata = projectLoader.LoadMetadataFile(metadataUri);
                decompilerSvc.Decompiler.Project.MetadataFiles.Add(metadata);
                RememberFilenameInMru(fileName);
            }
            catch (Exception e)
            {
                uiSvc.ShowError(e, "An error occured while parsing the metadata file {0}", fileName);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Master function for opening a new project.
 /// </summary>
 /// <param name="file"></param>
 /// <param name="openAction"></param>
 public void OpenBinary(string file, Func <string, bool> openAction)
 {
     try
     {
         CloseProject();
         SwitchInteractor(InitialPageInteractor);
         if (openAction(file))
         {
             ProjectFileName = file;
         }
     }
     catch (Exception ex)
     {
         Debug.Print("Caught exeption: {0}\r\n{1}", ex.Message, ex.StackTrace);
         uiSvc.ShowError(ex, "Couldn't open file '{0}'.", file);
     }
 }
 /// <summary>
 /// The UI thread requests a background operation by calling this method.
 /// </summary>
 /// <param name="caption"></param>
 /// <param name="backgroundTask"></param>
 /// <returns></returns>
 public bool StartBackgroundWork(string caption, Action backgroundTask)
 {
     lastException = null;
     try
     {
         this.task = backgroundTask;
         using (dlg = CreateDialog(caption))
         {
             if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
             {
                 return(true);
             }
             if (lastException != null)
             {
                 uiSvc.ShowError(lastException, "{0}", caption);
             }
             return(false);
         }
     }
     finally
     {
         dlg = null;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Master function for opening a new project.
 /// </summary>
 /// <param name="file"></param>
 /// <param name="openAction"></param>
 public void OpenBinary(string file, Func <string, bool> openAction, Func <string, bool> onFailAction)
 {
     try
     {
         CloseProject();
         SwitchInteractor(InitialPageInteractor);
         if (openAction(file) || onFailAction(file))
         {
             if (file.EndsWith(Project_v5.FileExtension))
             {
                 ProjectFileName = file;
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Print("Caught exception: {0}\r\n{1}", ex.Message, ex.StackTrace);
         uiSvc.ShowError(ex, "Couldn't open file '{0}'. {1}", file, ex.Message);
     }
     finally
     {
         Services.RequireService <IStatusBarService>().SetText("");
     }
 }
Beispiel #5
0
 /// <summary>
 /// Master function for opening a new project.
 /// </summary>
 /// <param name="file"></param>
 /// <param name="openAction"></param>
 public void OpenBinary(string file, string outputDir, Func <string, bool> openAction)
 {
     try
     {
         CloseProject();
         SwitchInteractor(InitialPageInteractor);
         openAction(file);
         ProjectFileName  = file;
         ProjectOutputDir = outputDir;
     }
     catch (Exception ex)
     {
         Debug.Print("Caught exception: {0}\r\n{1}", ex.Message, ex.StackTrace);
         uiSvc.ShowError(ex, "Couldn't open file '{0}'.", file);
     }
     finally
     {
         Services.RequireService <IStatusBarService>().SetText("");
     }
 }