public void Initialize()
        {
            int delay = Settings.StartDelay * 1000;

            Thread.Sleep(delay);

            RGBSurface surface = RGBSurface.Instance;

            LoadDeviceProviders();
            surface.AlignDevices();

            foreach (IRGBDevice device in surface.Devices)
            {
                device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack;
            }

            UpdateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / MathHelper.Clamp(Settings.UpdateRate, 1, 100)
            };
            surface.RegisterUpdateTrigger(UpdateTrigger);
            UpdateTrigger.Start();

            foreach (SyncGroup syncGroup in Settings.SyncGroups)
            {
                RegisterSyncGroup(syncGroup);
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            var config = new NLog.Config.LoggingConfiguration();

            // Targets where to log to: File and Console
            var logfile = new NLog.Targets.FileTarget("logfile")
            {
                FileName = "debugtool.log"
            };

            // Rules for mapping loggers to targets
            config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);

            // Apply config
            LogManager.Configuration = config;

            RGBSurface surface = RGBSurface.Instance;

            LoadDeviceProviders();
            surface.AlignDevices();

            foreach (IRGBDevice device in surface.Devices)
            {
                device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack;
            }

            UpdateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / 60
            };
            surface.RegisterUpdateTrigger(UpdateTrigger);

            ILedGroup group = new ListLedGroup(surface.Leds);


            // Create new gradient
            IGradient gradient = new RainbowGradient();

            // Add a MoveGradientDecorator to the gradient
            gradient.AddDecorator(new RGB.NET.Decorators.Gradient.MoveGradientDecorator());

            // Make new LinearGradientBrush from gradient
            LinearGradientBrush nBrush = new LinearGradientBrush(gradient);

            // Apply LinearGradientBrush to led group
            group.Brush = nBrush;

            // Start UpdateTrigger, without this, the gradient will be drawn, but will not move.
            UpdateTrigger.Start();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 60.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool          throwExceptions = true;
            RGBDeviceType loadType        = (RGBDeviceType)(-1);

            //RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + RGBSurface.Instance.Devices.Count());

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine(device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
            }

            ILedGroup ledGroup = new ListLedGroup(surface.Leds);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (true)
            {
                double time = stopwatch.Elapsed.TotalMilliseconds / 400.0;
                ledGroup.Brush = new RadialGradientBrush(new Point(0.5 + 0.4 * Math.Cos(time), 0.5 + 0.4 * Math.Sin(time)), new RainbowGradient());
            }

            Console.ReadKey();
        }
Exemplo n.º 4
0
        internal RgbService(ILogger logger)
        {
            _logger = logger;
            Surface = RGBSurface.Instance;

            // Let's throw these for now
            Surface.Exception += SurfaceOnException;

            _loadedDevices = new List <IRGBDevice>();
            _updateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / 30
            };
            Surface.RegisterUpdateTrigger(_updateTrigger);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Paints a moving gradient effect on a given ILedGroup
        /// </summary>
        /// <param name="group">The ILedGroup to apply the brush to</param>
        /// <param name="trigger">The UpdateTrigger registered to the RGBSurface used</param>
        public static void PaintGradient(ILedGroup group, TimerUpdateTrigger trigger)
        {
            // Create new gradient
            IGradient gradient = new RainbowGradient();

            // Add a MoveGradientDecorator to the gradient
            gradient.AddDecorator(new RGB.NET.Decorators.Gradient.MoveGradientDecorator());

            // Make new LinearGradientBrush from gradient
            LinearGradientBrush nBrush = new LinearGradientBrush(gradient);

            // Apply LinearGradientBrush to led group
            group.Brush = nBrush;

            // Start UpdateTrigger, without this, the gradient will be drawn, but will not move.
            trigger.Start();
        }
Exemplo n.º 6
0
        public RgbService(ILogger logger, ISettingsService settingsService)
        {
            _logger                 = logger;
            _renderScaleSetting     = settingsService.GetSetting("Core.RenderScale", 0.5);
            _targetFrameRateSetting = settingsService.GetSetting("Core.TargetFrameRate", 25);
            _sampleSizeSetting      = settingsService.GetSetting("Core.SampleSize", 1);

            Surface = RGBSurface.Instance;

            // Let's throw these for now
            Surface.Exception += SurfaceOnException;
            _renderScaleSetting.SettingChanged     += RenderScaleSettingOnSettingChanged;
            _targetFrameRateSetting.SettingChanged += TargetFrameRateSettingOnSettingChanged;
            _loadedDevices = new List <IRGBDevice>();
            UpdateTrigger  = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / _targetFrameRateSetting.Value
            };
            Surface.RegisterUpdateTrigger(UpdateTrigger);
        }
Exemplo n.º 7
0
        public void Initialize()
        {
            RGBSurface surface = RGBSurface.Instance;

            LoadDeviceProviders();
            surface.AlignDevices();

            surface.Devices.OfType <AsusMainboardRGBDevice>().First().UpdateMode = DeviceUpdateMode.SyncBack;

            UpdateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / 30.0
            };                                                                       //MathHelper.Clamp(Settings.UpdateRate, 1, 100) };
            surface.RegisterUpdateTrigger(UpdateTrigger);
            UpdateTrigger.Start();

            PremadeSyncGroups(); //Create your sync groups here!

            HueEntertainment = HueEntertainment.Instance;
            Task.Factory.StartNew(() => HueEntertainment.Initialize());
        }
Exemplo n.º 8
0
        public RgbService(ILogger logger, ISettingsService settingsService, IPluginManagementService pluginManagementService, IDeviceRepository deviceRepository)
        {
            _logger = logger;
            _pluginManagementService = pluginManagementService;
            _deviceRepository        = deviceRepository;
            _targetFrameRateSetting  = settingsService.GetSetting("Core.TargetFrameRate", 25);

            Surface = new RGBSurface();

            // Let's throw these for now
            Surface.Exception                      += SurfaceOnException;
            Surface.SurfaceLayoutChanged           += SurfaceOnLayoutChanged;
            _targetFrameRateSetting.SettingChanged += TargetFrameRateSettingOnSettingChanged;
            _enabledDevices = new List <ArtemisDevice>();
            _devices        = new List <ArtemisDevice>();
            _ledMap         = new Dictionary <Led, ArtemisLed>();

            UpdateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / _targetFrameRateSetting.Value
            };
            Surface.RegisterUpdateTrigger(UpdateTrigger);
        }
Exemplo n.º 9
0
        public static void Init()
        {
            if (!cvarRgb.Valueb())
            {
                return;
            }

            log.WriteLine("rgb: initialising api..");
            _surface            = RGBSurface.Instance;
            _surface.Exception += args => Console.WriteLine(args.Exception.Message);

            _surface.LoadDevices(CorsairDeviceProvider.Instance);
            //surface.LoadDevices(LogitechDeviceProvider.Instance);
            //surface.LoadDevices(MsiDeviceProvider.Instance);
            _surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
            _surface.LoadDevices(RazerDeviceProvider.Instance);

            TimerUpdateTrigger TimerTrigger = new TimerUpdateTrigger
            {
                UpdateFrequency = 0.05
            };

            RGBSurface.Instance.RegisterUpdateTrigger(TimerTrigger);
            TimerTrigger.Start();

            _surface.AlignDevices();

            foreach (var v in RGBSurface.Instance.Devices)
            {
                log.WriteLine("rgb: device connected " + v.DeviceInfo.Manufacturer + " " + v.DeviceInfo.Model + " (" +
                              v.DeviceInfo.DeviceType + ")");
            }
            log.WriteLine("rgb: ready (" + RGBSurface.Instance.Devices.Count() + " devices)", log.LogMessageType.Good);

            _rules             = new Dictionary <LedId, Color>();
            _surface.Updating += args => Update();
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            surface.Exception += args_ => Console.WriteLine(args_.Exception.Message);
            LoadDevices();

            /* LED Updates are triggered by an UpdateTrigger
             * UpdateTriggers must be registered to a surface
             */
            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            surface.RegisterUpdateTrigger(updateTrigger);

            /* You can also trigger an update manually by calling surface.Update();
             *  If calling surface.Update() more than once,
             *      an update trigger is almost always a better option.
             */
            surface.Update();

            /* To apply an led effect to some device(s), you must first make a ListLedGroup
             * ListLedGroups can be created from an individual IRGBDevice by passing
             *      the IRGBDevice as a parameter to the ListLedGroup constructor.
             */
            ILedGroup ledGroup = new ListLedGroup(surface.Leds);

            /* Once you have an ILedGroup with all of your desired Leds in it,
             *     To apply an effect, you will start with a brush.
             *
             * Brushes are used to "paint" leds, and they are kinda like
             *     bases that you can apply gradients and decorators to
             *      - Gradients tell the brush what colors to paint where, and when.
             *      - Decorators are like mods to a brush.
             */
            PaintGradient(ledGroup, updateTrigger);

            Console.ReadLine();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;
            Random     random  = new Random();

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 200.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool throwExceptions = true;
            //RGBDeviceType loadType = (RGBDeviceType)(-1);
            RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + surface.Devices.Count());

            int index = 0;

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine("[" + index + "] " + device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
                index++;
            }

            //Index of the chosen device
            int choice;

            if (surface.Devices.Count() < 1)
            {
                Console.WriteLine("No devices detected :(");
                Console.ReadKey();

                return;
            }
            else if (surface.Devices.Count() == 1)
            {
                choice = 0;
            }
            else
            {
                //Let the user choose which device the effect should be applied to by it's index in the enumeration
                Console.Write("Pick a device [Enter Number]:\n>");


                bool isOutOfRange = false;
                do
                {
                    //Is the entered string an int?
                    while (!int.TryParse(Console.ReadLine(), out choice))
                    {
                        Console.Write("Invalid Number.\n>");
                    }

                    //If it is an int, is it out of range?
                    isOutOfRange = choice <0 || choice> surface.Devices.Count() - 1;

                    if (isOutOfRange)
                    {
                        Console.Write("Invalid Number.\n>");
                    }
                } while (isOutOfRange);
            }


            //Determine device-specific led position minima and maxima (Rectangle Bounds)
            double minx = double.PositiveInfinity, miny = double.PositiveInfinity, maxx = double.NegativeInfinity, maxy = double.NegativeInfinity;
            int    count = 0;

            foreach (Led led in surface.Devices.ElementAt(choice))
            {
                if (led.ActualLocation.X < minx)
                {
                    minx = led.ActualLocation.X;
                }
                if (led.ActualLocation.Y < miny)
                {
                    miny = led.ActualLocation.Y;
                }
                if (led.ActualLocation.X > maxx)
                {
                    maxx = led.ActualLocation.X;
                }
                if (led.ActualLocation.Y > maxy)
                {
                    maxy = led.ActualLocation.Y;
                }
                count++;
            }

            Console.WriteLine($"Total LED count: {count}, X: [{minx}, {maxx}], Y: [{miny}, {maxy}]\nPress [ESC] to Close, any other key to continue the animation.");

            //Set background
            ListLedGroup groupBackground = new ListLedGroup(surface.Devices.ElementAt(choice));

            groupBackground.ZIndex = 0;
            groupBackground.Brush  = new SolidColorBrush(new Color(0, 0, 0));

            Dictionary <LedId, ListLedGroup> ledGroups = new Dictionary <LedId, ListLedGroup>();

            foreach (Led led in surface.Devices.ElementAt(choice))
            {
                if (!ledGroups.ContainsKey(led.Id))
                {
                    ListLedGroup group = new ListLedGroup(led);
                    group.ZIndex          = 1;
                    group.Brush           = new SolidColorBrush(new Color(0.0, 0.0, 0.0));
                    group.Brush.IsEnabled = false;

                    ledGroups.Add(led.Id, group);
                }
            }

            ConsoleKeyInfo key = Console.ReadKey();

            Console.Write("\r");
            while (key.Key != ConsoleKey.Escape)
            {
                LedId pressedKeyLedId = KeyConverter.GetLedByConsoleKey(key.Key);

                foreach (Led led in surface.Devices.ElementAt(choice))
                {
                    ledGroups[led.Id].Brush.IsEnabled = false;
                }

                if (pressedKeyLedId != LedId.Invalid)
                {
                    double hue = random.NextDouble() * 360;
                    foreach (Led led in surface.Devices.ElementAt(choice))
                    {
                        const double distScaleFac = 2.0;
                        double       deltaX       = led.ActualLocation.X - led.ActualSize.Width / 2 - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualLocation.X - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualSize.Width / 2;
                        double       deltaY       = led.ActualLocation.Y - led.ActualSize.Height / 2 - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualLocation.Y - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualSize.Height / 2;
                        double       dist         = distScaleFac * Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

                        Color color = new Color();
                        color = color.SetHSV(hue, 1.0, 1.0);
                        color = color.SetA(Math.Max(255.0 - dist, 0) / 255.0);

                        ledGroups[led.Id].Brush           = new SolidColorBrush(color);
                        ledGroups[led.Id].Brush.IsEnabled = true;
                    }
                }

                key = Console.ReadKey();
                Console.Write("\r");
            }


            Console.ReadKey();
            return;
        }
Exemplo n.º 12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.ShowInTaskbar   = false;
            this.WindowState     = FormWindowState.Minimized;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            if (chkShowNotification.Checked)
            {
                notifyIcon1.ShowBalloonTip(5000, "RGBSync", "Click the notification icon to configure RGB Devices.", ToolTipIcon.Info);
            }
            //Process.Start("C:\\Program Files (x86)\\ASUS\\AURA\\AURA.exe");
            //Thread.Sleep(1000);
            //Process.GetProcessesByName("Aura")[0].Kill();

            tabCorsairLink.Enabled = false;
            try
            {
                RGBSurface.Instance.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard, throwExceptions: true);
                if (chkCorsairCue.Checked)
                {
                    RGBSurface.Instance.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkLogitech.Checked)
                {
                    RGBSurface.Instance.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkCM.Checked)
                {
                    RGBSurface.Instance.LoadDevices(CoolerMasterDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkNovation.Checked)
                {
                    RGBSurface.Instance.LoadDevices(NovationDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkCorsairLink.Checked)
                {
                    RGBSurface.Instance.LoadDevices(CorsairLinkDeviceProvider.Instance, exclusiveAccessIfPossible: false, throwExceptions: true);
                }
                if (chkMSI.Checked)
                {
                    RGBSurface.Instance.LoadDevices(MsiDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkRazer.Checked)
                {
                    RGBSurface.Instance.LoadDevices(RazerDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }


                AsusMainboardRGBDevice mainboard = RGBSurface.Instance.GetDevices <AsusMainboardRGBDevice>().FirstOrDefault();
                if (mainboard == null)
                {
                    throw new ApplicationException("No mainboard to sync with is loaded.");
                }

                mainboard.UpdateMode = DeviceUpdateMode.SyncBack;

                _ledGroup       = new ListLedGroup(RGBSurface.Instance.Leds).Exclude(mainboard.ToArray());
                _ledGroup.Brush = new SyncBrush(((IRGBDevice)mainboard)[SYNC_LED]);
                TimerUpdateTrigger TimerTrigger = new TimerUpdateTrigger();
                TimerTrigger.UpdateFrequency = 0.05;
                RGBSurface.Instance.RegisterUpdateTrigger(TimerTrigger);
                TimerTrigger.Start();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 13
0
        public void Configure(DriverDetails driverDetails)
        {
            surface = RGBSurface.Instance;

            string deviceProvierDir = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? string.Empty, DEVICEPROVIDER_DIRECTORY);

            if (!Directory.Exists(deviceProvierDir))
            {
                return;
            }

            foreach (string file in Directory.GetFiles(deviceProvierDir, "*.dll"))
            {
                try
                {
                    Assembly assembly = Assembly.LoadFrom(file);
                    foreach (Type loaderType in assembly.GetTypes().Where(t =>
                                                                          !t.IsAbstract && !t.IsInterface && t.IsClass &&
                                                                          typeof(IRGBDeviceProviderLoader).IsAssignableFrom(t)))
                    {
                        if (Activator.CreateInstance(loaderType) is IRGBDeviceProviderLoader deviceProviderLoader)
                        {
                            if (deviceProviderLoader.RequiresInitialization)
                            {
                                continue;
                            }
                            RGBSurface.Instance.LoadDevices(deviceProviderLoader, RGBDeviceType.All);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            surface.AlignDevices();

            foreach (IRGBDevice device in surface.Devices)
            {
                device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack;
                ControlDevice slsDevice = new ControlDevice();
                slsDevice.Name         = device.DeviceInfo.Manufacturer + "-" + device.DeviceInfo.DeviceName;
                slsDevice.DeviceType   = DeviceTypeConverter.GetType(device.DeviceInfo.DeviceType);
                slsDevice.Driver       = this;
                slsDevice.Has2DSupport = false;
                slsDevice.ProductImage = (Bitmap)System.Drawing.Image.FromStream(imageStream);


                List <ControlDevice.LedUnit> deviceLeds = new List <ControlDevice.LedUnit>();

                int i = 0;

                foreach (Led led in device)
                {
                    RGBNetLed newLed = new RGBNetLed();
                    newLed.Data           = new ControlDevice.LEDData();
                    newLed.Data.LEDNumber = i;
                    i++;
                    newLed.LedId      = (int)led.Id;
                    newLed.DeviceName = led.Device.DeviceInfo.DeviceName;
                    deviceLeds.Add(newLed);
                }

                slsDevice.LEDs = deviceLeds.ToArray();

                DeviceAdded?.Invoke(slsDevice, new Events.DeviceChangeEventArgs(slsDevice));
            }

            UpdateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / 30
            };
            surface.RegisterUpdateTrigger(UpdateTrigger);
            UpdateTrigger.Start();
        }
Exemplo n.º 14
0
        public void Initialize()
        {
            var config = new NLog.Config.LoggingConfiguration();

            // Targets where to log to: File and Console
            var logfile = new NLog.Targets.FileTarget("logfile")
            {
                FileName = "rgbsync.log"
            };

            // Rules for mapping loggers to targets
            config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);

            // Apply config
            LogManager.Configuration = config;

            Logger.Debug("============ JackNet RGB Sync is Starting ============");

            if (AppSettings.RunAsAdmin == true)
            {
                Logger.Debug("App should be run as administrator.");
                Logger.Debug("Checking to see if app is running as administrator...");
                var  identity         = WindowsIdentity.GetCurrent();
                var  principal        = new WindowsPrincipal(identity);
                bool isRunningAsAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
                if (isRunningAsAdmin == false)
                {
                    Logger.Debug("App is not running as administrator, restarting...");
                    ExecuteAsAdmin("RGBSync+.exe");
                    Exit();
                }
                else
                {
                    Logger.Debug("App is running as administrator, proceding with startup.");
                }
            }

            CultureInfo ci = CultureInfo.InstalledUICulture;

            if (AppSettings.Lang == null)
            {
                Logger.Debug("Language is not set, inferring language from system culture. Lang=" + ci.TwoLetterISOLanguageName);
                AppSettings.Lang = ci.TwoLetterISOLanguageName;
            }
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(AppSettings.Lang);

            client = new DiscordRpcClient("581567509959016456");
            client.Initialize();

            string tempSetup = Directory.GetCurrentDirectory() + "\\~TEMP_setup.exe";

            if (File.Exists(tempSetup))
            {
                Logger.Debug("Found old installer, removing...");
                try
                {
                    File.Delete(tempSetup);
                    Logger.Debug("Old installer successfully removed.");
                }
                catch (Exception ex)
                {
                    Logger.Error("Error deleting file: " + ex.ToString());
                }
            }

            int delay = AppSettings.StartDelay * 1000;

            RGBSurface surface = RGBSurface.Instance;

            LoadDeviceProviders();
            surface.AlignDevices();

            foreach (IRGBDevice device in surface.Devices)
            {
                device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack;
            }

            UpdateTrigger = new TimerUpdateTrigger {
                UpdateFrequency = 1.0 / MathHelper.Clamp(AppSettings.UpdateRate, 1, 100)
            };
            surface.RegisterUpdateTrigger(UpdateTrigger);
            UpdateTrigger.Start();

            foreach (SyncGroup syncGroup in Settings.SyncGroups)
            {
                RegisterSyncGroup(syncGroup);
            }
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 144.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool throwExceptions = true;
            //RGBDeviceType loadType = (RGBDeviceType)(-1);
            RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + RGBSurface.Instance.Devices.Count());

            ILedGroup groupNum1 = null, groupNum2 = null, groupNum3 = null,
                      groupNum4 = null, groupNum5 = null, groupNum6 = null,
                      groupNum7 = null, groupNum8 = null, groupNum9 = null,
                      groupNumPad = null;

            foreach (IRGBDevice device in surface.Devices)
            {
                //Determine device-specific led position minima and maxima (Rectangle Bounds)
                double minx = double.PositiveInfinity, miny = double.PositiveInfinity, maxx = double.NegativeInfinity, maxy = double.NegativeInfinity;
                int    count = 0;
                foreach (Led led in device)
                {
                    if (led.ActualLocation.X < minx)
                    {
                        minx = led.ActualLocation.X;
                    }
                    if (led.ActualLocation.Y < miny)
                    {
                        miny = led.ActualLocation.Y;
                    }
                    if (led.ActualLocation.X > maxx)
                    {
                        maxx = led.ActualLocation.X;
                    }
                    if (led.ActualLocation.Y > maxy)
                    {
                        maxy = led.ActualLocation.Y;
                    }
                    count++;
                }

                foreach (Led led in device)
                {
                    ListLedGroup group = new ListLedGroup(led);
                    group.Brush = new SolidColorBrush(new Color(led.ActualLocation.X.Map(minx, maxx, 0.0, 1.0), led.ActualLocation.Y.Map(miny, maxy, 0.0, 1.0), 0.0));
                }

                Console.WriteLine($"Device {device.DeviceInfo.DeviceName} - Total LED count: {count}, X: [{minx}, {maxx}], Y: [{miny}, {maxy}]");
            }

            Console.ReadKey();
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Currently modes are supported: rainbow and sync");
            Console.WriteLine("For rainbow, just run the exe");
            Console.WriteLine("For sync, add the argument sync -> eg. 'RGB.exe sync'");

            RGBSurface surface = RGBSurface.Instance;

            bool sync = false;

            if (args != null && args.Length > 0 && args[0] == "sync")
            {
                sync = true;
                Console.WriteLine("Starting sync mode...");
            }
            else
            {
                Console.WriteLine("Starting rainbow mode...");
            }


            if (sync)
            {
                surface.LoadDevices(AsusDeviceProvider.Instance, exclusiveAccessIfPossible: false, throwExceptions: true);
                surface.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                surface.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
            }
            else
            {
                surface.LoadDevices(AsusDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                surface.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                surface.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
            }

            surface.AlignDevices();


            Console.WriteLine($"Found {surface.Devices.Count()} devices!");
            foreach (var dev in surface.Devices)
            {
                Console.WriteLine($"dev: {dev.DeviceInfo.DeviceName}");
            }

            if (sync)
            {
                AsusMainboardRGBDevice mainboard = RGBSurface.Instance.GetDevices <AsusMainboardRGBDevice>().FirstOrDefault();
                if (mainboard == null)
                {
                    throw new ApplicationException("No mainboard to sync with is loaded.");
                }

                mainboard.UpdateMode = DeviceUpdateMode.SyncBack;

                var group = new ListLedGroup(surface.Leds).Exclude(mainboard.ToArray());
                group.Brush = new SyncBrush(((IRGBDevice)mainboard)[LedId.Mainboard1]);
            }
            else
            {
                foreach (var dev in surface.Devices)
                {
                    dev.UpdateMode = DeviceUpdateMode.Sync;
                }

                var group    = new ListLedGroup(surface.Leds);
                var gradient = new RainbowGradient();
                var brush    = new LinearGradientBrush(gradient);
                group.Brush = brush;

                System.Timers.Timer aTimer = new System.Timers.Timer();
                aTimer.Elapsed += (s, e) => { gradient.Move(7); };
                aTimer.Interval = 100;
                aTimer.Start();
            }

            TimerUpdateTrigger timerTrigger = new TimerUpdateTrigger();

            timerTrigger.UpdateFrequency = 0.05;
            surface.RegisterUpdateTrigger(timerTrigger);
            timerTrigger.Start();

            Console.Read();
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 144.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool throwExceptions = true;
            //RGBDeviceType loadType = (RGBDeviceType)(-1);
            RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + RGBSurface.Instance.Devices.Count());

            ILedGroup groupNum1 = null, groupNum2 = null, groupNum3 = null,
                      groupNum4 = null, groupNum5 = null, groupNum6 = null,
                      groupNum7 = null, groupNum8 = null, groupNum9 = null,
                      groupNumPad = null;

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine(device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
                groupNum1 = new ListLedGroup(device[LedId.Keyboard_Num1]);
                groupNum2 = new ListLedGroup(device[LedId.Keyboard_Num2]);
                groupNum3 = new ListLedGroup(device[LedId.Keyboard_Num3]);
                groupNum4 = new ListLedGroup(device[LedId.Keyboard_Num4]);
                groupNum5 = new ListLedGroup(device[LedId.Keyboard_Num5]);
                groupNum6 = new ListLedGroup(device[LedId.Keyboard_Num6]);
                groupNum7 = new ListLedGroup(device[LedId.Keyboard_Num7]);
                groupNum8 = new ListLedGroup(device[LedId.Keyboard_Num8]);
                groupNum9 = new ListLedGroup(device[LedId.Keyboard_Num9]);
            }

            if (groupNum1 == null || groupNum2 == null || groupNum3 == null || groupNum4 == null || groupNum5 == null || groupNum6 == null || groupNum7 == null || groupNum8 == null || groupNum9 == null)
            {
                Console.WriteLine("[Error] No numpad LEDs identifiable.");
                return;
            }

            groupNum1.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum2.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum3.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum4.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum5.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum6.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum7.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum8.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum9.Brush = new SolidColorBrush(new Color(100, 100, 100));

            Console.WriteLine("Press [NumPad1-9] to play, [ESC] to quit.\n");

            ConsoleKeyInfo key = Console.ReadKey();

            Console.Write("\r");
            while (key.Key != ConsoleKey.Escape)
            {
                if (key.Key == ConsoleKey.NumPad1 || key.Key == ConsoleKey.NumPad2 || key.Key == ConsoleKey.NumPad3 ||
                    key.Key == ConsoleKey.NumPad4 || key.Key == ConsoleKey.NumPad5 || key.Key == ConsoleKey.NumPad6 ||
                    key.Key == ConsoleKey.NumPad7 || key.Key == ConsoleKey.NumPad8 || key.Key == ConsoleKey.NumPad9)
                {
                    groupNum1.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum2.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum3.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum4.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum5.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum6.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum7.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum8.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum9.Brush = new SolidColorBrush(new Color(100, 100, 100));
                }

                switch (key.Key)
                {
                default:
                    break;

                case ConsoleKey.NumPad1:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum1.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad2:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum2.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad3:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum3.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad4:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum4.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad5:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum5.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad6:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum6.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad7:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum7.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad8:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum8.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad9:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum9.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;
                }

                key = Console.ReadKey();
                Console.Write("\r");
            }
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 200.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool throwExceptions = true;
            //RGBDeviceType loadType = (RGBDeviceType)(-1);
            RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + surface.Devices.Count());

            int index = 0;

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine("[" + index + "] " + device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
                index++;
            }

            //Index of the chosen device
            int choice;

            if (surface.Devices.Count() < 1)
            {
                Console.WriteLine("No devices detected :(");
                Console.ReadKey();

                return;
            }
            else if (surface.Devices.Count() == 1)
            {
                choice = 0;
            }
            else
            {
                //Let the user choose which device the effect should be applied to by it's index in the enumeration
                Console.Write("Pick a device [Enter Number]:\n>");


                bool isOutOfRange = false;
                do
                {
                    //Is the entered string an int?
                    while (!int.TryParse(Console.ReadLine(), out choice))
                    {
                        Console.Write("Invalid Number.\n>");
                    }

                    //If it is an int, is it out of range?
                    isOutOfRange = choice <0 || choice> surface.Devices.Count() - 1;

                    if (isOutOfRange)
                    {
                        Console.Write("Invalid Number.\n>");
                    }
                } while (isOutOfRange);
            }

            //Determine device-specific led position minima and maxima (Rectangle Bounds)
            double minx = double.PositiveInfinity, miny = double.PositiveInfinity, maxx = double.NegativeInfinity, maxy = double.NegativeInfinity;
            int    count = 0;

            foreach (Led led in surface.Devices.ElementAt(choice))
            {
                if (led.ActualLocation.X < minx)
                {
                    minx = led.ActualLocation.X;
                }
                if (led.ActualLocation.Y < miny)
                {
                    miny = led.ActualLocation.Y;
                }
                if (led.ActualLocation.X > maxx)
                {
                    maxx = led.ActualLocation.X;
                }
                if (led.ActualLocation.Y > maxy)
                {
                    maxy = led.ActualLocation.Y;
                }
                count++;
            }

            Console.WriteLine($"Total LED count: {count}, X: [{minx}, {maxx}], Y: [{miny}, {maxy}]\nPress [ESC] to Close, any other key to continue the animation.");

            //Set background
            ListLedGroup groupBackground = new ListLedGroup(surface.Devices.ElementAt(choice));

            groupBackground.ZIndex = 0;
            groupBackground.Brush  = new SolidColorBrush(new Color(100, 100, 100));

            Dictionary <LedId, ListLedGroup> ledGroups = new Dictionary <LedId, ListLedGroup>();

            foreach (Led led in surface.Devices.ElementAt(choice))
            {
                if (!ledGroups.ContainsKey(led.Id))
                {
                    ListLedGroup group = new ListLedGroup(led);
                    group.ZIndex          = 1;
                    group.Brush           = new SolidColorBrush(new Color(0.0, 1.0, 0.0));
                    group.Brush.IsEnabled = false;

                    ledGroups.Add(led.Id, group);
                }
            }

            double xoff = 0.0;
            bool   play;

            do
            {
                foreach (Led led in surface.Devices.ElementAt(choice))
                {
                    //Map positions of Leds to Range
                    double x = (led.ActualLocation.X + led.ActualSize.Width / 2.0).Map(minx, maxx, 0.0, 4 * Math.PI);
                    double y = (led.ActualLocation.Y + led.ActualSize.Height / 2.0).Map(miny, maxy, 2, -2);

                    //Activate/Deactivate Brushes according to calculation
                    if (Math.Sin(x + xoff) >= y)
                    {
                        ledGroups[led.Id].Brush.IsEnabled = true;
                    }
                    else
                    {
                        ledGroups[led.Id].Brush.IsEnabled = false;
                    }
                }

                if (!anim_autoplay)
                {
                    play = Console.ReadKey().Key != ConsoleKey.Escape;
                }
                else
                {
                    Thread.Sleep(1000 / 12);
                }

                xoff += 0.1;
            } while (anim_autoplay || play);


            Console.ReadKey();
            return;
        }