public override void Enable() { PluginSetting <List <DeviceDefinition> > definitions = _settings.GetSetting("DeviceDefinitions", new List <DeviceDefinition>()); RGBDeviceProvider.Instance.DeviceDefinitions.Clear(); foreach (DeviceDefinition deviceDefinition in definitions.Value) { E131DMXDeviceDefinition definition = new(deviceDefinition.Hostname) { Port = deviceDefinition.Port, Manufacturer = deviceDefinition.Manufacturer, Model = deviceDefinition.Model, Universe = deviceDefinition.Universe }; foreach (LedDefinition ledDefinition in deviceDefinition.LedDefinitions.Where(l => l.LedId != LedId.Invalid)) { int rChannel = ledDefinition.R; int gChannel = ledDefinition.G; int bChannel = ledDefinition.B; definition.AddLed(ledDefinition.LedId, (rChannel, c => c.GetR()), (gChannel, c => c.GetG()), (bChannel, c => c.GetB())); } RGBDeviceProvider.Instance.AddDeviceDefinition(definition); } _rgbService.AddDeviceProvider(RgbDeviceProvider); }
public YeeLightDeviceProvider(IRgbService rgbService, PluginSettings pluginSettings) : base(RGB.NET.Devices.YeeLight.YeeLightDeviceProvider.Instance) { _rgbService = rgbService; _useAllAvailableMulticastAddresses = pluginSettings.GetSetting("UseAllAvailableMulticastAddresses", false); _yeeLightDeviceDefinitions = pluginSettings.GetSetting("YeeLightDeviceDefinitionsSetting", new List <YeeLightDeviceDefinition>()); _scanMode = pluginSettings.GetSetting("ScanMode", ScanMode.Automatic); }
public DiscordDataModelExpansion(PluginSettings pluginSettings, ILogger logger) { _logger = logger; clientId = pluginSettings.GetSetting <string>("DiscordClientId", null); clientSecret = pluginSettings.GetSetting <string>("DiscordClientSecret", null); token = pluginSettings.GetSetting <SavedToken>("DiscordToken", null); }
public HueDataModelExpansion(PluginSettings settings, ILogger logger, IHueService hueService) { _logger = logger; _hueService = hueService; _storedBridgesSetting = settings.GetSetting("Bridges", new List <PhilipsHueBridge>()); _pollingRateSetting = settings.GetSetting("PollingRate", 2); }
public PhilipsHueConfigurationViewModel(Plugin plugin, PluginSettings settings, IHueService hueService, IDialogService dialogService, IModelValidator <PhilipsHueConfigurationViewModel> validator) : base(plugin, validator) { _hueService = hueService; _dialogService = dialogService; _storedBridgesSetting = settings.GetSetting("Bridges", new List <PhilipsHueBridge>()); _pollingRateSetting = settings.GetSetting("PollingRate", 2000); // Reset to default if the setting is below 100ms because the scale changed from seconds to milliseconds if (_pollingRateSetting.Value < 100) { _pollingRateSetting.Value = 2000; } PollingRate = _pollingRateSetting.Value; if (_storedBridgesSetting.Value.Any()) { WizardPage = 3; } }
public DisplayModeDataModelExpansion(PluginSettings pluginSettings, ILogger logger) { _logger = logger; _apiKeySetting = pluginSettings.GetSetting("OpenWeatherApiKey", string.Empty); _citySetting = pluginSettings.GetSetting("OpenWeatherCity", string.Empty); _unitOfMeasurementSetting = pluginSettings.GetSetting("OpenWeatherUnitOfMeasurement", Enum.GetNames(typeof(UnitsOfMeasurement)).FirstOrDefault()); _apiKeySetting.PropertyChanged += _OpenWeatherSettingsChanged_PropertyChanged; _citySetting.PropertyChanged += _OpenWeatherSettingsChanged_PropertyChanged; _unitOfMeasurementSetting.PropertyChanged += _OpenWeatherSettingsChanged_PropertyChanged; }
public DMXConfigurationViewModel(Plugin plugin, PluginSettings settings, IWindowManager windowManager, IPluginManagementService pluginManagementService) : base(plugin) { _settings = settings; _windowManager = windowManager; _pluginManagementService = pluginManagementService; _definitions = _settings.GetSetting("DeviceDefinitions", new List <DeviceDefinition>()); TurnOffLedsOnShutdown = _settings.GetSetting("TurnOffLedsOnShutdown", false).Value; Definitions = new BindableCollection <DeviceDefinition>(_definitions.Value); }
public HueDataModelExpansion(PluginSettings settings, IHueService hueService) { _hueService = hueService; _storedBridgesSetting = settings.GetSetting("Bridges", new List <PhilipsHueBridge>()); _pollingRateSetting = settings.GetSetting("PollingRate", 2000); // Reset to default if the setting is below 100ms because the scale changed from seconds to milliseconds if (_pollingRateSetting.Value < 100) { _pollingRateSetting.Value = 2000; } }
public GeneralModule(IColorQuantizerService quantizerService, PluginSettings settings, IProcessMonitorService processMonitorService) { _quantizerService = quantizerService; _processMonitorService = processMonitorService; _enableActiveWindow = settings.GetSetting("EnableActiveWindow", true); if (settings.GetSetting("AutoDefaultProfilesCreation", true).Value) { AddDefaultProfile(DefaultCategoryName.General, "Profiles/rainbow.json"); AddDefaultProfile(DefaultCategoryName.General, "Profiles/noise.json"); } }
public OpenRGBDeviceProvider(IRgbService rgbService, PluginSettings settings) : base(RGB.NET.Devices.OpenRGB.OpenRGBDeviceProvider.Instance) { _rgbService = rgbService; _forceAddAllDevicesSetting = settings.GetSetting("ForceAddAllDevices", false); _deviceDefinitionsSettings = settings.GetSetting("DeviceDefinitions", new List <OpenRGBServerDefinition> { new() { ClientName = "Artemis", Ip = "127.0.0.1", Port = 6742 } });
public override void Enable() { PluginSetting <List <DeviceDefinition> > definitions = _settings.GetSetting("DeviceDefinitions", new List <DeviceDefinition>()); RGBDeviceProvider.Instance.DeviceDefinitions.Clear(); string[] ports = SerialPort.GetPortNames(); foreach (DeviceDefinition deviceDefinition in definitions.Value) { if (deviceDefinition.Type != DeviceDefinitionType.ESP8266 && !ports.Contains(deviceDefinition.Port)) { _logger.Warning($"Not adding WS281X device named {deviceDefinition.Name} because {deviceDefinition.Port} was not found"); continue; } if (deviceDefinition.Type == DeviceDefinitionType.ESP8266) { UdpClient client = new(); try { client.Connect(deviceDefinition.Hostname, 1872); } catch (SocketException e) { _logger.Warning(e, $"Not adding UDP based device named {deviceDefinition.Name} on {deviceDefinition.Hostname}:1872"); continue; } } switch (deviceDefinition.Type) { case DeviceDefinitionType.Arduino: RGBDeviceProvider.Instance.AddDeviceDefinition(new ArduinoWS281XDeviceDefinition(deviceDefinition.Port)); break; case DeviceDefinitionType.Bitwizard: RGBDeviceProvider.Instance.AddDeviceDefinition(new BitwizardWS281XDeviceDefinition(deviceDefinition.Port)); break; case DeviceDefinitionType.ESP8266: RGBDeviceProvider.Instance.AddDeviceDefinition(new NodeMCUWS281XDeviceDefinition(deviceDefinition.Hostname)); break; default: throw new ArgumentOutOfRangeException(); } } _rgbService.AddDeviceProvider(RgbDeviceProvider); }
public override void Enable() { PathHelper.ResolvingAbsolutePath += PathHelperOnResolvingAbsolutePath; PluginSetting <List <DeviceDefinition> > definitions = _settings.GetSetting("DeviceDefinitions", new List <DeviceDefinition>()); if (definitions.Value == null) { definitions.Value = new List <DeviceDefinition>(); } foreach (DeviceDefinition deviceDefinition in definitions.Value) { RGB.NET.Devices.Debug.DebugDeviceProvider.Instance.AddFakeDeviceDefinition(deviceDefinition.Layout, deviceDefinition.ImageLayout); } try { _rgbService.AddDeviceProvider(RgbDeviceProvider); } catch (Exception e) { _logger.Warning(e, "Debug device provided failed to initialize, check paths"); } }
public override void EnablePlugin() { ConfigurationDialog = new PluginConfigurationDialog <WS281XConfigurationViewModel>(); PluginSetting <List <DeviceDefinition> > definitions = _settings.GetSetting <List <DeviceDefinition> >("DeviceDefinitions"); if (definitions.Value == null) { definitions.Value = new List <DeviceDefinition>(); } foreach (DeviceDefinition deviceDefinition in definitions.Value) { switch (deviceDefinition.Type) { case DeviceDefinitionType.Arduino: RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance.AddDeviceDefinition(new ArduinoWS281XDeviceDefinition(deviceDefinition.Port)); break; case DeviceDefinitionType.Bitwizard: RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance.AddDeviceDefinition(new BitwizardWS281XDeviceDefinition(deviceDefinition.Port)); break; default: throw new ArgumentOutOfRangeException(); } } _rgbService.AddDeviceProvider(RgbDeviceProvider); }
public override void Enable() { PluginSetting <List <OpenRGBServerDefinition> > definitions = _settings.GetSetting <List <OpenRGBServerDefinition> >("DeviceDefinitions"); if (definitions.Value is null) { definitions.Value = new List <OpenRGBServerDefinition>(); OpenRGBServerDefinition definition = new OpenRGBServerDefinition { ClientName = "Artemis", Ip = "127.0.0.1", Port = 6742 }; definitions.Value.Add(definition); definitions.Save(); } foreach (OpenRGBServerDefinition def in definitions.Value) { RGB.NET.Devices.OpenRGB.OpenRGBDeviceProvider.Instance.DeviceDefinitions.Add(def); } PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(AbstractOpenRGBDevice <>), sender, args); _rgbService.AddDeviceProvider(RgbDeviceProvider); }
private static Log CreateLog(int start, int end, List <Player> PlayerList, EncounterData encounter, string append) { try { Log Log = new Log(); Log.successLevel = SuccessLevelEnum.GetByCode(encounter.GetEncounterSuccessLevel()).Name; Log.startTime = encounter.StartTime.TimeOfDay.ToString() + " " + append; Log.duration = encounter.Duration.ToString(); Log.maxHit = ValidateAndFill("MaxHitParty", encounter.GetMaxHit(false)); Log.totalHealing = ValidateAndFill("TotalHealing", encounter.Healed.ToString()); Log.targetName = encounter.GetStrongestEnemy(null); Log.mapName = ValidateAndFill("MapName", encounter.ZoneName); Log.sortBy = PluginSettings.GetSetting <string>("SortBy"); PlayerList.Where(Player => Player.number >= start && Player.number <= end).ToList().ForEach(Player => { Log.players.Add(Player); }); if (Log.players.Count > 0) { return(Log); } else { return(null); } } catch (Exception e) { return(null); } }
public static bool IsPluginEnabled() { bool enabled = PluginSettings.GetSetting <bool>("Enabled"); string token = PluginSettings.GetSetting <string>("Token"); return(enabled && token != null); }
public WS281XConfigurationViewModel(Plugin plugin, PluginSettings settings, IDialogService dialogService) : base(plugin) { _dialogService = dialogService; _definitions = settings.GetSetting <List <DeviceDefinition> >("DeviceDefinitions"); Definitions = new BindableCollection <DeviceDefinition>(_definitions.Value); }
private void PluginControl_Load(object sender, System.EventArgs e) { this.chkEnabled.Checked = PluginSettings.GetSetting <bool>("Enabled"); this.txtToken.Text = PluginSettings.GetSetting <string>("Token"); this.lblGuildName.Text = PluginSettings.GetSetting <string>("GuildName"); this.lblChannelName.Text = PluginSettings.GetSetting <string>("ChannelName"); this.txtToken.Text = PluginSettings.GetSetting <string>("Token"); this.chlAttributes.SetItemChecked(0, PluginSettings.GetSetting <bool>("MaxHitParty")); this.chlAttributes.SetItemChecked(1, PluginSettings.GetSetting <bool>("TotalHealing")); this.chlAttributes.SetItemChecked(2, PluginSettings.GetSetting <bool>("MapName")); this.chlAttributes.SetItemChecked(3, PluginSettings.GetSetting <bool>("DamagePerc")); this.chlAttributes.SetItemChecked(4, PluginSettings.GetSetting <bool>("MaxHitIndividual")); this.chlAttributes.SetItemChecked(5, PluginSettings.GetSetting <bool>("HPS")); this.chlAttributes.SetItemChecked(6, PluginSettings.GetSetting <bool>("HealingPerc")); this.chlAttributes.SetItemChecked(7, PluginSettings.GetSetting <bool>("MaxHeal")); this.chlAttributes.SetItemChecked(8, PluginSettings.GetSetting <bool>("OverHealPerc")); this.chlAttributes.SetItemChecked(9, PluginSettings.GetSetting <bool>("Deaths")); this.chlAttributes.SetItemChecked(10, PluginSettings.GetSetting <bool>("Crit")); this.chlAttributes.SetItemChecked(11, PluginSettings.GetSetting <bool>("DirectHit")); this.chlAttributes.SetItemChecked(12, PluginSettings.GetSetting <bool>("DirectHitCrit")); this.chlAttributes.SetItemChecked(13, PluginSettings.GetSetting <bool>("CritHealPerc")); this.cmbSort.Text = PluginSettings.GetSetting <string>("SortBy"); }
private void CombatEnded(bool isImport, CombatToggleEventArgs encounterInfo) { if (PluginUtil.IsPluginEnabled()) { try { Log Log = PluginUtil.ACTEncounterToModel(encounterInfo.encounter); if (Log != null) { string Json = PluginUtil.ToJson(Log); bool Sent = Service.PostDiscord(Json, PluginSettings.GetSetting <string>("Token")); if (Sent) { PluginControl.LogInfo("Parse sent to your Discord channel."); PluginControl.LogInfo("Waiting the next encounter..."); } else { PluginControl.LogInfo("Could not send the parse to your Discord channel. Check your token."); } } else { PluginControl.LogInfo("Nothing to be sent. Waiting the next encounter..."); } } catch (Exception ex) { PluginControl.LogInfo("Something went wrong. " + ex.Message); } } }
private static String ValidateAndFill(string setting, string data) { if (PluginSettings.GetSetting <bool>(setting)) { return(data); } return(""); }
public RazerDeviceProvider(IRgbService rgbService, PluginSettings pluginSettings, ILogger logger) : base(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance) { _rgbService = rgbService; _pluginSettings = pluginSettings; _logger = logger; _loadEmulatorDevices = _pluginSettings.GetSetting("LoadEmulatorDevices", false); _loadEmulatorDevices.SettingChanged += LoadEmulatorDevicesOnSettingChanged; }
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo) { _settings = settings; DisplayName = "General"; DisplayIcon = "AllInclusive"; ExpandsMainDataModel = true; var testSetting = _settings.GetSetting("TestSetting", DateTime.Now); }
public LedenetConfigurationDialogViewModel(Plugin plugin, PluginSettings settings, IPluginManagementService pluginManagementService) : base(plugin) { _pluginManagementService = pluginManagementService; _ledenetDeviceDefinitionsSetting = settings.GetSetting("LedenetDeviceDefinitionsSetting", new List <LedenetDeviceDefinition>()); _ledenetDeviceDefinitions = _ledenetDeviceDefinitionsSetting.Value; Definitions = new BindableCollection <LedenetDeviceDefinition>(_ledenetDeviceDefinitions); }
public SpotifyDataModelExpansion(PluginSettings settings, ILogger logger, IColorQuantizerService colorQuantizer) { _logger = logger; _colorQuantizer = colorQuantizer; _token = settings.GetSetting <PKCETokenResponse>(Constants.SPOTIFY_AUTH_SETTING); _httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(2) }; albumArtColorCache = new ConcurrentDictionary <string, TrackColorsDataModel>(); }
public PhilipsHueConfigurationViewModel(Plugin plugin, PluginSettings settings, IHueService hueService, IDialogService dialogService, IModelValidator <PhilipsHueConfigurationViewModel> validator) : base(plugin, validator) { _hueService = hueService; _dialogService = dialogService; _storedBridgesSetting = settings.GetSetting("Bridges", new List <PhilipsHueBridge>()); _pollingRateSetting = settings.GetSetting("PollingRate", 2); PollingRate = _pollingRateSetting.Value; if (_storedBridgesSetting.Value.Any()) { WizardPage = 3; } }
public GeneralModule(PluginInfo pluginInfo, IRgbService rgbService, PluginSettings settings) : base(pluginInfo) { _settings = settings; DisplayName = "General"; ExpandsMainDataModel = true; _surface = rgbService.Surface; var testSetting = _settings.GetSetting("TestSetting", DateTime.Now); _color = ColorHelpers.GetRandomRainbowColor(); }
public static Log ACTEncounterToModel(EncounterData encounter) { Log Log = new Log(); Log.successLevel = SuccessLevelEnum.GetByCode(encounter.GetEncounterSuccessLevel()).Name; Log.startTime = encounter.StartTime.TimeOfDay.ToString(); Log.duration = encounter.Duration.ToString(); Log.maxHit = ValidateAndFill("MaxHitParty", encounter.GetMaxHit(false)); Log.totalHealing = ValidateAndFill("TotalHealing", encounter.Healed.ToString()); Log.targetName = encounter.GetStrongestEnemy(null); Log.mapName = ValidateAndFill("MapName", encounter.ZoneName); Log.sortBy = PluginSettings.GetSetting <string>("SortBy"); encounter.GetAllies().ForEach(combatant => { Player Player = new Player(); if (IsLimitBreak(combatant.Name)) { Player.playerName = combatant.Name; Player.maxHit = combatant.GetMaxHit(true); Log.players.Add(Player); } else if (!IsLimitBreak(combatant.Name) && GetCustomColumnData(combatant, "Job") != "") { Player.playerJob = GetCustomColumnData(combatant, "Job").ToUpper(); Player.playerName = FormatName(combatant.Name); Player.damagePercentage = ValidateAndFill("DamagePerc", combatant.DamagePercent); Player.dps = Math.Round(combatant.EncDPS).ToString(); Player.maxHit = FormatSkill(ValidateAndFill("MaxHitIndividual", combatant.GetMaxHit(true))); Player.healingPercentage = ValidateAndFill("HealingPerc", combatant.HealedPercent); Player.hps = ValidateAndFill("HPS", Math.Round(combatant.EncHPS).ToString()); Player.maxHeal = FormatSkill(ValidateAndFill("MaxHeal", combatant.GetMaxHeal(true, false))); Player.overhealPercentage = ValidateAndFill("OverHealPerc", GetCustomColumnData(combatant, "OverHealPct")); Player.deaths = ValidateAndFill("Deaths", combatant.Deaths.ToString()); Player.crit = ValidateAndFill("Crit", Math.Round(combatant.CritDamPerc).ToString()); Player.dh = ValidateAndFill("DirectHit", GetCustomColumnData(combatant, "DirectHitPct")); Player.dhCrit = ValidateAndFill("DirectHitCrit", GetCustomColumnData(combatant, "CritDirectHitPct")); Player.critHealPercentage = ValidateAndFill("CritHealPerc", Math.Round(combatant.CritHealPerc).ToString()); Log.players.Add(Player); } }); if (Log.players.Count == 0 || Log.duration == "00:00:00") { return(null); } return(Log); }
private void CombatEnded(bool isImport, CombatToggleEventArgs encounterInfo) { if (PluginUtil.IsPluginEnabled()) { try { //PluginControl.LogInfo(PluginSettings.GetSetting<string>("MaxPlayers")); //Log Log = PluginUtil.ACTEncounterToModel(encounterInfo.encounter); List <Log> LogList = PluginUtil.ACTEncounterToModelList(encounterInfo.encounter); LogList.ForEach(Log => { //PluginControl.LogInfo(PluginSettings.GetSetting<string>("MaxPlayers")); if (Log != null) { if (PluginSettings.GetSetting <bool>("TimeEnabled") == true && PluginUtil.TimeBetween(DateTime.Now, DateTime.Parse(PluginSettings.GetSetting <string>("StartTime")).TimeOfDay, DateTime.Parse(PluginSettings.GetSetting <string>("EndTime")).TimeOfDay) == false) { PluginControl.LogInfo("Parse *not* sent to your Discord channel due to time lock rules."); PluginControl.LogInfo("Waiting for the next encounter..."); return; } string Json = PluginUtil.ToJson(Log); bool Sent = Service.PostDiscord(Json, PluginSettings.GetSetting <string>("Token")); if (Sent) { PluginControl.LogInfo("Parse sent to your Discord channel."); PluginControl.LogInfo("Waiting for the next encounter..."); } else { PluginControl.LogInfo("Could not send the parse to your Discord channel. Check your token and permissions."); } //PluginControl.LogInfo(Json); } else { PluginControl.LogInfo("Nothing to be sent. Waiting for the next encounter..."); } }); } catch (Exception e) { PluginControl.LogInfo("Something went wrong. Debug info:" + Environment.NewLine + e.ToString()); } } }
public override void Enable() { PluginSetting <List <OpenRGBServerDefinition> > definitions = _settings.GetSetting <List <OpenRGBServerDefinition> >("DeviceDefinitions"); if (definitions.Value is null) { definitions.Value = new List <OpenRGBServerDefinition>(); OpenRGBServerDefinition definition = new() { ClientName = "Artemis", Ip = "127.0.0.1", Port = 6742 }; definitions.Value.Add(definition); definitions.Save(); } foreach (OpenRGBServerDefinition def in definitions.Value) { RGB.NET.Devices.OpenRGB.OpenRGBDeviceProvider.Instance.DeviceDefinitions.Add(def); } _rgbService.AddDeviceProvider(RgbDeviceProvider); }
public PluginSetting <T> GetSetting <T>(string name, T defaultValue = default) { return(_pluginSettings.GetSetting(name, defaultValue)); }