Ejemplo n.º 1
0
 private void ClickItem(object sender, System.EventArgs e)
 {
     try
     {
         if (tool.IsEnabled(pfd, package))
         {
             SimPe.Interfaces.Plugin.IToolResult tr = tool.ShowDialog(ref pfd, ref package);
             WaitingScreen.Stop();
             if (tr.ChangedAny)
             {
                 PackageArg p = new PackageArg();
                 p.Package        = package;
                 p.FileDescriptor = pfd;
                 p.Result         = tr;
                 if (chghandler != null)
                 {
                     chghandler(this, p);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Helper.ExceptionMessage("Unable to Start ToolPlugin.", ex);
     }
 }
Ejemplo n.º 2
0
 private void tsmiStopWaiting_Click(object sender, EventArgs e)
 {
     Application.UseWaitCursor = false;
     Wait.Stop();
     WaitingScreen.Stop();
     Splash.Screen.Stop();
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
 void frm_FormClosed(object sender, FormClosedEventArgs e)
 {
     System.Diagnostics.Trace.WriteLine("SimPe.WaitingScreen.frm_FormClosed(...)");
     Application.UseWaitCursor = false;
     lock (lockFrm)
     {
         frm = null;
         lock (lockScr)
         {
             scr = null;
         }
     }
     count = 0;
 }
Ejemplo n.º 5
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(); }
        }
Ejemplo n.º 6
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();
                }
            }
        }
Ejemplo n.º 7
0
        public static DialogResult Show(string message, string caption, MessageBoxButtons mbb)
        {
            bool run = WaitingScreen.Running;
            bool spl = Splash.Running;

            if (run)
            {
                WaitingScreen.Stop();
            }
            if (spl)
            {
                Splash.Screen.Stop();
            }
            try
            {
                caption = SimPe.Localization.GetString(caption);
                Message m = new Message();
                if (mbb == MessageBoxButtons.YesNoCancel)
                {
                    m.AddButton(SimPe.Localization.Manager.GetString("cancel"), DialogResult.Cancel);
                    m.AddButton(SimPe.Localization.Manager.GetString("no"), DialogResult.No);
                    m.AddButton(SimPe.Localization.Manager.GetString("yes"), DialogResult.Yes);
                }
                else if (mbb == MessageBoxButtons.OKCancel)
                {
                    m.AddButton(SimPe.Localization.Manager.GetString("cancel"), DialogResult.Cancel);
                    m.AddButton(SimPe.Localization.Manager.GetString("ok"), DialogResult.OK);
                }
                else if (mbb == MessageBoxButtons.YesNo)
                {
                    m.AddButton(SimPe.Localization.Manager.GetString("no"), DialogResult.No);
                    m.AddButton(SimPe.Localization.Manager.GetString("yes"), DialogResult.Yes);
                }
                else
                {
                    m.AddButton(SimPe.Localization.Manager.GetString("ok"), DialogResult.OK);
                }

                if (caption != null)
                {
                    m.Text = caption;
                }
                m.label1.AutoSize = false;
                m.panel1.Width    = m.ClientRectangle.Width;
                m.panel2.Width    = m.panel1.Width;
                m.label1.Width    = m.panel2.Width - (2 * m.label1.Left);
                m.label1.Text     = message;

                string text     = m.label1.Text;
                Font   textFont = m.label1.Font;

                //Specify a fixed width, but let the height be "unlimited"
                SizeF    layoutSize = new SizeF(m.label1.Width, 5000.0F);
                Graphics g          = Graphics.FromHwnd(m.label1.Handle);
                SizeF    stringSize = g.MeasureString(text, textFont, layoutSize);
                g.Dispose();
                m.label1.Height = (int)stringSize.Height;
                int newsize = m.label1.Height + (2 * m.label1.Top);


                m.panel2.Height = newsize;
                m.panel1.Top    = m.panel2.Height;

                m.Height = m.panel2.Height + m.panel1.Height + System.Windows.Forms.SystemInformation.CaptionHeight;

                ThemeManager.Global.Theme(m.panel2);
                m.panel1.BackColor = ThemeManager.Global.ThemeColorDark;

                m.ShowDialog();

                return(m.DialogResult);
            }
            catch
            {
                return(MessageBox.Show(message, caption, mbb));
            }
            finally
            {
                if (run)
                {
                    WaitingScreen.Wait();
                }
                if (spl)
                {
                    Splash.Screen.SetMessage("");
                }
            }
        }