//DeviceLayout
        private void ConstructDeviceLayout()
        {
            DeviceLayout deviceLayout = this.SettingViewModel.Setting.DeviceLayout;

            this.ConstructDeviceLayoutType(deviceLayout.FallBackType, deviceLayout.IsAdaptive);
            this.ConstructDeviceLayoutAdaptive(deviceLayout.PhoneMaxWidth, deviceLayout.PadMaxWidth);
        }
示例#2
0
        /// <summary>
        /// Internal constructor of <see cref="DebugRGBDeviceInfo"/>.
        /// </summary>
        internal DebugRGBDevice(string layoutPath, Func <Dictionary <LedId, Color> > syncBackFunc = null, Action <IEnumerable <Led> > updateLedsAction = null)
        {
            this._syncBackFunc     = syncBackFunc;
            this._updateLedsAction = updateLedsAction;

            DeviceLayout layout = DeviceLayout.Load(layoutPath);

            DeviceInfo = new DebugRGBDeviceInfo(layout.Type, layout.Vendor, layout.Model, layout.Lighting, syncBackFunc != null);
        }
 //@Construct
 /// <summary>
 /// Initializes the device-layout.
 /// </summary>
 public void ConstructDeviceLayout()
 {
     // Width
     DeviceLayout layout = this.Setting.DeviceLayout;
     {
         double           width = Window.Current.Bounds.Width;
         DeviceLayoutType type  = layout.GetActualType(width);
         this.DeviceLayoutType = type;
     }
 }
        private void Window_SizeChanged(object sender, WindowSizeChangedEventArgs e)
        {
            this.WindowWidth  = e.Size.Width;
            this.WindowHeight = e.Size.Height;

            DeviceLayout layout = this.Setting.DeviceLayout;
            {
                double           width = e.Size.Width;
                DeviceLayoutType type  = layout.GetActualType(width);
                this.DeviceLayoutType = type;
            }
        }
        private async Task SetDeviceLayoutType(DeviceLayoutType type2, bool isAdaptive)
        {
            // Setting
            DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout;

            {
                layout.IsAdaptive   = isAdaptive;
                layout.FallBackType = type2;
                DeviceLayoutType type = layout.GetActualType(this.ActualWidth);
                this.SettingViewModel.DeviceLayoutType = type;
            }
            await this.Save();
        }
        private void ConstructDeviceLayoutAdaptive(int phone, int pad)
        {
            this.AdaptiveGrid.PhoneWidth = phone;
            this.AdaptiveGrid.PadWidth   = pad;
            this.AdaptiveGrid.SetWidth();


            this.AdaptiveGrid.ScrollModeChanged += (s, mode) =>
            {
                this.ScrollViewer.HorizontalScrollMode = mode;
                this.ScrollViewer.VerticalScrollMode   = mode;
            };
            this.AdaptiveGrid.PhoneWidthChanged += async(s, value) =>
            {
                //Setting
                this.SettingViewModel.Setting.DeviceLayout.PhoneMaxWidth = value;
                this.SettingViewModel.NotifyDeviceLayoutType();
                await this.Write();
            };
            this.AdaptiveGrid.PadWidthChanged += async(s, value) =>
            {
                //Setting
                this.SettingViewModel.Setting.DeviceLayout.PadMaxWidth = value;
                this.SettingViewModel.NotifyDeviceLayoutType();
                await this.Write();
            };


            this.AdaptiveResetButton.Click += async(s, e) =>
            {
                DeviceLayout default2 = DeviceLayout.Default;
                int          phone2   = default2.PhoneMaxWidth;
                int          pad2     = default2.PadMaxWidth;

                this.AdaptiveGrid.PhoneWidth = phone2;
                this.AdaptiveGrid.PadWidth   = pad2;
                this.AdaptiveGrid.SetWidth();

                //Setting
                this.SettingViewModel.Setting.DeviceLayout.PhoneMaxWidth = phone2;
                this.SettingViewModel.Setting.DeviceLayout.PadMaxWidth   = pad2;
                this.SettingViewModel.NotifyDeviceLayoutType();
                await this.Write();//Write
            };
        }
示例#7
0
            void InitGPI()
            {
                provider = new GPI.Vulkan.VulkanGPIProvider();
                if (!provider.IsSupported)
                {
                    throw new NotSupportedException(String.Format("IGPIProvider {0} is not supported and thus faild to init GPI", provider.Name));
                }
                instance = provider.CreateInstance();
                DeviceLayout layout = DeviceLayout.SimpleDeferred;

                if (!instance.IsSupported(layout))
                {
                    throw new NotSupportedException(String.Format("IGPIInstance from IGPIProvider {0} is not able to supported required layout", provider.Name));
                }
                device  = instance.CreateDevice(layout);
                mainCmd = device.CreateCommandBuffer();

                cleanupStack.Push(() => {
                    Console.WriteLine(" . Dispose GPI");
                });
            }
示例#8
0
        /// <summary>
        /// Applies the given layout.
        /// </summary>
        /// <param name="layoutPath">The file containing the layout.</param>
        /// <param name="imageLayout">The name of the layout used to get the images of the leds.</param>
        /// <param name="imageBasePath">The path images for this device are collected in.</param>
        protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath)
        {
            DeviceLayout layout = DeviceLayout.Load(layoutPath);

            if (layout != null)
            {
                LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));

                InternalSize = new Size(layout.Width, layout.Height);

                if (layout.Leds != null)
                {
                    foreach (LedLayout layoutLed in layout.Leds)
                    {
                        if (Enum.TryParse(layoutLed.Id, true, out LogitechLedIds ledId))
                        {
                            LogitechLedId id = new LogitechLedId(this, ledId);
                            if (!LedMapping.TryGetValue(id, out Led led))
                            {
                                led = InitializeLed(id, new Rectangle());
                            }

                            led.LedRectangle.Location.X  = layoutLed.X;
                            led.LedRectangle.Location.Y  = layoutLed.Y;
                            led.LedRectangle.Size.Width  = layoutLed.Width;
                            led.LedRectangle.Size.Height = layoutLed.Height;

                            led.Shape     = layoutLed.Shape;
                            led.ShapeData = layoutLed.ShapeData;

                            LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id);
                            led.Image = (!string.IsNullOrEmpty(image?.Image))
                                ? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute)
                                : new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute);
                        }
                    }
                }
            }
        }
示例#9
0
        public void LoadFromXml()
        {
            var model = new LayoutEditModel();

            _windowManager.ShowMessageBox("First, select the base folder of the layout. All other paths will be relative to this folder.");

            // Select a base path
            var folderDialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };

            if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                model.BasePath = folderDialog.FileName;
            }
            else
            {
                return;
            }

            _windowManager.ShowMessageBox("Now select the layout file itself, it should be relative to the base folder.");

            // Select a XML file
            var fileDialog = new CommonOpenFileDialog {
                InitialDirectory = model.BasePath, Filters = { new CommonFileDialogFilter("Layout Files", "*.xml") }
            };

            if (fileDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                model.DeviceLayout       = DeviceLayout.Load(fileDialog.FileName);
                model.DeviceLayoutSource = fileDialog.FileName;
            }
            else
            {
                return;
            }

            _shellViewModel.Start(model);
        }
示例#10
0
        private void InitForm()
        {
            //this.Text = DSF602.Language.LanguageHelper.GetValueOf("");
            this.Icon = Properties.Resources.setting;

            foreach (var block in AppManager.ListBlock)
            {
                var tabPageAdd = new TabPage()
                {
                    Name = string.Format(FOMAT_NAME_TAB_PAGE, block.BlockId.ToString()),
                    Text = block.BlockName,
                };

                var objDevice = new DeviceLayout(block.BlockId)
                {
                    Dock = DockStyle.Fill,
                };

                objDevice.EventSavedBlock += (sender, blockSaved) => tabPageAdd.Text = blockSaved.BlockName;
                tabPageAdd.Controls.Add(objDevice);
                tabMngt.Controls.Add(tabPageAdd);
            }
        }
示例#11
0
        private void LoadLayout()
        {
            DeviceLayout?deviceLayout = DeviceLayout.Load(FilePath, typeof(LayoutCustomDeviceData), typeof(LayoutCustomLedData));

            if (deviceLayout != null)
            {
                RgbLayout = deviceLayout;
                IsValid   = true;
            }
            else
            {
                RgbLayout = new DeviceLayout();
                IsValid   = false;
            }

            if (IsValid)
            {
                Leds.AddRange(RgbLayout.Leds.Select(l => new ArtemisLedLayout(this, l)));
            }

            LayoutCustomDeviceData = (LayoutCustomDeviceData?)RgbLayout.CustomData ?? new LayoutCustomDeviceData();
            ApplyCustomDeviceData();
        }
        public void LoadFromXml()
        {
            var model = new LayoutEditModel();

            // Select a XML file
            VistaOpenFileDialog fileDialog = new();

            fileDialog.Filter = "Layout files (*.xml)|*.xml";
            if (fileDialog.ShowDialog() == false)
            {
                return;
            }

            model.DeviceLayout = DeviceLayout.Load(fileDialog.FileName, typeof(LayoutCustomDeviceData), typeof(LayoutCustomLedData));
            model.FilePath     = fileDialog.FileName;

            if (model.DeviceLayout == null)
            {
                _windowManager.ShowMessageBox("Failed to load layout.", "", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            _shellViewModel.Start(model);
        }
示例#13
0
        // DeviceLayout
        private void ConstructDeviceLayout()
        {
            DeviceLayout deviceLayout = this.SettingViewModel.Setting.DeviceLayout;

            // Type
            {
                DeviceLayoutType type       = deviceLayout.FallBackType;
                bool             isAdaptive = deviceLayout.IsAdaptive;

                this.PhoneButton.IsChecked    = (isAdaptive == false && type == DeviceLayoutType.Phone);
                this.PadButton.IsChecked      = (isAdaptive == false && type == DeviceLayoutType.Pad);
                this.PCButton.IsChecked       = (isAdaptive == false && type == DeviceLayoutType.PC);
                this.AdaptiveButton.IsChecked = (isAdaptive);

                this.PhoneButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.Phone, false);

                this.PadButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.Pad, false);

                this.PCButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.PC, false);

                this.AdaptiveButton.Click += async(s, e) => await this.SetDeviceLayoutType(DeviceLayoutType.PC, true);
            }

            // Adaptive
            {
                int phone = deviceLayout.PhoneMaxWidth;
                int pad   = deviceLayout.PadMaxWidth;

                this.AdaptiveWidthGrid.PhoneWidth = phone;
                this.AdaptiveWidthGrid.PadWidth   = pad;
                this.AdaptiveWidthGrid.SetWidth();


                this.AdaptiveWidthGrid.ScrollModeChanged += (s, mode) =>
                {
                    this.ScrollViewer.HorizontalScrollMode = mode;
                    this.ScrollViewer.VerticalScrollMode   = mode;
                };
                this.AdaptiveWidthGrid.PhoneWidthChanged += async(s, value) =>
                {
                    // Setting
                    DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout;
                    {
                        layout.PhoneMaxWidth = value;
                        DeviceLayoutType type = layout.GetActualType(this.ActualWidth);
                        this.SettingViewModel.DeviceLayoutType = type;
                    }
                    await this.Save();
                };
                this.AdaptiveWidthGrid.PadWidthChanged += async(s, value) =>
                {
                    // Setting
                    DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout;
                    {
                        layout.PadMaxWidth = value;
                        DeviceLayoutType type = layout.GetActualType(this.ActualWidth);
                        this.SettingViewModel.DeviceLayoutType = type;
                    }
                    await this.Save();
                };
            }


            this.ResetAdaptiveWidthButton.Click += async(s, e) =>
            {
                DeviceLayout default2 = DeviceLayout.Default;
                int          phone2   = default2.PhoneMaxWidth;
                int          pad2     = default2.PadMaxWidth;

                this.AdaptiveWidthGrid.PhoneWidth = phone2;
                this.AdaptiveWidthGrid.PadWidth   = pad2;
                this.AdaptiveWidthGrid.SetWidth();

                // Setting
                DeviceLayout layout = this.SettingViewModel.Setting.DeviceLayout;
                {
                    layout.PhoneMaxWidth = phone2;
                    layout.PadMaxWidth   = pad2;
                    DeviceLayoutType type = layout.GetActualType(this.ActualWidth);
                    this.SettingViewModel.DeviceLayoutType = type;
                }
                await this.Save();
            };
        }
示例#14
0
 public DeviceLayoutTreeItemViewModel(DeviceLayout layout)
 {
     _layout     = layout;
     _isExpanded = false;
 }
示例#15
0
        public bool UpdateDevice(Dictionary <DeviceKeys, System.Drawing.Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            if (RyosTalkFX == null || !RyosInitialized)
            {
                return(false);
            }

            if (e.Cancel)
            {
                return(false);
            }

            try
            {
                DeviceLayout layout = DeviceLayout.ISO;
                if (Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.dvorak ||
                    Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.us ||
                    Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.ru)
                {
                    layout = DeviceLayout.ANSI;
                }
                else if (Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.jpn)
                {
                    layout = DeviceLayout.JP;
                }

                foreach (KeyValuePair <DeviceKeys, System.Drawing.Color> key in keyColors)
                {
                    if (e.Cancel)
                    {
                        return(false);
                    }
                    DeviceKeys dev_key = key.Key;
                    //Solution to slightly different mapping rather than giving a whole different dictionary
                    if (layout == DeviceLayout.ANSI)
                    {
                        if (dev_key == DeviceKeys.ENTER)
                        {
                            dev_key = DeviceKeys.BACKSLASH;
                        }
                        if (dev_key == DeviceKeys.HASHTAG)
                        {
                            dev_key = DeviceKeys.ENTER;
                        }
                    }

                    //set peripheral color to Roccat generic peripheral if enabled
                    if (Global.Configuration.VarRegistry.GetVariable <bool>($"{devicename}_enable_generic") == true)
                    {
                        generic_deactivated_first_time = true;
                        if (key.Key == DeviceKeys.Peripheral_Logo)
                        {
                            //Send to generic roccat device if color not equal or 1. time after generic got enabled
                            if (!previous_peripheral_Color.Equals(key.Value) || generic_activated_first_time == true)
                            {
                                send_to_roccat_generic(key.Value);
                                //talkFX.RestoreLedRgb(); //Does not even here work

                                previous_peripheral_Color    = key.Value;
                                generic_activated_first_time = false;
                            }
                        }
                    }
                    else
                    {
                        if (generic_deactivated_first_time == true)
                        {
                            Restoregeneric();
                            generic_deactivated_first_time = false;
                            //Global.logger.LogLine("first time");
                        }
                        generic_activated_first_time = true;
                    }

                    if (DeviceKeysMap.TryGetValue(dev_key, out byte i))
                    {
                        //Global.logger.LogLine("Roccat update device: " + key + " , " + key.Value);
                        Color roccatColor = ConvertToRoccatColor(key.Value);
                        stateStruct[i] = IsLedOn(roccatColor);
                        colorStruct[i] = roccatColor;
                    }
                }

                //send KeyboardState to Ryos only when enabled
                if (Global.Configuration.VarRegistry.GetVariable <bool>($"{devicename}_enable_ryos"))
                {
                    RyosTalkFX.SetMkFxKeyboardState(stateStruct, colorStruct, (byte)layout);
                }

                return(true);
            }
            catch (Exception exc)
            {
                Global.logger.Error("Roccat device, error when updating device. Error: " + exc);
                return(false);
            }
        }
 public bool IsSupported(DeviceLayout layout)
 {
     return(true);
 }
 public IGPIDevice CreateDevice(DeviceLayout layout)
 {
     return(new VulkanGPIDevice());
 }