예제 #1
0
        public IRawElementProviderSimple[] GetSelection()
        {
            if (this.Context == null)
            {
                return(new IRawElementProviderSimple[0]);
            }
            Selection selection1 = this.Context.Items.GetValue <Selection>();
            List <IRawElementProviderSimple> list = new List <IRawElementProviderSimple>(selection1.SelectionCount);

            if (selection1.SelectionCount == 0)
            {
                return(list.ToArray());
            }
            if (this._dataChildren == null)
            {
                this.PopulateDataChildren();
            }
            DesignerItemAutomationPeer itemAutomationPeer = (DesignerItemAutomationPeer)null;
            ModelItem root = this.ModelService.Root;

            if (root != null)
            {
                itemAutomationPeer = (DesignerItemAutomationPeer)this._dataChildren[(object)root];
            }
            foreach (ModelItem modelItem in selection1.SelectedObjects)
            {
                if (this._dataChildren.ContainsKey((object)modelItem) && itemAutomationPeer != null)
                {
                    list.Add(itemAutomationPeer.GetProviderFromPeer((AutomationPeer)itemAutomationPeer));
                }
                List <IRawElementProviderSimple> selection2 = itemAutomationPeer.GetSelection((object)modelItem);
                list.AddRange((IEnumerable <IRawElementProviderSimple>)selection2);
            }
            return(list.ToArray());
        }
예제 #2
0
        public List <DesignerItemAutomationPeer> GetSelectedAutomationPeers(Selection newSel)
        {
            List <DesignerItemAutomationPeer> list = new List <DesignerItemAutomationPeer>(newSel.SelectionCount);

            if (newSel.SelectionCount == 0)
            {
                return(list);
            }
            DesignerItemAutomationPeer itemAutomationPeer = (DesignerItemAutomationPeer)null;
            ModelItem root = this.ModelService.Root;

            if (root != this._root)
            {
                this._root = root;
                this.PopulateDataChildren();
            }
            if (root != null)
            {
                itemAutomationPeer = (DesignerItemAutomationPeer)this._dataChildren[(object)root];
            }
            foreach (ModelItem modelItem in newSel.SelectedObjects)
            {
                if (this._dataChildren.ContainsKey((object)modelItem) && itemAutomationPeer != null)
                {
                    list.Add(itemAutomationPeer);
                }
                List <DesignerItemAutomationPeer> selectedAutomationPeers = itemAutomationPeer.GetSelectedAutomationPeers((object)modelItem);
                list.AddRange((IEnumerable <DesignerItemAutomationPeer>)selectedAutomationPeers);
            }
            return(list);
        }
        public List <DesignerItemAutomationPeer> GetSelectedAutomationPeers(object selectedObj)
        {
            if (this._dataChildren == null)
            {
                this.GetChildren();
            }
            List <DesignerItemAutomationPeer> list = new List <DesignerItemAutomationPeer>();

            if (this._dataChildren.ContainsKey(selectedObj))
            {
                DesignerItemAutomationPeer itemAutomationPeer = this._dataChildren[selectedObj] as DesignerItemAutomationPeer;
                if (itemAutomationPeer != null)
                {
                    list.Add(itemAutomationPeer);
                }
            }
            else
            {
                foreach (DictionaryEntry dictionaryEntry in this._dataChildren)
                {
                    DesignerItemAutomationPeer itemAutomationPeer = dictionaryEntry.Value as DesignerItemAutomationPeer;
                    if (itemAutomationPeer != null)
                    {
                        list.AddRange((IEnumerable <DesignerItemAutomationPeer>)itemAutomationPeer.GetSelectedAutomationPeers(selectedObj));
                    }
                }
            }
            return(list);
        }
        public List <IRawElementProviderSimple> GetSelection(object selectedObj)
        {
            if (this._dataChildren == null)
            {
                this.GetChildren();
            }
            List <IRawElementProviderSimple> list = new List <IRawElementProviderSimple>();

            if (this._dataChildren.ContainsKey(selectedObj))
            {
                DesignerItemAutomationPeer itemAutomationPeer = this._dataChildren[selectedObj] as DesignerItemAutomationPeer;
                if (itemAutomationPeer != null)
                {
                    list.Add(itemAutomationPeer.ProviderFromPeer((AutomationPeer)itemAutomationPeer));
                }
            }
            else
            {
                foreach (DictionaryEntry dictionaryEntry in this._dataChildren)
                {
                    DesignerItemAutomationPeer itemAutomationPeer = dictionaryEntry.Value as DesignerItemAutomationPeer;
                    if (itemAutomationPeer != null)
                    {
                        list.AddRange((IEnumerable <IRawElementProviderSimple>)itemAutomationPeer.GetSelection(selectedObj));
                    }
                }
            }
            return(list);
        }
예제 #5
0
        private void OnSelectionChanged(Selection newSelection)
        {
            if (this._fromContext)
            {
                return;
            }
            List <DesignerItemAutomationPeer> list = new List <DesignerItemAutomationPeer>((IEnumerable <DesignerItemAutomationPeer>) this.GetSelectedAutomationPeers(newSelection));

            if (list.Count == 1)
            {
                DesignerItemAutomationPeer itemAutomationPeer = list[0];
                if (itemAutomationPeer != null)
                {
                    itemAutomationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
                    itemAutomationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected);
                }
            }
            else
            {
                foreach (DesignerItemAutomationPeer itemAutomationPeer in this._oldSelectionList)
                {
                    if (!list.Contains(itemAutomationPeer))
                    {
                        itemAutomationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
                        itemAutomationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection);
                    }
                }
                foreach (DesignerItemAutomationPeer itemAutomationPeer in list)
                {
                    if (!this._oldSelectionList.Contains(itemAutomationPeer))
                    {
                        itemAutomationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
                        itemAutomationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection);
                    }
                }
            }
            this._oldSelectionList = list;
        }
예제 #6
0
        private void PopulateDataChildren()
        {
            Hashtable hashtable = this._dataChildren;

            if (this.ModelService == null)
            {
                return;
            }
            ModelItem root = this.ModelService.Root;

            if (root == null)
            {
                return;
            }
            this._dataChildren = new Hashtable();
            Canvas canvas = this._owner.Child as Canvas;

            if (canvas != null && canvas.Children != null)
            {
                foreach (object key in canvas.Children)
                {
                    Image owner = key as Image;
                    if (owner != null)
                    {
                        this._dataChildren.Add(key, (object)new ImageAutomationPeer(owner));
                    }
                }
            }
            DesignerItemAutomationPeer itemAutomationPeer = (hashtable == null ? (DesignerItemAutomationPeer)null : (DesignerItemAutomationPeer)hashtable[(object)root]) ?? new DesignerItemAutomationPeer(root, this);

            if (this._dataChildren[(object)root] != null)
            {
                return;
            }
            this._dataChildren.Add((object)root, (object)itemAutomationPeer);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (this._disposed)
     {
         return;
     }
     if (disposing && this._dataChildren != null)
     {
         foreach (DictionaryEntry dictionaryEntry in this._dataChildren)
         {
             DesignerItemAutomationPeer itemAutomationPeer = dictionaryEntry.Value as DesignerItemAutomationPeer;
             if (itemAutomationPeer != null)
             {
                 itemAutomationPeer.Dispose();
             }
         }
     }
     this._item         = (ModelItem)null;
     this._view         = (DesignerView)null;
     this._dataChildren = (Hashtable)null;
     this._viewPeer     = (DesignerViewAutomationPeer)null;
     this._modelService = (ModelService)null;
     this._disposed     = true;
 }
        private void PopulateDataChildren(List <AutomationPeer> list)
        {
            Hashtable        hashtable = this._dataChildren;
            List <ModelItem> list1     = new List <ModelItem>(this.GetChildren(this._item));

            this._dataChildren = new Hashtable();
            foreach (ModelItem modelItem in list1)
            {
                DesignerItemAutomationPeer itemAutomationPeer = (hashtable == null ? (DesignerItemAutomationPeer)null : (DesignerItemAutomationPeer)hashtable[(object)modelItem]) ?? new DesignerItemAutomationPeer(modelItem, this._viewPeer);
                if (this._dataChildren[(object)modelItem] == null)
                {
                    this._dataChildren.Add((object)modelItem, (object)itemAutomationPeer);
                }
            }
            if (list1 == null)
            {
                return;
            }
            for (int index1 = list1.Count - 1; index1 >= 0; --index1)
            {
                object index2 = (object)list1[index1];
                list.Add(this._dataChildren[index2] as AutomationPeer);
            }
        }
        protected override Point GetClickablePointCore()
        {
            if (this._item.Parent == null && this._item != this._item.Root && (this.ModelService != null && this._item.Name != null))
            {
                ModelItem root = this.ModelService.Root;
                if (root != null)
                {
                    ModelItem modelItem = this.ModelService.FromName(root, this._item.Name, StringComparison.OrdinalIgnoreCase);
                    if (modelItem != null)
                    {
                        this._item = modelItem;
                    }
                }
            }
            ViewItem  viewItem     = this.ViewItem;
            UIElement uiElement    = (UIElement)this._view;
            ViewItem  ancestorView = this.ModelService == null || this.ModelService.Root == null ? (ViewItem)null : this.ModelService.Root.View;

            if (uiElement == null || viewItem == (ViewItem)null || PresentationSource.FromVisual((Visual)uiElement) == null)
            {
                return(new Point(0.0, 0.0));
            }
            Rect      selectionFrameBounds = viewItem.SelectionFrameBounds;
            double    width  = selectionFrameBounds.Width;
            double    height = selectionFrameBounds.Height;
            double    num1   = 2.0;
            int       num2   = 0;
            Point     point1 = new Point();
            Transform transformToDesignerView = TransformUtil.GetSelectionFrameTransformToDesignerView(this._item.Context, viewItem);
            Transform transformToParentView   = TransformUtil.GetSelectionFrameTransformToParentView(viewItem, ancestorView);

            while (num1 <= width || num1 <= height)
            {
                int    num3 = 1;
                double x    = width / num1;
                for (; (double)num3 < num1; ++num3)
                {
                    int    num4 = 1;
                    double y    = height / num1;
                    for (; (double)num4 < num1; ++num4)
                    {
                        if (num3 % 2 != 0 || num4 % 2 != 0)
                        {
                            if (++num2 > 1000)
                            {
                                return(new Point());
                            }
                            Point         point2        = transformToDesignerView.Transform(new Point(x, y));
                            HitTestResult hitTestResult = HitTestHelper.HitTest((Visual)uiElement, point2, false, (HitTestFilterCallback)null);
                            if (hitTestResult != null && hitTestResult.VisualHit is DesignerView.OpaqueElement)
                            {
                                Point             point3            = transformToParentView.Transform(new Point(x, y));
                                ViewHitTestResult viewHitTestResult = ancestorView.HitTest((ViewHitTestFilterCallback)null, (ViewHitTestResultCallback)null, (HitTestParameters) new PointHitTestParameters(point3));
                                if (viewHitTestResult != null && viewHitTestResult.ViewHit != (ViewItem)null)
                                {
                                    ViewItem viewHit = viewHitTestResult.ViewHit;
                                    bool     flag1   = false;
                                    if (viewItem != viewHit)
                                    {
                                        flag1 = DesignerItemAutomationPeer.IsPartOfTemplate(viewItem, viewHitTestResult.ViewHit);
                                    }
                                    bool flag2 = false;
                                    if (viewItem.ItemType.IsSubclassOf(typeof(UserControl)))
                                    {
                                        flag2 = viewHitTestResult.ViewHit.IsDescendantOf(viewItem);
                                    }
                                    if (viewItem == viewHitTestResult.ViewHit || flag1 || flag2)
                                    {
                                        return(ancestorView.PointToScreen(point3));
                                    }
                                }
                            }
                        }
                        y += height / num1;
                    }
                    x += width / num1;
                }
                num1 *= 2.0;
            }
            return(point1);
        }