Exemplo n.º 1
0
        public BindingEditor()
        {
            this.Content = new TableLayout
            {
                Padding = 5,
                Rows    =
                {
                    new TableRow
                    {
                        Cells =
                        {
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Tip Bindings",
                                    Content = new StackView
                                    {
                                        Items =
                                        {
                                            new Group
                                            {
                                                Text          = "Tip Button",
                                                Orientation   = Orientation.Horizontal,
                                                ExpandContent = false,
                                                Content       = tipButton = new BindingDisplay
                                                {
                                                    MinimumSize = new Size(300, 0)
                                                }
                                            },
                                            new Group
                                            {
                                                Text        = "Tip Pressure",
                                                Orientation = Orientation.Horizontal,
                                                Content     = tipPressure = new FloatSlider()
                                            }
                                        }
                                    }
                                }
                            },
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Eraser Bindings",
                                    Content = new StackView
                                    {
                                        Items =
                                        {
                                            new Group
                                            {
                                                Text          = "Eraser Button",
                                                ExpandContent = false,
                                                Orientation   = Orientation.Horizontal,
                                                Content       = eraserButton = new BindingDisplay
                                                {
                                                    MinimumSize = new Size(300, 0)
                                                }
                                            },
                                            new Group
                                            {
                                                Text        = "Eraser Pressure",
                                                Orientation = Orientation.Horizontal,
                                                Content     = eraserPressure = new FloatSlider()
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new TableRow
                    {
                        Cells =
                        {
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Pen Button Bindings",
                                    Content = new Scrollable
                                    {
                                        Border  = BorderType.None,
                                        Content = penButtons = new BindingDisplayList
                                        {
                                            Prefix = "Pen Button"
                                        }
                                    }
                                }
                            },
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Auxiliary Button Bindings",
                                    Content = new Scrollable
                                    {
                                        Border  = BorderType.None,
                                        Content = auxButtons = new BindingDisplayList
                                        {
                                            Prefix = "Auxiliary Button"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            tipButton.StoreBinding.Bind(SettingsBinding.Child(c => c.TipButton));
            eraserButton.StoreBinding.Bind(SettingsBinding.Child(c => c.EraserButton));
            tipPressure.ValueBinding.Bind(SettingsBinding.Child(c => c.TipActivationPressure));
            eraserPressure.ValueBinding.Bind(SettingsBinding.Child(c => c.EraserActivationPressure));
            penButtons.ItemSourceBinding.Bind(SettingsBinding.Child(c => (IList <PluginSettingStore>)c.PenButtons));
            auxButtons.ItemSourceBinding.Bind(SettingsBinding.Child(c => (IList <PluginSettingStore>)c.AuxButtons));
        }
Exemplo n.º 2
0
        public void UpdateBindings()
        {
            content.Items.Clear();

            var tipButton = new BindingDisplay(App.Settings?.TipButton)
            {
                Width = 250
            };

            tipButton.BindingUpdated += (sender, binding) => App.Settings.TipButton = binding;

            var tipPressure = new PressureSlider(
                "Tip Pressure",
                () => App.Settings.TipActivationPressure,
                (v) => App.Settings.TipActivationPressure = v
                );

            var tipSettingsStack = new StackView
            {
                Items =
                {
                    new Group("Tip Button", tipButton, Orientation.Horizontal, false),
                    tipPressure
                }
            };

            var tipSettings = new Group("Tip Bindings", tipSettingsStack);

            var penBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.PenButtons.Count; i++)
            {
                var penBinding = new BindingDisplay(App.Settings?.PenButtons[i])
                {
                    Width = 250,
                    Tag   = i
                };
                penBinding.BindingUpdated += (sender, binding) =>
                {
                    var index = (int)(sender as BindingDisplay).Tag;
                    App.Settings.PenButtons[index] = binding;
                };
                var penBindingGroup = new Group($"Pen Button {i + 1}", penBinding, Orientation.Horizontal, false);
                penBindingsStack.AddControl(penBindingGroup);
            }

            var penBindingSettings = new Group("Pen Button Bindings", penBindingsStack);

            var penSettings = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem(tipSettings,        true),
                    new StackLayoutItem(penBindingSettings, true)
                }
            };

            content.AddControl(penSettings);

            var auxBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.AuxButtons.Count; i++)
            {
                var auxBinding = new BindingDisplay(App.Settings?.AuxButtons[i])
                {
                    Width = 250,
                    Tag   = i
                };
                auxBinding.BindingUpdated += (sender, Binding) =>
                {
                    var index = (int)(sender as BindingDisplay).Tag;
                    App.Settings.AuxButtons[index] = Binding;
                };
                var auxBindingGroup = new Group($"Auxiliary Button {i + 1}", auxBinding, Orientation.Horizontal, false);
                auxBindingsStack.AddControl(auxBindingGroup);
            }

            var auxBindingSettings = new Group("Auxiliary Button Bindings", auxBindingsStack)
            {
                TitleHorizontalAlignment = HorizontalAlignment.Center
            };

            content.AddControl(auxBindingSettings);
        }
        public void UpdateBindings()
        {
            this.DataContext = App.Settings;

            var tipSettingsStack = new StackView
            {
                Items =
                {
                    new Group
                    {
                        Text          = "Tip Button",
                        Orientation   = Orientation.Horizontal,
                        ExpandContent = false,
                        Content       = tipButton = new BindingDisplay
                        {
                            MinimumSize = new Size(300, 0),
                            Store       = App.Settings?.TipButton
                        }
                    },
                    new Group
                    {
                        Text        = "Tip Pressure",
                        Orientation = Orientation.Horizontal,
                        Content     = tipPressure = new FloatSlider()
                    }
                }
            };

            tipButton.StoreBinding.BindDataContext <Settings>(s => s.TipButton);
            tipPressure.ValueBinding.BindDataContext <Settings>(s => s.TipActivationPressure);

            var eraserSettingsStack = new StackView
            {
                Items =
                {
                    new Group
                    {
                        Text          = "Eraser Button",
                        ExpandContent = false,
                        Orientation   = Orientation.Horizontal,
                        Content       = eraserButton = new BindingDisplay
                        {
                            MinimumSize = new Size(300, 0),
                            Store       = App.Settings?.EraserButton
                        }
                    },
                    new Group
                    {
                        Text        = "Eraser Pressure",
                        Orientation = Orientation.Horizontal,
                        Content     = eraserPressure = new FloatSlider()
                    }
                }
            };

            eraserButton.StoreBinding.BindDataContext <Settings>(s => s.EraserButton);
            eraserPressure.ValueBinding.BindDataContext <Settings>(s => s.EraserActivationPressure);

            var penBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.PenButtons.Count; i++)
            {
                BindingDisplay penBinding;

                var penBindingGroup = new Group
                {
                    Text          = $"Pen Button {i + 1}",
                    Orientation   = Orientation.Horizontal,
                    ExpandContent = false,
                    Content       = penBinding = new BindingDisplay
                    {
                        MinimumSize = new Size(300, 0),
                        Tag         = i,
                        Store       = App.Settings?.PenButtons[i]
                    }
                };
                penBinding.StoreChanged += (sender, e) =>
                {
                    var display = sender as BindingDisplay;
                    var index   = (int)display.Tag;
                    App.Settings.PenButtons[index] = display.Store;
                };
                penBindingsStack.AddControl(penBindingGroup);
            }

            var auxBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.AuxButtons.Count; i++)
            {
                BindingDisplay auxBinding;

                var auxBindingGroup = new Group
                {
                    Text          = $"Auxiliary Button {i + 1}",
                    Orientation   = Orientation.Horizontal,
                    ExpandContent = false,
                    Content       = auxBinding = new BindingDisplay
                    {
                        MinimumSize = new Size(300, 0),
                        Tag         = i,
                        Store       = App.Settings?.AuxButtons[i]
                    }
                };
                auxBinding.StoreChanged += (sender, e) =>
                {
                    var display = sender as BindingDisplay;
                    var index   = (int)display.Tag;
                    App.Settings.AuxButtons[index] = display.Store;
                };
                auxBindingsStack.AddControl(auxBindingGroup);
            }

            var firstRow = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Tip Bindings", tipSettingsStack)
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Eraser Bindings", eraserSettingsStack)
                    }
                }
            };

            var secondRow = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Pen Button Bindings", penBindingsStack)
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Auxiliary Button Bindings", auxBindingsStack)
                    }
                }
            };

            this.Content = new StackView
            {
                Orientation = Orientation.Vertical,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem(firstRow,  true),
                    new StackLayoutItem(secondRow, true)
                }
            };
        }
Exemplo n.º 4
0
        public void UpdateBindings()
        {
            content.Items.Clear();

            var tipButton = new BindingDisplay(App.Settings?.TipButton);

            tipButton.BindingUpdated += (sender, binding) => App.Settings.TipButton = binding;

            var tipPressure = new PressureSlider(
                "Tip Pressure",
                () => App.Settings.TipActivationPressure,
                (v) => App.Settings.TipActivationPressure = v
                );

            var tipSettingsStack = new StackView
            {
                Items =
                {
                    tipButton,
                    tipPressure
                }
            };

            var tipSettings = new GroupBoxBase("Tip Bindings", tipSettingsStack);

            content.AddControl(tipSettings, true);

            var penBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.PenButtons.Count; i++)
            {
                var penBinding = new BindingDisplay(App.Settings?.PenButtons[i])
                {
                    Tag = i
                };
                penBinding.BindingUpdated += (sender, binding) =>
                {
                    var index = (int)(sender as BindingDisplay).Tag;
                    App.Settings.PenButtons[index] = binding;
                };
                var penBindingGroup = new GroupBoxBase($"Pen Button {i + 1}", penBinding);
                penBindingsStack.AddControl(penBindingGroup);
            }

            var penBindingSettings = new GroupBoxBase("Pen Button Bindings", penBindingsStack);

            content.AddControl(penBindingSettings, true);

            var auxBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.AuxButtons.Count; i++)
            {
                var auxBinding = new BindingDisplay(App.Settings?.AuxButtons[i])
                {
                    Tag = i
                };
                auxBinding.BindingUpdated += (sender, Binding) =>
                {
                    var index = (int)(sender as BindingDisplay).Tag;
                    App.Settings.AuxButtons[index] = Binding;
                };
                var auxBindingGroup = new GroupBoxBase($"Auxiliary Button {i + 1}", auxBinding);
                auxBindingsStack.AddControl(auxBindingGroup);
            }

            var auxBindingSettings = new GroupBoxBase("Auxiliary Button Bindings", auxBindingsStack);

            content.AddControl(auxBindingSettings, true);
        }
Exemplo n.º 5
0
 public BindingEditor()
 {
     this.Content = new TableLayout
     {
         Padding = 5,
         Rows    =
         {
             new TableRow
             {
                 Cells =
                 {
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Tip Bindings",
                             Content = new StackView
                             {
                                 Items =
                                 {
                                     new Group
                                     {
                                         Text          = "Tip Button",
                                         Orientation   = Orientation.Horizontal,
                                         ExpandContent = false,
                                         Content       = tipButton = new BindingDisplay
                                         {
                                             MinimumSize = new Size(300, 0)
                                         }
                                     },
                                     new Group
                                     {
                                         Text        = "Tip Pressure",
                                         Orientation = Orientation.Horizontal,
                                         Content     = tipPressure = new FloatSlider()
                                     }
                                 }
                             }
                         }
                     },
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Eraser Bindings",
                             Content = new StackView
                             {
                                 Items =
                                 {
                                     new Group
                                     {
                                         Text          = "Eraser Button",
                                         ExpandContent = false,
                                         Orientation   = Orientation.Horizontal,
                                         Content       = eraserButton = new BindingDisplay
                                         {
                                             MinimumSize = new Size(300, 0)
                                         }
                                     },
                                     new Group
                                     {
                                         Text        = "Eraser Pressure",
                                         Orientation = Orientation.Horizontal,
                                         Content     = eraserPressure = new FloatSlider()
                                     }
                                 }
                             }
                         }
                     }
                 }
             },
             new TableRow
             {
                 Cells =
                 {
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Pen Button Bindings",
                             Content = new Scrollable
                             {
                                 Border  = BorderType.None,
                                 Content = penButtons = new BindingDisplayList
                                 {
                                     Prefix = "Pen Button"
                                 }
                             }
                         }
                     },
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Auxiliary Button Bindings",
                             Content = new Scrollable
                             {
                                 Border  = BorderType.None,
                                 Content = auxButtons = new BindingDisplayList
                                 {
                                     Prefix = "Auxiliary Button"
                                 }
                             }
                         }
                     }
                 }
             }
         }
     };
 }