Пример #1
0
        private bool SetSelectionPath(SelectionPath path)
        {
            // Dummy, this variable is only to satisfy SetSelectionPath(SelectionPath path, out bool pendingGeneration)
            bool isPendingGenerationDummy;

            return(SetSelectionPath(path, out isPendingGenerationDummy));
        }
Пример #2
0
 //
 // Pulls the SelectionPath from the CategoryList, but only if it was Sticky,
 // meaning we should preserve it
 //
 public void RestoreState(object state)
 {
     if (state != null)
     {
         SelectionPath restoredPath = SelectionPath.FromState(state);
         _parent.LastSelectionPath = restoredPath;
     }
 }
Пример #3
0
            //
            // Pulls the SelectionPath from the CategoryList, but only if it was Sticky,
            // meaning we should preserve it
            //
            public object RetrieveState()
            {
                if (_parent.CategoryList != null)
                {
                    SelectionPath path = _parent._objectSelectionInitialized ? _parent.CategoryList.SelectionPath : _parent.LastSelectionPath;
                    return(path == null ? null : path.State);
                }

                return(null);
            }
Пример #4
0
        /// <param name="canvasOnly">false for the whole selection, true for the part only on our canvas</param>
        public Gdk.Rectangle GetSelectedBounds(bool canvasOnly)
        {
            var bounds = SelectionPath.GetBounds();

            if (canvasOnly)
            {
                bounds = ClampToImageSize(bounds);
            }

            return(bounds);
        }
 private CompilerContext(
     IObjectType type,
     IImmutableStack <IObjectField> path,
     SelectionPath selectionPath,
     SelectionSetNode selectionSet,
     SelectionVariants selectionVariants,
     bool isInternalSelection,
     IDictionary <SelectionReference, SelectionIncludeCondition> includeConditionLookup,
     IImmutableList <ISelectionOptimizer> optimizers,
     Stack <CompilerContext> backlog,
     IDictionary <SelectionSetNode, SelectionVariants> selectionVariantsLookup,
     HashSet <(SelectionSetNode, NameString)> processed,
Пример #6
0
        private void SelectPropertyByPathOnIdle()
        {
            SelectionPath selectionPath =
                new SelectionPath(PropertySelectionPathInterpreter.PropertyPathTypeId, propertyPathToSelect);
            bool pendingGeneration;
            bool result = this._categoryList.SetSelectionPath(selectionPath, out pendingGeneration);

            if (!result && pendingGeneration)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new MethodInvoker(SelectPropertyByPathOnIdle));
            }
        }
Пример #7
0
        // Attempts to resolve the specified path and set it as the current selection, returning
        // true or false based on success.  If the path is found, selection is set to Sticky.
        // If the UI is not ready, return false and pendingGeneration is true.
        internal bool SetSelectionPath(SelectionPath path, out bool pendingGeneration)
        {
            DependencyObject newSelection = SelectionPathResolver.ResolveSelectionPath(this, path, out pendingGeneration);

            if (newSelection != null)
            {
                SelectAndFocus(newSelection, StealFocusMode.OnlyIfCategoryListHasFocusWithin);
                this.SelectionMode = PropertySelectionMode.Sticky;
                return(true);
            }

            return(false);
        }
Пример #8
0
        // <summary>
        // Updates property selection to the specified SelectionPath (if any)
        // or the specified default property.  Returns true if some property was selected,
        // false otherwise (such as in the case when no properties are showing).
        // </summary>
        // <param name="stickyPath">SelectionPath to select.  Takes precedence over default property.</param>
        // <param name="defaultPropertyName">Property to select when no SelectionPath is specified or
        // if the path cannot be resolved.</param>
        // <param name="fallbackPath">SelectionPath to use when all else fails.  May be null.</param>
        // <returns>True if some property was selected, false otherwise (such as in the case
        // when no properties are showing).</returns>
        public bool UpdateSelectedProperty(
            SelectionPath stickyPath,
            string defaultPropertyName,
            SelectionPath fallbackPath)
        {
            // First, try selecting the given stickyPath, if any
            //
            if (stickyPath == null || !SetSelectionPath(stickyPath))
            {
                ResetSelectionMode();
            }

            bool propertySelected;

            if (SelectionMode == PropertySelectionMode.Default)
            {
                // Then, try finding and selecting the default property
                //
                propertySelected = defaultPropertyName == null ? false : SelectDefaultProperty(defaultPropertyName);
                if (!propertySelected && fallbackPath != null)
                {
                    // And if that fails, go to the specified fallback SelectionPath,
                    // if any
                    //
                    propertySelected = SetSelectionPath(fallbackPath);
                }

                // Make sure that we are still in Default selection mode
                // at this point
                //
                ResetSelectionMode();
            }
            else
            {
                propertySelected = true;
            }

            return(propertySelected);
        }
Пример #9
0
        // Tries to figure out what property to select and selects is
        private void UpdateSelectedProperty(View.Selection selection)
        {
            // If we are not loaded, skip any and all selection magic
            if (!this.IsLoaded)
            {
                return;
            }

            if (selection != null)
            {
                // See what the view would like us to select if we run out of things
                // we can think of selecting
                //
                SelectionPath fallbackSelection = null;
                if (_propertyToolBar.CurrentViewManager != null)
                {
                    fallbackSelection = _propertyToolBar.CurrentViewManager.GetDefaultSelectionPath(_categoryList);
                }

                // Select the first thing we request that exists, using the following
                // precedence order:
                //
                //  * LastSelectionPath
                //  * DefaultProperty
                //  * Whatever the view wants to show (first category, first property, ...)
                //
                _categoryList.UpdateSelectedProperty(
                    this.LastSelectionPath,
                    ModelPropertyMerger.GetMergedDefaultProperty(selection.SelectedObjects),
                    fallbackSelection);
            }

            if (DesignerPerfEventProvider != null)
            {
                DesignerPerfEventProvider.PropertyInspectorUpdatePropertyListEnd();
            }
        }
Пример #10
0
        private void ResolveFieldSelection(
            CompilerContext context,
            FieldNode selection,
            SelectionIncludeCondition?includeCondition)
        {
            NameString fieldName    = selection.Name.Value;
            NameString responseName = selection.Alias is null
                ? selection.Name.Value
                : selection.Alias.Value;

            if (context.Type.Fields.TryGetField(fieldName, out IObjectField? field))
            {
                if ((selection.SelectionSet is null ||
                     selection.SelectionSet.Selections.Count == 0) &&
                    field.Type.NamedType().IsCompositeType())
                {
                    throw OperationCompiler_NoCompositeSelections(selection);
                }

                if (context.Fields.TryGetValue(responseName, out Selection? preparedSelection))
                {
                    preparedSelection.AddSelection(selection, includeCondition);
                }
                else
                {
                    Func <object, IAsyncEnumerable <object?> >?createStream = null;
                    bool isStreamable = selection.IsStreamable();

                    if (field.MaybeStream || field.Type.IsListType() && isStreamable)
                    {
                        IType elementType = field.Type.ElementType();

                        if (elementType.IsCompositeType())
                        {
                            Type runtimeType = elementType.ToRuntimeType();
                            CreateStreamDelegate streamDelegate = CreateStream(runtimeType);
                            createStream = o => streamDelegate(o);
                        }
                    }

                    // if this is the first time we find a selection to this field we have to
                    // create a new prepared selection.
                    preparedSelection = new Selection(
                        GetNextId(),
                        context.Type,
                        field,
                        selection.SelectionSet is not null
                            ? selection.WithSelectionSet(
                            selection.SelectionSet.WithSelections(
                                selection.SelectionSet.Selections))
                            : selection,
                        responseName: responseName,
                        resolverPipeline: CreateFieldMiddleware(field, selection),
                        pureResolver: TryCreatePureField(field, selection),
                        strategy: field.IsParallelExecutable
                            ? null // use default strategy
                            : SelectionExecutionStrategy.Serial,
                        arguments: CoerceArgumentValues(field, selection, responseName),
                        includeCondition: includeCondition,
                        internalSelection: context.IsInternalSelection,
                        createStream: createStream,
                        isStreamable: isStreamable);

                    context.Fields.Add(responseName, preparedSelection);
                }

                if (includeCondition is not null && selection.SelectionSet is not null)
                {
                    SelectionPath selectionPath = context.SelectionPath.Append(responseName);

                    for (var i = 0; i < selection.SelectionSet.Selections.Count; i++)
                    {
                        ISelectionNode child     = selection.SelectionSet.Selections[i];
                        var            reference = new SelectionReference(selectionPath, child);

                        if (!context.IncludeConditionLookup.ContainsKey(reference))
                        {
                            context.IncludeConditionLookup.Add(reference, includeCondition);
                        }
                    }
                }
            }
            else
            {
                throw FieldDoesNotExistOnType(selection, context.Type.Name);
            }
        }