Ejemplo n.º 1
0
        public void CreateDefaultAndSave()
        {
            var ob  = SettingsSerializer.CreateDefault <Sample>();
            var xml = SettingsSerializer.ToXmlString(ob, "Settings");

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<Settings Name=\"Default\" Value=\"1\" FiddleFactor=\"3.14159\" Problematic=\"0\">\r\n  <Child Payload=\"42\" />\r\n</Settings>", xml);
        }
Ejemplo n.º 2
0
        public void TestSerializeJson()
        {
            var serializer = new SettingsSerializer();

            var tmpDir = new DirectoryInfo("Tmp");

            if (tmpDir.Exists)
            {
                tmpDir.Delete(true);
                Thread.Sleep(100);
            }

            serializer.SaveJson(_settings, @"Tmp\settings.json");

            Assert.IsTrue(File.Exists(@"Tmp\settings.json"));
            Assert.IsTrue(File.Exists(@"Tmp\Users.json"));
            Assert.IsTrue(File.Exists(@"Tmp\Roles.json"));
            Assert.IsTrue(File.Exists(@"Tmp\Data.bin"));
            Assert.IsTrue(File.Exists(@"Tmp\Text.txt"));
            Assert.IsTrue(File.Exists(@"Tmp\Lines.txt"));

            CompareJsons(@"Data\Serialization\ExpectedSettings.json", @"Tmp\settings.json");
            CompareJsons(@"Data\Serialization\Users.json", @"Tmp\Users.json");
            CompareJsons(@"Data\Serialization\Roles.json", @"Tmp\Roles.json");
            CompareBytes(@"Data\Serialization\Data.bin", @"Tmp\Data.bin");
            CompareBytes(@"Data\Serialization\Text.txt", @"Tmp\Text.txt");
            CompareLines(@"Data\Serialization\Lines.txt", @"Tmp\Lines.txt");

            var manager = new SettingsManager();

            var jsonSettings  = manager.LoadSettings(@"Tmp\settings");
            var typedSettings = jsonSettings.ToObject <Settings>();

            Assert.AreEqual(JsonConvert.SerializeObject(_settings), JsonConvert.SerializeObject(typedSettings));
        }
Ejemplo n.º 3
0
        public void LoadFromFile()
        {
            var          fileName = _testFileManager.GetFileName();
            const string json     = "{\"DecimalKey\":1.23,\"IntKey\":1,\"ObjectKey\":{\"Property\":\"Value\"},\"StringKey\":\"Value\"}";

            File.WriteAllText(fileName, json);

            IDictionary <string, object> settings = new Dictionary <string, object>();
            var settingsServiceMock = new Mock <ISettingsService>();

            settingsServiceMock
            .Setup(s => s.SetSettingAsync(It.IsAny <string>(), It.IsAny <object>()))
            .Callback <string, object>((key, value) => settings.Add(key, value));

            var importer = new SettingsSerializer(LogManager.GetCurrentClassLogger(), settingsServiceMock.Object);
            var result   = importer.Import(fileName);

            Assert.True(result);
            Assert.Contains("DecimalKey", settings);
            Assert.Contains("IntKey", settings);
            Assert.Contains("ObjectKey", settings);
            Assert.Contains("StringKey", settings);
            Assert.Equal(1.23d, settings["DecimalKey"]);
            Assert.Equal(1L, settings["IntKey"]);
            Assert.IsType <JObject>(settings["ObjectKey"]);
            Assert.Equal("Value", settings["StringKey"]);
        }
Ejemplo n.º 4
0
        //NOTE: Don't use IoC to avoid additional dependencies.
        private void InitializePresenters(bool isRunOnStartup)
        {
            NavigationWindow navigationWindow = new NavigationWindow(new PresentationService());

            MainWindow = navigationWindow;

            IRegistryService    registryService    = new RegistryService();
            ISettingsSerializer settingsSerializer = new SettingsSerializer(registryService);

            IPresenter navigationPresenter = new NavigationPresenter(navigationWindow,
                                                                     settingsSerializer,
                                                                     new KeyboardListener(),
                                                                     new MatchModelMapper(),
                                                                     new PresentationService(),
                                                                     new NavigationServiceBuilder(isRunOnStartup));

            TrayView   trayView      = new TrayView();
            IPresenter trayPresenter = new TrayIconPresenter(trayView, settingsSerializer);

            SettingsWindow settingsWindow    = new SettingsWindow();
            IPresenter     settingsPresenter = new SettingsPresenter(settingsWindow, settingsSerializer);

            List <IPresenter> presenters = new List <IPresenter> {
                navigationPresenter, trayPresenter, settingsPresenter
            };

            _presenterManager         = new PresenterManager(presenters);
            _presenterManager.Exited += HandleExited;
        }
Ejemplo n.º 5
0
 public SettingsManager(
     SettingsSerializer settingsSerializer,
     SettingsDeserializer settingsDeserializer)
 {
     _settingsSerializer   = settingsSerializer;
     _settingsDeserializer = settingsDeserializer;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 保存されている設定を読み込む
        /// </summary>
        /// <param name="xmlSettings"></param>
        public static void LoadSettings(SettingsSerializer xmlSettings)
        {
            if (File.Exists(settingsFile))
            {
                FileStream    fs      = new FileStream(settingsFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                XmlTextReader xReader = new XmlTextReader(fs);

                try
                {
                    while (xReader.Read())
                    {
                        if (xReader.NodeType == XmlNodeType.Element)
                        {
                            if (xReader.LocalName == "SettingsSerializer")
                            {
                                xmlSettings.ImportFromXml(xReader);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex);
                }
                xReader.Close();
            }
            else
            {
                // XMLを作成する
                CreateXML();
            }
        }
        public void TestTypeNameSerialization()
        {
            var data = new Human()
            {
                Items = new List <IUnit>()
                {
                    new Dog(),
                    new Human()
                    {
                        Items = new List <IUnit>()
                        {
                            new Dog(), new Dog()
                        }
                    }
                }
            };

            var serializer = new SettingsSerializer();

            serializer.SaveJson(data, "TmpResult.json");

            SerializeTests.CompareJsons(@"Data\SerializationDeep\ExpectedSettings.json", "TmpResult.json");

            var manager = new SettingsManager();

            var loadedData = manager.LoadSettings <IUnit>("TmpResult.json");

            Assert.AreEqual(JsonConvert.SerializeObject(data), JsonConvert.SerializeObject(loadedData));

            var loadedData2 = manager.LoadSettings <Human>("TmpResult.json");

            Assert.AreEqual(JsonConvert.SerializeObject(data), JsonConvert.SerializeObject(loadedData2));
        }
Ejemplo n.º 8
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            //lbStatus = pluginStatusText;   // Hand the status label's reference to our local var
            pluginScreenSpace.Controls.Add(this); // Add this UserControl to the tab ACT provides
            Dock = DockStyle.Fill;                // Expand the UserControl to fill the tab's client space
                                                  // MultiProject.BasePlugin.xmlSettings = new SettingsSerializer(this); // Create a new settings serializer and pass it this instance

            pluginScreenSpace.Text = "LogActionChecker";
            pluginStatusText.Text  = "ACTLogActionCheckerStart";

            // インターフェイス情報を格納する
            this.xmlSettings = new SettingsSerializer(this);

            // コントロール情報を取得する
            Control[] ct = ACTInitSetting.GetAllControls(this);

            // 取得したコントロール情報を全て回し、初期表示用の情報を格納する
            foreach (Control tempct in ct)
            {
                if (tempct.Name.IndexOf("_init") > 0)
                {
                    // コントロールリストの情報を格納する
                    this.xmlSettings.AddControlSetting(tempct.Name, tempct);
                }
            }

            // 設定ファイルを読み込む
            ACTInitSetting.LoadSettings(xmlSettings);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 保存されている設定を読み込む
        /// </summary>
        /// <param name="xmlSettings"></param>
        public static void LoadSettings(SettingsSerializer xmlSettings, string FileName)
        {
            string settingsFile = Path.Combine(ActGlobals.oFormActMain.AppDataFolder.FullName, "Config\\" + FileName + ".config.xml");

            if (File.Exists(settingsFile))
            {
                FileStream    fs      = new FileStream(settingsFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                XmlTextReader xReader = new XmlTextReader(fs);

                try
                {
                    while (xReader.Read())
                    {
                        if (xReader.NodeType == XmlNodeType.Element)
                        {
                            if (xReader.LocalName == "SettingsSerializer")
                            {
                                xmlSettings.ImportFromXml(xReader);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex);
                }
                xReader.Close();
            }
            else
            {
                // XMLを作成する
                CreateXML(FileName);
            }
        }
Ejemplo n.º 10
0
        public virtual bool ImportSettings(object?import)
        {
            try
            {
                // Try convert
                var data = (Dictionary <string, object?>?)import;
                if (data == null)
                {
                    return(false);
                }

                // Serialize
                var serialized = JsonSettingsSerializer.SerializeToJson(data);

                // Write to file
                return(SettingsSerializer.WriteToFile(serialized));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Debugger.Break();

                return(false);
            }
        }
Ejemplo n.º 11
0
        public void ReadSettingsSerialized()
        {
            var fileText = File.ReadAllText(SettingsPath);
            var settings = SettingsSerializer.FromXmlString <AppSettings>(fileText);

            var xml = SettingsSerializer.ToXmlString(settings, "Settings");
        }
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            lblStatus = pluginStatusText;               // Hand the status label's reference to our local var
            pluginScreenSpace.Controls.Add(this);       // Add this UserControl to the tab ACT provides
            this.Dock   = DockStyle.Fill;               // Expand the UserControl to fill the tab's client space
            xmlSettings = new SettingsSerializer(this); // Create a new settings serializer and pass it this instance
            xmlSettings.AddControlSetting(textBox_addr.Name, textBox_addr);
            xmlSettings.AddControlSetting(checkbox_sendraw.Name, checkbox_sendraw);

            LoadSettings();

            pluginScreenSpace.Text = "DauntUtils";


            try
            {
                _definitions = new Definitions();
                FfxivPlugin  = GetFfxivPlugin();

                FfxivPlugin.DataSubscription.LogLine         += DataSubscriptionLogLine;
                FfxivPlugin.DataSubscription.NetworkReceived += DataSubscriptionOnNetworkReceived;
                FfxivPlugin.DataSubscription.NetworkSent     += DataSubscriptionOnNetworkSent;

                Log("plugin loaded.");
                lblStatus.Text = "Plugin Started";
            }
            catch (Exception ex)
            {
                Log("[ERROR] Could not initialize plugin:\n" + ex);
                lblStatus.Text = "Plugin Failed";
            }
        }
Ejemplo n.º 13
0
        private static TSettings deserialize <TSettings>(string filename, SettingsSerializer serializer) where TSettings : SettingsBase, new()
        {
            return(Ut.WaitSharingVio(maximum: TimeSpan.FromSeconds(5), func: () =>
            {
                switch (serializer)
                {
                case SettingsSerializer.ClassifyXml:
                    return ClassifyXml.DeserializeFile <TSettings>(filename);

                case SettingsSerializer.ClassifyJson:
                    return ClassifyJson.DeserializeFile <TSettings>(filename);

                case SettingsSerializer.ClassifyBinary:
                    return ClassifyBinary.DeserializeFile <TSettings>(filename);

                case SettingsSerializer.DotNetBinary:
                    var bf = new BinaryFormatter();
                    using (var fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                        return (TSettings)bf.Deserialize(fs);

                default:
                    throw new InternalErrorException("6843184");
                }
            }));
        }
 public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
 {
     lblStatus = pluginStatusText;               // Hand the status label's reference to our local var
     pluginScreenSpace.Controls.Add(this);       // Add this UserControl to the tab ACT provides
     this.Dock   = DockStyle.Fill;               // Expand the UserControl to fill the tab's client space
     xmlSettings = new SettingsSerializer(this); // Create a new settings serializer and pass it this instance
     LoadSettings();
     lstLog.Items.Add("Plugin Started, loading assemblies...");
     foreach (var assembly in chklstAssemblies.CheckedItems)
     {
         var tempAssembly = assembly.ToString();
         lstLog.Items.Add("Loading assembly [" + tempAssembly + "]...");
         if (!File.Exists(tempAssembly))
         {
             tempAssembly = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + tempAssembly;
         }
         try
         {
             Assembly a = Assembly.LoadFile(tempAssembly);
             lstLog.Items.Add(" Loaded assembly, location = " + a.Location);
         }
         catch
         {
             lstLog.Items.Add(" Error loading assembly");
         }
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        ///     Adds or updates the specified setting.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="setting">The setting.</param>
        private void AddOrUpdate(SettingsFile file, Setting setting)
        {
            var replacementContent = GetReplacementContent(_extension, setting.Name);

            if (replacementContent == null)
            {
                return;
            }

            // Read the settings
            var serializedContainer = File.ReadAllText(file.FullPath);
            var settingsContainer   = SettingsSerializer.Deserialize(serializedContainer);

            // Let's add the new entry
            settingsContainer.AddOrUpdate(setting);

            // ... and write the settings again
            serializedContainer = SettingsSerializer.Serialize(settingsContainer);
            File.WriteAllText(file.FullPath, serializedContainer);

            SettingsFileGenerator.Write(file, settingsContainer);
            AppConfigFileGenerator.Write(settingsContainer);

            var startEditPoint = _textSelection.TopPoint.CreateEditPoint();
            var endEditPoint   = _textSelection.BottomPoint.CreateEditPoint();

            startEditPoint.Delete(endEditPoint);
            startEditPoint.Insert(replacementContent);
        }
Ejemplo n.º 16
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            Config = new config();
            lblStatus = pluginStatusText;
            pluginScreenSpace.Controls.Add(Config);
            xmlSettings = new SettingsSerializer(Config);
            LoadSettings();
            Config.selectedFolder = Config.Controls["directory"].Text;
            lblStatus.Text = "Loaded PSO2ACT Plugin";

            if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed())
                new Thread(oFormActMain_UpdateCheckClicked).Start();
            else
                Config.refreshFlag = true;

            ActGlobals.oFormActMain.GetDateTimeFromLog = ParseDateTime;
            ActGlobals.oFormActMain.BeforeLogLineRead += new LogLineEventDelegate(oFormActMain_BeforeLogLineRead);
            ActGlobals.oFormActMain.OnCombatEnd += new CombatToggleEventDelegate(oFormActMain_OnCombatEnd);
            ActGlobals.oFormActMain.OnCombatStart += new CombatToggleEventDelegate(oFormActMain_OnCombatStart);

            try
            {
                InitializeSkillDict();
                logThread = new Thread(this.LogThread);
                logThread.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            return;
        }
Ejemplo n.º 17
0
        public void WriteToFile()
        {
            var fileName = _testFileManager.GetFileName();

            var settingsServiceMock = new Mock <ISettingsService>();

            settingsServiceMock.Setup(s => s.GetSettings()).Returns(new Dictionary <string, object>
            {
                { "DecimalKey", 1.23d },
                { "IntKey", 1 },
                { "ObjectKey", new { Property = "Value" } },
                { "StringKey", "Value" }
            });

            var exporter = new SettingsSerializer(LogManager.GetCurrentClassLogger(), settingsServiceMock.Object);

            var result = exporter.Export(fileName);

            Assert.True(result);
            Assert.True(File.Exists(fileName));

            var fileContent = File.ReadAllText(fileName);

            Assert.Equal("{\"DecimalKey\":1.23,\"IntKey\":1,\"ObjectKey\":{\"Property\":\"Value\"},\"StringKey\":\"Value\"}", fileContent);
        }
Ejemplo n.º 18
0
        private void linkLabel_view_client_profile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var comboboxItem = (ComboboxItem)comboBox_client.SelectedItem;

            if (comboboxItem.Value == null)
            {
                return;
            }
            var clientProfile = new ClientProfile();

            var clientProfileInfo = (ClientProfileInfo)comboboxItem.Value;

            clientProfile.ClientProfileInfo = clientProfileInfo;
            clientProfile.IsEdit            = true;
            clientProfile.ShowDialog();
            if (!clientProfile.Saved)
            {
                return;
            }
            comboboxItem.Text            = clientProfile.ClientProfileInfo.ClientName;
            comboboxItem.Value           = clientProfile.ClientProfileInfo;
            comboBox_client.SelectedItem = comboboxItem;
            comboBox_client.Invalidate(true);

            SettingsSerializer.SaveSettings(Tracked.Preferences);
        }
Ejemplo n.º 19
0
 static void CreateSaveLoadGeneric <T>()
     where T : INotifyPropertyChanged, new()
 {
     var createdOb      = SettingsSerializer.CreateDefault <T>();
     var savedXmlString = SettingsSerializer.ToXmlString(createdOb, "Settings");
     var loadedOb       = SettingsSerializer.FromXmlString <T>(savedXmlString);
 }
Ejemplo n.º 20
0
        protected override void OnLoad(EventArgs args)
        {
            base.OnLoad(args);

            if (SettingsSerializer.Load(Program.SettingsFilename, out ProgramSettings settings))
            {
                this.settings = settings;
            }
            else
            {
                this.settings = new ProgramSettings();
            }

            this.settings.MainWindow.EnsureDisplayAttributes(this);

            if (this.settings.MainWindow.LastVisible < 0 || this.settings.MainWindow.LastVisible > this.tvcContent.TabCount)
            {
                this.settings.MainWindow.LastVisible = 0;
            }

            this.tvcContent.SelectedIndex = this.settings.MainWindow.LastVisible;

            this.gusCommon.UpdateStatus     += this.OnControlUpdateStatus;
            this.gusExchange.UpdateStatus   += this.OnControlUpdateStatus;
            this.gusExtended.UpdateStatus   += this.OnControlUpdateStatus;
            this.gusSecurity.UpdateStatus   += this.OnControlUpdateStatus;
            this.gusInspection.UpdateStatus += this.OnControlUpdateStatus;

            this.gusExchange.ShowSettings += this.OnControlShowSettings;

            this.gusCommon.Attach(this.settings.CommonData);
            this.gusExchange.Attach(this.settings.ExchangeData);
            this.gusExtended.Attach(this.settings.ExtendedData);
            this.gusSecurity.Attach(this.settings.SecurityData);
        }
Ejemplo n.º 21
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            Shared = this;

            lblStatus = pluginStatusText;                     // Hand the status label's reference to our local var
            pluginScreenSpace.Controls.Add(this);             // Add this UserControl to the tab ACT provides
            pluginScreenSpace.Text = "FFXIV Helper Settings"; // Tab name
            this.Dock   = DockStyle.Fill;                     // Expand the UserControl to fill the tab's client space
            xmlSettings = new SettingsSerializer(this);       // Create a new settings serializer and pass it this instance

            LoadSettings();
            DownloadData();
            LoadData();
            UpdateUI();
            actUIController.UpdateTable();
            actEventHandler.Setup();

            // Automatic update
            if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed())
            {
                new PluginUpdater(this).UpdateCheckOnBackground();
            }

            lblStatus.Text = Properties.Resources.MessagePluginInit;
        }
Ejemplo n.º 22
0
        protected override void OnFormClosing(FormClosingEventArgs args)
        {
            this.settings.MainWindow.LastVisible = this.tvcContent.SelectedIndex;

            SettingsSerializer.Save(Program.SettingsFilename, this.settings);

            base.OnFormClosing(args);
        }
Ejemplo n.º 23
0
 public void Dispose()
 {
     _logger                = null;
     _mainControl           = null;
     _xmlSettingsSerializer = null;
     _pluginData            = null;
     _instance              = null;
 }
Ejemplo n.º 24
0
        public ACTPluginSettingsHelper()
        {
            _mainControl = Locator.Current.GetService <MainControl>();
            _pluginData  = Locator.Current.GetService <ActPluginData>();
            _logger      = Locator.Current.GetService <IActLogger>();

            _xmlSettingsSerializer = new SettingsSerializer(_mainControl);
            _settingsFile          = Path.Combine(ActGlobals.oFormActMain.AppDataFolder.FullName, "Config", "DFAssist.config.xml");
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 numberspinner 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static HtmlHelper NumberSpinner(this HtmlHelper htmlHelper, string exp, NumberSpinnerSettings settings = null)
        {
            var options = SettingsSerializer.Serialize(settings);

            htmlHelper.ResetBuilderWithCheck("INPUT", "txt", exp);
            htmlHelper.EasyUI("easyui-numberspinner", options);

            return(htmlHelper);
        }
        public void CorruptedSettingsFile_ReturnsSettingsInstance()
        {
            string path = Path.GetTempFileName();
            var    settingsSerializer = new SettingsSerializer(path);

            var settings = settingsSerializer.LoadSettings();

            Assert.IsInstanceOfType(settings, typeof(Settings));
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            DesignMode = false;             // The designer doesn't call Main()

            CommandLineArgs = new CommandLineArgs(args);

            try
            {
                DpiUtil.ConfigureProcess();
            }
            catch
            {
            }

            MonoSpaceFont = new FontEx
            {
                Font   = new Font("Courier New", DpiUtil.ScaleIntX(13), GraphicsUnit.Pixel),
                Width  = DpiUtil.ScaleIntX(8),
                Height = DpiUtil.ScaleIntY(16)
            };

            NativeMethods.EnableDebugPrivileges();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            Settings = SettingsSerializer.Load();
            Logger   = new GuiLogger();

#if !DEBUG
            try
            {
#endif
            using (var coreFunctions = new CoreFunctionsManager())
            {
                RemoteProcess = new RemoteProcess(coreFunctions);

                MainForm = new MainForm();

                Application.Run(MainForm);

                RemoteProcess.Dispose();
            }
#if !DEBUG
        }

        catch (Exception ex)
        {
            ShowException(ex);
        }
#endif

            SettingsSerializer.Save(Settings);
        }
Ejemplo n.º 28
0
        public void CreateDefault()
        {
            var ob = SettingsSerializer.CreateDefault <Sample>();

            Assert.AreEqual("Default", ob.Name);
            Assert.AreEqual(1, ob.Value);
            Assert.AreEqual(3.14159, ob.FiddleFactor);
            Assert.IsNotNull(ob.Child);
            Assert.AreEqual(42, ob.Child.Payload);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 linkbutton 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="id">ID 属性值。</param>
        /// <param name="onClick">单击时执行的 js 脚本。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static HtmlHelper LinkButton(this HtmlHelper htmlHelper, string id, string onClick, LinkButtonSettings settings = null)
        {
            var options = SettingsSerializer.Serialize(settings);

            htmlHelper.ResetBuilder("A", id);
            htmlHelper.AddAttribute("onclick", onClick)
            .EasyUI("easyui-linkbutton", options);

            return(htmlHelper);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 为 <see cref="HtmlHelper"/> 对象扩展 datebox 元素。
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
        /// <param name="settings">参数选项。</param>
        /// <returns></returns>
        public static HtmlHelper DateBox(this HtmlHelper htmlHelper, string exp, DateBoxSettings settings = null)
        {
            var options = SettingsSerializer.Serialize(settings);

            htmlHelper.ResetBuilderWithCheck("INPUT", "txt", exp);
            htmlHelper.AddStyle("width", "160px")
            .EasyUI("easyui-datebox", options);

            return(htmlHelper);
        }
Ejemplo n.º 31
0
 public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
 {
     lblStatus = pluginStatusText;               // Hand the status label's reference to our local var
     pluginScreenSpace.Controls.Add(this);       // Add this UserControl to the tab ACT provides
     this.Dock   = DockStyle.Fill;               // Expand the UserControl to fill the tab's client space
     xmlSettings = new SettingsSerializer(this); // Create a new settings serializer and pass it this instance
     LoadSettings();
     ActGlobals.oFormActMain.OnLogLineRead += OFormActMain_OnLogLineRead;
     lblStatus.Text = "Plugin Started";
 }
Ejemplo n.º 32
0
        public void Initialize(Label pluginStatusText)
        {
            lblStatus = pluginStatusText;    // Hand the status label's reference to our local var
            this.Dock = DockStyle.Fill;    // Expand the UserControl to fill the tab's client space
            xmlSettings = new SettingsSerializer(this);    // Create a new settings serializer and pass it this instance

            showHotkeyText.Text = "None";
            LoadSettings();
            RegisterVisibilityHotKey(showHotkeyText.Text);

            lblStatus.Text = "Plugin Started";
        }
Ejemplo n.º 33
0
        private static void Uninstall()
        {
            IRegistryService registryService = new RegistryService();
            ICacheSerializer cacheSerializer = new CacheSerializer();
            ISettingsSerializer settingsSerializer = new SettingsSerializer(registryService);

            cacheSerializer.DeleteCache();
            registryService.DeleteRunOnStartup();

            //Not sure, if it will be user-friendly; but i prefer if applications remove themselves completely,
            //especially small ones.
            settingsSerializer.DeleteSettings();
        }
Ejemplo n.º 34
0
        public MainTabPage(LanPlugin plugin)
        {
            InitializeComponent();

            _plugin = plugin;
            _plugin.Controller.ActiveUpdate += Controller_ActiveUpdate;
            Controller_ActiveUpdate(this, null);
            _plugin.Controller.ModeUpdate += Controller_ModeUpdate;
            Controller_ModeUpdate(this, null);

            _AddLogUpdate = addLog;

            _xmlSettings = new SettingsSerializer(this);
            LoadSettings();
            if (textBoxPort.Text.Length == 0)
                textBoxPort.Text = "5000";
        }
Ejemplo n.º 35
0
        //NOTE: Don't use IoC to avoid additional dependencies.
        private void InitializePresenters(bool isRunOnStartup)
        {
            NavigationWindow navigationWindow = new NavigationWindow(new PresentationService());
            MainWindow = navigationWindow;

            IRegistryService registryService = new RegistryService();
            ISettingsSerializer settingsSerializer = new SettingsSerializer(registryService);

            IPresenter navigationPresenter = new NavigationPresenter(navigationWindow,
                                     settingsSerializer,
                                     new KeyboardListener(),
                                     new MatchModelMapper(),
                                     new PresentationService(),
                                     new NavigationServiceBuilder(isRunOnStartup));

            TrayView trayView = new TrayView();
            IPresenter trayPresenter = new TrayIconPresenter(trayView, settingsSerializer);

            SettingsWindow settingsWindow = new SettingsWindow();
            IPresenter settingsPresenter = new SettingsPresenter(settingsWindow, settingsSerializer);

            List<IPresenter> presenters = new List<IPresenter> { navigationPresenter, trayPresenter, settingsPresenter };

            _presenterManager = new PresenterManager(presenters);
            _presenterManager.Exited += HandleExited;
        }
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            // Push the option screen into the option tab
            int dcIndex = -1;
            for (int i = 0; i < ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count; i++)
            {
                if (ActGlobals.oFormActMain.OptionsTreeView.Nodes[i].Text == "Neverwinter")
                    dcIndex = i;
            }
            if (dcIndex != -1)
            {
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("General");
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"Neverwinter\General", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Find the applicable options in the Options tab, Neverwinter section.";
                pluginScreenSpace.Controls.Add(lblConfig);
            }
            else
            {
                ActGlobals.oFormActMain.OptionsTreeView.Nodes.Add("Neverwinter");
                dcIndex = ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count - 1;
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("General");
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"Neverwinter\General", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Find the applicable options in the Options tab, Neverwinter section.";
                pluginScreenSpace.Controls.Add(lblConfig);
            }
            ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Expand();

            // Neverwinter settings file
            xmlSettings = new SettingsSerializer(this);
            LoadSettings();

            // Setting this Regex will allow ACT to extract the character's name from the file name as the first capture group
            // when opening new log files. We'll say the log file name may look like "20080706-Player.log"
            ActGlobals.oFormActMain.LogPathHasCharName = false;

            // A windows file system filter to search updated log files with.
            ActGlobals.oFormActMain.LogFileFilter = "Combat*.log";

            // If all log files are in a single folder, this isn't an issue. If log files are split into different folders,
            // enter the parent folder name here. This way ACT will monitor that base folder and all sub-folders for updated files.
            ActGlobals.oFormActMain.LogFileParentFolderName = "GameClient";

            // Then to apply the settings and restart the log checking thread
            try
            {
                ActGlobals.oFormActMain.ResetCheckLogs();
            }
            catch
            {
                // Ignore when no log file is currently open
            }

            // This is the absolute path of where you wish ACT generated macro exports to be put. I'll leave it up to you
            // to determine this path programatically. If left blank, ACT will attempt to find EQ2 by registry or log file parents.
            // ActGlobals.oFormActMain.GameMacroFolder = @"C:\Program Files\Game Company\Game Folder";

            // Lets say that the log file time stamp is like: "[13:42:57]"
            // ACT needs to know the length of the timestamp and spacing at the beginning of the log line
            ActGlobals.oFormActMain.TimeStampLen = 19; // Remember to include spaces after the time stamp

            // Replace ACT's default DateTime parser with your own implementation matching your format
            ActGlobals.oFormActMain.GetDateTimeFromLog = new FormActMain.DateTimeLogParser(ParseDateTime);

            // This Regex is only used by a quick parsing method to find the current zone name based on a file position
            // If you do not define this correctly, the quick parser will fail and take a while to do so.
            // You still need to implement a zone change parser in your engine regardless of this
            // ActGlobals.oFormActMain.ZoneChangeRegex = new Regex(@"You have entered: (.+)\.", RegexOptions.Compiled);

            // All of your parsing engine will be based off of this event
            // You should not use Before/AfterCombatAction as you may enter infinite loops. AfterLogLineRead is okay, but not recommended
            ActGlobals.oFormActMain.BeforeLogLineRead += new LogLineEventDelegate(oFormActMain_BeforeLogLineRead);

            // Hooks for periodic pet cache purge
            ActGlobals.oFormActMain.OnCombatEnd += new CombatToggleEventDelegate(oFormActMain_OnCombatEnd);
            ActGlobals.oFormActMain.LogFileChanged += new LogFileChangedDelegate(oFormActMain_LogFileChanged);

            FixupCombatDataStructures();

            // Set status text to successfully loaded
            lblStatus = pluginStatusText;
            lblStatus.Text = "Neverwinter ACT plugin loaded";
        }
Ejemplo n.º 37
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            lblStatus = pluginStatusText;

            // Push the option screen into the option tab
            int dcIndex = -1;
            for (int i = 0; i < ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count; i++)
            {
                if (ActGlobals.oFormActMain.OptionsTreeView.Nodes[i].Text == "Secret Parsing")
                    dcIndex = i;
            }
            if (dcIndex != -1)
            {
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("General");
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"Secret Parsing\General", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Find the applicable options in the Options tab, Secret Parsing section.";
                pluginScreenSpace.Controls.Add(lblConfig);
            }
            else
            {
                ActGlobals.oFormActMain.OptionsTreeView.Nodes.Add("Secret Parsing");
                dcIndex = ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count - 1;
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("General");
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"Secret Parsing\General", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Find the applicable options in the Options tab, Secret Parsing section.";
                pluginScreenSpace.Controls.Add(lblConfig);
            }
            ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Expand();
            ActGlobals.oFormActMain.SetOptionsHelpText("testing");

            // Add the export item to the treeview menu
            var exportButton = new ToolStripMenuItem();
            exportButton.Name = "ACT_export_button";
            exportButton.Text = "Export to TSW chat script";
            exportButton.Click += new System.EventHandler(ExportEncounterToScript);
            int sepIndx = 0;
            for (sepIndx = 0; sepIndx < ActGlobals.oFormActMain.MainTreeView.ContextMenuStrip.Items.Count; ++sepIndx)
            {
                if (ActGlobals.oFormActMain.MainTreeView.ContextMenuStrip.Items[sepIndx] is ToolStripSeparator)
                {
                    break;
                }
            }
            ActGlobals.oFormActMain.MainTreeView.ContextMenuStrip.Items.Insert(sepIndx, exportButton);
            ActGlobals.oFormActMain.MainTreeView.ContextMenuStrip.Opening += new CancelEventHandler((a, b) =>
            {
                exportButton.Enabled = IsEncounterSelected();
            });

            xmlSettings = new SettingsSerializer(this);
            string FileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Secret\\recents.cfg";
            FileInfo RecFile = new FileInfo(FileName);

            SetExportFieldDefaults();

            LoadSettings();

            SetExportFieldStatus();

            checkBox_EnableTSWAddon_CheckedChanged(null, null);

            SetupSecretEnglishEnvironment();

            //ActGlobals.oFormActMain.SetParserToNull(); // Set the input log file language to (None)
            ActGlobals.oFormActMain.LogPathHasCharName = false;
            ActGlobals.oFormActMain.LogFileFilter = "CombatLog*.txt";
            ActGlobals.oFormActMain.ResetCheckLogs();

            ActGlobals.oFormActMain.TimeStampLen = 8; // Size of timestamp section in the logfile
            ActGlobals.oFormActMain.GetDateTimeFromLog = new FormActMain.DateTimeLogParser(ParseDateTime); // Replace internal Eq2 date parser

            ActGlobals.oFormActMain.BeforeLogLineRead += new LogLineEventDelegate(oFormActMain_BeforeLogLineRead); // Interupt the EQ2 parse, and replace it with Secret.
            ActGlobals.oFormActMain.OnCombatEnd += new CombatToggleEventDelegate(oFormActMain_OnCombatEnd);
            ActGlobals.oFormActMain.OnCombatStart += new CombatToggleEventDelegate(oFormActMain_OnCombatStart);

            // Setup up update checks
            ActGlobals.oFormActMain.UpdateCheckClicked += new FormActMain.NullDelegate(SecretCheckUpdate);
            if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed() == true)
            {
                new Thread(new ThreadStart(SecretCheckUpdate)).Start();
            }

            FixDBConfFile();

            Task.Factory.StartNew(() => { CheckTSWACTEnabled(this); });

            if ((lblStatus.Text != "Secret plugin unloaded") && (lblStatus.Text != "No Status"))
            {
                lblStatus.Text = lblStatus.Text + "\nSecret plugin loaded";
            }
            else
            {
                lblStatus.Text = "Secret plugin loaded";
            }
        }
Ejemplo n.º 38
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            lblStatus = pluginStatusText;	// Hand the status label's reference to our local var
            pluginScreenSpace.Controls.Add(this);
            this.Dock = DockStyle.Fill;

            int dcIndex = -1;   // Find the Data Correction node in the Options tab
            for (int i = 0; i < ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count; i++)
            {
                if (ActGlobals.oFormActMain.OptionsTreeView.Nodes[i].Text == "Data Correction")
                    dcIndex = i;
            }
            if (dcIndex != -1)
            {
                // Add our own node to the Data Correction node
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("EQ2 English Settings");
                // Register our user control(this) to our newly create node path.  All controls added to the list will be laid out left to right, top to bottom
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"Data Correction\EQ2 English Settings", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Option タブの Data Correction セクションの EQ2 English Settings にてオプション設定ができます。";
                pluginScreenSpace.Controls.Add(lblConfig);
            }

            xmlSettings = new SettingsSerializer(this);	// Create a new settings serializer and pass it this instance
            LoadSettings();

            PopulateRegexArray();
            ActGlobals.oFormActMain.BeforeLogLineRead += new LogLineEventDelegate(oFormActMain_BeforeLogLineRead);
            ActGlobals.oFormActMain.BeforeCombatAction += new CombatActionDelegate(oFormActMain_BeforeCombatAction);
            ActGlobals.oFormActMain.AfterCombatAction += new CombatActionDelegate(oFormActMain_AfterCombatAction);
            ActGlobals.oFormActMain.OnLogLineRead += new LogLineEventDelegate(oFormActMain_OnLogLineRead);
            lblStatus.Text = "Plugin は有効です。";
        }
Ejemplo n.º 39
0
		public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
		{
            pluginScreenSpace.Text = "TPMonitor"; 
			lblStatus = pluginStatusText;	// Hand the status label's reference to our local var
			pluginScreenSpace.Controls.Add(this);	// Add this UserControl to the tab ACT provides
			this.Dock = DockStyle.Fill;	// Expand the UserControl to fill the tab's client space            
			xmlSettings = new SettingsSerializer(this);	// Create a new settings serializer and pass it this instance
			LoadSettings();

            // 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");
                    if (query.Any())
                    {
                        return System.Reflection.Assembly.LoadFrom(query.First().pluginFile.FullName);
                    }
                }

                return null;
            };

			lblStatus.Text = "Plugin Started.";

            controller = new TPMonitorController();
            controller.CharFolder = textBoxCharacterFolder.Text;
            controller.PartyListUI = Util.GetPartyListLocation(textBoxCharacterFolder.Text);
            controller.ChangedStatus += new EventHandler(this.ChangedStatus);

            SetFontName();
        }
Ejemplo n.º 40
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            ActPluginData pluginData = ActGlobals.oFormActMain.PluginGetSelfData(this);
            pluginEnviroment = Path.GetDirectoryName(pluginData.pluginFile.ToString());

            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.AssemblyResolve += new ResolveEventHandler((sender, e) => LoadFromSameFolder(sender, e, pluginEnviroment));

            if (File.Exists(Environment.GetEnvironmentVariable("ProgramFiles") + @"\Razer Chroma SDK\bin\RzChromaSDK64.dll"))
            {
                RazerSDK = true;
                InitializeComponent();
                InitializeDevices();
            }
            else
            {
                RazerSDK = false;
                InitializeComponent();
                InitializeDevices();
            }

            lblStatus = pluginStatusText;
            pluginScreenSpace.Text = "Chromatics";
            pluginScreenSpace.Controls.Add(this);
            this.Dock = DockStyle.Fill;
            xmlSettings = new SettingsSerializer(this);
            var cTriggers = ActGlobals.oFormActMain.ActiveCustomTriggers;
            pic_Logo.Image = Image.FromFile(pluginEnviroment + "\\lib\\logo.png");
            LoadSettings();

            // Create parsing event handlers.  After the "+=" hit TAB twice and the code will be generated for you.
            ActGlobals.oFormActMain.AfterCombatAction += new CombatActionDelegate(oFormActMain_AfterCombatAction);
            ActGlobals.oFormActMain.OnCombatStart += new CombatToggleEventDelegate(oFormActMain_OnCombatStart);
            ActGlobals.oFormActMain.OnCombatEnd += new CombatToggleEventDelegate(oFormActMain_OnCombatEnd);
            ActGlobals.oFormActMain.BeforeLogLineRead += new LogLineEventDelegate(oFormActMain_BeforeLogLineRead); //READ
            ActGlobals.oFormSpellTimers.OnSpellTimerExpire += new SpellTimerEventDelegate(oFormSpellTimers_OnSpellTimerExpire);
            ActGlobals.oFormSpellTimers.OnSpellTimerWarning += new SpellTimerEventDelegate(oFormSpellTimers_OnSpellTimerWarning);
            ActGlobals.oFormSpellTimers.OnSpellTimerRemoved += new SpellTimerEventDelegate(oFormSpellTimers_OnSpellTimerRemoved);
            Application.ApplicationExit += new EventHandler(this.OnApplicationExit);
            ActGlobals.oFormActMain.UpdateCheckClicked += new FormActMain.NullDelegate(oFormActMain_UpdateCheckClicked);

            //Start Automatic update listener on init
            if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed())
            {
                new Thread(new ThreadStart(oFormActMain_UpdateCheckClicked)).Start();
            }

            //Fetch custom triggers from ACT and store in array
            foreach (var cTrigger in cTriggers)
            {
                var preparse = cTrigger.Key;
                string[] preparsearray = preparse.Split(new string[] { "|" }, StringSplitOptions.None);
                customTriggers.Add(preparsearray[1]);
            }

            //Setup Weather timer
            skyWatcher = new System.Timers.Timer();
            skyWatcher.Elapsed += (source, e) => { weatherLoop(); };
            skyWatcher.Interval = 10000;
            skyWatcher.Enabled = false;

            if (chk_reactiveWeather.Checked)
            {
                skyWatcher.Enabled = true;
            }

            //Setup Raid Zones
            raidZoneList.Add("Lower Aetheroacoustic Exploratory Site");
            raidZoneList.Add("Upper Aetheroacoustic Exploratory Site");
            raidZoneList.Add("The Ragnarok");
            raidZoneList.Add("Ragnarok Drive Cylinder");
            raidZoneList.Add("Ragnarok Central Core");
            raidZoneList.Add("Dalamud's Shadow");
            raidZoneList.Add("The Outer Coil");
            raidZoneList.Add("Central Decks");
            raidZoneList.Add("The Holocharts");
            raidZoneList.Add("IC-06 Central Decks");
            raidZoneList.Add("IC-06 Regeneration Grid");
            raidZoneList.Add("IC-06 Main Bridge");
            raidZoneList.Add("The Burning Heart");
            raidZoneList.Add("Labyrinth Of The Ancients");
            raidZoneList.Add("Syrcus Tower");
            raidZoneList.Add("The World Of Darkness");
            raidZoneList.Add("Fist Of The Father");
            raidZoneList.Add("Cuff Of The Father");
            raidZoneList.Add("Arm Of The Father");
            raidZoneList.Add("Burden Of The Father");
            raidZoneList.Add("Fist Of The Father (Savage)");
            raidZoneList.Add("Cuff Of The Father (Savage)");
            raidZoneList.Add("Arm Of The Father (Savage)");
            raidZoneList.Add("Burden Of The Father (Savage)");
            raidZoneList.Add("Void Ark");
            raidZoneList.Add("The Binding Coil Of Bahamut - Turn (1)");
            raidZoneList.Add("The Binding Coil Of Bahamut - Turn (2)");
            raidZoneList.Add("The Binding Coil Of Bahamut - Turn (3)");
            raidZoneList.Add("The Binding Coil Of Bahamut - Turn (4)");
            raidZoneList.Add("The Binding Coil Of Bahamut - Turn (5)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (1)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (2)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (3)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (4)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (1)(Savage)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (2)(Savage)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (3)(Savage)");
            raidZoneList.Add("The Second Coil Of Bahamut - Turn (4)(Savage)");
            raidZoneList.Add("The Final Coil Of Bahamut - Turn (1)");
            raidZoneList.Add("The Final Coil Of Bahamut - Turn (2)");
            raidZoneList.Add("The Final Coil Of Bahamut - Turn (3)");
            raidZoneList.Add("The Final Coil Of Bahamut - Turn (4)");

            //Return positive attach
            lblStatus.Text = "Chromatics Plugin Started";
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Findet den passenden Serialisierer (durch Ausprobieren) und gibt das deserialisierte Objekt zurück.
 /// </summary>
 /// <returns>null bei Fehler, sonst ein object</returns>
 private static object FindDeserializerGetValue (string value) {
     SettingsSerializer[] serializers = new SettingsSerializer[] { new PrimitiveSerializer (), new CommonSerializer (), new BinarySerializer () };
     foreach (SettingsSerializer serializer in serializers) {
         object result = serializer.Deserialize (value);
         // Die Deserialisierer brechen frühzeitig ab, wenn sie mit dem Wert nicht klarkommen.
         // Insofern können wir hier alle durchprobieren.
         if (result != null) {
             return result;
         }
     }
     return null;
 }
Ejemplo n.º 42
0
        public void InitPlugin(TabPage pluginScreenSpace, System.Windows.Forms.Label pluginStatusText)
        {
            lblStatus = pluginStatusText;   // Hand the status label's reference to our local var
            pluginScreenSpace.Controls.Add(this);   // Add this UserControl to the tab ACT provides
            this.Dock = DockStyle.Fill; // Expand the UserControl to fill the tab's client space
            xmlSettings = new SettingsSerializer(this); // Create a new settings serializer and pass it this instance
            LoadSettings();

            // Create some sort of parsing event handler.  After the "+=" hit TAB twice and the code will be generated for you.
            ActGlobals.oFormActMain.AfterCombatAction += new CombatActionDelegate(oFormActMain_AfterCombatAction);

            lblStatus.Text = "Plugin Started";
        }
Ejemplo n.º 43
0
		public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
		{
            ActGlobals.oFormActMain.UpdateCheckClicked += new FormActMain.NullDelegate(CheckForUpdate);
            if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed())   // If ACT is set to automatically check for updates, check for updates to the plugin
                new Thread(new ThreadStart(CheckForUpdate)).Start();    // If we don't put this on a separate thread, web latency will delay the plugin init phase
            
            pluginScreenSpace.Text = "TPMonitor";
            lblStatus = pluginStatusText;	        // Hand the status label's reference to our local var
            pluginScreenSpace.Controls.Add(this);	// Add this UserControl to the tab ACT provides
            this.Dock = DockStyle.Fill;	            // Expand the UserControl to fill the tab's client space            

            controller = new TPMonitorController(this);
            
            xmlSettings = new SettingsSerializer(this);	// Create a new settings serializer and pass it this instance
            LoadSettings();

            // 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");
                    if (query.Any())
                    {
                        return System.Reflection.Assembly.LoadFrom(query.First().pluginFile.FullName);
                    }
                }

                return null;
            };

            controller.CharFolder = textBoxCharacterFolder.Text;
            controller.HideWhenDissolve = checkBoxHideWhenDissolve.Checked;
            controller.HideWhenEnded = checkBoxHideWhenEnded.Checked;
            controller.ShowMyTP = checkBoxShowMyTP.Checked;
            controller.IsFixedMode = radioButtonFixed.Checked;
            controller.ChangedStatus += new EventHandler(this.ChangedStatus);
            OnChangeLocation();
            SetFontName();

            if (string.IsNullOrEmpty(textBoxColors.Text))
            {
                SetDefaultColor();
                dtColor = GetDataTable();
            }
            SetColorSetting();
            buttonApply_Click(this, null);

            lblStatus.Text = "TPMonitor Plugin Started.";
        }
Ejemplo n.º 44
0
        /// <summary>
        /// Initialize plugin
        /// </summary>
        /// <param name="pluginScreenSpace"></param>
        /// <param name="pluginStatusText"></param>
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {

            // Push the option screen into the option tab
            int dcIndex = -1;
            for (int i = 0; i < ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count; i++)
            {
                if (ActGlobals.oFormActMain.OptionsTreeView.Nodes[i].Text == "CO Parsing")
                    dcIndex = i;
            }
            if (dcIndex != -1)
            {
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("General");
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"CO Parsing\General", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Find the applicable options in the Options tab, CO Parsing section.";
                pluginScreenSpace.Controls.Add(lblConfig);
            }
            else
            {
                ActGlobals.oFormActMain.OptionsTreeView.Nodes.Add("CO Parsing");
                dcIndex = ActGlobals.oFormActMain.OptionsTreeView.Nodes.Count - 1;
                optionsNode = ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Nodes.Add("General");
                ActGlobals.oFormActMain.OptionsControlSets.Add(@"CO Parsing\General", new List<Control> { this });
                Label lblConfig = new Label();
                lblConfig.AutoSize = true;
                lblConfig.Text = "Find the applicable options in the Options tab, CO Parsing section.";
                pluginScreenSpace.Controls.Add(lblConfig);
            }
            ActGlobals.oFormActMain.OptionsTreeView.Nodes[dcIndex].Expand();

            xmlSettings = new SettingsSerializer(this);
            string FileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\CO_ACTLib\\recents.cfg";
            FileInfo RecFile = new FileInfo(FileName);

            LoadSettings();


            ActGlobals.oFormActMain.LogPathHasCharName = false;
            ActGlobals.oFormActMain.LogFileFilter = "Combat*.log";
            ActGlobals.oFormActMain.LogFileParentFolderName = "GameClient";
            ActGlobals.oFormActMain.ResetCheckLogs();
            ActGlobals.oFormActMain.TimeStampLen = 19; // Remember to include spaces after the time stamp
            ActGlobals.oFormActMain.GetDateTimeFromLog = new FormActMain.DateTimeLogParser(ParseDateTime);
            ActGlobals.oFormActMain.BeforeLogLineRead += new LogLineEventDelegate(oFormActMain_BeforeLogLineRead);
            ActGlobals.oFormActMain.OnCombatEnd += new CombatToggleEventDelegate(oFormActMain_OnCombatEnd);

            SetupDataTypes();

            pluginStatusText.Text = Constants.OnLoadStatusText + " Expire Date: None";

        }