Esempio n. 1
0
            public IComparable Bind(PropertySelection selection)
            {
                string runtimeBinding = null;
                string propertyChain  = null;

                try
                {
                    runtimeBinding = data.bindingContainer.ContextBinding[selection.ContextKey];
                }
                catch (KeyNotFoundException e)
                {
                    throw new Exception("no runtime binding mapping for: " + selection.ContextKey, e);
                }

                try
                {
                    propertyChain = data.bindingContainer.ReferenceBinding[selection.ReferenceMeaning];
                }
                catch (KeyNotFoundException e)
                {
                    throw new Exception("no property chain binding mapping for: " + selection.ReferenceMeaning, e);
                }


                object         obj    = data.Contexts.Get(runtimeBinding);
                PropertyBinder binder = getPropertyBinder(propertyChain, runtimeBinding, obj);


                return(binder.Bind(obj));
            }
Esempio n. 2
0
        // We use the ItemStatus to convey read-only property selection status
        protected override string GetItemStatusCore()
        {
            FrameworkElement selection = _control.Selection;
            string           status;

            if (selection != null)
            {
                ISelectionStop selectionStop = PropertySelection.GetSelectionStop(selection);
                status = selectionStop == null ? null : selectionStop.Description;

                if (status == null)
                {
                    status = string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.PropertyEditing_SelectionStatus_Unknown,
                        selection.GetType().Name);
                }
            }
            else
            {
                status = Resources.PropertyEditing_SelectionStatus_Empty;
            }

            return(status);
        }
Esempio n. 3
0
        // Find the closest IsSelectable parent and select it.  Don't mess with focus.
        //
        private void Select(DependencyObject visualSource)
        {
            if (visualSource != null)
            {
                FrameworkElement selection = PropertySelection.FindParentSelectionStop <FrameworkElement>(visualSource);

                if (selection != _selection)
                {
                    // Unselect anything that was selected previously
                    if (_selection != null)
                    {
                        PropertySelection.SetIsSelected(_selection, false);
                    }

                    _selection = selection;

                    // Select whatever we need to select now
                    if (_selection != null)
                    {
                        PropertySelection.SetIsSelected(_selection, true);

                        // Bring the full PropertyContainer into view, if one exists
                        FrameworkElement focusableElement        = VisualTreeUtils.FindFocusableElement <FrameworkElement>(_selection) ?? _selection;
                        FrameworkElement parentPropertyContainer = VisualTreeUtils.FindVisualAncestor <PropertyContainer>(focusableElement);
                        FrameworkElement bringIntoViewElement    = parentPropertyContainer ?? focusableElement;

                        bringIntoViewElement.BringIntoView();

                        // As soon as the user manually selects a property, automatically switch to Sticky mode
                        _selectionMode = PropertySelectionMode.Sticky;
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the property selection.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="personId">The person identifier.</param>
        /// <returns></returns>
        public static PropertySelection GetPropertySelection(GridViewRow row, int personId)
        {
            Panel selectionControlContainer = row.FindControl($"selectionControlContainer_{personId}") as Panel;

            RockCheckBox    selectionControlCheckbox    = selectionControlContainer.FindControl($"selectionControlCheckbox_{personId}") as RockCheckBox;
            RockRadioButton selectionControlRadioButton = selectionControlContainer.FindControl($"selectionControlRadioButton_{personId}") as RockRadioButton;

            var result = new PropertySelection
            {
                PropertyKey = (row.NamingContainer as Grid).DataKeys[row.RowIndex].Value as string
            };

            if (selectionControlCheckbox.Visible)
            {
                result.Selected = selectionControlCheckbox.Checked;
            }
            else if (selectionControlRadioButton.Visible)
            {
                result.Selected = selectionControlRadioButton.Checked;
            }
            else
            {
                result.IsSectionHeader = true;
                result.Selected        = false;
            }

            return(result);
        }
Esempio n. 5
0
        private void setTypeComboValue(IComparable comparedObject_)
        {
            if (comparedObject_ == null)
            {
                return;                             // shouldn't be!!
            }
            if (comparedObject_ is PropertySelection)
            {
                PropertySelection comparedObject = (PropertySelection)comparedObject_;
                ObjectType.SelectedIndex = 3;
                setObjectGUI(true);

                CompareToPath.Text = comparedObject.ReferenceMeaning;
                CompareTo.Text     = comparedObject.ContextKey;
                return;
            }

            if (comparedObject_ is System.Int32)
            {
                ObjectType.SelectedIndex = 0;
            }
            else if (comparedObject_ is System.String)
            {
                ObjectType.SelectedIndex = 1;
            }
            else if (comparedObject_ is System.Single)
            {
                ObjectType.SelectedIndex = 2;
            }

            CompareTo.Text = comparedObject_.ToString();
        }
Esempio n. 6
0
 public UnableToBindEvent(FlowErrorTrace parent, Exception linkedException, ValidationRule rule, PropertySelection selection, int argument) :
     base(parent, "unable to bind object " + selection, rule)
 {
     this.selection       = selection;
     this.argument        = argument;
     this.linkedException = linkedException;
 }
Esempio n. 7
0
        private bool SelectDefaultPropertyHelper(string defaultPropertyName, bool firstTime)
        {
            if (string.IsNullOrEmpty(defaultPropertyName))
            {
                return(false);
            }

            ModelCategoryEntry defaultPropertyCategory;
            PropertyEntry      defaultProperty       = FindPropertyEntry(defaultPropertyName, out defaultPropertyCategory);
            CategoryEditor     defaultCategoryEditor = FindCategoryEditor(defaultProperty, defaultPropertyCategory);
            UIElement          element    = null;
            bool elementPendingGeneration = false;

            // Try to look up the correct UIElement to select
            //
            if (defaultCategoryEditor != null)
            {
                element = FindCategoryEditorVisual(defaultCategoryEditor, defaultPropertyCategory, out elementPendingGeneration);
            }
            else if (defaultProperty != null)
            {
                element = FindPropertyEntryVisual(defaultProperty, defaultPropertyCategory, out elementPendingGeneration);
            }
            else if (this.Count > 0)
            {
                // Nothing found, so select the first selectable thing in the list
                element = PropertySelection.FindNeighborSelectionStop <UIElement>(this, SearchDirection.Next);
                elementPendingGeneration = false;
            }

            // If the UIElement was found, select it.  Otherwise, if it should exist but it wasn't generated yet,
            // wait until it is and try again.
            //
            if (element != null)
            {
                SelectAndFocus(element, StealFocusMode.OnlyIfCategoryListHasFocusWithin);

                // Ensure that we are in Default SelectionMode because calling SelectAndFocus automatically switches us
                // to Sticky mode
                //
                ResetSelectionMode();
            }
            else if (elementPendingGeneration && firstTime)
            {
                // Set the firstTime flag to false, to prevent any infinite loops should things go wrong
                this.Dispatcher.BeginInvoke(
                    DispatcherPriority.Loaded,
                    new SelectDefaultPropertyHelperDelegate(SelectDefaultPropertyHelper),
                    defaultPropertyName,
                    false);
            }
            else if (elementPendingGeneration && !firstTime)
            {
                elementPendingGeneration = false;
            }

            return(element != null || elementPendingGeneration);
        }
            // <summary>
            // The actual event handler, that fires when the IsSelected DP changes.
            // Here we raise the AutomationFocus event for the
            // Advanced (More Properties) properties expander.
            // </summary>
            // <param name="sender">Expander</param>
            // <param name="e">EventArgs</param>
            private void OnIsSelectedValueChanged(object sender, EventArgs e)
            {
                // Add logic to respond to "Selection"
                bool curVal = PropertySelection.GetIsSelected(sender as DependencyObject);

                if (curVal)
                {
                    this.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
                }
            }
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            if (item != null)
            {
                string editorTypeName = item.GetType().Name;

                // Make each CategoryEditor its own selection stop
                PropertySelection.SetSelectionStop(element, new CategoryEditorSelectionStop(editorTypeName));
            }
        }
Esempio n. 10
0
        private void OnOwningPropertyContainerChanged(PropertyContainer oldValue, PropertyContainer newValue)
        {
            if (oldValue != null)
            {
                PropertySelection.ClearSelectionStop(oldValue);
                PropertySelection.ClearIsSelectionStopDoubleClickTarget(oldValue);
            }

            if (newValue != null)
            {
                PropertySelection.SetSelectionStop(newValue, this);
                PropertySelection.SetIsSelectionStopDoubleClickTarget(newValue, true);
            }
        }
Esempio n. 11
0
 public void PropertySelectionTestMethod()
 {
     try
     {
         log.Info("PropertySelectionTestMethod test Started.");
         Thread.Sleep(3000);
         PropertySelection propertySelection = new PropertySelection(driver);
         propertySelection.PropertySelectionMethod();
         log.Info("PropertySelectionTestMethod test Ended.");
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
Esempio n. 12
0
        protected override void createProperties()
        {
            base.createProperties();

            //Will need to choose output sample space.
            Property p = new PropertySelection(options, (int)outSamples, "output sample space");

            p.eValueChanged         += P_eValueChanged;
            properties["outSamples"] = p;

            //To pad or not to pad?
            p = new PropertyCheckbox("pad the channels to\na multiple of 8?");
            p.eValueChanged     += e_padded;
            properties["padded"] = p;
        }
Esempio n. 13
0
        protected override void createProperties()
        {
            base.createProperties();

            setExtra(inSpace.ToString() + " to " + outSpace.ToString());

            //Will need to choose input color space
            //and output color space.
            Property p = new PropertySelection(options, (int)inSpace, "input color space");

            p.eValueChanged      += P_eValueChanged;
            properties["inSpace"] = p;
            p = new PropertySelection(options, (int)outSpace, "output color space");
            p.eValueChanged       += P_eValueChanged;
            properties["outSpace"] = p;
        }
Esempio n. 14
0
 public void ParticularAgentPropertyTestMethod()
 {
     try
     {
         log.Info("ParticularAgentPropertyTestMethod test Started.");
         Thread.Sleep(3000);
         PropertySelection popertySelection = new PropertySelection(driver);
         var expectedAgentsPropertyName     = popertySelection.AgentSelectionMethod();
         Assert.IsTrue(expectedAgentsPropertyName);
         log.Info("ParticularAgentPropertyTestMethod test Ended.");
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
Esempio n. 15
0
        // Keyboard Navigation

        protected override void OnKeyDown(KeyEventArgs e)
        {
            // Intercept Up, Down, Left, Right key strokes and use them to navigate around the
            // the control
            //
            if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
            {
                if (_selection != null && !e.Handled)
                {
                    if (object.Equals(
                            Keyboard.FocusedElement,
                            VisualTreeUtils.FindFocusableElement <FrameworkElement>(_selection)))
                    {
                        ISelectionStop selectionStop = PropertySelection.GetSelectionStop(_selection);
                        if (selectionStop != null)
                        {
                            if (selectionStop.IsExpandable)
                            {
                                if ((e.Key == Key.Right && !selectionStop.IsExpanded) ||
                                    (e.Key == Key.Left && selectionStop.IsExpanded))
                                {
                                    selectionStop.IsExpanded = !selectionStop.IsExpanded;
                                    e.Handled = true;
                                }
                            }
                        }

                        if (!e.Handled)
                        {
                            SearchDirection  direction = e.Key == Key.Up || e.Key == Key.Left ? SearchDirection.Previous : SearchDirection.Next;
                            FrameworkElement nextStop  = PropertySelection.FindNeighborSelectionStop <FrameworkElement>(_selection, direction);

                            // If need to select something, select it
                            if (nextStop != null)
                            {
                                SelectAndFocus(nextStop, StealFocusMode.Always);
                            }

                            e.Handled = true;
                        }
                    }
                }
            }

            base.OnKeyDown(e);
        }
Esempio n. 16
0
        protected override void createProperties()
        {
            base.createProperties();

            Property p = new PropertySelection(options, (int)method, "merge operator");

            p.eValueChanged          += e_OpChanged;
            properties["mergeMethod"] = p;

            p = new PropertyButton("Swap", "Swap inputs A and B");
            p.eValueChanged      += e_SwapInputs;
            properties["btnSwap"] = p;

            properties.Add("inColorA", new PropertyColor(true, false));
            properties.Add("inColorB", new PropertyColor(true, false));
            properties.Add("outColor", new PropertyColor(false, true));
        }
Esempio n. 17
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            if (element != null)
            {
                PropertyEntry property = ((PropertyContainer)element).PropertyEntry;

                if (property != null)
                {
                    // Make each PropertyContainer its own selection stop
                    PropertySelection.SetSelectionStop(element, new PropertySelectionStop(property));
                }

                PropertyContainer container = element as PropertyContainer;
                if (container != null)
                {
                    container.Loaded += new RoutedEventHandler(OnPropertyContainerLoaded);
                }
            }
        }