Example #1
0
 /// <summary>
 /// Sets the value of the attached <see cref="FontSizeProperty"/> on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value to set.</param>
 /// <returns>The font family.</returns>
 public static void SetFontSize(Control control, double value)
 {
     control.SetValue(FontSizeProperty, value);
 }
Example #2
0
 /// <summary>
 /// Sets the value of the IsTemplateFocusTargetProperty attached property on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value.</param>
 /// <remarks>
 /// When a control is navigated to using the keyboard, a focus adorner is shown - usually
 /// around the control itself. However if the TemplatedControl.IsTemplateFocusTarget
 /// attached property is set to true on an element in the control template, then the focus
 /// adorner will be shown around that control instead.
 /// </remarks>
 public static void SetIsTemplateFocusTarget(Control control, bool value)
 {
     control.SetValue(IsTemplateFocusTargetProperty, value);
 }
Example #3
0
 public static void SetIsControlSizeBound(Control element, bool Value)
 {
     element.SetValue(IsControlSizeBoundProperty, Value);
 }
 public static void SetCommand(Control target, ICommand value)
 {
     target.SetValue(CommandProperty, value);
 }
 public static void SetEventType(Control target, EventType value)
 {
     target.SetValue(EventTypeProperty, value);
 }
Example #6
0
 /// <summary>
 /// Sets the value of the ToolTip.Tip attached property.
 /// </summary>
 /// <param name="element">The control to get the property from.</param>
 /// <param name="value">The content to be displayed in the control's tooltip.</param>
 public static void SetTip(Control element, object value)
 {
     element.SetValue(TipProperty, value);
 }
Example #7
0
 public static void SetDataContext(Control control, object value)
 {
     control.SetValue(DataContextProperty, value);
 }
 /// <summary>
 /// Sets the show delay.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">The value.</param>
 public static void SetShowDelay(Control element, int value)
 {
     element.SetValue(ShowDelayProperty, value);
 }
 /// <summary>
 /// Sets the tip.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">The value.</param>
 public static void SetTip(Control element, object value)
 {
     element.SetValue(TipProperty, value);
 }
 /// <summary>
 /// Sets the placement.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">The value.</param>
 public static void SetPlacement(Control element, PlacementMode value)
 {
     element.SetValue(PlacementProperty, value);
 }
 /// <summary>
 /// Sets the react to parent.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetReactToParent(Control element, bool value)
 {
     element.SetValue(ReactToParentProperty, value);
 }
 /// <summary>
 /// Sets the is open.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetIsOpen(Control element, bool value)
 {
     element.SetValue(IsOpenProperty, value);
 }
Example #13
0
 private static void SetFocusedElement(Control control, FrameworkElement value)
 {
     control.SetValue(FocusedElementProperty, value);
 }
Example #14
0
 public static void SetIsSystemFocusVisual(Control control, bool value)
 {
     control.SetValue(IsSystemFocusVisualProperty, value);
 }
Example #15
0
 /// <summary>
 /// Sets the value of the attached <see cref="FontWeightProperty"/> on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value to set.</param>
 /// <returns>The font family.</returns>
 public static void SetFontWeight(Control control, FontWeight value)
 {
     control.SetValue(FontWeightProperty, value);
 }
 /// <summary>
 /// Sets the vertical offset.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="value">The value.</param>
 public static void SetVerticalOffset(Control element, double value)
 {
     element.SetValue(VerticalOffsetProperty, value);
 }
Example #17
0
 /// <summary>
 /// Sets the value of the attached <see cref="NameScopeProperty"/> on a visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <param name="value">The value to set.</param>
 public static void SetNameScope(Control visual, INameScope value)
 {
     visual.SetValue(NameScopeProperty, value);
 }
Example #18
0
 // Standard Get and Set methods for an AttachedProperty
 public static void SetAskUserRequest(Control element, IResponsive <string, bool> value)
 {
     element.SetValue(AskUserRequestProperty, value);
 }
Example #19
0
 public static void SetHeight(Control control, double value)
 {
     control.SetValue(HeightProperty, value);
 }
Example #20
0
 public static void SetIsEnabled(Control o, bool value)
 {
     o.SetValue(IsEnabledProperty, value);
 }
Example #21
0
 public static void SetUsingTextContextMenu(Control textControl, bool value)
 {
     textControl.SetValue(UsingTextContextMenuProperty, value);
 }
Example #22
0
 public static void SetFocus(Control attached, ShortcutName value)
 {
     attached.SetValue(FocusProperty, value);
 }
 public static void SetCommandParameter(Control target, object value)
 {
     target.SetValue(CommandParameterProperty, value);
 }
Example #24
0
        public void TestAttachedPropertiesValidate()
        {
            var control = new Control();

            Assert.Throws <ArgumentException>(() => control.SetValue(_refTypeAttachedProperty, "bar"));
        }
Example #25
0
 public static void SetFocusOnFirstElement(Control control, bool value)
 {
     control.SetValue(FocusOnFirstElementProperty, value);
 }
Example #26
0
        public void TestAttachedPropertiesInvalidNull()
        {
            var control = new Control();

            Assert.Throws <ArgumentNullException>(() => control.SetValue(_valueTypeAttachedProperty, null));
        }
 public static void SetFocusFirst(Control control, bool value) => control.SetValue(FocusFirstProperty, value);
Example #28
0
        public void TestAttachedPropertiesValidNull()
        {
            var control = new Control();

            control.SetValue(_nullableAttachedProperty, null);
        }
Example #29
0
 /// <summary>
 /// Sets the value of the attached <see cref="FontFamilyProperty"/> on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value to set.</param>
 /// <returns>The font family.</returns>
 public static void SetFontFamily(Control control, string value)
 {
     control.SetValue(FontFamilyProperty, value);
 }
Example #30
0
 public static void SetHeight(Control control, double value)
 {
     control.SetValue(HeightProperty, value);
 }
Example #31
0
 /// <summary>
 /// Sets the value of the attached <see cref="FontStyleProperty"/> on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value to set.</param>
 /// <returns>The font family.</returns>
 public static void SetFontStyle(Control control, FontStyle value)
 {
     control.SetValue(FontStyleProperty, value);
 }
Example #32
0
 public static void SetWidth(Control control, double value)
 {
     control.SetValue(WidthProperty, value);
 }
Example #33
0
 /// <summary>
 /// Sets the value of the attached <see cref="ForegroundProperty"/> on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value to set.</param>
 /// <returns>The font family.</returns>
 public static void SetForeground(Control control, Brush value)
 {
     control.SetValue(ForegroundProperty, value);
 }
Example #34
0
 public static void SetDataContext(Control control, object value)
 {
     control.SetValue(DataContextProperty, value);
 }
        //display filter settings in the UI
        private void DisplayCurrentFilterSettings()
        {
            //set the info label text
            var infoLabel = ((System.Windows.Controls.Label) this.FindName("FilterInfo"));

            infoLabel.Content = this.currentFilter?.Info ?? "no Filter Selected...";

            var settingsGrid = ((System.Windows.Controls.Grid) this.FindName("SettingsGrid"));

            //clear all row and setting-elementss if there are some
            settingsGrid.RowDefinitions.Clear();
            settingsGrid.Children.Clear();

            int rowCount = 0;

            if (null != currentFilter && currentFilter.Settings.Count() > 0)
            {
                foreach (Setting setting in currentFilter.Settings)
                {
                    //add a row for this setting
                    settingsGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });

                    //create label
                    Label label = new Label();
                    label.Content = setting.Name;
                    label.ToolTip = setting.Info;
                    label.SetValue(Grid.ColumnProperty, 0);
                    label.SetValue(Grid.RowProperty, rowCount);
                    settingsGrid.Children.Add(label);

                    Control newSettingControl = null;

                    if (setting.GetType() == typeof(SettingInteger))
                    {
                        label.Content = $"{setting.Name} : {((SettingInteger)setting).Value}";

                        Slider slider = new Slider();
                        slider.ToolTip              = setting.Info;
                        slider.Maximum              = ((SettingInteger)setting).MaxValue;
                        slider.Minimum              = ((SettingInteger)setting).MinValue;
                        slider.Value                = ((SettingInteger)setting).Value;
                        slider.TickPlacement        = System.Windows.Controls.Primitives.TickPlacement.BottomRight;
                        slider.AutoToolTipPlacement = System.Windows.Controls.Primitives.AutoToolTipPlacement.BottomRight;

                        slider.ValueChanged += (object sender, RoutedPropertyChangedEventArgs <double> e) =>
                        {
                            ((SettingInteger)setting).Value = (int)e.NewValue;
                            label.Content = $"{setting.Name} : {((SettingInteger)setting).Value}";
                            return;
                        };
                        newSettingControl = slider;
                    }
                    else if (setting.GetType() == typeof(SettingBoolean))
                    {
                        CheckBox checkBox = new CheckBox();
                        checkBox.IsChecked = ((SettingBoolean)setting).Value;

                        checkBox.Checked += (object sender, RoutedEventArgs e) =>
                        {
                            ((SettingBoolean)setting).Value = true;
                        };

                        checkBox.Unchecked += (object sender, RoutedEventArgs e) =>
                        {
                            ((SettingBoolean)setting).Value = false;
                        };
                        newSettingControl = checkBox;
                    }
                    else if (setting.GetType() == typeof(SettingOption))
                    {
                        ComboBox comboBox = new ComboBox();
                        foreach (string option in ((SettingOption)setting).Options)
                        {
                            comboBox.Items.Add(option);
                        }

                        comboBox.SelectedValue     = ((SettingOption)setting).GetSelected();
                        comboBox.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
                        {
                            string selectedFilterName = (string)((ComboBox)sender).SelectedItem;
                            ((SettingOption)setting).TrySetSelected(selectedFilterName);
                        };

                        newSettingControl = comboBox;
                    }
                    settingsGrid.Children.Add(newSettingControl);
                    newSettingControl?.SetValue(Grid.ColumnProperty, 1);
                    newSettingControl?.SetValue(Slider.IsSnapToTickEnabledProperty, true);
                    newSettingControl?.SetValue(Slider.TickFrequencyProperty, 1.0);
                    newSettingControl?.SetValue(Grid.RowProperty, rowCount);
                    rowCount++;
                }
            }
        }
 public static void SetMaxTime(Control o, string value)
 {
     o.SetValue(MaxTimeProperty, value);
 }
Example #37
0
 /// <summary>
 /// Sets the value of the Dock attached property on the specified control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value of the Dock property.</param>
 public static void SetDock(Control control, Dock value)
 {
     control.SetValue(DockProperty, value);
 }
 public static void SetValue(Control o, TimeSpan value)
 {
     o.SetValue(ValueProperty, value);
 }
Example #39
0
 public static void SetWidth(Control control, double value)
 {
     control.SetValue(WidthProperty, value);
 }
 public static void SetTimeFormat(Control o, TimerFormats TimeFormat)
 {
     o.SetValue(TimeFormatProperty, TimeFormat);
 }
Example #41
0
 /// <summary>
 /// Sets the value of the IsTemplateFocusTargetProperty attached property on a control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The property value.</param>
 /// <remarks>
 /// When a control is navigated to using the keyboard, a focus adorner is shown - usually
 /// around the control itself. However if the TemplatedControl.IsTemplateFocusTarget 
 /// attached property is set to true on an element in the control template, then the focus
 /// adorner will be shown around that control instead.
 /// </remarks>
 public void SetIsTemplateFocusTarget(Control control, bool value)
 {
     control.SetValue(IsTemplateFocusTargetProperty, value);
 }
Example #42
0
        public void Attach(MetaAction metaAction, Control control)
        {
            ValidateType(control);

            var existingItems = controlAction.Where(it => it.Item1 == metaAction);
            var targetItem    = existingItems.FirstOrDefault(it =>
            {
                Control c;
                if (it.Item2.TryGetTarget(out c))
                {
                    return(c.Equals(control));
                }
                return(false);
            });

            // already attached
            if (targetItem != null)
            {
                return;
            }
            Image image = null;

            if (metaAction.Icon != null)
            {
                image           = ImageHelper.CreateImage(metaAction);
                image.MaxWidth  = MetaAction.ToolBarIconSize;
                image.MaxHeight = MetaAction.ToolBarIconSize;
            }

            if (control is MenuItem)
            {
                var menu = (MenuItem)control;
                menu.Icon             = image;
                menu.InputGestureText = metaAction.ShortCut;
                menu.Header           = metaAction.Title;
                menu.ToolTip          = metaAction.ToolTip;
            }
            if (control is ButtonBase)
            {
                var button = (ButtonBase)control;
                button.Content = image;
                button.ToolTip = metaAction.ToolTip;
                if (!string.IsNullOrEmpty(metaAction.ShortCut))
                {
                    button.ToolTip += ": " + metaAction.ShortCut;
                }
            }

            control.SetValue(ToolTipService.ShowOnDisabledProperty, true);
            // IsEnabled property

            // Visibility
            control.SetBinding(UIElement.VisibilityProperty,
                               new Binding
            {
                Source              = metaAction,
                Path                = new PropertyPath("IsVisible"),
                Mode                = BindingMode.OneWay,
                Converter           = BooleanToVisibilityConverter.Instance,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });

            // Shortcut
            if (metaAction.KeyBinding != null)
            {
                var window = GetWindow(control);
                if (!window.InputBindings.Contains(metaAction.KeyBinding))
                {
                    window.InputBindings.Add(metaAction.KeyBinding);
                }
            }
            //  Message.SetAttach(control, metaAction.CaliburnAction);
            control.SetValue(Message.AttachProperty, metaAction.CaliburnAction);
            controlAction.Add(new Tuple <MetaAction, WeakReference <Control> >(metaAction, new WeakReference <Control>(control)));
        }