当前位置: 首页>>代码示例>>C#>>正文


C# Visual.GetType方法代码示例

本文整理汇总了C#中Visual.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.GetType方法的具体用法?C# Visual.GetType怎么用?C# Visual.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Visual的用法示例。


在下文中一共展示了Visual.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDescendantByType

 public static Visual GetDescendantByType(Visual element, Type type)
 {
     if (element == null)
     {
         return null;
     }
     if (element.GetType() == type)
     {
         return element;
     }
     Visual descendantByType = null;
     if (element is FrameworkElement)
     {
         (element as FrameworkElement).ApplyTemplate();
     }
     for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
     {
         Visual child = VisualTreeHelper.GetChild(element, i) as Visual;
         descendantByType = GetDescendantByType(child, type);
         if (descendantByType != null)
         {
             return descendantByType;
         }
     }
     return descendantByType;
 }
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:26,代码来源:Tools.cs

示例2: GetDescendantByType

        public static Visual GetDescendantByType(Visual element, Type type)
        {
            if (element != null)
            {
                if (element.GetType() != type)
                {
                    Visual foundElement = null;
                    if (element is FrameworkElement)
                    {
                        (element as FrameworkElement).ApplyTemplate();
                    }

                    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
                    {
                        Visual visual = VisualTreeHelper.GetChild(element, i) as Visual;
                        foundElement = GetDescendantByType(visual, type);
                        if (foundElement != null)
                        {
                            break;
                        }
                    }

                    return foundElement;
                }

                return element;
            }

            return null;
        }
开发者ID:jkoplo,项目名称:Sentinel,代码行数:30,代码来源:ScrollingHelper.cs

示例3: GetDescendantByType

        private static Visual GetDescendantByType(Visual element, Type type)
        {
            if (element == null) return null;

            if (element.GetType() == type || element.GetType().IsSubclassOf(type)) return element;

            Visual foundElement = null;
            if (element is FrameworkElement)
                (element as FrameworkElement).ApplyTemplate();

            for (int i = 0;
                i < VisualTreeHelper.GetChildrenCount(element); i++)
            {
                Visual visual = VisualTreeHelper.GetChild(element, i) as Visual;
                foundElement = GetDescendantByType(visual, type);
                if (foundElement != null)
                    break;
            }

            return foundElement;
        }
开发者ID:habs57,项目名称:tablet-interaction,代码行数:21,代码来源:LoopingListBox.cs

示例4: PrintVisualTree

        public void PrintVisualTree(Visual v)
        {
            if (v == null)
                return;

            string name = null;

            increaseIndent();

            if (v is FrameworkElement)
                name = ((FrameworkElement)v).Name;

            print("Visual Type: " + v.GetType().ToString() + (name != null ? ", Name: " + name : ""));

            // recurse through the children
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(v); i++)
            {
                PrintVisualTree(VisualTreeHelper.GetChild(v, i) as Visual);
            }
            decreaseIndent();
        }
开发者ID:fednep,项目名称:UV-Outliner,代码行数:21,代码来源:VisualHelpers.cs

示例5: EventsListener

        public EventsListener(Visual visual)
        {
            EventsListener.current = this;
            this.visual = visual;

            Type type = visual.GetType();

            // Cannot unregister for events once we've registered, so keep the registration simple and only do it once.
            for (Type baseType = type; baseType != null; baseType = baseType.BaseType)
            {
                if (!registeredTypes.ContainsKey(baseType))
                {
                    registeredTypes[baseType] = baseType;

                    RoutedEvent[] routedEvents = EventManager.GetRoutedEventsForOwner(baseType);
                    if (routedEvents != null)
                    {
                        foreach (RoutedEvent routedEvent in routedEvents)
                            EventManager.RegisterClassHandler(baseType, routedEvent, new RoutedEventHandler(EventsListener.HandleEvent), true);
                    }
                }
            }
        }
开发者ID:noamkfir,项目名称:snoopwpf,代码行数:23,代码来源:EventsListener.cs

示例6: DumpVisual

        // ------------------------------------------------------------------
        //
        //  Basic UIElement/Visual Dump
        //
        // ------------------------------------------------------------------

        #region Basic UIElement/Visual Dump

        // ------------------------------------------------------------------
        // Dump content of Visual.
        // ------------------------------------------------------------------
        internal static void DumpVisual(XmlTextWriter writer, Visual visual, Visual parent)
        {
            if (visual is UIElement)
            {
                DumpUIElement(writer, (UIElement)visual, parent, false);
            }
            else
            {
                writer.WriteStartElement(visual.GetType().Name);

                // Dump visual bounds
                Rect bounds = visual.VisualContentBounds;
                if(!bounds.IsEmpty)
                {
                    DumpRect(writer, "ContentRect", bounds);
                }

                // Dump clip geometry
                Geometry clip = VisualTreeHelper.GetClip(visual);
                if (clip != null)
                {
                    DumpRect(writer, "Clip.Bounds", clip.Bounds);
                }

                // Dump transform relative to its parent
                GeneralTransform g = visual.TransformToAncestor(parent);
                Point point = new Point(0, 0);
                g.TryTransform(point, out point);
                if (point.X != 0 || point.Y != 0)
                {
                    DumpPoint(writer, "Position", point);
                }

                // Dump visual children
                DumpVisualChildren(writer, "Children", visual);
                
                writer.WriteEndElement();
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:50,代码来源:LayoutDump.cs

示例7: FindAllChildren

 private void FindAllChildren(Type T, Visual root, List<Visual> elementList)
 {
     if (root == null)
         return;
     if (T.Equals(root.GetType()))
     {
         elementList.Add(root);
         return;
     }
     for (int i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
     {
         Visual child = VisualTreeHelper.GetChild(root, i) as Visual;
         FindAllChildren(T, child, elementList);
     }
 }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:15,代码来源:GlobalSites.xaml.cs

示例8: GetDescendantByType

 public static Visual GetDescendantByType(Visual element, Type type, string name)
 {
     if (element == null) return null;
     if (element.GetType() == type)
     {
         FrameworkElement fe = element as FrameworkElement;
         if (fe != null)
         {
             if (fe.Name == name)
             {
                 return fe;
             }
         }
     }
     Visual foundElement = null;
     if (element is FrameworkElement)
         (element as FrameworkElement).ApplyTemplate();
     for (int i = 0;
         i < VisualTreeHelper.GetChildrenCount(element); i++)
     {
         Visual visual = VisualTreeHelper.GetChild(element, i) as Visual;
         foundElement = GetDescendantByType(visual, type, name);
         if (foundElement != null)
             break;
     }
     return foundElement;
 }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:27,代码来源:CAFTSetting.xaml.cs

示例9: GetCanvasZoom

        private double GetCanvasZoom(Visual referenceVisual)
        {
            if (referenceVisual.GetType() == typeof(Canvas))
            {
                return (referenceVisual as Canvas).LayoutTransform.Value.M11;
            }
            
            var parent = VisualTreeHelper.GetParent(referenceVisual) as Visual;

            if (parent.GetType() == typeof(Canvas))
            {
                return (parent as Canvas).LayoutTransform.Value.M11;
            }

            return 1;
        }
开发者ID:dbremner,项目名称:ScreenToGif,代码行数:16,代码来源:ResizingAdorner.cs


注:本文中的Visual.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。