Exemple #1
0
        /// <summary>
        /// Saves all assemblies and returns true if all assemblies were saved to disk
        /// </summary>
        /// <param name="asms">All assemblies to save</param>
        /// <returns></returns>
        public static bool SaveAssemblies(IEnumerable<LoadedAssembly> asms)
        {
            var asmsAry = asms.ToArray();
            if (asmsAry.Length == 0)
                return true;

            if (asmsAry.Length == 1) {
                var optsData = new SaveModuleOptionsVM(asmsAry[0].ModuleDefinition);
                var optsWin = new SaveModuleOptions();
                optsWin.Owner = MainWindow.Instance;
                optsWin.DataContext = optsData;
                var res = optsWin.ShowDialog();
                if (res != true)
                    return false;

                var data = new SaveMultiModuleVM(optsData);
                var win = new SaveSingleModule();
                win.Owner = MainWindow.Instance;
                win.DataContext = data;
                data.Save();
                win.ShowDialog();
                return MarkAsSaved(data, asmsAry);
            }
            else {
                var data = new SaveMultiModuleVM(asmsAry.Select(a => a.ModuleDefinition));
                var win = new SaveMultiModule();
                win.Owner = MainWindow.Instance;
                win.DataContext = data;
                win.ShowDialog();
                return MarkAsSaved(data, asmsAry);
            }
        }
Exemple #2
0
        internal void ShowOptions(SaveModuleOptionsVM data)
        {
            if (data == null)
                return;

            var win = new SaveModuleOptions();
            win.Owner = this;
            var clone = data.Clone();
            win.DataContext = clone;
            var res = win.ShowDialog();
            if (res == true) {
                clone.CopyTo(data);
                ((SaveMultiModuleVM)DataContext).OnModuleSettingsSaved();
            }
        }
Exemple #3
0
 public ModuleSaverWriteEventArgs(SaveModuleOptionsVM vm, bool starting)
 {
     this.File = vm;
     this.Starting = starting;
 }
Exemple #4
0
 public SaveState(SaveModuleOptionsVM vm)
 {
     this.File = vm;
 }
Exemple #5
0
 public SaveMultiModuleVM(SaveModuleOptionsVM options)
 {
     this.modules.Add(options);
 }
Exemple #6
0
        void SaveAsync(SaveModuleOptionsVM[] mods)
        {
            try {
                moduleSaver = new ModuleSaver(mods);
                moduleSaver.OnProgressUpdated += moduleSaver_OnProgressUpdated;
                moduleSaver.OnLogMessage += moduleSaver_OnLogMessage;
                moduleSaver.OnWritingFile += moduleSaver_OnWritingFile;
                moduleSaver.SaveAll();
                AsyncAddMessage("All files written to disk.", false, false);
            }
            catch (TaskCanceledException) {
                AsyncAddMessage("Save was canceled by user.", true, false);
            }
            catch (UnauthorizedAccessException ex) {
                AsyncAddMessage(string.Format("Access error: {0}", ex.Message), true, false);
            }
            catch (IOException ex) {
                AsyncAddMessage(string.Format("File error: {0}", ex.Message), true, false);
            }
            catch (Exception ex) {
                AsyncAddMessage(string.Format("An exception occurred\n\n{0}", ex), true, false);
            }
            moduleSaver = null;

            ExecInOldThread(() => {
                CurrentFileName = string.Empty;
                State = SaveState.Saved;
            });
        }
Exemple #7
0
 public SaveModuleOptionsVM CopyTo(SaveModuleOptionsVM other)
 {
     other.FileName = FileName;
     other.UseMixedMode = UseMixedMode;
     other.InitializeFrom(CreateWriterOptions());
     return other;
 }