Beispiel #1
0
        /// <summary>
        /// Load a Package File or add exported Files
        /// </summary>
        /// <param name="names">list of FileNames</param>
        /// <param name="create">true, if you want to create a new Package if none was loaded</param>
        public void LoadOrImportFiles(string[] names, bool create)
        {
            if (names.Length == 0)
            {
                return;
            }
            if (!Loaded && !create)
            {
                return;
            }

            if (!Loaded && create)
            {
                this.LoadFromPackage(SimPe.Packages.GeneratableFile.CreateNew());
            }

            ExtensionType et = ExtensionProvider.GetExtension(names[0]);

            if (names.Length == 1 && (et == ExtensionType.Package || et == ExtensionType.DisabledPackage))
            {
                if (System.IO.File.Exists(names[0]))
                {
                    this.LoadFromFile(names[0]);
                }
            }
            else if (et == ExtensionType.ExtractedFile || et == ExtensionType.ExtractedFileDescriptor || names.Length > 1 || et == ExtensionType.ExtrackedPackageDescriptor)
            {
                this.PauseIndexChangedEvents();
                this.Package.BeginUpdate();
                try
                {
                    for (int i = 0; i < names.Length; i++)
                    {
                        if (System.IO.File.Exists(names[i]))
                        {
                            PackedFileDescriptors pfds = LoadDescriptorsFromDisk(names[i]);

                            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                            {
                                this.Package.Add(pfd);
                            }
                        }
                    }
                }
                finally
                {
                    this.Package.EndUpdate();
                    this.RestartIndexChangedEvents();
                }
            }
        }
Beispiel #2
0
 void Activate_miOpen(object sender, System.EventArgs e)
 {
     ofd.Filter = ExtensionProvider.BuildFilterString(
         new SimPe.ExtensionType[] {
         SimPe.ExtensionType.Package,
         SimPe.ExtensionType.DisabledPackage,
         SimPe.ExtensionType.AllFiles
     }
         );
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         package.LoadFromFile(ofd.FileName);
     }
 }
Beispiel #3
0
 private void Activate_miSaveAs(object sender, System.EventArgs e)
 {
     sfd.Filter = ExtensionProvider.BuildFilterString(
         new SimPe.ExtensionType[] {
         SimPe.ExtensionType.Package,
         SimPe.ExtensionType.DisabledPackage,
         SimPe.ExtensionType.AllFiles
     }
         );
     sfd.FileName = package.FileName;
     if (sfd.ShowDialog() == DialogResult.OK)
     {
         package.Save(sfd.FileName, false);
         package.UpdateRecentFileMenu(this.miRecent);
     }
 }
Beispiel #4
0
        private void Activate_miSaveCopyAs(object sender, System.EventArgs e)
        {
            sfd.Filter = ExtensionProvider.BuildFilterString(
                new SimPe.ExtensionType[] {
                SimPe.ExtensionType.Package,
                SimPe.ExtensionType.DisabledPackage,
                SimPe.ExtensionType.AllFiles
            }
                );

            sfd.FileName = package.FileName;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                SimPe.Packages.GeneratableFile gf = (SimPe.Packages.GeneratableFile)package.Package.Clone();
                gf.Save(sfd.FileName);
                //package.UpdateRecentFileMenu(this.miRecent);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Returns the Effect that should be displayed based on the Files
        /// </summary>
        /// <param name="flname"></param>
        /// <returns></returns>
        DragDropEffects DragDropEffect(string[] names)
        {
            if (names.Length == 0)
            {
                return(DragDropEffects.None);
            }

            ExtensionType et = ExtensionProvider.GetExtension(names[0]);

            if (names.Length == 1)
            {
                if (et == ExtensionType.Package || et == ExtensionType.DisabledPackage || et == ExtensionType.ExtrackedPackageDescriptor)
                {
                    return(DragDropEffects.Move);
                }
                else if (et == ExtensionType.ExtractedFile || et == ExtensionType.ExtractedFileDescriptor)
                {
                    return(DragDropEffects.Copy);
                }
            }

            return(DragDropEffects.Copy);
        }