示例#1
0
        private void PluginsForm_Load(object sender, EventArgs e)
        {
            SettingsFile.Settingsxml?.ReopenFile();
            if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("SaveToZip"), out this.saveToZip))
            {
                // do nothing to silence a compile error.
            }

            var pluginTypes = new List <Type>();

            foreach (var callbackplugin in KOMManager.Callbackplugins)
            {
                pluginTypes.Add(callbackplugin.GetType());
            }

            foreach (var komplugin in KOMManager.Komplugins)
            {
                pluginTypes.Add(komplugin.GetType());
            }

            // update the list if there were new sources added during the program execution.
            MainForm.PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                SettingsFile.Settingsxml?.TryRead("Sources", "Source", null),
                pluginTypes);
        }
示例#2
0
        /// <summary>
        /// Initializes the Plugins control for Els_kom's Plugins installer/updater form.
        /// </summary>
        public void InitControl()
        {
            // var closing = false;
            // this.doc = new List<XDocument>();
            SettingsFile.Settingsxml?.ReopenFile();
            if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("SaveToZip"), out this.saveToZip))
            {
                // do nothing to silence a compile error.
            }

            var pluginTypes = new List <Type>();

            foreach (var callbackplugin in ExecutionManager.Callbackplugins)
            {
                pluginTypes.Add(callbackplugin.GetType());
            }

            foreach (var komplugin in KOMStream.Komplugins)
            {
                pluginTypes.Add(komplugin.GetType());
            }

            // update the list if there were new sources added during the program execution.
            MainControl.PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                SettingsFile.Settingsxml?.TryRead("Sources", "Source", null),
                pluginTypes);
        }
示例#3
0
        private void PluginsForm_Load(object sender, EventArgs e)
        {
            this.saveToZip = SettingsFile.SettingsJson.SaveToZip;
            var pluginTypes = new List <Type>();

            pluginTypes.AddRange(KOMManager.Callbackplugins.Select((x) => x.GetType()));
            pluginTypes.AddRange(KOMManager.Komplugins.Select((x) => x.GetType()));

            // update the list if there were new sources added during the program execution.
            MainForm.PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                SettingsFile.SettingsJson.Sources.Source.ToArray(),
                pluginTypes,
                Els_kom_Main.ServiceProvider);
        }
示例#4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Hide();
            var closing = false;

            if (!Directory.Exists(Application.StartupPath + "\\koms"))
            {
                _ = Directory.CreateDirectory(Application.StartupPath + "\\koms");
            }

            if (ExecutionManager.IsElsKomRunning() == true)
            {
                _       = MessageManager.ShowError("Sorry, Only 1 Instance is allowed at a time.", "Error!", false);
                closing = true;
            }
            else
            {
                SettingsFile.Settingsxml = new XmlObject(SettingsFile.Path, "<Settings></Settings>");
                this.elsDir = SettingsFile.Settingsxml?.TryRead("ElsDir");
                if (this.elsDir.Length < 1)
                {
                    _ = MessageManager.ShowInfo("Welcome to Els_kom." + Environment.NewLine + "Now your fist step is to Configure Els_kom to the path that you have installed Elsword to and then you can Use the test Mods and the executing of the Launcher features. It will only take less than 1~3 minutes tops." + Environment.NewLine + "Also if you encounter any bugs or other things take a look at the Issue Tracker.", "Welcome!", false);

                    // avoids an issue where more than 1 settings form can be opened at the same time.
                    if (this.settingsfrm == null && this.aboutfrm == null)
                    {
                        this.settingsfrm = new SettingsForm();
                        _ = this.settingsfrm.ShowDialog();
                        this.settingsfrm.Dispose();
                        this.settingsfrm = null;
                    }
                }

                if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("SaveToZip"), out var saveToZip1))
                {
                    // do nothing to silence a compile error.
                }

                if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("LoadPDB"), out var loadPDB1))
                {
                    // do nothing to silence a compile error.
                }

                var komplugins = new GenericPluginLoader <IKomPlugin>().LoadPlugins("plugins", Convert.ToBoolean(saveToZip1), Convert.ToBoolean(loadPDB1));
                KOMManager.Komplugins.AddRange(komplugins);
                var callbackplugins = new GenericPluginLoader <ICallbackPlugin>().LoadPlugins("plugins", Convert.ToBoolean(saveToZip1), Convert.ToBoolean(loadPDB1));
                KOMManager.Callbackplugins.AddRange(callbackplugins);
                if (!GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsMaster ?? false)
                {
                    _ = MessageManager.ShowInfo("This branch is not the master branch, meaning this is a feature branch to test changes. When finished please pull request them for the possibility of them getting merged into master.", "Info!", Convert.ToBoolean(Convert.ToInt32(SettingsFile.Settingsxml?.TryRead("UseNotifications") != string.Empty ? SettingsFile.Settingsxml?.TryRead("UseNotifications") : "0")));
                }

                if (GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsDirty ?? false)
                {
                    var resp = MessageBox.Show("This build was compiled with Uncommitted changes. As a result, this build might be unstable. Are you sure you want to run this build to test some changes to the code?", "Info!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (resp == DialogResult.No)
                    {
                        closing = true;
                    }
                }
            }

            if (!closing)
            {
                this.MessageManager1.Icon    = this.Icon;
                this.MessageManager1.Text    = this.Text;
                this.MessageManager1.Visible = true;
                var pluginTypes = new List <Type>();
                foreach (var callbackplugin in KOMManager.Callbackplugins)
                {
                    pluginTypes.Add(callbackplugin.GetType());
                }

                foreach (var komplugin in KOMManager.Komplugins)
                {
                    pluginTypes.Add(komplugin.GetType());
                }

                PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                    SettingsFile.Settingsxml?.TryRead("Sources", "Source", null),
                    pluginTypes);
                foreach (var pluginUpdateCheck in PluginUpdateChecks)
                {
                    // discard result.
                    var result = pluginUpdateCheck.ShowMessage;
                }

                this.Show();
                this.Activate();
            }
            else
            {
                SettingsFile.Settingsxml = null;
                this.aboutfrm?.Close();
                this.settingsfrm?.Close();
                this.Close();
            }
        }
示例#5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Hide();
            this.packToolStripMenuItem.Image     = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.archive, ShareXResources.Theme.TextColor);
            this.unpackToolStripMenuItem.Image   = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.unarchive, ShareXResources.Theme.TextColor);
            this.testModsToolStripMenuItem.Image = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.vial_solid, ShareXResources.Theme.TextColor);
            this.launcherToolStripMenuItem.Image = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.launch, ShareXResources.Theme.TextColor);
            this.exitToolStripMenuItem.Image     = NativeMethods.GetNativeMenuItemImage(new IntPtr(NativeMethods.HBMMENU_POPUP_CLOSE), true);
            var closing = false;

            if (!Directory.Exists(Application.StartupPath + "\\koms"))
            {
                _ = Directory.CreateDirectory(Application.StartupPath + "\\koms");
            }

            if (ExecutionManager.IsElsKomRunning())
            {
                _       = MessageManager.ShowError("Sorry, Only 1 Instance is allowed at a time.", "Error!", false);
                closing = true;
            }
            else
            {
                this.elsDir = SettingsFile.SettingsJson.ElsDir;
                if (this.elsDir.Length < 1)
                {
                    _ = MessageManager.ShowInfo($"Welcome to Els_kom.{Environment.NewLine}Now your fist step is to Configure Els_kom to the path that you have installed Elsword to and then you can Use the test Mods and the executing of the Launcher features. It will only take less than 1~3 minutes tops.{Environment.NewLine}Also if you encounter any bugs or other things take a look at the Issue Tracker.", "Welcome!", false);

                    // avoids an issue where more than 1 settings form can be opened at the same time.
                    if (this.settingsfrm == null && this.aboutfrm == null)
                    {
                        using (this.settingsfrm = new SettingsForm())
                        {
                            _ = this.settingsfrm.ShowDialog();
                        }

                        this.settingsfrm = null;
                    }
                }

                var komplugins = new GenericPluginLoader <IKomPlugin>().LoadPlugins("plugins", out var domains1, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Komplugins.AddRange(komplugins);
                var callbackplugins = new GenericPluginLoader <ICallbackPlugin>().LoadPlugins("plugins", out var domains2, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Callbackplugins.AddRange(callbackplugins);
                var encryptionplugins = new GenericPluginLoader <IEncryptionPlugin>().LoadPlugins("plugins", out var domains3, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Encryptionplugins.AddRange(encryptionplugins);
#if NET5_0_OR_GREATER
                Contexts.AddRange(domains1);
                Contexts.AddRange(domains2);
                Contexts.AddRange(domains3);
#else
                Domains.AddRange(domains1);
                Domains.AddRange(domains2);
                Domains.AddRange(domains3);
#endif
                if (!GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsMain ?? false)
                {
                    _ = MessageManager.ShowInfo("This branch is not the main branch, meaning this is a feature branch to test changes. When finished please pull request them for the possibility of them getting merged into main.", "Info!", Convert.ToBoolean(SettingsFile.SettingsJson.UseNotifications));
                }

                if (GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsDirty ?? false)
                {
                    var resp = MessageBox.Show("This build was compiled with Uncommitted changes. As a result, this build might be unstable. Are you sure you want to run this build to test some changes to the code?", "Info!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (resp == DialogResult.No)
                    {
                        closing = true;
                    }
                }
            }

            if (!closing)
            {
                MessageManager.Icon = this.Icon;
                MessageManager.Text = this.Text;
                var pluginTypes = new List <Type>();
                pluginTypes.AddRange(KOMManager.Callbackplugins.Select((x) => x.GetType()));
                pluginTypes.AddRange(KOMManager.Komplugins.Select((x) => x.GetType()));
                pluginTypes.AddRange(KOMManager.Encryptionplugins.Select((x) => x.GetType()));
                PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                    SettingsFile.SettingsJson.Sources.Source.ToArray(),
                    pluginTypes,
                    Els_kom_Main.ServiceProvider);
                foreach (var pluginUpdateCheck in PluginUpdateChecks)
                {
                    // discard result.
                    _ = pluginUpdateCheck.ShowMessage;
                }

                MessageManager.Visible = true;
                this.Show();
                this.Activate();
            }
            else
            {
                SettingsFile.SettingsJson = null;
                this.aboutfrm?.Close();
                this.settingsfrm?.Close();
                this.Close();
            }
        }
示例#6
0
        /// <summary>
        /// Initializes the MainControl's constants.
        /// </summary>
        public void LoadControl()
        {
            this.MakeTrayIcon();
            var closing = false;

            if (!Directory.Exists(Application.StartupPath + "\\koms"))
            {
                Directory.CreateDirectory(Application.StartupPath + "\\koms");
            }

            if (ExecutionManager.IsElsKomRunning() == true)
            {
                MessageManager.ShowError("Sorry, Only 1 Instance is allowed at a time.", "Error!", Convert.ToBoolean(Convert.ToInt32(SettingsFile.Settingsxml?.TryRead("UseNotifications") != string.Empty ? SettingsFile.Settingsxml?.TryRead("UseNotifications") : "0")));
                closing = true;
            }
            else
            {
                SettingsFile.Settingsxml = new XmlObject(SettingsFile.Path, "<Settings></Settings>");
                this.elsDir = SettingsFile.Settingsxml?.TryRead("ElsDir");
                if (this.elsDir.Length < 1)
                {
                    MessageManager.ShowInfo("Welcome to Els_kom." + Environment.NewLine + "Now your fist step is to Configure Els_kom to the path that you have installed Elsword to and then you can Use the test Mods and the executing of the Launcher features. It will only take less than 1~3 minutes tops." + Environment.NewLine + "Also if you encounter any bugs or other things take a look at the Issue Tracker.", "Welcome!", Convert.ToBoolean(Convert.ToInt32(SettingsFile.Settingsxml?.TryRead("UseNotifications") != string.Empty ? SettingsFile.Settingsxml?.TryRead("UseNotifications") : "0")));
                    this.ConfigForm?.Invoke(this, new EventArgs());
                }

                if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("SaveToZip"), out var saveToZip1))
                {
                    // do nothing to silence a compile error.
                }

                if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("LoadPDB"), out var loadPDB1))
                {
                    // do nothing to silence a compile error.
                }

                var komplugins = GenericPluginLoader <IKomPlugin> .LoadPlugins("plugins", Convert.ToBoolean(saveToZip1), Convert.ToBoolean(loadPDB1));

                KOMStream.Komplugins.AddRange(komplugins);
                var callbackplugins = GenericPluginLoader <ICallbackPlugin> .LoadPlugins("plugins", Convert.ToBoolean(saveToZip1), Convert.ToBoolean(loadPDB1));

                ExecutionManager.Callbackplugins.AddRange(callbackplugins);
                if (!Git.IsMaster)
                {
                    MessageManager.ShowInfo("This branch is not the master branch, meaning this is a feature branch to test changes. When finished please pull request them for the possibility of them getting merged into master.", "Info!", Convert.ToBoolean(Convert.ToInt32(SettingsFile.Settingsxml?.TryRead("UseNotifications") != string.Empty ? SettingsFile.Settingsxml?.TryRead("UseNotifications") : "0")));
                }

                if (Git.IsDirty)
                {
                    var resp = MessageBox.Show("This build was compiled with Uncommitted changes. As a result, this build might be unstable. Are you sure you want to run this build to test some changes to the code?", "Info!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (resp == DialogResult.No)
                    {
                        closing = true;
                    }
                }
            }

            if (!closing)
            {
                if (this.components == null)
                {
                    this.components = new Container();
                }

                this.settingsTmr?.Dispose();
                this.settingsTmr = new System.Windows.Forms.Timer(this.components)
                {
                    Enabled  = true,
                    Interval = 1,
                };
                this.settingsTmr.Tick += new EventHandler(this.CheckSettings);
                this.packingTmr?.Dispose();
                this.packingTmr = new System.Windows.Forms.Timer(this.components)
                {
                    Enabled  = false,
                    Interval = 1,
                };
                this.packingTmr.Tick += new EventHandler(this.Packing);
                this.unpackingTmr?.Dispose();
                this.unpackingTmr = new System.Windows.Forms.Timer(this.components)
                {
                    Enabled  = false,
                    Interval = 1,
                };
                this.unpackingTmr.Tick += new EventHandler(this.Unpacking);
                this.testModsTmr?.Dispose();
                this.testModsTmr = new System.Windows.Forms.Timer(this.components)
                {
                    Enabled  = false,
                    Interval = 1,
                };
                this.testModsTmr.Tick += new EventHandler(this.TestMods2);
                this.launcherTmr?.Dispose();
                this.launcherTmr = new System.Windows.Forms.Timer(this.components)
                {
                    Enabled  = false,
                    Interval = 1,
                };
                this.launcherTmr.Tick            += new EventHandler(this.Launcher);
                MessageManager.NotifyIcon.Icon    = this.FindForm().Icon;
                MessageManager.NotifyIcon.Text    = this.FindForm().Text;
                MessageManager.NotifyIcon.Visible = true;
                var pluginTypes = new List <Type>();
                foreach (var callbackplugin in ExecutionManager.Callbackplugins)
                {
                    pluginTypes.Add(callbackplugin.GetType());
                }

                foreach (var komplugin in KOMStream.Komplugins)
                {
                    pluginTypes.Add(komplugin.GetType());
                }

                PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                    SettingsFile.Settingsxml?.TryRead("Sources", "Source", null),
                    pluginTypes);
                foreach (var pluginUpdateCheck in PluginUpdateChecks)
                {
                    // discard result.
                    var result = pluginUpdateCheck.ShowMessage;
                }

                this.FindForm().Show();
            }
            else
            {
                SettingsFile.Settingsxml = null;
                this.CloseForm?.Invoke(this, new EventArgs());
            }
        }