Example #1
0
 public SimPe.Collections.PackedFileDescriptors GetDescriptors()
 {
     SimPe.Collections.PackedFileDescriptors pfds = new SimPe.Collections.PackedFileDescriptors();
     foreach (SimPe.Events.ResourceContainer e in list)
     {
         if (e.HasFileDescriptor)
         {
             pfds.Add(e.Resource.FileDescriptor);
         }
     }
     return(pfds);
 }
Example #2
0
        public override void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs es)
        {
            if (!ChangeEnabledStateEventHandler(null, es))
            {
                return;
            }

            bool   multi  = es.Count > 1;
            string flname = SetupSaveDialog(es[0].Resource.FileDescriptor.ExportFileName, multi);

            if (flname == null)
            {
                return;
            }

#if !DEBUG
            try
#endif
            {
                if (!multi)                 //extract one File
                {
                    SimPe.Packages.PackedFileDescriptor pfd = (SimPe.Packages.PackedFileDescriptor)es[0].Resource.FileDescriptor;

                    ToolLoaderItemExt.SavePackedFile(flname, true, pfd, es.LoadedPackage.Package);
                    pfd.Path = null;
                }
                else                 //extract multiple Files
                {
                    SimPe.Collections.PackedFileDescriptors pfds = new SimPe.Collections.PackedFileDescriptors();
                    foreach (SimPe.Events.ResourceContainer e in es)
                    {
                        if (e.HasFileDescriptor)
                        {
                            pfds.Add(e.Resource.FileDescriptor);
                        }
                    }

                    SimPe.Interfaces.Files.IPackedFileDescriptor[] ar = new SimPe.Interfaces.Files.IPackedFileDescriptor[pfds.Length];
                    pfds.CopyTo(ar);
                    ExtractAllFiles(flname, ar, es.LoadedPackage.Package);
                }
            }
#if !DEBUG
            catch (Exception ex)
            {
                Helper.ExceptionMessage(Localization.Manager.GetString("err002") + flname, ex);
            }
#endif
        }
Example #3
0
        void SaveRelations()
        {
            if (locked)
            {
                return;
            }
            SimPe.Collections.PackedFileDescriptors pfds = new SimPe.Collections.PackedFileDescriptors();
            locked = true;

            try
            {
                foreach (ExtSrel srel in crmap.Values)
                {
                    if (srel.Package != null)
                    {
                        srel.SynchronizeUserData();
                    }
                    else
                    {
                        srel.Package = this.Package;
                        srel.SynchronizeUserData();
                        pfds.Add(srel.FileDescriptor);
                    }

                    if (!this.Equals(srel.SourceSim))
                    {
                        if (srel.SourceSim != null)
                        {
                            if (srel.SourceSim.Changed)
                            {
                                srel.SourceSim.SynchronizeUserData();
                            }
                        }
                    }
                }

                crmap.Clear();

                locked = false;

                this.Package.BeginUpdate();
                try
                {
                    for (int i = pfds.Count - 1; i >= 0; i--)
                    {
                        if (i == 0)
                        {
                            this.Package.ForgetUpdate();
                        }
                        this.Package.Add(pfds[i], true);
                    }
                }
                finally
                {
                    this.Package.EndUpdate();
                }
            }
            finally
            {
                locked = false;
            }
        }