Esempio n. 1
0
        public void StartEntry()
        {
            var textInputLayer = GetWindowTextInputLayer();
            var textBox        = _owner.TextBox;

            if (textBox == null || textInputLayer == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            _contentElement = textBox.ContentElement;

            EnsureWidgetForAcceptsReturn();

            if (textInputLayer.Children.Count == 0)
            {
                textInputLayer.Children.Add(_currentInputWidget !);
            }

            UpdateNativeView();
            SetTextNative(textBox.Text);

            InvalidateLayout();

            _currentInputWidget !.Focus();
        }
Esempio n. 2
0
        public void StartEntry()
        {
            var textInputLayer = GetWindowTextInputLayer();
            var textBox        = _owner.TextBox;

            if (textBox == null || textInputLayer == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            _contentElement = textBox.ContentElement;

            EnsureWidgetForAcceptsReturn();
            textInputLayer.Children.Add(_currentInputWidget !);

            textBox.SizeChanged   += ContentElementSizeChanged;
            textBox.LayoutUpdated += ContentElementLayoutUpdated;

            _textBoxEventSubscriptions.Disposable = Disposable.Create(() =>
            {
                textBox.SizeChanged   -= ContentElementSizeChanged;
                textBox.LayoutUpdated -= ContentElementLayoutUpdated;
            });

            UpdateNativeView();
            SetTextNative(textBox.Text);

            UpdateSize();
            UpdatePosition();

            _currentInputWidget !.Focus();
        }
Esempio n. 3
0
        public void StartEntry()
        {
            var textBox = _owner.TextBox;

            if (textBox == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            _contentElement = textBox.ContentElement;
            EnsureWidget(textBox);
            var textInputLayer = GetWindowTextInputLayer();

            textInputLayer.Put(_currentInputWidget !, 0, 0);

            textBox.SizeChanged   += ContentElementSizeChanged;
            textBox.LayoutUpdated += ContentElementLayoutUpdated;
            _textBoxEventSubscriptions.Disposable = Disposable.Create(() =>
            {
                textBox.SizeChanged   -= ContentElementSizeChanged;
                textBox.LayoutUpdated -= ContentElementLayoutUpdated;
            });

            UpdateNativeView();
            SetWidgetText(textBox.Text);

            UpdateSize();
            UpdatePosition();

            textInputLayer.ShowAll();
            _currentInputWidget !.HasFocus = true;
        }
Esempio n. 4
0
        public static async Task <MessageBoxResult> Show(string text, MessageBoxButtons buttons)
        {
            ContentControl?autoFocusControl = null;
            var            messageBoxResult = MessageBoxResult.Ok;

            var msgbox = new MessageBox();

            msgbox.FindControl <TextBlock>(TitleName).Text = App.GetString("title");
            msgbox.FindControl <TextBlock>(TextName).Text  = text;

            var buttonPanel = msgbox.FindControl <StackPanel>(ButtonsName);

            if (buttons == MessageBoxButtons.Ok || buttons == MessageBoxButtons.OkCancel)
            {
                AddButton("OK", MessageBoxResult.Ok, isDefaultButton: true);
            }

            if (buttons == MessageBoxButtons.YesNo || buttons == MessageBoxButtons.YesNoCancel)
            {
                AddButton("Yes", MessageBoxResult.Yes);
                AddButton("No", MessageBoxResult.No, isDefaultButton: true);
            }

            if (buttons == MessageBoxButtons.OkCancel || buttons == MessageBoxButtons.YesNoCancel)
            {
                AddButton("Cancel", MessageBoxResult.Cancel, isDefaultButton: true);
            }

            await msgbox.ShowDialog(App.MainWindow).ConfigureAwait(false);

            autoFocusControl?.Focus();
            return(messageBoxResult);

            void AddButton(string caption, MessageBoxResult mbr, bool isDefaultButton = false)
            {
                var btn = new Button {
                    Content = caption
                };

                btn.Click += delegate
                {
                    messageBoxResult = mbr;
                    msgbox.Close();
                };

                buttonPanel.Children.Add(btn);

                if (isDefaultButton)
                {
                    messageBoxResult = mbr;
                    autoFocusControl = btn;
                }
            }
        }
Esempio n. 5
0
        public void EndEntry()
        {
            if (GetInputText() is { } inputText)
            {
                _owner.UpdateTextFromNative(inputText);
            }

            _contentElement = null;

            var textInputLayer = GetWindowTextInputLayer();

            textInputLayer?.Children.Remove(_currentInputWidget);
        }
Esempio n. 6
0
        public void EndEntry()
        {
            if (GetInputText() is { } inputText)
            {
                _owner.UpdateTextFromNative(inputText);
            }

            _contentElement = null;
            _textBoxEventSubscriptions.Disposable = null;

            var textInputLayer = GetWindowTextInputLayer();

            textInputLayer.Remove(_currentInputWidget);
        }
Esempio n. 7
0
        public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            _contentControl = GetTemplateChild("FeatureDataField_ContentControl") as ContentControl;
            if (_contentControl != null)
            {
                _contentControl.GotFocus  += ContentControl_GotFocus;
                _contentControl.LostFocus += ContentControl_LostFocus;
            }

            Refresh();
        }
Esempio n. 8
0
        public void EndEntry()
        {
            if (GetInputText() is { } inputText)
            {
                _owner.UpdateTextFromNative(inputText);
            }

            _contentElement = null;

            if (_currentInputWidget != null)
            {
                var bounds = GetNativeSelectionBounds();
                (_selectionStartCache, _selectionLengthCache) = (bounds.start, bounds.end - bounds.start);
                var textInputLayer = GetWindowTextInputLayer();
                textInputLayer.Remove(_currentInputWidget);
            }
        }
Esempio n. 9
0
        public void StartEntry()
        {
            var textBox = _owner.TextBox;

            if (textBox == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            _contentElement = textBox.ContentElement;
            EnsureWidget(textBox);
            var textInputLayer = GetWindowTextInputLayer();

            if (_currentInputWidget !.Parent != textInputLayer)
            {
                textInputLayer.Put(_currentInputWidget !, 0, 0);
            }
            _lastSize     = new GdkSize(-1, -1);
            _lastPosition = new GdkPoint(-1, -1);
            UpdateNativeView();
            SetWidgetText(textBox.Text);

            InvalidateLayout();

            textInputLayer.ShowAll();
            _currentInputWidget !.HasFocus = true;

            // Selection is now handled by native control
            if (_selectionStartCache != null && _selectionLengthCache != null)
            {
                Select(_selectionStartCache.Value, _selectionLengthCache.Value);
            }
            else
            {
                // Select end of the text
                var endIndex = textBox.Text.Length;
                Select(endIndex, 0);
            }
            _selectionStartCache  = null;
            _selectionLengthCache = null;
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the UI elements out of the template.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _border = GetTemplateChild("PART_Border") as Border;
            _topLeftContentControl     = GetTemplateChild("PART_TopLeftContentControl") as ContentControl;
            _topRightContentControl    = GetTemplateChild("PART_TopRightContentControl") as ContentControl;
            _bottomRightContentControl = GetTemplateChild("PART_BottomRightContentControl") as ContentControl;
            _bottomLeftContentControl  = GetTemplateChild("PART_BottomLeftContentControl") as ContentControl;

            if (_topLeftContentControl is not null)
            {
                _topLeftContentControl.SizeChanged += ContentControlSizeChanged;
            }

            _topLeftClip     = GetTemplateChild("PART_TopLeftClip") as RectangleGeometry;
            _topRightClip    = GetTemplateChild("PART_TopRightClip") as RectangleGeometry;
            _bottomRightClip = GetTemplateChild("PART_BottomRightClip") as RectangleGeometry;
            _bottomLeftClip  = GetTemplateChild("PART_BottomLeftClip") as RectangleGeometry;

            UpdateClipContent(ClipContent);

            UpdateCornerRadius(CornerRadius);
        }
Esempio n. 11
0
 internal static void SetContentControl(UIElement element, ContentControl?value)
 {
     element.SetValue(ContentControlProperty, value);
 }
Esempio n. 12
0
 public void PlatformInitialize(Dispatcher uiThreadDispatcher, ContentControl root)
 {
     _uiThreadDispatcher = uiThreadDispatcher;
     _root = root;
 }
Esempio n. 13
0
        public static async Task <MessageBoxResult> Show(string text, MessageBoxButtons buttons, PixelPoint?pixelPoint = null)
        {
            ContentControl?autoFocusControl = null;
            var            messageBoxResult = MessageBoxResult.Ok;

            var msgbox = new MessageBox();

            if (pixelPoint is not null)
            {
                msgbox.WindowStartupLocation = WindowStartupLocation.Manual;
                msgbox.Position = pixelPoint.Value;
            }

            msgbox.FindControl <TextBlock>(TitleName).Text = App.GetString("title");
            msgbox.FindControl <TextBlock>(TextName).Text  = text;

            var buttonPanel = msgbox.FindControl <StackPanel>(ButtonsName);

            // ReSharper disable once ConvertIfStatementToSwitchStatement
            if (buttons is MessageBoxButtons.Ok or MessageBoxButtons.OkCancel)
            {
                AddButton("OK", MessageBoxResult.Ok, isDefaultButton: true);
            }

            if (buttons is MessageBoxButtons.YesNo or MessageBoxButtons.YesNoCancel)
            {
                AddButton("Yes", MessageBoxResult.Yes);
                AddButton("No", MessageBoxResult.No, isDefaultButton: true);
            }

            if (buttons is MessageBoxButtons.OkCancel or MessageBoxButtons.YesNoCancel)
            {
                AddButton("Cancel", MessageBoxResult.Cancel, isDefaultButton: true);
            }

            await msgbox.ShowDialog(App.MainWindow);

            autoFocusControl?.Focus();
            return(messageBoxResult);

            void AddButton(string caption, MessageBoxResult mbr, bool isDefaultButton = false)
            {
                var btn = new Button {
                    Content = caption, MinWidth = 50
                };

                btn.Click += delegate
                {
                    messageBoxResult = mbr;
                    msgbox.Close();
                };

                buttonPanel.Children.Add(btn);

                if (isDefaultButton)
                {
                    messageBoxResult = mbr;
                    autoFocusControl = btn;
                }
            }
        }