public CommandyContext([NotNull] Commandy commandy, [NotNull] IMode mode, [NotNull] string text)
        {
            Assert.ArgumentNotNull(commandy, nameof(commandy));
            Assert.ArgumentNotNull(mode, nameof(mode));
            Assert.ArgumentNotNull(text, nameof(text));

            Commandy = commandy;
            Mode     = mode;
            Text     = text;
        }
示例#2
0
        public static void Open([NotNull] object parameter, [CanBeNull] IMode initialMode = null, bool allowOtherModes = true)
        {
            Assert.ArgumentNotNull(parameter, nameof(parameter));

            var popup = new Popup();

            var grid = new Grid();

            var thumb = new Thumb
            {
                Width  = 0,
                Height = 0,
            };

            popup.MouseDown += (sender, e) =>
            {
                if (e.ChangedButton == MouseButton.Left)
                {
                    thumb.RaiseEvent(e);
                }
            };

            thumb.DragDelta += (sender, e) =>
            {
                popup.HorizontalOffset += e.HorizontalChange;
                popup.VerticalOffset   += e.VerticalChange;
            };

            thumb.DragCompleted += delegate
            {
                PopupVerticalOffset   = popup.VerticalOffset;
                PopupHorizontalOffset = popup.HorizontalOffset;
            };

            var commandy = new Commandy(popup, parameter, initialMode, allowOtherModes);

            grid.Children.Add(thumb);
            grid.Children.Add(commandy);

            popup.Child              = grid;
            popup.StaysOpen          = false;
            popup.AllowsTransparency = true;

            var verticalOffset   = PopupVerticalOffset != 0 ? PopupVerticalOffset : (SystemParameters.FullPrimaryScreenHeight - 300) / 2;
            var horizontalOffset = PopupHorizontalOffset != 0 ? PopupHorizontalOffset : (SystemParameters.FullPrimaryScreenWidth - 300) / 2;

            popup.VerticalOffset   = verticalOffset;
            popup.HorizontalOffset = horizontalOffset;

            popup.IsOpen = true;

            commandy.CommandTextBox.TextBox.Focus();
        }