Пример #1
0
        public bool CanDrop(IElementClipboardData data)
        {
            if (Operator != null)
            {
                return(false);
            }

            if (data.Items.Length != 1)
            {
                return(false);
            }

            IElementFactory factory = data.Items[0].Factory;

            if (factory == null)
            {
                factory = Owner.Context.ElementFactoryManager.GetFactory(data.Items[0].ElementMetadata.ElementTypeId);
            }

            if (factory == null)
            {
                return(false);
            }

            return(factory.ElementType.IsOperator());
        }
Пример #2
0
 public ConvertedElementFactory(IElementFactory elementFactory, Type elementTargetType, XamlNamespaces namespaces)
 {
     this.valueFactory  = elementFactory;
     this.ElementType   = elementTargetType;
     this.namespaces    = namespaces;
     this.typeConverter = TypeConverter.GetTypeConverter(elementFactory.ElementType, elementTargetType);
 }
Пример #3
0
        /// <summary>
        ///     Reads an individual Edge from JSON.  The edge must match the accepted GraphSON format.
        /// </summary>
        /// <param name="json">a single edge in GraphSON format as a Stream</param>
        /// <param name="out_"></param>
        /// <param name="in_"></param>
        /// <param name="factory">the factory responsible for constructing graph elements</param>
        /// <param name="mode">the mode of the GraphSON</param>
        /// <param name="propertyKeys">a list of keys to include when reading of element properties</param>
        public static IEdge EdgeFromJson(JObject json, IVertex out_, IVertex in_,
                                         IElementFactory factory, GraphSonMode mode,
                                         IEnumerable <string> propertyKeys)
        {
            if (json == null)
            {
                throw new ArgumentNullException(nameof(json));
            }
            if (out_ == null)
            {
                throw new ArgumentNullException(nameof(out_));
            }
            if (in_ == null)
            {
                throw new ArgumentNullException(nameof(in_));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            var graphson = new GraphSonUtility(mode, factory, null, propertyKeys);

            return(graphson.EdgeFromJson(json, out_, in_));
        }
Пример #4
0
 public ElementClipboardData(IElementFactory elementFactory)
 {
     _items = new IClipboardDataItem[]
     {
         new ElementClipboardDataItem(elementFactory, null)
     };
 }
Пример #5
0
        public T CreateElement <T>(
            IUiItemWrapper itemWrapper,
            IUiNavigationProvider uiNavigationProvider,
            IElementFactory elementFactory,
            IAwaitingService awaitingService,
            ILogger logger)
            where T : Element
        {
            var type = typeof(T);

            if (type == typeof(NumericParameterElement))
            {
                return(new NumericParameterElement(itemWrapper, uiNavigationProvider, elementFactory, awaitingService, logger) as T);
            }
            else if (type == typeof(StringParameterElement))
            {
                return(new StringParameterElement(itemWrapper, uiNavigationProvider, elementFactory, awaitingService, logger) as T);
            }
            else if (type == typeof(EnumerationParameterElement))
            {
                return(new EnumerationParameterElement(itemWrapper, uiNavigationProvider, elementFactory, awaitingService, logger) as T);
            }
            else if (type == typeof(BitEnumerationParameterElement))
            {
                return(new BitEnumerationParameterElement(itemWrapper, uiNavigationProvider, elementFactory, awaitingService, logger) as T);
            }
            else if (type == typeof(DateTimeParameterElement))
            {
                return(new DateTimeParameterElement(itemWrapper, uiNavigationProvider, elementFactory, awaitingService, logger) as T);
            }

            return(default);
Пример #6
0
        public WebDriver(
            IWebDriver seleniumDriver,
            Func <Uri> rootUrl,
            SeleniumGridConfiguration configuration,
            IRetryExecutor retryExecutor,
            ISelectorFactory selectorFactory,
            IElementFactory elementFactory,
            IXpathProvider xpathProvider,
            IMovieLogger movieLogger,
            IWebElementSourceLog webElementSourceLog,
            IEnumerable <SelectorPrefix> prefixes = null)
        {
            SeleniumDriver            = seleniumDriver;
            SuccessfulSearchers       = new List <Searcher>();
            RootUrl                   = rootUrl;
            SeleniumGridConfiguration = configuration;
            RetryExecutor             = retryExecutor;
            SelectorFactory           = selectorFactory;
            MovieLogger               = movieLogger;
            Prefixes                  = prefixes?.ToList() ?? new List <SelectorPrefix>()
            {
                new EmptySelectorPrefix()
            };

            Children            = new List <WebDriver>();
            Screenshots         = new List <byte[]>();
            ElementFactory      = elementFactory;
            XpathProvider       = xpathProvider;
            WebElementSourceLog = webElementSourceLog;
        }
Пример #7
0
 public ElementClipboardData(IElementFactory elementFactory)
 {
     _items = new IClipboardDataItem[]
     {
         new ElementClipboardDataItem(elementFactory, null)
     };
 }
Пример #8
0
        protected override void CreateBarsOverride(IElementFactory factory)
        {
            int length = this.pattern.Length;
            int num1   = 0;
            int index  = 0;

            for (; num1 < length; num1 = index)
            {
                while (index < length && (int)this.pattern[index] == (int)Symbology1D.BarChar)
                {
                    ++index;
                }
                int num2 = index - num1;
                if (num2 > 0)
                {
                    RectangleF barRect = this.barRect;
                    barRect.X    += this.barRect.Width * (float)num1 / (float)length;
                    barRect.Width = this.barRect.Width * (float)num2 / (float)length;
                    factory.CreateBarElement(barRect);
                }
                while (index < length && (int)this.pattern[index] == (int)Symbology1D.GapChar)
                {
                    ++index;
                }
            }
        }
Пример #9
0
        public void CreateElements(IElementFactory factory, Rectangle bounds)
        {
            int length1 = this.dataMatrix.GetLength(0);
            int length2 = this.dataMatrix.GetLength(1);
            int left    = bounds.Left;
            int top     = bounds.Top;
            int width   = bounds.Width / this.dataMatrix.GetLength(1);
            int height  = bounds.Height / this.dataMatrix.GetLength(0);
            List <Rectangle> rectangleList = new List <Rectangle>();

            for (int index1 = 0; index1 < length1; ++index1)
            {
                for (int index2 = 0; index2 < length2; ++index2)
                {
                    if (this.dataMatrix[index1, index2])
                    {
                        Rectangle rectangle = new Rectangle(left + index2 * width, top + index1 * height, width, height);
                        rectangleList.Add(rectangle);
                    }
                }
            }
            factory.ClearElements();
            foreach (Rectangle rectangle in rectangleList)
            {
                RectangleF rect = (RectangleF)rectangle;
                factory.CreateBarElement(rect);
            }
        }
Пример #10
0
        public GraphSonUtility(GraphSonMode mode, IElementFactory factory, ElementPropertyConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _vertexPropertyKeys   = config.VertexPropertyKeys;
            _edgePropertyKeys     = config.EdgePropertyKeys;
            _vertexPropertiesRule = config.VertexPropertiesRule;
            _edgePropertiesRule   = config.EdgePropertiesRule;

            _mode             = mode;
            _factory          = factory;
            _hasEmbeddedTypes = mode == GraphSonMode.EXTENDED;

// ReSharper disable PossibleMultipleEnumeration
            _includeReservedVertexId = IncludeReservedKey(mode, GraphSonTokens.Id, _vertexPropertyKeys,
                                                          _vertexPropertiesRule);
            _includeReservedEdgeId     = IncludeReservedKey(mode, GraphSonTokens.Id, _edgePropertyKeys, _edgePropertiesRule);
            _includeReservedVertexType = IncludeReservedKey(mode, GraphSonTokens.UnderscoreType, _vertexPropertyKeys,
                                                            _vertexPropertiesRule);
            _includeReservedEdgeType = IncludeReservedKey(mode, GraphSonTokens.UnderscoreType, _edgePropertyKeys,
                                                          _edgePropertiesRule);
            _includeReservedEdgeLabel = IncludeReservedKey(mode, GraphSonTokens.Label, _edgePropertyKeys,
                                                           _edgePropertiesRule);
            _includeReservedEdgeOutV = IncludeReservedKey(mode, GraphSonTokens.OutV, _edgePropertyKeys,
                                                          _edgePropertiesRule);
            _includeReservedEdgeInV = IncludeReservedKey(mode, GraphSonTokens.InV, _edgePropertyKeys,
                                                         _edgePropertiesRule);
// ReSharper restore PossibleMultipleEnumeration
        }
Пример #11
0
 public FormFormService(IAuthenticationService authenticationService, IAuthorizationService authorizationService, IElementFactory elementFactory, IFormHelperService formHelperService)
 {
     _authenticationService = authenticationService;
     _authorizationService  = authorizationService;
     _elementFactory        = elementFactory;
     _formHelperService     = formHelperService;
 }
Пример #12
0
 /// <summary>
 ///     A GraphSONUtility that includes the specified properties.
 /// </summary>
 public GraphSonUtility(GraphSonMode mode, IElementFactory factory,
                        IEnumerable <string> vertexPropertyKeys, IEnumerable <string> edgePropertyKeys) :
     this(
         mode, factory,
         ElementPropertyConfig.IncludeProperties(vertexPropertyKeys, edgePropertyKeys))
 {
 }
Пример #13
0
        public static IElementInitializer Create(IPropertyAdapter propertyAdapter, IEnumerable <object> values, XamlNamespaces namespaces)
        {
            if (!values.Any())
            {
                return(ElementInitializer.Empty);
            }

            if (ElementCollectionContentInitailizer.IsCollectionType(propertyAdapter.PropertyType) &&
                !(values.Count() == 1 && values.First() is XamlElement && propertyAdapter.PropertyType.IsAssignableFrom(((XamlElement)values.First()).GetElementType())))
            {
                IElementInitializer propertyContentInitializer = ElementCollectionContentInitailizer.Create(values, propertyAdapter.PropertyType);

                // wrap with a factory that creates the collection (when it's null) before adding its values
                return(new ElementPropertyMemberFactoryInitializer(propertyAdapter, propertyContentInitializer));
            }

            if (values.Count() == 1)
            {
                if (propertyAdapter.PropertyType == typeof(IFrameworkElementFactory))
                {
                    return(new FrameworkElementFactoryInitializer(propertyAdapter, ElementFactory.FromValue(values.First(), null, namespaces)));
                }

                IElementFactory contentFactory = ElementFactory.FromValue(values.First(), propertyAdapter.PropertyType, namespaces);
                return(new ElementPropertyMemberInitializer(propertyAdapter, contentFactory));
            }

            throw new Granular.Exception("Member of type \"{0}\" cannot have more than one child", propertyAdapter.PropertyType.Name);
        }
Пример #14
0
        /// <summary>
        /// Creates an instance of <see cref="Element"/> for UI item.
        /// </summary>
        /// <typeparam name="T">A desired type or subtype of instance to initialize.</typeparam>
        /// <param name="itemWrapper">An automation framework-specific wrapper of UI item.</param>
        /// <param name="uiNavigationProvider">
        /// Service for locating UI items and navigating
        /// among several running applications.
        /// </param>
        /// <param name="elementFactory">
        /// Service for locating UI items in a visual tree
        /// and initializing instances of <see cref="Element"/> for located items.
        /// </param>
        /// <param name="awaitingService">Service for awaiting various conditions to match.</param>
        /// <param name="logger">Logging service.</param>
        /// <returns>Created instance.</returns>
        public T CreateElement <T>(
            IUiItemWrapper itemWrapper,
            IUiNavigationProvider uiNavigationProvider,
            IElementFactory elementFactory,
            IAwaitingService awaitingService,
            ILogger logger)
            where T : Element
        {
            foreach (var factory in this.elementFactories)
            {
                T result = factory.CreateElement <T>(
                    itemWrapper,
                    uiNavigationProvider,
                    elementFactory,
                    awaitingService,
                    logger);

                if (result != default(T))
                {
                    return(result);
                }
            }

            throw new ArgumentException($"ElementCreator Couldn't create element of type {typeof(T).FullName}");
        }
Пример #15
0
        internal override IElement CreateElement(IElementFactory elementFactory, IElement parent, IRule rule, IdentifierCollection ruleIds)
        {
            IRuleRef garbage = elementFactory.Garbage;

            elementFactory.InitSpecialRuleRef(parent, garbage);
            return(garbage);
        }
Пример #16
0
        private static IEnumerable <KeyValueElementFactory> CreateElementsFactories(Type dictionaryType, Type keyType, Type valueType, IEnumerable <object> values)
        {
            if (values.Any(value => !(value is XamlElement)))
            {
                throw new Granular.Exception("Can't add a value of type \"{0}\" to a dictionary, as it cannot have a key", values.First(value => !(value is XamlElement)).GetType().Name);
            }

            IEnumerable <XamlElement> valuesElements = System.Linq.Enumerable.Cast <XamlElement>(values);

            bool isValueProviderSupported = dictionaryType.GetCustomAttributes(true).OfType <SupportsValueProviderAttribute>().Any();

            List <KeyValueElementFactory> list = new List <KeyValueElementFactory>();

            foreach (XamlElement contentChild in valuesElements)
            {
                bool isShared = contentChild.Directives.All(directive => directive.Name != XamlLanguage.SharedDirective || (bool)TypeConverter.ConvertValue(directive.GetSingleValue(), typeof(bool), XamlNamespaces.Empty, null));

                if (!isShared && !isValueProviderSupported)
                {
                    throw new Granular.Exception($"Can't add a non shared value to \"{dictionaryType.FullName}\" as it does not declare a \"SupportsValueProvider\" attribute");
                }

                IElementFactory contentChildFactory = isValueProviderSupported ? new DeferredValueFactory(contentChild, valueType, isShared) : ElementFactory.FromXamlElement(contentChild, valueType);

                list.Add(new KeyValueElementFactory(keyType, contentChildFactory, contentChild, isValueProviderSupported));
            }

            return(list);
        }
Пример #17
0
 protected override void CreateTextElementsOverride(IElementFactory factory)
 {
     this.CreateTextElement(factory, this.headText, this.headSize, this.headRect);
     this.CreateTextElement(factory, this.tailText, this.tailSize, this.tailRect);
     this.CreateTextElement(factory, this.leftText, this.leftSize, this.leftRect);
     this.CreateTextElement(factory, this.rightText, this.rightSize, this.rightRect);
 }
Пример #18
0
        internal void CreateGrammar(IElementFactory elementFactory)
        {
            IdentifierCollection ruleIds = new IdentifierCollection();

            elementFactory.Grammar.Culture = Culture;
            _grammarBuilder.CreateElement(elementFactory, null, null, ruleIds);
        }
Пример #19
0
        internal override IElement CreateElement(IElementFactory elementFactory, IElement parent, IRule rule, IdentifierCollection ruleIds)
        {
            // Create the children elements
            IItem item = parent as IItem;

            if (item != null)
            {
                CreateChildrenElements(elementFactory, item, rule, ruleIds);
            }
            else
            {
                if (parent == rule)
                {
                    CreateChildrenElements(elementFactory, rule, ruleIds);
                }
                else
                {
                    System.Diagnostics.Debug.Assert(false);
                }
            }

            // Create the tag element at the end only if there were some children
            IPropertyTag tag = elementFactory.CreatePropertyTag(parent);

            tag.NameValue(parent, null, _value);
            return(tag);
        }
Пример #20
0
        internal override IElement CreateElement(IElementFactory elementFactory, IElement parent, IRule rule, IdentifierCollection ruleIds)
        {
            IItem item = elementFactory.CreateItem(parent, rule, _minRepeat, _maxRepeat, 0.5f, 1f);

            CreateChildrenElements(elementFactory, item, rule, ruleIds);
            return(item);
        }
Пример #21
0
        private static IEnumerable <KeyValueElementFactory> CreateElementsFactories(Type keyType, Type valueType, IEnumerable <object> values)
        {
            if (values.Any(value => !(value is XamlElement)))
            {
                throw new Granular.Exception("Can't add a value of type \"{0}\" to a dictionary, as it cannot have a key", values.First(value => !(value is XamlElement)).GetType().Name);
            }

            IEnumerable <XamlElement> valuesElements = values.Cast <XamlElement>();

            List <KeyValueElementFactory> list = new List <KeyValueElementFactory>();

            foreach (XamlElement contentChild in valuesElements)
            {
                bool isShared = contentChild.Directives.All(directive => directive.Name != XamlLanguage.SharedDirective || (bool)TypeConverter.ConvertValue(directive.GetSingleValue(), typeof(bool), XamlNamespaces.Empty));

                IElementFactory contentChildFactory = ElementFactory.FromXamlElement(contentChild, valueType);

                if (!isShared)
                {
                    contentChildFactory = new ValueProviderFactory(contentChildFactory);
                }

                list.Add(new KeyValueElementFactory(keyType, contentChildFactory, contentChild));
            }

            return(list);
        }
Пример #22
0
 public Element(IUiElementWrapper uiInstance, Navigator navigator, ILogger logger, IElementFactory eFactory)
 {
     this.UiInstance     = uiInstance ?? throw new ArgumentNullException(nameof(IUiElementWrapper));
     this.navigator      = navigator ?? throw new ArgumentNullException(nameof(Navigator));
     this.logger         = logger ?? throw new ArgumentNullException(nameof(ILogger));
     this.elementFactory = eFactory;
 }
Пример #23
0
 internal HtmlDocument(IBrowsingContext context, TextSource source)
     : base(context ?? BrowsingContext.New(), source)
 {
     ContentType  = MimeTypeNames.Html;
     _htmlFactory = Context.GetFactory <IElementFactory <Document, HtmlElement> >();
     _mathFactory = Context.GetFactory <IElementFactory <Document, MathElement> >();
     _svgFactory  = Context.GetFactory <IElementFactory <Document, SvgElement> >();
 }
Пример #24
0
 public Navigator(AppiumSessionHandler sessionHandler, AppiumUiWrapperFactory factory, ISettings settings, ILogger logger, IElementFactory eFactory)
 {
     this.sessionHandler = sessionHandler;
     this.wFactory       = factory;
     this.settings       = settings;
     this.logger         = logger;
     this.elementFactory = eFactory;
 }
Пример #25
0
    public void RegisterListeners(MainViewModel model, ElementViewModel element, Contexts contexts, IFactories factories, GameEntity entity)
    {
        _board          = model.Board;
        _element        = element;
        _elementFactory = factories.ElementFactory;

        contexts.Game.RegisterAddedComponentListener <DestroyedComponent>(entity, OnEntityDestroyed);
    }
Пример #26
0
        public Line(IFlags flags, IElementFactory elementFactory) : base(flags)
        {
            this.frame = (IFrame)Global.FrameProvider.CreateFrame(FrameType.Frame, GenerateFrameName("GHD_DocumentLine"));

            // TODO: Identify where to anchor children
            //this.FirstChild.Object.Region.SetParent(this.frame);
            //this.FirstChild.Object.Region.SetPoint(FramePoint.BOTTOMLEFT, this.frame, FramePoint.BOTTOMLEFT);
        }
Пример #27
0
 public AlbumAdminFormService(IAuthenticationService authenticationService, IAuthorizationService authorizationService, IAlbumValidator albumValidator, IElementFactory elementFactory, IFormHelperService formHelperService)
 {
     _authenticationService = authenticationService;
     _authorizationService  = authorizationService;
     _albumValidator        = albumValidator;
     _elementFactory        = elementFactory;
     _formHelperService     = formHelperService;
 }
Пример #28
0
 private void CreateTextElement(
     IElementFactory factory,
     string text,
     SizeF textSize,
     RectangleF bounds)
 {
     factory.CreateTextElement(text, Symbology1D.GetTextRect(textSize, bounds, this.TextAlign, this.LineAlign));
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentBuffer"/> class.
 /// </summary>
 /// <param name="elementFactory"></param>
 /// <param name="data"></param>
 public DocumentBuffer(IElementFactory elementFactory, ITextScoper textScoper, IDocumentData data = null)
 {
     // TODO: Init the document deleter
     this.Deleter        = null;
     this.elements       = new List <BufferElement>();
     this.elementFactory = elementFactory;
     this.textScoper     = textScoper;
 }
Пример #30
0
 public DynamicElementTests()
 {
     visitor = Substitute.For<IDynamicElementVisitor>();
     element = Substitute.For<IElementContainer>();
     factory = Substitute.For<IElementFactory>();
     graphDecorator = Substitute.For<Func<BaseDynamicElement, BaseDynamicElement>>();
     sut = new DynamicElement(element, factory, graphDecorator);
 }
 public PageHeaderAdminFormService(IAuthenticationService authenticationService, IAuthorizationService authorizationService, IElementFactory elementFactory, IFormHelperService formHelperService, IPageService pageService)
 {
     _authenticationService = authenticationService;
     _authorizationService  = authorizationService;
     _elementFactory        = elementFactory;
     _formHelperService     = formHelperService;
     _pageService           = pageService;
 }
Пример #32
0
        internal ElementClipboardDataItem(IElementFactory elementFactory, ElementMetadata elementMetadata)
        {
            if (elementMetadata == null && elementFactory == null)
                throw new ArgumentException("Both arguments cannot not be null.");

            _elementFactory = elementFactory;
            _elementMetadata = elementMetadata;
        }
Пример #33
0
 public HtmlAdminFormService(IAuthenticationService authenticationService, IAuthorizationService authorizationService, IHtmlUrlService htmlUrlService, IElementFactory elementFactory, IFormHelperService formHelperService)
 {
     _authenticationService = authenticationService;
     _authorizationService = authorizationService;
     _htmlUrlService = htmlUrlService;
     _elementFactory = elementFactory;
     _formHelperService = formHelperService;
 }
 public FindElementHandler(
     IUIAutomation uiAutomation, IOverlay overlay, IElementFactory elementFactory,
     IElementSearcher searcher)
 {
     this.uiAutomation = uiAutomation;
     this.overlay = overlay;
     this.elementFactory = elementFactory;
     this.searcher = searcher;
 }
Пример #35
0
        public ElementCreationContext(IElementOwner owner, string data, IElementFactory factory)
        {
            if (owner == null) throw new ArgumentNullException(nameof(owner));
            if (factory == null) throw new ArgumentNullException(nameof(factory));

            _owner = owner;
            _data = data;
            _factory = factory;
        }
Пример #36
0
        public ElementRepository(IElementFactory elementFactory, ITreeOfLifeSession session)
        {
            _session = session;

            _elements = new ReadOnlyCollection<Element>(new List<Element>
            {
                elementFactory.Create("Elements/1", 11, "Air", "\U0001F701"),
                elementFactory.Create("Elements/2", 23, "Water", "\U0001F704"),
                elementFactory.Create("Elements/3", 31, "Fire", "\U0001F702"),
                elementFactory.Create("Elements/4", 33, "Earth", "\U0001F703"),
                elementFactory.Create("Elements/5", 34, "Spirit", "\U0001F700")
            });
        }
Пример #37
0
        /// <summary>
        /// Creates the comparison plugin.
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateComparisonPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.ComparisonOperator, CategoryNames.Comparison, "<", context => new ComparisonOperator(context, ComparisonOperator.ComparisonOperatorType.LessThan), typeof(ComparisonOperator), VplTypeId.Boolean, description: "Less than."),
                new ElementFactory(PluginElementIds.ComparisonOperator, CategoryNames.Comparison, "<=", context => new ComparisonOperator(context, ComparisonOperator.ComparisonOperatorType.LessThanOrEqual), typeof(ComparisonOperator), VplTypeId.Boolean, description: "Less than or equal."),
                new ElementFactory(PluginElementIds.ComparisonOperator, CategoryNames.Comparison, "=", context => new ComparisonOperator(context, ComparisonOperator.ComparisonOperatorType.Equal), typeof(ComparisonOperator), VplTypeId.Boolean, description: "Equals."),
                new ElementFactory(PluginElementIds.ComparisonOperator, CategoryNames.Comparison, "<>", context => new ComparisonOperator(context, ComparisonOperator.ComparisonOperatorType.NotEqual), typeof(ComparisonOperator), VplTypeId.Boolean, description: "Does not equal."),
                new ElementFactory(PluginElementIds.ComparisonOperator, CategoryNames.Comparison, ">", context => new ComparisonOperator(context, ComparisonOperator.ComparisonOperatorType.GreaterThan), typeof(ComparisonOperator), VplTypeId.Boolean, description: "Greater than."),
                new ElementFactory(PluginElementIds.ComparisonOperator, CategoryNames.Comparison, ">=", context => new ComparisonOperator(context, ComparisonOperator.ComparisonOperatorType.GreaterThanOrEqual), typeof(ComparisonOperator), VplTypeId.Boolean, description: "Greater than or equal."),
            };

            return new VplPlugin("Comparison", factories);
        }
Пример #38
0
        protected Element(IElementCreationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _owner = context.Owner;
            _factory = context.Factory;

            DeleteCommand = new RelayCommand(DeleteSelected, CanDelete);
            CopyCommand = new RelayCommand(Copy);
            CutCommand = new RelayCommand(Cut, CanDelete);
            PasteCommand = new RelayCommand(Paste, CanPaste);

            BackgroundColor = Colors.Plum;
            ForegroundColor = Colors.Black;
        }
Пример #39
0
        /// <summary>
        /// Creates the annotation plugin.
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateAnnotationPlugin()
        {
            var resources = new ResourceDictionary[]
            {
                new AnnotationResources()
            };

            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.Comment, CategoryNames.Annotation, "Comment", context => new CommentStatement(context), typeof(CommentStatement), description: "An inline comment."),
                new ElementFactory(PluginElementIds.Annotation, CategoryNames.Annotation, "Annotation", context => new Annotation(context), typeof(Annotation), description: "A free floating comment.", showInToolbox: false),
            };

            return new VplPlugin("Annotations", factories, resources);
        }
Пример #40
0
 /// <summary>
 /// Creates a new instance of the HTML parser with the specified
 /// document based on the given source manager.
 /// </summary>
 /// <param name="document">
 /// The document instance to be constructed.
 /// </param>
 public HtmlDomBuilder(HtmlDocument document)
 {
     var options = document.Options;
     var context = document.Context;
     var resolver = options.GetProvider<IEntityProvider>() ?? HtmlEntityService.Resolver;
     _tokenizer = new HtmlTokenizer(document.Source, resolver);
     _tokenizer.Error += (_, error) => context.Fire(error);
     _document = document;
     _openElements = new List<Element>();
     _templateModes = new Stack<HtmlTreeMode>();
     _formattingElements = new List<Element>();
     _frameset = true;
     _currentMode = HtmlTreeMode.Initial;
     _htmlFactory = options.GetFactory<IElementFactory<HtmlElement>>();
     _mathFactory = options.GetFactory<IElementFactory<MathElement>>();
     _svgFactory = options.GetFactory<IElementFactory<SvgElement>>();
 }
Пример #41
0
 public DynamicElement(IElementContainer element, IElementFactory elementFactory,
     Func<BaseDynamicElement, BaseDynamicElement> graphDecorator)
 {
     if (element == null)
     {
         throw new ArgumentNullException(nameof(element));
     }
     if (elementFactory == null)
     {
         throw new ArgumentNullException(nameof(elementFactory));
     }
     if (graphDecorator == null)
     {
         throw new ArgumentNullException(nameof(graphDecorator));
     }
     this.element = element;
     this.elementFactory = elementFactory;
     this.graphDecorator = graphDecorator;
 }
Пример #42
0
        static HostViewModelLocator()
        {
            var customResources = new View.CustomResources();

            customResources.InitializeComponent();

            var commentFactory = new ElementFactory(CustomElementTypeIds.Comment, "Custom", "Comment",
                context => new CommentViewModel(context), typeof(CommentViewModel));

            var functionService = new FunctionService(GetFunctions, GetFunction);

            var factories = new IElementFactory[]
            {
                commentFactory,
            };

            //Create the plugin
            var plugin = new VplPlugin(
                "Host",
                factories,
                new[] { customResources },
                services: new[] { functionService });

            var plugin1 = new VplPlugin("Alert",
                new IElementFactory[]
                {
                    new ElementFactory(new Guid("FBB6804C-B90C-4A88-B28B-8B733C1A9F0D"), "Interaction", "Alert", context => new Alert(context), typeof(Alert)),
                });

            var plugins = SystemPluginFactory.CreateAllPlugins()
                .ToList();

            plugins.Add(plugin);
            plugins.Add(plugin1);

            VplService = new VplService(plugins);
        }
 public ClearTextHandler(IElementFactory elementFactory)
 {
     this.elementFactory = elementFactory;
 }
Пример #44
0
        /// <summary>
        /// Create the control plugin (has elements such as "Wait", "If /Else"
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateControlPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.Wait, CategoryNames.Control, "Wait", context => new WaitStatement(context), typeof(WaitStatement), description:"Pauses execution for the specified number of seconds."),
                new ElementFactory(PluginElementIds.IfElse, CategoryNames.Control, "If / Else", context => new IfElseStatement(context), typeof(IfElseStatement), description: "Conditionally executes code."),
                new ElementFactory(PluginElementIds.Repeat, CategoryNames.Control, "Repeat", context => new RepeatStatement(context), typeof(RepeatStatement), description: "Repeats a block of code a given number of times."),
                new ElementFactory(PluginElementIds.While, CategoryNames.Control, "While", context => new WhileStatement(context), typeof(WhileStatement), description: "Repeats a block of code while the specified condition is true."),
            };

            return new VplPlugin("Comparison", factories);
        }
Пример #45
0
 public MoveToHandler(IMouse mouse, IElementFactory elementFactory)
 {
     this.mouse = mouse;
     this.elementFactory = elementFactory;
 }
Пример #46
0
            public KeyValueElementFactory(Type keyType, IElementFactory valueFactory, XamlElement xamlElement)
            {
                this.valueFactory = valueFactory;

                keyProperty = GetKeyProperty(valueFactory.ElementType);
                keyDirectiveFactory = GetKeyDirectiveFactory(xamlElement, keyType);

                if (keyDirectiveFactory == null && keyProperty == null)
                {
                    throw new Granular.Exception("Dictionary item \"{0}\" must have a key", xamlElement.Name);
                }
            }
Пример #47
0
        /// <summary>
        /// Provides support for calling functions.
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateFunctionsPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.CallFunction, CategoryNames.Control, "Call", context => new CallFunctionStatement(context), typeof(CallFunctionStatement), description: "Calls a function and ignores any return value."),
                new ElementFactory(PluginElementIds.EvaluateFunction, CategoryNames.Control, "Evaluate", context => new EvaluateFunctionOperator(context), typeof(EvaluateFunctionOperator), VplTypeId.Any, description: "Calls a function and returns its value."),
            };

            return new VplPlugin("Functions", factories);
        }
Пример #48
0
        /// <summary>
        /// Creates the date plugin.
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateDatePlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.AddToDate, CategoryNames.Date, "Add To Date", context => new AddToDate(context), typeof(AddToDate), VplTypeId.DateTime, description: "Adds a number of seconds, minutes, hours or days to a date."),
                new ElementFactory(PluginElementIds.Now, CategoryNames.Date, "Now", context => new Now(context),typeof(Now), description: "Gets the current local time."),
                new ElementFactory(PluginElementIds.UtcNow, CategoryNames.Date, "UTC Now", context => new UtcNow(context), typeof(UtcNow), description: "Gets the current UTC time."),
            };

            return new VplPlugin("Date", factories);
        }
Пример #49
0
        public static IVplPlugin CreateConversionPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.Cast, CategoryNames.Converion, "Cast", context => new Cast(context), typeof(Cast), VplTypeId.Any, description: "Provides a way to supply a typed parameter."),
            };

            return new VplPlugin("Conversion", factories);
        }
 public ElementSearcher(IUIAutomation uiAutomation, IElementFactory elementFactory)
 {
     this.uiAutomation = uiAutomation;
     this.elementFactory = elementFactory;
 }
Пример #51
0
 public FrameworkElementFactoryInitializer(IPropertyAdapter propertyAdapter, IElementFactory elementFactory)
 {
     this.propertyAdapter = propertyAdapter;
     this.elementFactory = elementFactory;
 }
Пример #52
0
 private ElementPropertyMemberInitializer(IPropertyAdapter propertyAdapter, IElementFactory propertyValueFactory)
 {
     this.propertyAdapter = propertyAdapter;
     this.propertyValueFactory = propertyValueFactory;
 }
Пример #53
0
 public ValueProviderFactory(IElementFactory elementFactory)
 {
     this.elementFactory = elementFactory;
 }
Пример #54
0
        /// <summary>
        /// Creates the logical plugin.
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateLogicalPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.BinaryLogicOperator, CategoryNames.Logic, "And", context => new BinaryLogicalOperator(context, BinaryLogicalOperator.BinaryLogicalOperatorType.And), typeof(BinaryLogicalOperator), VplTypeId.Boolean, description: "True only when both parameters are true."),
                new ElementFactory(PluginElementIds.BinaryLogicOperator, CategoryNames.Logic, "Or", context => new BinaryLogicalOperator(context, BinaryLogicalOperator.BinaryLogicalOperatorType.Or), typeof(BinaryLogicalOperator), VplTypeId.Boolean, description: "True when at least one parameter is true."),
                new ElementFactory(PluginElementIds.NotOperator, CategoryNames.Logic, "Not", context => new NotOperator(context), typeof(NotOperator), VplTypeId.Boolean, description: "Logic 'Not' operator. Inverts a boolean value.")
            };

            return new VplPlugin("Logical", factories);
        }
Пример #55
0
 public void SetElementFactory(IElementFactory elementFactory)
 {
     this.elementFactory = elementFactory;
 }
Пример #56
0
        /// <summary>
        /// Create the math plugin.
        /// </summary>
        /// <returns></returns>
        public static IVplPlugin CreateMathPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "+", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.Addition), typeof(BinaryOperator), VplTypeId.Float, description: "Addition"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "-", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.Subtraction), typeof(BinaryOperator), VplTypeId.Float, description: "Subtraction"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "*", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.Multiplication), typeof(BinaryOperator), VplTypeId.Float, description: "Multiplication"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "/", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.Division), typeof(BinaryOperator), VplTypeId.Float, description: "Division"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, ">>", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.ShiftRight), typeof(BinaryOperator), VplTypeId.Int, description: "Shift right"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "<<", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.ShiftLeft), typeof(BinaryOperator), VplTypeId.Int, description: "Shift left"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "&", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.BitwiseAnd), typeof(BinaryOperator), VplTypeId.Int, description: "Bitwise and"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "|", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.BitwiseOr), typeof(BinaryOperator), VplTypeId.Int, description: "Bitwise or"),
                new ElementFactory(PluginElementIds.BinaryMathOperator, CategoryNames.Math, "%", context => new BinaryOperator(context, BinaryOperator.BinaryOperatorType.Modulus), typeof(BinaryOperator), VplTypeId.Int, description: "Modulus"),
            };

            return new VplPlugin("Math", factories);
        }
Пример #57
0
 private void AddElementFactory(IElementFactory factory)
 {
     m_elementFactories.Add(factory.CreateElementType, factory);
     factory.WorldModel = this;
     factory.ObjectsUpdated += ElementsUpdated;
 }
Пример #58
0
        public static IVplPlugin CreateTrigPlugin()
        {
            var factories = new IElementFactory[]
            {
                new ElementFactory(PluginElementIds.Acos, CategoryNames.Trig, "Acos", context => new UnaryFloatOperator(context, System.Math.Acos, "Acos"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the angle whose cosine is the specified number."),
                new ElementFactory(PluginElementIds.Asin, CategoryNames.Trig, "Asin", context => new UnaryFloatOperator(context, System.Math.Asin, "Asin"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the angle whose sine is the specified number."),
                new ElementFactory(PluginElementIds.Atan, CategoryNames.Trig, "Atan", context => new UnaryFloatOperator(context, System.Math.Atan, "Atan"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the angle whose tangent is the specified number."),
                new ElementFactory(PluginElementIds.Cos, CategoryNames.Trig, "Cos", context => new UnaryFloatOperator(context, System.Math.Cos, "Cos"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the cosine of the specified angle."),
                new ElementFactory(PluginElementIds.Cosh, CategoryNames.Trig, "Cosh", context => new UnaryFloatOperator(context, System.Math.Cosh, "Cosh"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the hyperbolic cosine of the specified angle."),
                new ElementFactory(PluginElementIds.Sin, CategoryNames.Trig, "Sin", context => new UnaryFloatOperator(context, System.Math.Sin, "Sin"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the sine of the specified angle."),
                new ElementFactory(PluginElementIds.Sinh, CategoryNames.Trig, "Sinh", context => new UnaryFloatOperator(context, System.Math.Sinh, "Sinh"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the hyperbolic sine of the specified angle."),
                new ElementFactory(PluginElementIds.Tan, CategoryNames.Trig, "Tan", context => new UnaryFloatOperator(context, System.Math.Tan, "Tan"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the tangent of the specified angle."),
                new ElementFactory(PluginElementIds.Tanh, CategoryNames.Trig, "Tanh", context => new UnaryFloatOperator(context, System.Math.Tanh, "Tanh"), typeof(UnaryFloatOperator), VplTypeId.Float, description: "Returns the hyperbolic tangent of the specified angle."),
            };

            return new VplPlugin("Trig", factories);
        }
 public GetElementLocationInViewHandler(IElementFactory elementFactory)
 {
     this.elementFactory = elementFactory;
 }
Пример #60
0
 public GetElementSizeHandler(IElementFactory elementFactory)
 {
     this.elementFactory = elementFactory;
 }