コード例 #1
0
        public FloatSlider()
        {
            var slider = new Slider
            {
                MinValue = Minimum,
                MaxValue = Maximum
            };

            var nb = new FloatNumberBox();

            slider.Bind(
                s => s.Value,
                nb.ValueBinding
                );

            nb.ValueBinding.Bind(this.ValueBinding);

            this.Content = new StackView
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Center,
                Items =
                {
                    new StackLayoutItem(slider, true),
                    new StackLayoutItem(nb,     false)
                }
            };
        }
コード例 #2
0
        public DigitizerSpecificationsEditor()
        {
            this.Content = new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Spacing = 5,
                Padding = 5,
                Items   =
                {
                    new StackLayoutItem
                    {
                        Control = enable = new CheckBox
                        {
                            Text = "Enable"
                        }
                    },
                    new Group
                    {
                        Text        = "Width (mm)",
                        Orientation = Orientation.Horizontal,
                        Content     = width = new FloatNumberBox()
                    },
                    new Group
                    {
                        Text        = "Height (mm)",
                        Orientation = Orientation.Horizontal,
                        Content     = height = new FloatNumberBox()
                    },
                    new Group
                    {
                        Text        = "Horizontal Resolution",
                        Orientation = Orientation.Horizontal,
                        Content     = maxX = new FloatNumberBox()
                    },
                    new Group
                    {
                        Text        = "Vertical Resolution",
                        Orientation = Orientation.Horizontal,
                        Content     = maxY = new FloatNumberBox()
                    }
                }
            };

            enable.CheckedBinding.Cast <bool>().Bind(
                DigitizerSpecificationsBinding.Convert(
                    c => c != null,
                    v => v ? new DigitizerSpecifications() : null
                    )
                );
            enable.CheckedBinding.Bind(width, c => c.Enabled);
            enable.CheckedBinding.Bind(height, c => c.Enabled);
            enable.CheckedBinding.Bind(maxX, c => c.Enabled);
            enable.CheckedBinding.Bind(maxY, c => c.Enabled);

            width.ValueBinding.Bind(DigitizerSpecificationsBinding.Child <float>(c => c.Width));
            height.ValueBinding.Bind(DigitizerSpecificationsBinding.Child <float>(c => c.Height));
            maxX.ValueBinding.Bind(DigitizerSpecificationsBinding.Child <float>(c => c.MaxX));
            maxY.ValueBinding.Bind(DigitizerSpecificationsBinding.Child <float>(c => c.MaxY));
        }
コード例 #3
0
        public RelativeModeEditor()
        {
            this.Content = new Group
            {
                Text    = "Relative",
                Content = new StackLayout
                {
                    Orientation = Orientation.Horizontal,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    VerticalContentAlignment   = VerticalAlignment.Top,
                    Spacing = 5,
                    Items   =
                    {
                        new StackLayoutItem(null, true),
                        new UnitGroup
                        {
                            Text        = "X Sensitivity",
                            Orientation = Orientation.Horizontal,
                            Unit        = "px/mm",
                            Content     = xSens = new FloatNumberBox()
                        },
                        new UnitGroup
                        {
                            Text        = "Y Sensitivity",
                            Orientation = Orientation.Horizontal,
                            Unit        = "px/mm",
                            Content     = ySens = new FloatNumberBox()
                        },
                        new UnitGroup
                        {
                            Text        = "Rotation",
                            Orientation = Orientation.Horizontal,
                            Unit        = "°",
                            Content     = rotation = new FloatNumberBox()
                        },
                        new UnitGroup
                        {
                            Text        = "Reset Time",
                            Orientation = Orientation.Horizontal,
                            Unit        = "ms",
                            Content     = resetTime = new FloatNumberBox()
                        },
                        new StackLayoutItem(null, true)
                    }
                }
            };

            xSens.ValueBinding.Bind(SettingsBinding.Child(s => s.XSensitivity));
            ySens.ValueBinding.Bind(SettingsBinding.Child(s => s.YSensitivity));
            rotation.ValueBinding.Bind(SettingsBinding.Child(s => s.RelativeRotation));
            resetTime.ValueBinding.Convert <TimeSpan>(
                c => TimeSpan.FromMilliseconds(c),
                v => (float)v.TotalMilliseconds
                ).Bind(SettingsBinding.Child(s => s.ResetTime));
        }
コード例 #4
0
        public RotationAreaEditor()
            : base()
        {
            settingsPanel.Items.Add(
                new StackLayoutItem
            {
                Control = new UnitGroup
                {
                    Text        = "Rotation",
                    Unit        = "°",
                    ToolTip     = "Angle of rotation about the center of the area.",
                    Orientation = Orientation.Horizontal,
                    Content     = rotation = new FloatNumberBox()
                }
            }
                );

            var rotationBinding = AreaBinding.Child(c => c.Rotation);

            rotation.ValueBinding.Bind(rotationBinding);
        }
コード例 #5
0
        protected override async void OnLoadComplete(EventArgs e)
        {
            base.OnLoadComplete(e);

            topGroup = new Group
            {
                Content = top = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };
            leftGroup = new Group
            {
                Content = left = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };
            bottomGroup = new Group
            {
                Content = bottom = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };
            rightGroup = new Group
            {
                Content = right = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };

            this.Content = new StackLayout
            {
                Orientation = Orientation.Vertical,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Padding = 5,
                Spacing = 5,
                Items   =
                {
                    new Group
                    {
                        Text        = "Converter",
                        Content     = converterList,
                        Orientation = Orientation.Horizontal
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            Spacing     = 5,
                            Items       =
                            {
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new StackLayout
                                    {
                                        HorizontalContentAlignment = HorizontalAlignment.Stretch,
                                        Spacing = 5,
                                        Items   =
                                        {
                                            topGroup,
                                            leftGroup
                                        }
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new StackLayout
                                    {
                                        HorizontalContentAlignment = HorizontalAlignment.Stretch,
                                        Spacing = 5,
                                        Items   =
                                        {
                                            bottomGroup,
                                            rightGroup
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new StackLayoutItem
                    {
                        HorizontalAlignment = HorizontalAlignment.Right,
                        Control             = applyButton = new Button((sender, e) => ConvertArea())
                        {
                            Text    = "Apply",
                            Enabled = false
                        }
                    }
                }
            };

            var tablet = await App.Driver.Instance.GetTablet();

            SelectConverterForTablet(tablet);
        }
コード例 #6
0
        public AreaConverterDialog()
            : base(Application.Instance.MainForm)
        {
            base.Title = "Convert Area...";

            topGroup = new Group
            {
                Content = top = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };
            leftGroup = new Group
            {
                Content = left = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };
            bottomGroup = new Group
            {
                Content = bottom = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };
            rightGroup = new Group
            {
                Content = right = new FloatNumberBox()
                {
                    PlaceholderText = "0"
                }
            };

            this.Content = new StackLayout
            {
                Orientation = Orientation.Vertical,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Padding = 5,
                Spacing = 5,
                Items   =
                {
                    new Group
                    {
                        Text        = "Converter",
                        Content     = converterList,
                        Orientation = Orientation.Horizontal
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            Spacing     = 5,
                            Items       =
                            {
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new StackLayout
                                    {
                                        HorizontalContentAlignment = HorizontalAlignment.Stretch,
                                        Spacing = 5,
                                        Items   =
                                        {
                                            topGroup,
                                            leftGroup
                                        }
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Expand  = true,
                                    Control = new StackLayout
                                    {
                                        HorizontalContentAlignment = HorizontalAlignment.Stretch,
                                        Spacing = 5,
                                        Items   =
                                        {
                                            bottomGroup,
                                            rightGroup
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new StackLayoutItem
                    {
                        HorizontalAlignment = HorizontalAlignment.Right,
                        Control             = applyButton = new Button((sender, e) => ConvertArea())
                        {
                            Text    = "Apply",
                            Enabled = false
                        }
                    }
                }
            };

            converterList.SelectedIndexChanged += (sender, e) => OnSelectionChanged();

            Application.Instance.AsyncInvoke(async() =>
            {
                var tablets       = await App.Driver.Instance.GetTablets();
                var targetProfile = App.Current.Settings.Profiles.FirstOrDefault(p => p.AbsoluteModeSettings.Tablet == this.DataContext);
                var tablet        = tablets.FirstOrDefault(t => t.Properties.Name == targetProfile.Tablet);
                Select(tablet);
            });
        }
コード例 #7
0
ファイル: AreaEditor.cs プロジェクト: adryzz/OpenTabletDriver
        public AreaEditor()
        {
            this.Content = new StackLayout
            {
                Spacing = 5,
                Items   =
                {
                    new StackLayoutItem
                    {
                        Expand = true,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        Control             = new Panel
                        {
                            Padding = new Padding(5),
                            Content = display = new AreaDisplay()
                        }
                    },
                    new StackLayoutItem
                    {
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Control             = settingsPanel = new StackLayout
                        {
                            Orientation = Orientation.Horizontal,
                            Spacing     = 5,
                            Items       =
                            {
                                new StackLayoutItem
                                {
                                    Control = widthGroup = new UnitGroup
                                    {
                                        Text        = "Width",
                                        Unit        = Unit,
                                        ToolTip     = $"Area width in {Unit}",
                                        Orientation = Orientation.Horizontal,
                                        Content     = width = new FloatNumberBox()
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Control = heightGroup = new UnitGroup
                                    {
                                        Text        = "Height",
                                        Unit        = Unit,
                                        ToolTip     = $"Area height in {Unit}",
                                        Orientation = Orientation.Horizontal,
                                        Content     = height = new FloatNumberBox()
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Control = xGroup = new UnitGroup
                                    {
                                        Text        = "X",
                                        Unit        = Unit,
                                        ToolTip     = $"Area center X offset in {Unit}",
                                        Orientation = Orientation.Horizontal,
                                        Content     = x = new FloatNumberBox()
                                    }
                                },
                                new StackLayoutItem
                                {
                                    Control = yGroup = new UnitGroup
                                    {
                                        Text        = "Y",
                                        Unit        = Unit,
                                        ToolTip     = $"Area center Y offset in {Unit}",
                                        Orientation = Orientation.Horizontal,
                                        Content     = y = new FloatNumberBox()
                                    }
                                }
                            }
                        }
                    }
                }
            };

            CreateMenu();

            widthGroup.UnitBinding.Bind(UnitBinding);
            heightGroup.UnitBinding.Bind(UnitBinding);
            xGroup.UnitBinding.Bind(UnitBinding);
            yGroup.UnitBinding.Bind(UnitBinding);

            var widthBinding  = AreaBinding.Child((AreaSettings s) => s.Width);
            var heightBinding = AreaBinding.Child((AreaSettings s) => s.Height);
            var xBinding      = AreaBinding.Child((AreaSettings s) => s.X);
            var yBinding      = AreaBinding.Child((AreaSettings s) => s.Y);

            width.ValueBinding.Bind(widthBinding);
            height.ValueBinding.Bind(heightBinding);
            x.ValueBinding.Bind(xBinding);
            y.ValueBinding.Bind(yBinding);

            display.AreaBinding.Bind(AreaBinding);
            display.LockToUsableAreaBinding.Bind(LockToUsableAreaBinding);
            display.UnitBinding.Bind(UnitBinding);
            display.AreaBoundsBinding.Bind(AreaBoundsBinding);
            display.FullAreaBoundsBinding.Bind(FullAreaBoundsBinding);
            display.InvalidForegroundErrorBinding.Bind(InvalidForegroundErrorBinding);
            display.InvalidBackgroundErrorBinding.Bind(InvalidBackgroundErrorBinding);
        }