Exemplo n.º 1
0
        /// <summary>
        /// Gets spell checking culture of the specified control.
        /// </summary>
        /// <param name="control">
        /// The control.
        /// </param>
        /// <returns>
        /// The spell checking culture.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="control"/> parameter is null.
        /// </exception>
        public static CultureInfo GetCulture(Control control)
        {
            if (control == null)
                throw new ArgumentNullException("control");

            return (CultureInfo)control.GetValue(CultureProperty);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the IsSendingMouseWheelEventToParent for a given <see cref="TextBox"/>.
        /// </summary>
        /// <param name="control">
        /// The <see cref="TextBox"/> whose IsSendingMouseWheelEventToParent is to be retrieved.
        /// </param>
        /// <returns>
        /// The IsSendingMouseWheelEventToParent, or <see langword="null"/>
        /// if no IsSendingMouseWheelEventToParent has been set.
        /// </returns>
        public static bool? GetIsSendingMouseWheelEventToParent(Control control)
        {
            if (control == null)
                throw new ArgumentNullException("");

            return control.GetValue(ScrollProperty) as bool?;
        }
Exemplo n.º 3
0
        private static DoubleClickCommandBehavior GetOrCreateBehavior(Control control)
        {
            var behavior = control.GetValue(DoubleClickCommandBehaviorProperty) as DoubleClickCommandBehavior;
            if (behavior == null)
            {
                behavior = new DoubleClickCommandBehavior(control);
                control.SetValue(DoubleClickCommandBehaviorProperty, behavior);
            }

            return behavior;
        }
Exemplo n.º 4
0
 /// <summary>
 /// This method retrieves the default style key of a control.
 /// </summary>
 /// <param name="control">The control to retrieve the default style key 
 /// from.</param>
 /// <returns>The default style key of the control.</returns>
 public static object GetDefaultStyleKey(Control control)
 {
     return control.GetValue(Control.DefaultStyleKeyProperty);
 }
 public static double GetOneWayControlHeight(Control element)
 {
     return (double)element.GetValue(OneWayControlHeightProperty);
 }
Exemplo n.º 6
0
 private static Guid GetOperationId(Control control)
 {
     return (Guid)control.GetValue(OperationIdProperty);
 }
Exemplo n.º 7
0
 public static bool GetShiftWheelScrollsHorizontally(Control element)
 => (bool)element.GetValue(ShiftWheelScrollsHorizontallyProperty);
 public static bool GetFocusOnFirstElement(Control control)
 {
     return (bool)control.GetValue(FocusOnFirstElementProperty);
 }
Exemplo n.º 9
0
        void selectedDevice_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            selectedDevice = (Control)sender;
            selectedDevice.CaptureMouse();
            deltaX = e.GetPosition(grdDeviceLayer).X - ((Thickness)selectedDevice.GetValue(Grid.MarginProperty)).Left;
            deltaY = e.GetPosition(grdDeviceLayer).Y - ((Thickness)selectedDevice.GetValue(Grid.MarginProperty)).Top;

            UnSelectAllDevice();

            (sender as I_IO).IsSelect = true;
            this.grdSetting.DataContext = selectedDevice.DataContext;
           // throw new NotImplementedException();
        }
Exemplo n.º 10
0
		void VisualInheritanceCore (Control c1, DependencyProperty prop1, FrameworkElement c2, DependencyProperty prop2, object value, object other)
		{
			Assert.AreSame (c1, c2.Parent, "#parented");
			Assert.AreNotEqual (value, c1.GetValue (prop1), "#1");
			Assert.AreNotEqual (value, c2.GetValue (prop2), "#2");
			Assert.IsNull (VisualTreeHelper.GetParent (c2), "#c2 no parent");
			Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (c1), "#c1 no children");

			c1.SetValue (prop1, value);
			Assert.IsNotNull (c1.GetValue (prop1), "#3");
			Assert.IsNotNull (c2.GetValue (prop2), "#4");
			Assert.AreNotEqual (c1.GetValue (prop1), c2.GetValue (prop2), "#5");

			// Once we connect c2 to c1 via the template visual tree, it will inherit the value
			CreateAsyncTest (c1,
				() => {
					c1.ApplyTemplate ();
				}, () => {
					Assert.AreEqual (c1.GetValue (prop1), c2.GetValue (prop2), "#6");

					// And if we change the value inside the template, it affects c2
					var visualParent = (FrameworkElement) VisualTreeHelper.GetChild (c1, 0);
					visualParent.SetValue (prop1, other);
					Assert.AreEqual (c2.GetValue (prop2), other, "#7");
				}
			);
		}
 public static bool GetOpenShellContextMenu(Control control)
 {
     return (bool)control.GetValue(OpenShellContextMenuProperty);
 }
 public static bool GetInterceptKeySelectionEvents(Control element)
 {
     return (bool)element.GetValue(InterceptKeySelectionEventsProperty);
 }
Exemplo n.º 13
0
 public static object GetParameter(Control target)
 {
     return target.GetValue(ParameterProperty);
 }
Exemplo n.º 14
0
 public static ICommand GetCommand(Control target)
 {
     return (ICommand)target.GetValue(CommandProperty);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Gets a value indicating whether the control should receive focus on Loaded event.
        /// </summary>
        /// <param name="control">
        /// The control.
        /// </param>
        /// <returns>
        /// <c>true</c> if the control should receive focus on Loaded event; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="control"/> parameter is null.
        /// </exception>
        public static bool GetFocusOnLoaded(Control control)
        {
            if (control == null)
                throw new ArgumentNullException("control");

            return (bool)control.GetValue(FocusOnLoadedProperty);
        }
Exemplo n.º 16
0
		private static AutoComplete EnsureInstance( Control ctrl )
		{
			var ac = ( AutoComplete )ctrl.GetValue( AutoComplete.AutoCompleteInstance );
			if( ac == null )
			{
				ac = new AutoComplete( ctrl );
				//ac.SetControl( ctrl );
				ctrl.SetValue( AutoCompleteInstancePropertyKey, ac );
			}

			return ac;
		}
Exemplo n.º 17
0
 public static string GetStateName(Control o)
 {
     return (string)o.GetValue(StateNameProperty);
 }
Exemplo n.º 18
0
		void LogicalInheritanceCore (Control c1, DependencyProperty prop1, FrameworkElement c2, DependencyProperty prop2, object value, object other)
		{
			// Check that we inherit values even if the visual tree doesn't exist,
			// i.e. if we use logical inheritance.
			Assert.AreNotEqual (value, c1.GetValue (prop1), "#1");
			Assert.AreNotEqual (value, c2.GetValue (prop2), "#2");
			Assert.IsNull (VisualTreeHelper.GetParent (c2), "#c2 no parent");
			Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (c1), "#c1 no children");

			c1.SetValue (prop1, value);
			Assert.IsNotNull (c1.GetValue (prop1), "#3");
			Assert.IsNotNull (c2.GetValue (prop2), "#4");
			Assert.AreEqual (c1.GetValue (prop1), c2.GetValue (prop2), "#5");

			// Now generate a visual tree with 'c2' at the end and check that the visual
			// tree doesn't affect which value is inherited
			CreateAsyncTest (c1,
				() => {
					c1.ApplyTemplate ();
				}, () => {
					var visualParent = (FrameworkElement) VisualTreeHelper.GetChild (c1, 0);
					visualParent.SetValue (prop1, other);
					Assert.AreEqual (c2.GetValue (prop2), value, "#6");
				}
			);
		}
Exemplo n.º 19
0
 public static bool GetWPFFocusFirst(Control control)
 {
     return (bool)control.GetValue(WPFFocusFirstProperty);
 }
Exemplo n.º 20
0
 private static void Subscribe(Control control, DependencyProperty property)
 {
     var binding = BindingOperations.GetBinding(control, property);
     if (binding != null && binding.IsBoundToDataContext())
     {
         if (!binding.IsNotifiying())
         {
             binding = binding.CreateNotifying(control.DataContext);
             BindingOperations.ClearBinding(control, property);
             BindingOperations.SetBinding(control, property, binding);
         }
         control.SourceUpdated += (o, args) =>
         {
             if (args.Property == property)
             {
                 var undoManager = GetUndoManager(control);
                 var value = control.GetValue(property);
                 undoManager._history.Update(control, value, property, UpdateReason.UserInput);
             }
         };
         control.TargetUpdated += (o, args) =>
         {
             if (args.Property == property)
             {
                 var undoManager = GetUndoManager(control);
                 var value = control.GetValue(property);
                 undoManager._history.Update(control, value, property, UpdateReason.DataUpdated);
             }
         };
     }
 }
Exemplo n.º 21
0
        private static CommandBehaviorBase<Control> GetOrCreateBehavior(Control control)
        {
            var behavior = control.GetValue(EventCommandBehaviorProperty) as CommandBehaviorBase<Control>;

            if (behavior == null)
            {
                behavior = CreateCommandBehavior(control, control.GetValue(EventNameProperty).ToString());
                control.SetValue(EventCommandBehaviorProperty, behavior);
            }

            return behavior;
        }
Exemplo n.º 22
0
 /// <summary>
 /// 获取外层的控件。
 /// 
 /// DesignerItem 返回 BlockControl。
 /// Connection 返回 Controls.Connection
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public static IModelingDesignerComponent GetComponent(Control element)
 {
     return element.GetValue(ComponentProperty) as IModelingDesignerComponent;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the value in EventName attached property on the provided <see cref="Control"/>.
 /// </summary>
 /// <param name="control">The DependencyObject that has the EventName.</param>
 /// <returns>The value of the property.</returns>
 public static String GetEventName(Control control)
 {
     return control.GetValue(EventNameProperty).ToString();
 }
 public static bool GetIsControlSizeBound(Control element)
 {
     return (bool)element.GetValue(IsControlSizeBoundProperty);
 }
Exemplo n.º 25
0
 public static EnabledOpacity GetEnabledOpacity(Control element) { return (EnabledOpacity)element.GetValue(EnabledOpacityProperty); }
 public static double GetOneWayControlWidth(Control element)
 {
     return (double)element.GetValue(OneWayControlWidthProperty);
 }
Exemplo n.º 27
0
 public static ICommand GetDoubleClickCommand(Control element)
 {
     return (ICommand)element.GetValue(DoubleClickCommandProperty);
 }
Exemplo n.º 28
0
 public static ICommand GetCommand(Control control)
 {
     return control.GetValue(CommandProperty) as ICommand;
 }
Exemplo n.º 29
0
 public static object GetDoubleClickCommandParameter(Control element)
 {
     return element.GetValue(DoubleClickCommandParameterProperty);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Gets the visual state associated with the specified control.
 /// </summary>
 /// <param name="control">The control to lookup.</param>
 /// <returns>The current visual state as it was last set.</returns>
 public static string GetVisualState(Control control)
 {
     return (string)control.GetValue(VisualStateProperty);
 }
Exemplo n.º 31
0
 public static object GetCommandParameter(Control control)
 {
     return control.GetValue(CommandParameterProperty);
 }