Exemple #1
0
 public SettingsHolder()
 {
     Settings = new PluginSettings(this);
 }
Exemple #2
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            ParentTabPage      = pluginScreenSpace;
            StatusLabel        = pluginStatusText;
            ParentTabPage.Text = "Chatting Translate";

            try
            {
                // Load FFXIV plugin's assembly if needed
                AppDomain.CurrentDomain.AssemblyResolve += (o, e) =>
                {
                    var simpleName = new string(e.Name.TakeWhile(x => x != ',').ToArray());
                    if (simpleName == "FFXIV_ACT_Plugin")
                    {
                        var query =
                            ActGlobals.oFormActMain.ActPlugins.Where(
                                x => x.lblPluginTitle.Text == "FFXIV_ACT_Plugin.dll");
                        var plugin = query.FirstOrDefault();

                        if (plugin != null)
                        {
                            return(System.Reflection.Assembly.LoadFrom(plugin.pluginFile.FullName));
                        }
                    }

                    return(null);
                };

                Controller = new MainController();

                Settings = new PluginSettings(this);

                Overlay = new TranslateForm();
                Overlay.AttachToAct(this);
                Overlay.Show();

                SettingsTab = new FFXIVTranslateTabControl();
                SettingsTab.AttachToAct(this);

                Controller.ChannelFilterChanged += ControllerOnChannelFilterChanged;
                Controller.ChannelColorChanged  += ControllerOnChannelColorChanged;
                Controller.ChannelLabelChanged  += ControllerOnChannelLabelChanged;
                Controller.LanguageChanged      += ControllerOnLanguageChanged;
                Controller.OverlayFontChanged   += ControllerOnOverlayFontChanged;

                Controller.TranslateProviderChanged += ControllerOnTranslateProviderChanged;
                TranslateService.AttachToAct(this);

                Settings.Load();

                DoLocalization();

                ActGlobals.oFormActMain.LogFileChanged += OFormActMainOnLogFileChanged;

                _workingThread.StartWorkingThread(ActGlobals.oFormActMain.LogFilePath);

                try
                {
                    Controller.NotifyOverlayFontChanged(false,
                                                        (Font)TypeDescriptor.GetConverter(typeof(Font)).ConvertFromString(OverlayFont));
                }
                catch (Exception)
                {
                    Controller.NotifyOverlayFontChanged(true, new Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular));
                }

                Controller.NotifyTranslateProviderChanged(false, TranslateProvider, TranslateApiKey, TranslateLangFrom, TranslateLangTo);

                StatusLabel.Text = "Init Success. >w<";
            }
            catch (Exception ex)
            {
                StatusLabel.Text = "Init Failed: " + ex.ToString();
            }
        }