Ejemplo n.º 1
0
        public PropertySettingGroup Deserialize()
        {
            PropertySettingGroup propertySettingGroup = new PropertySettingGroup();

            propertySettingGroup.BasedOn = this.basedOn;
            if (this.propertySettings != null)
            {
                for (int index = 0; index < this.PropertySettings.Count; ++index)
                {
                    IPropertySetting propertySetting = this.PropertySettings[index].Deserialize();
                    if (propertySetting is PropertySetting)
                    {
                        propertySettingGroup.PropertySettings.Add(propertySetting as PropertySetting);
                    }
                }
            }
            if (this.selectors != null)
            {
                for (int index = 0; index < this.Selectors.Count; ++index)
                {
                    IElementSelector internalSelector = this.Selectors[index].Deserialize();
                    propertySettingGroup.Selector = (ElementSelector) new WrapSelector(internalSelector);
                }
            }
            return(propertySettingGroup);
        }
Ejemplo n.º 2
0
        public void ProcessStyle(RadElement rootElement, bool isDynamicallyAddedElement)
        {
            PrepareCache(rootElement);

            for (int i = 0; i < this.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = this.PropertySettingGroups[i];
                group.SetIsFromStyleSheet();
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector selector = group.Selectors[k];
                    if (selector is HierarchicalSelector)
                    {
                        ((HierarchicalSelector)selector).SetCache(this.cachedChildrenHierarchyByElement);
                    }

                    //if (isDynamicallyAddedElement && selector is GeneralSelector)
                    //{
                    //    continue;
                    //}

                    LinkedList <RadElement> selectedElements = selector.GetSelectedElements(rootElement);
                    foreach (RadElement selected in selectedElements)
                    {
                        selected.AddRangeBehavior(selector.GetBehaviors(group));
                        selected.RoutedEventBehaviors.AddRange(selector.GetRoutedEventBehaviors(group));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public IElementSelector Deserialize()
        {
            IElementSelector instance = this.CreateInstance();

            this.DeserializeProperties(instance);
            return(instance);
        }
Ejemplo n.º 4
0
        public XmlPropertySettingGroup Serialize()
        {
            XmlPropertySettingGroup xmlGroup = new XmlPropertySettingGroup();

            xmlGroup.BasedOn = this.basedOn;

            for (int settingIndex = 0; settingIndex < this.PropertySettings.OriginalPropertySettings.Count; settingIndex++)
            {
                IPropertySetting setting = this.PropertySettings.OriginalPropertySettings[settingIndex];
                //serialize value;
                XmlPropertySetting xmlSetting = setting.Serialize();
                xmlGroup.PropertySettings.Add(xmlSetting);
            }

            if (this.Selectors.Count > 0)
            {
                for (int selectorIndex = 0; selectorIndex < this.Selectors.Count; selectorIndex++)
                {
                    IElementSelector selector = this.Selectors[selectorIndex];
                    xmlGroup.Selectors.Add(selector.Serialize());
                }
            }

            return(xmlGroup);
        }
        public NeuralNetworkVisualizerControl()
        {
            InitializeComponent();

            var selectableElementRegisterResolver = new SelectableElementRegister();

            _selector = new ElementSelector(selectableElementRegisterResolver);

            _controlDrawing       = new ControlDrawing(new ControlCanvas(this.picCanvas, this), _selector, selectableElementRegisterResolver, selectableElementRegisterResolver);
            _toolTipFiring        = new ToolTipFiring(this, picCanvas, selectableElementRegisterResolver);
            _selectionEventFiring = new SelectionEventFiring(this, _selector,
                                                             () => this.SelectInputLayer,
                                                             () => this.SelectPerceptronLayer,
                                                             () => this.SelectBias,
                                                             () => this.SelectInput,
                                                             () => this.SelectPerceptron,
                                                             () => this.SelectEdge);

            Control.CheckForIllegalCrossThreadCalls = true;
            this.BackColor = Color.White;

            picCanvas.MouseDown  += PicCanvas_MouseDown;
            picCanvas.MouseMove  += PicCanvas_MouseMove;
            picCanvas.MouseLeave += PicCanvas_MouseLeave;
        }
Ejemplo n.º 6
0
        public virtual IElementSelector CreateSelectorForChildMetadata(VsbElementMetadata child, string state)
        {
            if (child.UserSelector != null)
            {
                return(child.UserSelector);
            }

            IElementSelector defaultSelector = CreateDefaultSelector(child);

            if (!child.CanHaveChildSelector)
            {
                // Element metadata equals our theme type. For example GridDataCellElement.
                if (child.ElementThemeType == this.ElementThemeType)
                {
                    return(this.CreateOwnSelector(state));
                }
                return(defaultSelector);
            }

            IElementSelector ownSelector = this.CreateOwnSelector(state);

            if (ownSelector != null)
            {
                ownSelector.ChildSelector = defaultSelector;
                return(ownSelector);
            }

            return(defaultSelector);
        }
Ejemplo n.º 7
0
        public PropertySettingGroup Deserialize()
        {
            PropertySettingGroup group = new PropertySettingGroup();

            group.BasedOn = this.basedOn;

            if (this.propertySettings != null)
            {
                for (int settingIndex = 0; settingIndex < this.PropertySettings.Count; settingIndex++)
                {
                    XmlPropertySetting xmlPropertySetting = this.PropertySettings[settingIndex];
                    IPropertySetting   setting            = xmlPropertySetting.Deserialize();
                    group.PropertySettings.Add(setting);
                }
            }

            if (this.selectors != null)
            {
                for (int selectorIndex = 0; selectorIndex < this.Selectors.Count; selectorIndex++)
                {
                    XmlElementSelector xmlSelector = this.Selectors[selectorIndex];
                    IElementSelector   selector    = xmlSelector.Deserialize();
                    group.Selectors.Add(selector);
                }
            }

            return(group);
        }
Ejemplo n.º 8
0
        public void DeleteFromBlackList(IElementSelector <User> sel)
        {
            if (_blackListSelectors.Contains(sel))
            {
                _blackListSelectors.Remove(sel);

                var remItems = new List <User>();
                foreach (var item in _blackList)
                {
                    var flag = false;
                    foreach (var s in _blackListSelectors)
                    {
                        if (s.isOk(item))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (!flag)
                    {
                        remItems.Add(item);
                    }
                }

                foreach (var rem in remItems)
                {
                    _blackList.Remove(rem);
                }
            }
        }
Ejemplo n.º 9
0
 public void RemoveDeselector(IElementSelector <T> sel)
 {
     _Deselectors.Remove(sel);
     if (CollectionChanged != null)
     {
         CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
     }
 }
Ejemplo n.º 10
0
        public IElementSelector Deserialize()
        {
            IElementSelector selector = this.CreateInstance();

            this.DeserializeProperties(selector);

            return(selector);
        }
Ejemplo n.º 11
0
        public virtual void Unapply(RadElement radElement)
        {
            if (cachedChildrenHierarchyByElement.Count == 0)
            {
                PrepareCache(radElement);
            }

            for (int i = 0; i < this.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = this.PropertySettingGroups[i];
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector selector = group.Selectors[k];
                    if (selector is HierarchicalSelector)
                    {
                        ((HierarchicalSelector)selector).SetCache(this.cachedChildrenHierarchyByElement);
                    }

                    LinkedList <RadElement> selectedElements = selector.GetSelectedElements(radElement);
                    foreach (RadElement selected in selectedElements)
                    {
                        selector.Unregister(selected, group.PropertySettings);
                    }
                }
            }

            for (int i = 0; i < this.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = this.PropertySettingGroups[i];
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector        selector         = group.Selectors[k];
                    LinkedList <RadElement> selectedElements = selector.GetSelectedElements(radElement);
                    foreach (RadElement selected in selectedElements)
                    {
                        PropertyChangeBehaviorCollection propertyChangeBehaviors = selector.GetBehaviors(group);
                        for (int behaviorIndex = 0; behaviorIndex < propertyChangeBehaviors.Count; behaviorIndex++)
                        {
                            PropertyChangeBehavior toRemove = propertyChangeBehaviors[behaviorIndex];
                            toRemove.BehaviorRemoving(selected);
                        }

                        RoutedEventBehaviorCollection routedEventBehaviors = selector.GetRoutedEventBehaviors(group);
                        for (int eventIndex = 0; eventIndex < routedEventBehaviors.Count; eventIndex++)
                        {
                            RoutedEventBehavior routedEventBehavior = routedEventBehaviors[eventIndex];
                            routedEventBehavior.BehaviorRemoving(selected);
                        }

                        selected.RemoveRangeBehaviors(propertyChangeBehaviors);
                        selected.RemoveRangeRoutedEventBehaviors(routedEventBehaviors);
                    }
                }
            }

            this.cachedChildrenHierarchyByElement.Clear();
        }
Ejemplo n.º 12
0
        public string SelectDocument(ISelector selector)
        {
            IElementSelector elementSelector = selector as IElementSelector;

            if (elementSelector != null)
            {
                return(elementSelector.Select(Document));
            }
            return(selector?.Select(GetFirstSourceText()));
        }
Ejemplo n.º 13
0
        public override bool Equals(IElementSelector elementSelector)
        {
            TypeSelector typeSelector = elementSelector as TypeSelector;

            if (typeSelector != null)
            {
                return((object)typeSelector.elementType == (object)this.elementType);
            }
            return(false);
        }
Ejemplo n.º 14
0
        public override bool Equals(IElementSelector elementSelector)
        {
            VisualStateSelector visualStateSelector = elementSelector as VisualStateSelector;

            if (visualStateSelector != null)
            {
                return(visualStateSelector.visualState == this.visualState);
            }
            return(false);
        }
Ejemplo n.º 15
0
        public override bool Equals(IElementSelector elementSelector)
        {
            ClassSelector classSelector = elementSelector as ClassSelector;

            if (classSelector != null)
            {
                return(classSelector.elementClass == this.elementClass);
            }
            return(false);
        }
Ejemplo n.º 16
0
        public override bool Equals(IElementSelector elementSelector)
        {
            NameSelector nameSelector = elementSelector as NameSelector;

            if (nameSelector != null)
            {
                return(nameSelector.elementName == this.elementName);
            }
            return(false);
        }
Ejemplo n.º 17
0
        public StylesheetTreeNode(StylesheetTree ownerTree, IElementSelector selector)
        {
            this.ownerTree = ownerTree;
            this.selector  = selector;
            this.nodes     = new StylesheetTreeNodeCollection(this);
            int selectorKey = 0;

            //Generally RootNode registers with
            if (selector != null)
            {
                selectorKey = selector.Key;
            }
            ownerTree.RegisterNodeWithKey(selectorKey, this);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds tree nodes from the PropertySettingGroups in the stylesheet. Root nodes are grouped by groups' Selector Key.
        /// Child nodes correspond to child selectors.
        /// </summary>
        /// <param name="styleSheet"></param>
        public void CreateNodesFromStyle(StyleSheet styleSheet)
        {
            for (int i = 0; i < styleSheet.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = styleSheet.PropertySettingGroups[i];
                group.SetIsFromStyleSheet();
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector selector = group.Selectors[k];

                    this.RootNode.Nodes.AddElementSelector(group, selector);
                }
            }
        }
Ejemplo n.º 19
0
        public void ApplyStyle(RadElement rootElement, bool isDynamicallyAddedElement)
        {
            //bool animationsEnabled = AnimatedPropertySetting.AnimationsEnabled;
            //AnimatedPropertySetting.AnimationsEnabled = false;

            //first should be applied selectors without any apply conditions
            LinkedList <NotAppliedSelector> selectorsWithConditions = new LinkedList <NotAppliedSelector>();

            for (int i = 0; i < this.PropertySettingGroups.Count; i++)
            {
                PropertySettingGroup group = this.PropertySettingGroups[i];
                for (int k = 0; k < group.Selectors.Count; k++)
                {
                    IElementSelector selector = group.Selectors[k];
                    //if (isDynamicallyAddedElement && selector is GeneralSelector)
                    //{
                    //    continue;
                    //}

                    if (selector.HasApplyCondition)
                    {
                        selectorsWithConditions.AddLast(new NotAppliedSelector(selector, group.PropertySettings));
                    }
                    else
                    {
                        //Selector selects internally all applicable elements
                        //selector.Apply(rootElement, group.PropertySettings);

                        LinkedList <RadElement> selectedElements = selector.GetSelectedElements(rootElement);
                        foreach (RadElement selected in selectedElements)
                        {
                            selector.Apply(selected, group.PropertySettings);
                        }
                    }
                }
            }

            foreach (NotAppliedSelector notApplied in selectorsWithConditions)
            {
                //Selector selects internally all applicable elements
                //notApplied.Selector.Apply(rootElement, notApplied.PropertySettings);
                foreach (RadElement selected in notApplied.Selector.GetSelectedElements(rootElement))
                {
                    notApplied.Selector.Apply(selected, notApplied.PropertySettings);
                }
            }

            //Temp optimization
            this.cachedChildrenHierarchyByElement.Clear();
        }
Ejemplo n.º 20
0
        public static IDisposable UseFrame(this IWebDriver driver, IElementSelector selector)
        {
            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            driver.SwitchTo().Frame(selector.Find(driver, driver));

            return(new DisposableAction(() => driver.SwitchTo().DefaultContent()));
        }
Ejemplo n.º 21
0
        public bool CheckKeyMatches(IElementSelector elementSelector)
        {
            return(this.selector != null && this.selector.Equals(elementSelector));

            //if (this.key.GetType() == typeof(string))
            //{
            //    //TODO: multi-class selector logic
            //    return elementSelector.Key is string && string.CompareOrdinal((string)this.key, (string)elementSelector.Key) == 0;
            //}
            //else if (this.key is Type)
            //{
            //    return elementSelector.Key is Type && (Type)this.key == (Type)elementSelector.Key;
            //}

            //return false;
        }
Ejemplo n.º 22
0
        public ComposedElementModifier(
            IElementSelector elementSelector, 
            IElementModifier elementModifier)
        {
            if (elementSelector == null)
            {
                throw new ArgumentNullException("elementSelector");
            }

            if (elementModifier == null)
            {
                throw new ArgumentNullException("elementModifier");
            }

            this.elementSelector = elementSelector;
            this.elementModifier = elementModifier;
        }
        internal SelectionEventFiring(NeuralNetworkVisualizerControl control, IElementSelector selector,
                                      SelectInputLayer selectInputLayer,
                                      SelectNeuronLayer selectNeuronLayer,
                                      SelectBias selectBias,
                                      SelectInput selectInput,
                                      SelectNeuron selectNeuron,
                                      SelectEdge selectEdge)
        {
            _control  = control;
            _selector = selector;

            _selectInputLayer       = selectInputLayer;
            this._selectNeuronLayer = selectNeuronLayer;
            _selectBias             = selectBias;
            _selectInput            = selectInput;
            _selectNeuron           = selectNeuron;
            _selectEdge             = selectEdge;
        }
Ejemplo n.º 24
0
        protected override void DeserializeProperties(IElementSelector selector)
        {
            SelectorBase selectorBase = (SelectorBase)selector;

            if (this.Condition != null)
            {
                selectorBase.Condition = this.Condition.Deserialize();
            }
            if (this.UnapplyCondition != null)
            {
                selectorBase.UnapplyCondition = this.UnapplyCondition.Deserialize();
            }
            if (this.ChildSelector != null)
            {
                selectorBase.ChildSelector = this.ChildSelector.Deserialize();
            }
            selectorBase.AutoUnapply = this.AutoUnapply;
        }
Ejemplo n.º 25
0
        private static String checkForSuitableElement(IHTMLElement element)
        {
            IElementTraversal el = element as IElementTraversal;

            if (el.previousElementSibling != null)
            {
                if (el.previousElementSibling.tagName == "LABEL")
                {
                    return(el.previousElementSibling.innerText);
                }
                IElementSelector selector = el.previousElementSibling as IElementSelector;
                if (selector.querySelector("label") != null)
                {
                    return(selector.querySelector("label").innerText);
                }
                selector = element.parentElement as IElementSelector;
                if (selector.querySelector("label") != null)
                {
                    return(selector.querySelector("label").innerText);
                }
            }
            return(null);
        }
Ejemplo n.º 26
0
        public ComposedElementModifier(
            IElementSelector elementSelector, 
            IElementAttributeSelector attributeSelector, 
            IAttributeModifier attributeModifier)
        {
            if (elementSelector == null)
            {
                throw new ArgumentNullException("elementSelector");
            }

            if (attributeSelector == null)
            {
                throw new ArgumentNullException("attributeSelector");
            }

            if (attributeModifier == null)
            {
                throw new ArgumentNullException("attributeModifier");
            }

            this.elementSelector = elementSelector;
            this.attributeSelector = attributeSelector;
            this.attributeModifier = attributeModifier;
        }
Ejemplo n.º 27
0
 public SubmitAction(IElementSelector elementSelector)
 {
     _elementSelector = elementSelector ?? throw new ArgumentNullException(nameof(elementSelector));
 }
Ejemplo n.º 28
0
        public override bool Equals(IElementSelector elementSelector)
        {
            NameSelector selector = elementSelector as NameSelector;

            return(selector != null && selector.elementName == this.elementName);
        }
Ejemplo n.º 29
0
 public abstract bool Equals(IElementSelector elementSelector);
Ejemplo n.º 30
0
 public ClickAction(IElementSelector selector)
 {
     _selector = selector ?? throw new ArgumentNullException(nameof(selector));
 }