Beispiel #1
0
        public static bool ImportOldData()
        {
            try
            {
                if (!System.IO.Directory.Exists(Helper.SimPeDataPath))
                {
                    System.IO.Directory.CreateDirectory(Helper.SimPeDataPath);
                }

                if (!System.IO.File.Exists(Helper.DataFolder.SimPeXREG))
                {
                    if (System.IO.Directory.Exists(Helper.WindowsRegistry.PreviousDataFolder))
                    {
                        if (Helper.WindowsRegistry.PreviousDataFolder.Trim().ToLower() != Helper.SimPeDataPath.Trim().ToLower())
                        {
                            if (Helper.SimPeVersionLong > Helper.WindowsRegistry.PreviousVersion && Helper.WindowsRegistry.PreviousVersion > 0)
                            {
                                if (Message.Show("Should SimPE import old Settings from \"" + Helper.WindowsRegistry.PreviousDataFolder + "\"?", "Import Settings", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    WaitingScreen.Wait();
                                    try
                                    {
                                        int      ct    = 0;
                                        string[] files = System.IO.Directory.GetFiles(Helper.WindowsRegistry.PreviousDataFolder, "*.*");
                                        foreach (string file in files)
                                        {
                                            string name = System.IO.Path.GetFileName(file).Trim().ToLower();
                                            if (name == "tgi.xml")
                                            {
                                                continue;
                                            }

                                            string newfile = file.Trim().ToLower().Replace(Helper.WindowsRegistry.PreviousDataFolder.Trim().ToLower(), Helper.SimPeDataPath.Trim());
                                            WaitingScreen.UpdateMessage((ct++).ToString() + " / " + files.Length);
                                            System.IO.File.Copy(file, newfile, true);
                                        }

                                        Helper.WindowsRegistry.Reload();
                                        ThemeManager.Global.CurrentTheme = (SimPe.GuiTheme)Helper.WindowsRegistry.Layout.SelectedTheme;
                                    }
#if !DEBUG
                                    catch (Exception ex) { Helper.ExceptionMessage(new Warning("Unable to import Settings.", ex.Message, ex)); }
#endif
                                    finally { WaitingScreen.Stop(); }
                                }
                            }
                        }
                    }
                }

                return(ConvertData());
            }
            finally
            {
            }

            //return true;
        }
Beispiel #2
0
        public ImportSemi()
        {
            //
            // Erforderlich für die Windows Form-Designerunterstützung
            //
            InitializeComponent();

            WaitingScreen.Wait();
            try
            {
                WaitingScreen.UpdateMessage("getting all SemiGlobal Groups");
                FileTable.FileIndex.Load();

                Interfaces.Scenegraph.IScenegraphFileIndexItem[] globs = FileTable.FileIndex.FindFile(Data.MetaData.GLOB_FILE, true);
                ArrayList names = new ArrayList();
                string    max   = " / " + globs.Length.ToString();
                int       ct    = 0;
                foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in globs)
                {
                    if (ct % 17 == 0)
                    {
                        WaitingScreen.UpdateMessage(ct.ToString() + max);
                    }
                    ct++;

                    SimPe.Plugin.NamedGlob glob = new SimPe.Plugin.NamedGlob();
                    glob.ProcessData(item.FileDescriptor, item.Package);

                    if (!names.Contains(glob.SemiGlobalName.Trim().ToLower()))
                    {
                        cbsemi.Items.Add(glob);
                        names.Add(glob.SemiGlobalName.Trim().ToLower());
                    }
                }
                cbsemi.Sorted = true;
            }
            finally { WaitingScreen.Stop(); }
        }
Beispiel #3
0
        /// <summary>
        /// Load FileDescriptors that are stored in the given File
        /// </summary>
        /// <param name="flname"></param>
        /// <param name="list">null or the list that should be used to add the Items</param>
        /// <returns></returns>
        public static void LoadDescriptorsFromDisk(string flname, PackedFileDescriptors list)
        {
            if (list == null)
            {
                return;
            }
            bool run = WaitingScreen.Running;

            if (!run)
            {
                WaitingScreen.Wait();
            }
            WaitingScreen.UpdateMessage("Load Descriptors From Disk");
            //list = new PackedFileDescriptors();
            try
            {
                if (flname.ToLower().EndsWith("package.xml"))
                {
                    SimPe.Packages.File pkg = Packages.GeneratableFile.LoadFromStream(XmlPackageReader.OpenExtractedPackage(null, flname));
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in pkg.Index)
                    {
                        Interfaces.Files.IPackedFile file = pkg.Read(pfd);
                        pfd.UserData = file.UncompressedData;
                        if (!list.Contains(pfd))
                        {
                            list.Add(pfd);
                        }
                    }
                }
                else if (flname.ToLower().EndsWith(".xml"))
                {
                    Interfaces.Files.IPackedFileDescriptor pfd = XmlPackageReader.OpenExtractedPackedFile(flname);
                    if (!list.Contains(pfd))
                    {
                        list.Add(pfd);
                    }
                }
                else if (flname.ToLower().EndsWith(".package") || flname.ToLower().EndsWith(".simpedis"))
                {
                    SimPe.Packages.File pkg = SimPe.Packages.File.LoadFromFile(flname);
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in pkg.Index)
                    {
                        Interfaces.Files.IPackedFile file = pkg.Read(pfd);
                        pfd.UserData = file.UncompressedData;
                        if (!list.Contains(pfd))
                        {
                            list.Add(pfd);
                        }
                    }
                }
                else
                {
                    Packages.PackedFileDescriptor pfd = new SimPe.Packages.PackedFileDescriptor();
                    pfd.Type = 0xffffffff;
                    ToolLoaderItemExt.OpenPackedFile(flname, ref pfd);
                    list.Add(pfd);
                }
            }
            finally
            {
                if (!run)
                {
                    WaitingScreen.Stop();
                }
            }
        }