Ejemplo n.º 1
0
        public static void RefreshContextMenu(this IDataUi dataUi, ContextMenu contextMenu)
        {
            RoutedEventHandler makeDefaultHandler = (sender, e) =>
            {
                dataUi.InstanceMember.IsDefault = true;
                dataUi.Refresh();

                // the instance member may have undone the IsDefault, so let's only do this if it's still set to default:
                if (dataUi is ISetDefaultable && dataUi.InstanceMember.IsDefault)
                {
                    ((ISetDefaultable)dataUi).SetToDefault();
                }
            };



            contextMenu.Items.Clear();

            AddContextMenuItem("Make Default", makeDefaultHandler, contextMenu);
            if (dataUi.InstanceMember != null)
            {
                foreach (var kvp in dataUi.InstanceMember.ContextMenuEvents)
                {
                    AddContextMenuItem(kvp.Key, kvp.Value, contextMenu).Tag = dataUi.InstanceMember;
                }
            }
        }
Ejemplo n.º 2
0
        public static void RefreshContextMenu(this IDataUi dataUi, ContextMenu contextMenu)
        {
            RoutedEventHandler makeDefaultHandler = (sender, e) =>
            {
                dataUi.InstanceMember.IsDefault = true;
                dataUi.Refresh();
                if (dataUi is ISetDefaultable)
                {
                    ((ISetDefaultable)dataUi).SetToDefault();
                }
            };



            contextMenu.Items.Clear();

            AddContextMenuItem("Make Default", makeDefaultHandler, contextMenu);
            if (dataUi.InstanceMember != null)
            {
                foreach (var kvp in dataUi.InstanceMember.ContextMenuEvents)
                {
                    AddContextMenuItem(kvp.Key, kvp.Value, contextMenu).Tag = dataUi.InstanceMember;
                }
            }
        }
Ejemplo n.º 3
0
        private void HandlePreviewKeydown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter && (HandlesEnter))
            {
                e.Handled = true;

                ClampTextBoxValuesToMinMax();

                var result = TryApplyToInstance();

                TextAtStartOfEditing = mAssociatedTextBox.Text;

                if (result == ApplyValueResult.Success)
                {
                    mContainer.Refresh(forceRefreshEvenIfFocused: true);
                }
            }
            else if (e.Key == Key.Escape)
            {
                HasUserChangedAnything  = false;
                mAssociatedTextBox.Text = TextAtStartOfEditing;
            }
        }