Exemplo n.º 1
0
        public ShortcutPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor            = editorParams.EditBoxFactory();
            editor.Updating  += Updating;
            editor.Updated   += Updated;
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.AddChangeLateWatcher(CoalescedPropertyValue(), v => {
                var text    = v.Value.ToString();
                editor.Text = v.IsDefined ? v.Value.Main != Key.Unknown ? text : text.Replace("Unknown", "") : ManyValuesText;
            });
            editor.IsReadOnly = true;
            editor.TextWidget.Tasks.Clear();
            editor.TextWidget.Position = new Vector2(0, editor.MinHeight / 2);
            editor.TextWidget.Padding  = new Thickness(5, 0);
            editor.Gestures.Add(new ClickGesture(() => editor.SetFocus()));
            editor.Gestures.Add(new ClickGesture(1, () => {
                main      = Key.Unknown;
                modifiers = Modifiers.None;
                SetValue(new Shortcut(modifiers, main));
            }));
            editor.AddToNode(EditorContainer);

            PropertyLabel.Tasks.Clear();
            PropertyLabel.Tasks.Add(ManageLabelFocus());
            ContainerWidget.Tasks.Add(ManageFocusTask());

            var value = CoalescedPropertyValue().GetValue();

            main              = value.Value.Main;
            modifiers         = value.Value.Modifiers;
            flatFillPresenter = new WidgetFlatFillPresenter(Theme.Colors.GrayBackground);
            ContainerWidget.CompoundPresenter.Add(flatFillPresenter);
        }