Beispiel #1
0
        private static void RemoveDialog(this CrystalWindow window, CrystalDialogBase dialog)
        {
            if (window.crystalActiveDialogContainer is null)
            {
                throw new InvalidOperationException("Active dialog container could not be found.");
            }

            if (window.crystalInactiveDialogContainer is null)
            {
                throw new InvalidOperationException("Inactive dialog container could not be found.");
            }

            if (window.crystalActiveDialogContainer.Children.Contains(dialog))
            {
                window.crystalActiveDialogContainer.Children.Remove(dialog); //remove the dialog from the container

                // if there's an inactive dialog, bring it to the front
                var dlg = window.crystalInactiveDialogContainer.Children.OfType <CrystalDialogBase>().LastOrDefault();
                if (dlg != null)
                {
                    window.crystalInactiveDialogContainer.Children.Remove(dlg);
                    window.crystalActiveDialogContainer.Children.Add(dlg);
                }
            }
            else
            {
                window.crystalInactiveDialogContainer.Children.Remove(dialog);
            }

            window.SetValue(CrystalWindow.IsAnyDialogOpenPropertyKey, BooleanBoxes.Box(window.crystalActiveDialogContainer.Children.Count > 0));
        }
        private static void IsSpellCheckContextMenuEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var tb = d as TextBoxBase;

            if (null == tb)
            {
                throw new InvalidOperationException("The property 'IsSpellCheckContextMenuEnabled' may only be set on TextBoxBase elements.");
            }

            if (e.OldValue != e.NewValue)
            {
                tb.SetCurrentValue(SpellCheck.IsEnabledProperty, BooleanBoxes.Box((bool)e.NewValue));
                if ((bool)e.NewValue)
                {
                    tb.ContextMenuOpening += TextBoxBaseContextMenuOpening;
                    tb.LostFocus          += TextBoxBaseLostFocus;
                    tb.ContextMenuClosing += TextBoxBaseContextMenuClosing;
                }
                else
                {
                    tb.ContextMenuOpening -= TextBoxBaseContextMenuOpening;
                    tb.LostFocus          -= TextBoxBaseLostFocus;
                    tb.ContextMenuClosing -= TextBoxBaseContextMenuClosing;
                }
            }
        }
 private static void ComboBoxLoaded(object sender, RoutedEventArgs e)
 {
     if (sender is ComboBox comboBox)
     {
         comboBox.SetValue(HasTextProperty, BooleanBoxes.Box(!string.IsNullOrWhiteSpace(comboBox.Text) || comboBox.SelectedItem != null));
     }
 }
Beispiel #4
0
        /// <summary>
        /// 结果输出
        /// </summary>
        /// <param name="service"></param>
        /// <param name="properties"></param>
        /// <param name="res"></param>
        private static void ReadOutputProperties(IService service, System.Reflection.PropertyInfo[] properties, DynamicJsonModel res)
        {
            foreach (var property in properties)
            {
                if (ServiceHelper.IsOutput(property))
                {
                    var value = property.GetValue(service, null);

                    //如果是 FlowService.Result ,则使用小写直接把 Result 输出。
                    //这里的判断不能直接使用 property == FlowServiceResultName,这是因为它们是两个不同的运行时对象。
                    if (property.DeclaringType == FlowServiceResultName.DeclaringType && property.Name == FlowServiceResultName.Name)
                    {
                        var result = (Result)value;
                        res.SetProperty(ClientResult.SuccessProperty, BooleanBoxes.Box(result.Success));
                        res.SetProperty(ClientResult.MessageProperty, result.Message);
                        continue;
                    }

                    //进行格式转换。
                    value = ConvertOutputComponent(value);

                    res.SetProperty(property.Name, value);
                }
            }
        }
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------
        #region Private Methods

        private void OnBackForwardStateChange(object sender, EventArgs e)
        {
            Debug.Assert(sender == _journal);

            // Update CanGoBack and CanGoForward on the host navigator, only if actually changed.
            DependencyObject navigator           = (DependencyObject)_host;
            bool             canGoBackFwdChanged = false;
            bool             newState            = _journal.CanGoBack;

            if (newState != (bool)navigator.GetValue(CanGoBackProperty))
            {
                navigator.SetValue(CanGoBackPropertyKey, BooleanBoxes.Box(newState));
                canGoBackFwdChanged = true;
            }
            newState = _journal.CanGoForward;
            if (newState != (bool)navigator.GetValue(CanGoForwardProperty))
            {
                navigator.SetValue(CanGoForwardPropertyKey, BooleanBoxes.Box(newState));
                canGoBackFwdChanged = true;
            }

            if (canGoBackFwdChanged)
            {
                System.Windows.Input.CommandManager.InvalidateRequerySuggested();
            }
        }
Beispiel #6
0
        /// <summary>Provides class handling for an <see cref="E:System.Windows.ContentElement.IsKeyboardFocusWithinChanged" /> event when the keyboard focus changes for a <see cref="T:System.Windows.Controls.TreeView" />.</summary>
        /// <param name="e">The event data.</param>
        // Token: 0x060058EC RID: 22764 RVA: 0x0018988C File Offset: 0x00187A8C
        protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnIsKeyboardFocusWithinChanged(e);
            bool flag = false;
            bool isKeyboardFocusWithin = base.IsKeyboardFocusWithin;

            if (isKeyboardFocusWithin)
            {
                flag = true;
            }
            else
            {
                DependencyObject dependencyObject = Keyboard.FocusedElement as DependencyObject;
                if (dependencyObject != null)
                {
                    UIElement uielement = KeyboardNavigation.GetVisualRoot(this) as UIElement;
                    if (uielement != null && uielement.IsKeyboardFocusWithin && FocusManager.GetFocusScope(dependencyObject) != uielement)
                    {
                        flag = true;
                    }
                }
            }
            if ((bool)base.GetValue(Selector.IsSelectionActiveProperty) != flag)
            {
                base.SetValue(Selector.IsSelectionActivePropertyKey, BooleanBoxes.Box(flag));
            }
            if (isKeyboardFocusWithin && base.IsKeyboardFocused && this._selectedContainer != null && !this._selectedContainer.IsKeyboardFocusWithin)
            {
                this._selectedContainer.Focus();
            }
        }
        // Token: 0x0600513F RID: 20799 RVA: 0x0016C9F0 File Offset: 0x0016ABF0
        private void MakeToggleSelection(ListBoxItem item)
        {
            bool value = !item.IsSelected;

            item.SetCurrentValueInternal(Selector.IsSelectedProperty, BooleanBoxes.Box(value));
            this.UpdateAnchorAndActionItem(base.ItemInfoFromContainer(item));
        }
Beispiel #8
0
        public virtual LibraryTheme GenerateRuntimeLibraryTheme(LibraryThemeProvider libraryThemeProvider, Dictionary <string, string> values, RuntimeThemeColorValues runtimeThemeColorValues, string themeTemplateContent, string themeName, string themeDisplayName, ThemeGenerator.ThemeGeneratorBaseColorScheme baseColorScheme, ThemeGenerator.ThemeGeneratorColorScheme colorScheme, ThemeGenerator.ThemeGeneratorParameters generatorParameters)
        {
            values.Add("ThemeGenerator.Colors.PrimaryAccentColor", runtimeThemeColorValues.PrimaryAccentColor.ToString());
            values.Add("ThemeGenerator.Colors.AccentBaseColor", runtimeThemeColorValues.AccentBaseColor.ToString());
            values.Add("ThemeGenerator.Colors.AccentColor80", runtimeThemeColorValues.AccentColor80.ToString());
            values.Add("ThemeGenerator.Colors.AccentColor60", runtimeThemeColorValues.AccentColor60.ToString());
            values.Add("ThemeGenerator.Colors.AccentColor40", runtimeThemeColorValues.AccentColor40.ToString());
            values.Add("ThemeGenerator.Colors.AccentColor20", runtimeThemeColorValues.AccentColor20.ToString());

            values.Add("ThemeGenerator.Colors.HighlightColor", runtimeThemeColorValues.HighlightColor.ToString());
            values.Add("ThemeGenerator.Colors.IdealForegroundColor", runtimeThemeColorValues.IdealForegroundColor.ToString());

            libraryThemeProvider.FillColorSchemeValues(values, runtimeThemeColorValues);

            var xamlContent = ThemeGenerator.Current.GenerateColorSchemeFileContent(themeTemplateContent, themeName, themeDisplayName, baseColorScheme.Name, colorScheme.Name, colorScheme.Name, runtimeThemeColorValues.Options.IsHighContrast, colorScheme.Values, baseColorScheme.Values, generatorParameters.DefaultValues);

            var preparedXamlContent = libraryThemeProvider.PrepareXamlContent(this, xamlContent, runtimeThemeColorValues);

            var resourceDictionary = (ResourceDictionary)XamlReader.Parse(preparedXamlContent);

            resourceDictionary.Add(Theme.ThemeIsRuntimeGeneratedKey, BooleanBoxes.TrueBox);
            resourceDictionary[Theme.ThemeIsHighContrastKey]            = BooleanBoxes.Box(runtimeThemeColorValues.Options.IsHighContrast);
            resourceDictionary[LibraryTheme.RuntimeThemeColorValuesKey] = runtimeThemeColorValues;

            libraryThemeProvider.PrepareRuntimeThemeResourceDictionary(this, resourceDictionary, runtimeThemeColorValues);

            var runtimeLibraryTheme = libraryThemeProvider.CreateRuntimeLibraryTheme(resourceDictionary, runtimeThemeColorValues);

            return(runtimeLibraryTheme);
        }
Beispiel #9
0
 /// <summary>
 ///     Sets the value of the IsEnabled property.
 /// </summary>
 /// <param name="element">The object on which to set the value.</param>
 /// <param name="value">The desired value of the property.</param>
 public static void SetIsEnabled(DependencyObject element, bool value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(IsEnabledProperty, BooleanBoxes.Box(value));
 }
 /// <summary> Sets the value of the <see cref="P:System.Windows.Controls.ContextMenuService.ShowOnDisabled" /> property of the specified object. </summary>
 /// <param name="element">Object to set value on.</param>
 /// <param name="value">Value to set.</param>
 // Token: 0x0600446C RID: 17516 RVA: 0x001374D3 File Offset: 0x001356D3
 public static void SetShowOnDisabled(DependencyObject element, bool value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(ContextMenuService.ShowOnDisabledProperty, BooleanBoxes.Box(value));
 }
Beispiel #11
0
 /// <summary>
 ///     *** WARNING ***: This runs on the composition thread!
 ///
 ///     What the composition thread calls when it wants to update D3DImage about
 ///     front buffer state. It may be called multiple times with the same value.
 ///     Since we're on a different thread we can't touch this, so queue a dispatcher
 ///     operation.
 /// </summary>
 // NOTE: Called from the render thread!We must execute the reaction on the UI thread.
 private void Callback(bool isFrontBufferAvailable, uint version)
 {
     Dispatcher.BeginInvoke(
         DispatcherPriority.Normal,
         new DispatcherOperationCallback(SetIsFrontBufferAvailable),
         new Pair(BooleanBoxes.Box(isFrontBufferAvailable), version)
         );
 }
Beispiel #12
0
        private void MakeToggleSelection(ListBoxItem item)
        {
            bool select = !item.IsSelected;

            item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.Box(select));

            UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
        }
 // Token: 0x060058A7 RID: 22695 RVA: 0x001888C1 File Offset: 0x00186AC1
 private static void SetIsOpen(DependencyObject element, bool value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(ToolTipService.IsOpenPropertyKey, BooleanBoxes.Box(value));
 }
 /// <summary>Sets the value of the <see cref="P:System.Windows.Controls.ToolTipService.HasDropShadow" /> attached property for an object.</summary>
 /// <param name="element">The object to which the attached property is written.</param>
 /// <param name="value">The value to set.</param>
 // Token: 0x0600589D RID: 22685 RVA: 0x00188781 File Offset: 0x00186981
 public static void SetHasDropShadow(DependencyObject element, bool value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(ToolTipService.HasDropShadowProperty, BooleanBoxes.Box(value));
 }
Beispiel #15
0
        private void UpdateHasCustomText()
        {
            string selectedItemsText = GetSelectedItemsText();

            bool hasCustomText = !((string.IsNullOrEmpty(selectedItemsText) && string.IsNullOrEmpty(Text)) || string.Equals(Text, selectedItemsText, StringComparison.Ordinal));

            SetCurrentValue(HasCustomTextProperty, BooleanBoxes.Box(hasCustomText));
        }
Beispiel #16
0
        /// <summary>Helper for setting <see cref="SelectAllOnClickProperty"/> on <paramref name="element"/>.</summary>
        /// <param name="element"><see cref="UIElement"/> to set <see cref="SelectAllOnClickProperty"/> on.</param>
        /// <param name="value">SelectAllOnClick property value.</param>
        public static void SetSelectAllOnClick(this UIElement element, bool value)
        {
            if (element is null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            element.SetValue(SelectAllOnClickProperty, BooleanBoxes.Box(value));
        }
Beispiel #17
0
        /// <summary>Helper for setting <see cref="MoveFocusOnEnterProperty"/> on <paramref name="element"/>.</summary>
        /// <param name="element"><see cref="UIElement"/> to set <see cref="MoveFocusOnEnterProperty"/> on.</param>
        /// <param name="value">MoveFocusOnEnter property value.</param>
        public static void SetMoveFocusOnEnter(this UIElement element, bool value)
        {
            if (element is null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            element.SetValue(MoveFocusOnEnterProperty, BooleanBoxes.Box(value));
        }
Beispiel #18
0
 // Token: 0x06005C0D RID: 23565 RVA: 0x0019E107 File Offset: 0x0019C307
 private void SetIsPressed(bool pressed)
 {
     if (pressed)
     {
         base.SetValue(ButtonBase.IsPressedPropertyKey, BooleanBoxes.Box(pressed));
         return;
     }
     base.ClearValue(ButtonBase.IsPressedPropertyKey);
 }
Beispiel #19
0
        public static void SetIsHitTestVisibleInChrome(IInputElement inputElement, bool hitTestVisible)
        {
            if (inputElement is not DependencyObject dependencyObject)
            {
                throw new ArgumentException("The element must be a DependencyObject", nameof(inputElement));
            }

            dependencyObject.SetValue(IsHitTestVisibleInChromeProperty, BooleanBoxes.Box(hitTestVisible));
        }
 private static void SetTextLength <TDependencyObject>(TDependencyObject sender, Func <TDependencyObject, int> funcTextLength)
     where TDependencyObject : DependencyObject
 {
     if (sender != null)
     {
         var value = funcTextLength(sender);
         sender.SetValue(TextLengthProperty, value);
         sender.SetValue(HasTextProperty, BooleanBoxes.Box(value >= 1));
     }
 }
 private void SetIsPressed(bool pressed)
 {
     if (pressed)
     {
         this.SetValue(ButtonBase.IsPressedPropertyKey, BooleanBoxes.Box(pressed));
     }
     else
     {
         this.ClearValue(ButtonBase.IsPressedPropertyKey);
     }
 }
Beispiel #22
0
 private void SetIsPressed(bool pressed)
 {
     if (pressed)
     {
         SetValue(IsPressedPropertyKey, BooleanBoxes.Box(pressed));
     }
     else
     {
         ClearValue(IsPressedPropertyKey);
     }
 }
Beispiel #23
0
        private static object?CoerceIsOpen(DependencyObject d, object?baseValue)
        {
            var backstage = (Backstage)d;

            if (backstage.CanChangeIsOpen == false)
            {
                return(BooleanBoxes.Box(backstage.IsOpen));
            }

            return(baseValue);
        }
Beispiel #24
0
        private static void DataGridOnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var dataGrid = (DataGrid)sender;

            var inputHitTest = dataGrid.InputHitTest(e.GetPosition((DataGrid)sender)) as DependencyObject;

            while (inputHitTest != null)
            {
                var dataGridCell = inputHitTest as DataGridCell;
                if (dataGridCell != null && dataGrid.Equals(dataGridCell.TryFindParent <DataGrid>()))
                {
                    if (dataGridCell.IsReadOnly)
                    {
                        return;
                    }

                    ToggleButton toggleButton;
                    ComboBox     comboBox;
                    if (IsDirectHitOnEditComponent(dataGridCell, e, out toggleButton))
                    {
                        dataGrid.CurrentCell = new DataGridCellInfo(dataGridCell);
                        dataGrid.BeginEdit();
                        toggleButton.SetCurrentValue(ToggleButton.IsCheckedProperty, BooleanBoxes.Box(!toggleButton.IsChecked.GetValueOrDefault()));
                        dataGrid.CommitEdit();
                        e.Handled = true;
                    }
                    else if (IsDirectHitOnEditComponent(dataGridCell, e, out comboBox))
                    {
                        if (_suppressComboAutoDropDown != null)
                        {
                            return;
                        }

                        dataGrid.CurrentCell = new DataGridCellInfo(dataGridCell);
                        dataGrid.BeginEdit();
                        //check again, as we move to  the edit  template
                        if (IsDirectHitOnEditComponent(dataGridCell, e, out comboBox))
                        {
                            _suppressComboAutoDropDown = dataGrid;
                            comboBox.DropDownClosed   += ComboBoxOnDropDownClosed;
                            comboBox.IsDropDownOpen    = true;
                        }

                        e.Handled = true;
                    }

                    return;
                }

                inputHitTest = (inputHitTest is Visual || inputHitTest is Visual3D)
                    ? VisualTreeHelper.GetParent(inputHitTest)
                    : null;
            }
        }
Beispiel #25
0
        private void EnableDisableElement()
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            var command = this.Command;

            this.AssociatedObject.SetCurrentValue(UIElement.IsEnabledProperty, BooleanBoxes.Box(command == null || command.CanExecute(this.GetCommandParameter())));
        }
Beispiel #26
0
        /// <summary>
        /// Coerces Focusable
        /// </summary>
        private static object?CoerceFocusable(DependencyObject d, object?basevalue)
        {
            var control = d as RibbonTabItem;
            var ribbon  = control?.FindParentRibbon();

            if (ribbon is not null &&
                basevalue is bool boolValue)
            {
                return(BooleanBoxes.Box(boolValue && ribbon.Focusable));
            }

            return(basevalue);
        }
Beispiel #27
0
        /// <summary>This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.</summary>
        // Token: 0x0600278E RID: 10126 RVA: 0x000BA460 File Offset: 0x000B8660
        void IToggleProvider.Toggle()
        {
            if (!base.IsEnabled())
            {
                throw new ElementNotEnabledException();
            }
            MenuItem menuItem = (MenuItem)base.Owner;

            if (!menuItem.IsCheckable)
            {
                throw new InvalidOperationException(SR.Get("UIA_OperationCannotBePerformed"));
            }
            menuItem.SetCurrentValueInternal(MenuItem.IsCheckedProperty, BooleanBoxes.Box(!menuItem.IsChecked));
        }
        private object QueryEnabled(object command)
        {
            if (Application.Current.MainWindow == null)
            {
                return(false);
            }
            IInputElement inputElement = FocusManager.GetFocusedElement(Application.Current.MainWindow);

            if (inputElement == null)
            {
                inputElement = Application.Current.MainWindow;
            }
            return(BooleanBoxes.Box(((CommandWithArgument)command).QueryEnabled(inputElement, null)));
        }
Beispiel #29
0
        private object QueryEnabled(object command)
        {
            if (Application.Current.MainWindow == null)
            {
                return(false);
            }
            IInputElement target = FocusManager.GetFocusedElement(Application.Current.MainWindow);

            if (target == null)
            {
                // This will always succeed because Window is IInputElement
                target = (IInputElement)Application.Current.MainWindow;
            }
            return(BooleanBoxes.Box(((CommandWithArgument)command).QueryEnabled(target, null)));
        }
Beispiel #30
0
        private static object?CoerceIsDropDownOpen(DependencyObject d, object?basevalue)
        {
            var tabControl = d as RibbonTabControl;

            if (tabControl is null)
            {
                return(basevalue);
            }

            if (!tabControl.IsMinimized)
            {
                return(BooleanBoxes.Box(false));
            }

            return(basevalue);
        }