コード例 #1
0
ファイル: MainForm.cs プロジェクト: lagdotcom/gbdisassembler
        public bool SaveProject()
        {
            if (Project == null)
            {
                return(true);
            }

            if (string.IsNullOrEmpty(FileName))
            {
                if (SaveProjectDialog.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }

                FileName = SaveProjectDialog.FileName;
            }

            Serializer.SaveProject(FileName, Project);

            UnsavedChanges = false;
            UpdateTitleBar();

            ProjectSaved?.Invoke(this, null);
            return(true);
        }
コード例 #2
0
        public async Task <LoggerResult> SaveProject()
        {
            if (PackageSession == null)
            {
                throw new InvalidOperationException("Cannot save the project before it was loaded.");
            }

            // TODO: check asset consistency

            // TODO: read more about Stride.Core.Assets.Editor.PackageViewModel
            //// Prepare packages to be saved by setting their dirty flag correctly
            //foreach (var package in LocalPackages)
            //{
            //    package.PreparePackageForSaving();
            //}

            var viewUpdater = Services.GetService <IViewUpdater>();

            PackageSessionResult sessionResult = await SetupResultProgress(viewUpdater, SaveProjectScope);

            // TODO: display a dialog with save progress

            // Force PackageSession.Save to be executed on the thread pool
            // otherwise it would block execution and we want this process to be async
            using (var scope = new TimedScope(SaveProjectScope, TimedScope.Status.Success))
            {
                await Task.Run(() =>
                {
                    try
                    {
                        var saveParameters = PackageSaveParameters.Default();

                        // TODO: read more about Stride.Core.Assets.Editor.AssetViewModel
                        // AllAssets.ForEach(x => x.PrepareSave(sessionResult));
                        PackageSession.Save(sessionResult, saveParameters);
                    }
                    catch (Exception e)
                    {
                        sessionResult.Error(string.Format("There was a problem saving the solution. {0}", e.Message), e);
                        scope.Result = TimedScope.Status.Failure;
                    }
                });

                if (sessionResult.HasErrors)
                {
                    scope.Result = TimedScope.Status.Failure;
                }
            }

            EditorViewModel.LoadingStatus = null;
            await viewUpdater.UpdateView();

            ProjectSaved?.Invoke(sessionResult);

            return(sessionResult);
        }
コード例 #3
0
 protected virtual void OnProjectSaved()
 {
     ProjectSaved?.Invoke(this, EventArgs.Empty);
 }
コード例 #4
0
ファイル: LoadSave.cs プロジェクト: DJuttmann/SM3E
        // Write all data to the Rom.
        public void Save()
        {
            if (!ProjectLoaded)
            {
                return;
            }

            ReallocateAll();
            RepointAll();
            List <Data> objects = CurrentRom.AllData;

            objects.Sort((x, y) => x.StartAddressPC - y.StartAddressPC);

            Stream output  = new FileStream(ProjectPath + RomFileName, FileMode.Create);
            int    address = 0;

            for (int n = 0; n < objects.Count; n++)
            {
                if (address < objects [n].StartAddressPC)
                {
                    CurrentRom.Seek(address);
                    CurrentRom.WriteToFile(output, objects [n].StartAddressPC - address);
                    address = objects [n].StartAddressPC;
                }
                if (address == objects [n].StartAddressPC)
                {
                    int  oldAddress  = address;
                    long oldPosition = output.Position;
                    objects [n].WriteToROM(output, ref address);
                    if (address - oldAddress != output.Position - oldPosition)
                    {
                        Logging.WriteLine("Write error: incorrect # bytes written for " +
                                          objects [n].GetType().ToString() + " at " +
                                          Tools.IntToHex(objects [n].StartAddressPC) +
                                          " - should be " + (address - oldAddress) +
                                          " instead of " + (output.Position - oldPosition));
                    }
                    if (address != output.Position)
                    {
                        Logging.WriteLine("Desync: " + address + " ~ " + output.Position);
                    }
                }
                else
                {
                    Logging.WriteLine("Write error: Invalid address for " +
                                      objects [n].GetType().ToString() + " at " +
                                      Tools.IntToHex(objects [n].StartAddressPC) +
                                      " - output stream already at " + Tools.IntToHex(address));
                }
            }

            // Round address up to multiple of bank size and write remaining data up to there.
            int roundedSize = Math.Max(CurrentRom.Data.Length, (address + 0x7FFF) & ~0x7FFF);

            if (address < roundedSize)
            {
                CurrentRom.Seek(address);
                CurrentRom.WriteToFile(output, roundedSize - address);
            }
            output.Close();

            WriteProjectFileXml();
            ChangesMade = false;
            ProjectSaved?.Invoke(this, null);
        }
コード例 #5
0
 public void Handle(ProjectSaved @event)
 {
     RecentProjects.Add(@event.ProjectLocation);
 }