示例#1
0
        public NewOverlayDialog(PluginMain pluginMain)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;

            // Default validator
            this.NameValidator = (name) => { return(name != null); };

            foreach (var overlayType in Registry.Overlays)
            {
                var name = overlayType.Name;
                if (name.EndsWith("Overlay"))
                {
                    name = name.Substring(0, name.Length - 7);
                }

                comboBox1.Items.Add(new KeyValuePair <string, Type>(name, overlayType));
            }

            comboBox1.DisplayMember = "Key";
            comboBox1.SelectedIndex = 0;

            textBox1.Focus();
        }
示例#2
0
        public ControlPanel(PluginMain pluginMain, PluginConfig config)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;
            this.config     = config;

            SetupMiniParseConfigHandlers();
            SetupSpellTimerConfigHandlers();

            SetupMiniParseTab();
            SetupSpellTimerTab();

            this.menuFollowLatestLog.Checked  = this.config.FollowLatestLog;
            this.listViewLog.VirtualListSize  = pluginMain.Logs.Count;
            this.pluginMain.Logs.ListChanged += (o, e) =>
            {
                this.listViewLog.BeginUpdate();
                this.listViewLog.VirtualListSize = pluginMain.Logs.Count;
                if (this.config.FollowLatestLog && this.pluginMain.Logs.Count > 0)
                {
                    this.listViewLog.EnsureVisible(this.pluginMain.Logs.Count - 1);
                }
                this.listViewLog.EndUpdate();
            };
        }
示例#3
0
        public ControlPanel(PluginMain pluginMain, PluginConfig config)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;
            this.config     = config;

            this.checkBoxAutoHide.Checked = this.config.HideOverlaysWhenNotActive;

            this.menuFollowLatestLog.Checked         = this.config.FollowLatestLog;
            this.listViewLog.VirtualListSize         = pluginMain.Logger.Logs.Count;
            this.pluginMain.Logger.Logs.ListChanged += (o, e) =>
            {
                this.listViewLog.BeginUpdate();
                this.listViewLog.VirtualListSize = pluginMain.Logger.Logs.Count;
                if (this.config.FollowLatestLog && this.listViewLog.VirtualListSize > 0)
                {
                    this.listViewLog.EnsureVisible(this.listViewLog.VirtualListSize - 1);
                }
                this.listViewLog.EndUpdate();
            };

            InitializeOverlayConfigTabs();
            UpdateOverlayListView();
        }
示例#4
0
        private void Initialize(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            pluginStatusText.Text = "Initializing Runtime...";

            Registry.Init();
            logger = new Logger();
            asmResolver.ExceptionOccured += (o, e) => logger.Log(LogLevel.Error, "AssemblyResolver: Error: {0}", e.Exception);
            asmResolver.AssemblyLoaded   += (o, e) => logger.Log(LogLevel.Debug, "AssemblyResolver: Loaded: {0}", e.LoadedAssembly.FullName);
            pluginMain = new PluginMain(pluginDirectory, logger);

            if (ActGlobals.oFormActMain.Visible)
            {
                // ACT is running and this plugin was added. Immediately initialize!
                InitPluginCore(pluginScreenSpace, pluginStatusText);
            }
            else
            {
                // ACT is starting up and loading plugins. Wait until it's done and the main window becomes visible before we start initializing.
                EventHandler initHandler = null;
                initHandler = (o, e) =>
                {
                    ActGlobals.oFormActMain.VisibleChanged -= initHandler;
                    InitPluginCore(pluginScreenSpace, pluginStatusText);
                };

                ActGlobals.oFormActMain.VisibleChanged += initHandler;
                pluginStatusText.Text = "Waiting for ACT to finish startup...";
            }
        }
示例#5
0
        private async void Initialize()
        {
            pluginStatusText.Text = Resources.InitRuntime;

            var container = new TinyIoCContainer();

            logger = new Logger();
            container.Register(logger);
            container.Register <ILogger>(logger);

            asmResolver.ExceptionOccured += (o, e) => logger.Log(LogLevel.Error, Resources.AssemblyResolverError, e.Exception);
            asmResolver.AssemblyLoaded   += (o, e) => logger.Log(LogLevel.Debug, Resources.AssemblyResolverLoaded, e.LoadedAssembly.FullName);

            this.Container = container;
            pluginMain     = new PluginMain(pluginDirectory, logger, container);
            container.Register(pluginMain);

            pluginStatusText.Text = Resources.InitCef;

            SanityChecker.CheckDependencyVersions(logger);

            try
            {
                CurlWrapper.Init(pluginDirectory);
            } catch (Exception ex)
            {
                logger.Log(LogLevel.Error, ex.ToString());
                ActGlobals.oFormActMain.WriteDebugLog(ex.ToString());
            }

            await FinishInit(container);
        }
示例#6
0
        public ControlPanel(PluginMain pluginMain, PluginConfig config)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;
            this.config     = config;

            this.checkBoxAutoHide.Checked = this.config.HideOverlaysWhenNotActive;

            this.menuFollowLatestLog.Checked         = this.config.FollowLatestLog;
            this.listViewLog.VirtualListSize         = pluginMain.Logger.Logs.Count;
            this.pluginMain.Logger.Logs.ListChanged += (o, e) =>
            {
                this.listViewLog.BeginUpdate();
                this.listViewLog.VirtualListSize = pluginMain.Logger.Logs.Count;
                if (this.config.FollowLatestLog && this.listViewLog.VirtualListSize > 0)
                {
                    this.listViewLog.EnsureVisible(this.listViewLog.VirtualListSize - 1);
                }
                this.listViewLog.EndUpdate();
            };

            InitializeOverlayConfigTabs();

            screenShotPath.Text                    = config.ScreenShotSavePath;
            screenShotBackgroundPath.Text          = config.ScreenShotBackgroundPath;
            screenShotBackgroundMode.SelectedIndex = config.ScreenShotBackgroundMode;
            screenShotAutoClipping.Checked         = config.ScreenShotAutoClipping;
            screenShotMargin.Value                 = config.ScreenShotMargin;

            if (string.IsNullOrWhiteSpace(screenShotPath.Text))
            {
                screenShotPath.Text = PluginMain.DefaultScreenShotPath;
            }
        }
示例#7
0
 private void Initialize(TabPage pluginScreenSpace, Label pluginStatusText)
 {
     asmResolver.ExceptionOccured += (o, e) => logger.Log(LogLevel.Error, "AssemblyResolver: Error: {0}", e.Exception);
     asmResolver.AssemblyLoaded   += (o, e) => logger.Log(LogLevel.Debug, "AssemblyResolver: Loaded: {0}", e.LoadedAssembly.FullName);
     pluginMain = new PluginMain(pluginDirectory, logger);
     pluginMain.InitPlugin(pluginScreenSpace, pluginStatusText);
 }
示例#8
0
        public ControlPanel(TinyIoCContainer container)
        {
            InitializeComponent();
            tableLayoutPanel0.PerformLayout();
            splitContainer1.SplitterDistance = (int)Math.Round(Height * 0.75);

            _container  = container;
            _logger     = container.Resolve <ILogger>();
            _pluginMain = container.Resolve <PluginMain>();
            _config     = container.Resolve <IPluginConfig>();
            _registry   = container.Resolve <Registry>();

            this.checkBoxFollowLog.Checked = _config.FollowLatestLog;

            _generalTab = new ConfigTabPage
            {
                Name = Resources.GeneralTab,
                Text = "",
            };
            _generalTab.Controls.Add(new GeneralConfigTab(container));

            _eventTab = new ConfigTabPage
            {
                Name = Resources.EventConfigTab,
                Text = "",
            };
            _eventTab.Controls.Add(new EventSources.BuiltinEventConfigPanel(container));

            _logger.RegisterListener(AddLogEntry);
            _registry.EventSourceRegistered += (o, e) => Invoke((Action)(() => AddEventSourceTab(o, e)));
        }
        public TriggIntegration(TinyIoCContainer container)
        {
            var logger = container.Resolve <ILogger>();

            _plugin = container.Resolve <PluginMain>();

            try
            {
                var trigg = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.lblPluginTitle.Text == "Triggernometry.dll");
                if (trigg == null || trigg.pluginObj == null)
                {
                    return;
                }

                var triggType = trigg.pluginObj.GetType();
                var deleType  = triggType.GetNestedType("CustomCallbackDelegate");
                if (deleType == null)
                {
                    return;
                }

                var dele = Delegate.CreateDelegate(deleType, this, typeof(TriggIntegration).GetMethod("SendOverlayMessage"));
                triggType.GetMethod("RegisterNamedCallback")?.Invoke(trigg.pluginObj, new object[] { "OverlayPluginMessage", dele, null });
            } catch (Exception ex)
            {
                logger.Log(LogLevel.Error, $"Failed to register Triggernometry callback: {ex}");
            }
        }
示例#10
0
        private void Initialize(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            // Prevent a stack overflow in the assembly loaded handler by loading the logger interface early.
            var dummy = typeof(ILogger);

            Registry.Init();
            logger = new Logger();
            asmResolver.ExceptionOccured += (o, e) => logger.Log(LogLevel.Error, "AssemblyResolver: Error: {0}", e.Exception);
            asmResolver.AssemblyLoaded   += (o, e) => logger.Log(LogLevel.Debug, "AssemblyResolver: Loaded: {0}", e.LoadedAssembly.FullName);
            pluginMain = new PluginMain(pluginDirectory, logger);

            if (ActGlobals.oFormActMain.Visible)
            {
                // ACT is running and this plugin was added. Immediately initialize!
                pluginMain.InitPlugin(pluginScreenSpace, pluginStatusText);
            }
            else
            {
                // ACT is starting up and loading plugins. Wait until it's done and the main window becomes visible before we start initializing.
                EventHandler initHandler = null;
                initHandler = (o, e) =>
                {
                    ActGlobals.oFormActMain.VisibleChanged -= initHandler;

                    pluginMain.InitPlugin(pluginScreenSpace, pluginStatusText);
                };

                ActGlobals.oFormActMain.VisibleChanged += initHandler;
            }
        }
示例#11
0
        public OverlayHider(TinyIoCContainer container)
        {
            this.config     = container.Resolve <IPluginConfig>();
            this.logger     = container.Resolve <ILogger>();
            this.main       = container.Resolve <PluginMain>();
            this.repository = container.Resolve <FFXIVRepository>();

            container.Resolve <NativeMethods>().ActiveWindowChanged   += ActiveWindowChangedHandler;
            container.Resolve <NetworkParser>().OnOnlineStatusChanged += OnlineStatusChanged;
            container.Resolve <EventSources.EnmityEventSource>().CombatStatusChanged += CombatStatusChanged;

            try
            {
                repository.RegisterProcessChangedHandler(UpdateFFXIVProcess);
            } catch (Exception ex)
            {
                logger.Log(LogLevel.Error, "Failed to register process watcher for FFXIV; this is only an issue if you're playing FFXIV. As a consequence, OverlayPlugin won't be able to hide overlays if you're not in-game.");
                logger.Log(LogLevel.Error, "Details: " + ex.ToString());
            }

            focusTimer          = new Timer();
            focusTimer.Tick    += (o, e) => ActiveWindowChangedHandler(this, IntPtr.Zero);
            focusTimer.Interval = 10000;  // 10 seconds
            focusTimer.Start();
        }
示例#12
0
 public WSServer(TinyIoCContainer container)
 {
     _container = container;
     _logger    = container.Resolve <ILogger>();
     _cfg       = container.Resolve <IPluginConfig>();
     _plugin    = container.Resolve <PluginMain>();
 }
示例#13
0
        public NewOverlayDialog(PluginMain pluginMain)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;

            // Default validator
            NameValidator = (name) => { return(name != null); };

            foreach (var overlayType in Registry.Overlays)
            {
                var name = overlayType.Name;
                if (name.EndsWith("Overlay"))
                {
                    name = name.Substring(0, name.Length - 7);
                }

                if (overlayNames.ContainsKey(name))
                {
                    name = overlayNames[name];
                }

                cbType.Items.Add(new KeyValuePair <string, Type>(name, overlayType));
            }

            cbType.DisplayMember = "Key";
            cbType.SelectedIndex = 0;
            presets = PreparePresetCombo(cbPreset);

            lblType.Visible     = false;
            cbType.Visible      = false;
            lblTypeDesc.Visible = false;

            textBox1.Focus();
        }
示例#14
0
        public WSConfigPanel(TinyIoCContainer container)
        {
            InitializeComponent();

            _config   = container.Resolve <IPluginConfig>();
            _server   = container.Resolve <WSServer>();
            _plugin   = container.Resolve <PluginMain>();
            _registry = container.Resolve <Registry>();


            ipTxt.Text     = _config.WSServerIP;
            portTxt.Text   = "" + _config.WSServerPort;
            sslBox.Checked = _config.WSServerSSL;
            sslBox.Enabled = _server.IsSSLPossible();

            for (var i = 0; i < regionCb.Items.Count; i++)
            {
                if ((string)regionCb.Items[i] == _config.TunnelRegion)
                {
                    regionCb.SelectedIndex = i;
                    break;
                }
            }

            UpdateStatus(null, new WSServer.StateChangedArgs(_server.IsRunning(), _server.IsFailed()));
            _server.OnStateChanged += UpdateStatus;

            UpdateTunnelStatus(TunnelStatus.Inactive);

            lblUrlConfidentWarning.Visible = false;
        }
示例#15
0
        public ControlPanel(PluginMain pluginMain, PluginConfig config)
        {
            InitializeComponent();
            tableLayoutPanel0.PerformLayout();
            splitContainer1.SplitterDistance = splitContainer1.Height - 180;

            this.pluginMain = pluginMain;
            this.config     = config;

            this.checkBoxFollowLog.Checked = this.config.FollowLatestLog;

            generalTab = new ConfigTabPage
            {
                Name = Resources.GeneralTab,
                Text = "",
            };
            generalTab.Controls.Add(new GeneralConfigTab());

            eventTab = new ConfigTabPage
            {
                Name = Resources.EventConfigTab,
                Text = "",
            };
            eventTab.Controls.Add(new EventSources.BuiltinEventConfigPanel());

            PluginMain.Logger.RegisterListener(AddLogEntry);
            Registry.EventSourceRegistered += (o, e) => Invoke((Action)(() => AddEventSourceTab(o, e)));
        }
示例#16
0
        public static void Init()
        {
            main   = Registry.Resolve <PluginMain>();
            logger = Registry.Resolve <ILogger>();

            var span = TimeSpan.FromSeconds(3);

            timer = new Timer(EnsureOverlaysAreOverGame, null, span, span);
        }
示例#17
0
        public static void Init()
        {
            config = Registry.Resolve <IPluginConfig>();
            logger = Registry.Resolve <ILogger>();
            main   = Registry.Resolve <PluginMain>();

            NativeMethods.ActiveWindowChanged   += ActiveWindowChangedHandler;
            NetworkParser.OnOnlineStatusChanged += OnlineStatusChanged;
        }
示例#18
0
        public OverlayHider(TinyIoCContainer container)
        {
            this.config     = container.Resolve <IPluginConfig>();
            this.logger     = container.Resolve <ILogger>();
            this.main       = container.Resolve <PluginMain>();
            this.repository = container.Resolve <FFXIVRepository>();

            container.Resolve <NativeMethods>().ActiveWindowChanged   += ActiveWindowChangedHandler;
            container.Resolve <NetworkParser>().OnOnlineStatusChanged += OnlineStatusChanged;
        }
示例#19
0
        public OverlayZCorrector(TinyIoCContainer container)
        {
            main       = container.Resolve <PluginMain>();
            logger     = container.Resolve <ILogger>();
            repository = container.Resolve <FFXIVRepository>();

            var span = TimeSpan.FromSeconds(3);

            timer = new Timer(EnsureOverlaysAreOverGame, null, span, span);
        }
示例#20
0
        public ControlPanel(PluginMain pluginMain, PluginConfig config)
        {
            InitializeComponent();
            tableLayoutPanel0.PerformLayout();

            this.pluginMain = pluginMain;
            this.config     = config;

            this.checkBoxAutoHide.Checked  = this.config.HideOverlaysWhenNotActive;
            this.checkBoxFollowLog.Checked = this.config.FollowLatestLog;

            PluginMain.Logger.RegisterListener(addLogEntry);
            Registry.AddonRegistered += InitializeOverlayConfigTabs;
            InitializeOverlayConfigTabs(null, null);
        }
示例#21
0
        public NewOverlayDialog(PluginMain pluginMain)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;

            this.NameValidator = (name) => { return(name != null); };

            foreach (var addon in pluginMain.Addons)
            {
                comboBox1.Items.Add(addon);
            }

            comboBox1.DisplayMember = "Name";
            comboBox1.SelectedIndex = 0;
        }
示例#22
0
        public OverlayHider(TinyIoCContainer container)
        {
            this.config     = container.Resolve <IPluginConfig>();
            this.logger     = container.Resolve <ILogger>();
            this.main       = container.Resolve <PluginMain>();
            this.repository = container.Resolve <FFXIVRepository>();

            container.Resolve <NativeMethods>().ActiveWindowChanged   += ActiveWindowChangedHandler;
            container.Resolve <NetworkParser>().OnOnlineStatusChanged += OnlineStatusChanged;
            repository.RegisterProcessChangedHandler(UpdateFFXIVProcess);

            focusTimer          = new Timer();
            focusTimer.Tick    += (o, e) => ActiveWindowChangedHandler(this, IntPtr.Zero);
            focusTimer.Interval = 10000;  // 10 seconds
            focusTimer.Start();
        }
示例#23
0
        public NewOverlayDialog(TinyIoCContainer container)
        {
            InitializeComponent();

            pluginMain     = container.Resolve <PluginMain>();
            registry       = container.Resolve <Registry>();
            logger         = container.Resolve <ILogger>();
            this.container = container;

            // Default validator
            NameValidator = (name) => { return(name != null); };

            foreach (var overlayType in registry.Overlays)
            {
                var name = overlayType.Name;
                if (name.EndsWith("Overlay"))
                {
                    name = name.Substring(0, name.Length - 7);
                }

                if (overlayNames.ContainsKey(name))
                {
                    name = overlayNames[name];
                }

                cbType.Items.Add(new KeyValuePair <string, Type>(name, overlayType));
            }

            cbType.DisplayMember = "Key";
            // Workaround for the special case where no overlay type has been registered.
            // That still indicates a bug but showing an empty combo box is better than crashing.
            if (cbType.Items.Count > 0)
            {
                cbType.SelectedIndex = 0;
            }

            presets = PreparePresetCombo(cbPreset);

            lblType.Visible     = false;
            cbType.Visible      = false;
            lblTypeDesc.Visible = false;

            textBox1.Focus();
        }
示例#24
0
        public ControlPanel(TinyIoCContainer container)
        {
            InitializeComponent();
            tableLayoutPanel0.PerformLayout();
            // Make the log box big until we load the overlays since the log is going to be *very*
            // important if we never make it that far.
            splitContainer1.SplitterDistance = 5;

            _container  = container;
            _logger     = container.Resolve <ILogger>();
            _pluginMain = container.Resolve <PluginMain>();
            _config     = container.Resolve <IPluginConfig>();
            _registry   = container.Resolve <Registry>();

            this.checkBoxFollowLog.Checked = _config.FollowLatestLog;

            _generalTab = new ConfigTabPage
            {
                Name = Resources.GeneralTab,
                Text = "",
            };
            _generalTab.Controls.Add(new GeneralConfigTab(container));

            _eventTab = new ConfigTabPage
            {
                Name = Resources.EventConfigTab,
                Text = "",
            };
            _eventTab.Controls.Add(new EventSources.BuiltinEventConfigPanel(container));

            _logger.RegisterListener(AddLogEntry);
            _registry.EventSourceRegistered += (o, e) => Invoke((Action)(() => AddEventSourceTab(o, e)));

            Resize += (o, e) =>
            {
                if (!logResized && Height > 500 && tabControl.TabCount > 0)
                {
                    logResized = true;
                    // Overlay tabs have been initialised, everything is fine; make the log small again.
                    splitContainer1.SplitterDistance = (int)Math.Round(Height * 0.75);
                }
            };
        }
示例#25
0
        public ControlPanel(PluginMain pluginMain, PluginConfig config)
        {
            InitializeComponent();
            tableLayoutPanel0.PerformLayout();
            splitContainer1.SplitterDistance = splitContainer1.Height - 180;

            this.pluginMain = pluginMain;
            this.config     = config;

            this.checkBoxFollowLog.Checked = this.config.FollowLatestLog;

            generalTab = new TabPage
            {
                Name = "General",
                Text = "",
            };
            generalTab.Controls.Add(new GeneralConfigTab());

            PluginMain.Logger.RegisterListener(addLogEntry);
            Registry.AddonRegistered += InitializeOverlayConfigTabs;
            InitializeOverlayConfigTabs(null, null);
        }
示例#26
0
        private async void Initialize()
        {
            pluginStatusText.Text = Resources.InitRuntime;

            Registry.Init();
            logger = new Logger();
            asmResolver.ExceptionOccured += (o, e) => logger.Log(LogLevel.Error, Resources.AssemblyResolverError, e.Exception);
            asmResolver.AssemblyLoaded   += (o, e) => logger.Log(LogLevel.Debug, Resources.AssemblyResolverLoaded, e.LoadedAssembly.FullName);
            pluginMain = new PluginMain(pluginDirectory, logger);

            pluginStatusText.Text = Resources.InitCef;

            try
            {
                CurlWrapper.Init(pluginDirectory);
            } catch (Exception ex)
            {
                logger.Log(LogLevel.Error, ex.ToString());
            }

            await FinishInit();
        }
示例#27
0
        private async void Initialize(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            pluginStatusText.Text = Resources.InitRuntime;

            Registry.Init();
            logger = new Logger();
            asmResolver.ExceptionOccured += (o, e) => logger.Log(LogLevel.Error, Resources.AssemblyResolverError, e.Exception);
            asmResolver.AssemblyLoaded   += (o, e) => logger.Log(LogLevel.Debug, Resources.AssemblyResolverLoaded, e.LoadedAssembly.FullName);
            pluginMain = new PluginMain(pluginDirectory, logger);

            pluginStatusText.Text = Resources.InitCef;

            try
            {
                CurlWrapper.Init(pluginDirectory);
            } catch (Exception ex)
            {
                logger.Log(LogLevel.Error, ex.ToString());
            }

            if (await CefInstaller.EnsureCef(GetCefPath()))
            {
                // Finally, load the html renderer. We load it here since HtmlRenderer depends on CEF which we can't load these before
                // the CefInstaller is done.
                if (SanityChecker.LoadSaneAssembly("HtmlRenderer"))
                {
                    // Since this is an async method, we could have switched threds. Make sure InitPlugin() runs on the ACT main thread.
                    ActGlobals.oFormActMain.Invoke((Action)(() =>
                    {
                        pluginMain.InitPlugin(pluginScreenSpace, pluginStatusText);
                    }));
                }
                else
                {
                    pluginStatusText.Text = Resources.CoreOrHtmlRendererInsane;
                }
            }
        }
        public TriggIntegration(TinyIoCContainer container)
        {
            var logger = container.Resolve <ILogger>();

            _plugin = container.Resolve <PluginMain>();

            try
            {
                var trigg = GetPluginData();
                if (trigg == null || trigg.pluginObj == null)
                {
                    return;
                }

                var triggType = trigg.pluginObj.GetType();
                var deleType  = triggType.GetNestedType("CustomCallbackDelegate");
                if (deleType == null)
                {
                    return;
                }

                var registerType = triggType.GetMethod("RegisterNamedCallback");

                var sendDele = Delegate.CreateDelegate(deleType, this, typeof(TriggIntegration).GetMethod("SendOverlayMessage"));
                registerType?.Invoke(trigg.pluginObj, new object[] { "OverlayPluginMessage", sendDele, null });

                var hideDele = Delegate.CreateDelegate(deleType, this, typeof(TriggIntegration).GetMethod("HideOverlay"));
                registerType?.Invoke(trigg.pluginObj, new object[] { "HideOverlay", hideDele, null });

                var showDele = Delegate.CreateDelegate(deleType, this, typeof(TriggIntegration).GetMethod("ShowOverlay"));
                registerType?.Invoke(trigg.pluginObj, new object[] { "ShowOverlay", showDele, null });
            } catch (Exception ex)
            {
                logger.Log(LogLevel.Error, $"Failed to register Triggernometry callback: {ex}");
            }
        }
示例#29
0
        public NewOverlayDialog(PluginMain pluginMain)
        {
            InitializeComponent();

            this.pluginMain = pluginMain;

            // Default validator
            NameValidator = (name) => { return(name != null); };

            foreach (var overlayType in Registry.Overlays)
            {
                var name = overlayType.Name;
                if (name.EndsWith("Overlay"))
                {
                    name = name.Substring(0, name.Length - 7);
                }

                if (overlayNames.ContainsKey(name))
                {
                    name = overlayNames[name];
                }

                cbType.Items.Add(new KeyValuePair <string, Type>(name, overlayType));
            }

            cbType.DisplayMember = "Key";
            cbType.SelectedIndex = 0;

#if DEBUG
            var presetFile = Path.Combine(PluginMain.PluginDirectory, "libs", "resources", "presets.json");
#else
            var presetFile = Path.Combine(PluginMain.PluginDirectory, "resources", "presets.json");
#endif
            var presetData = "{}";

            try
            {
                presetData = File.ReadAllText(presetFile);
            } catch (Exception ex)
            {
                Registry.Resolve <ILogger>().Log(LogLevel.Error, string.Format(Resources.ErrorCouldNotLoadPresets, ex));
            }

            presets = JsonConvert.DeserializeObject <Dictionary <string, OverlayPreset> >(presetData);
            foreach (var pair in presets)
            {
                pair.Value.Name = pair.Key;
                cbPreset.Items.Add(pair.Value);
            }

            foreach (var item in Registry.OverlayPresets)
            {
                cbPreset.Items.Add(item);
            }

            cbPreset.Items.Add(new OverlayPreset
            {
                Name = Resources.CustomPresetLabel,
                Url  = "special:custom",
            });

            cbPreset.DisplayMember = "Name";

            lblType.Visible     = false;
            cbType.Visible      = false;
            lblTypeDesc.Visible = false;

            textBox1.Focus();
        }