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


C# Control.GetControl方法代码示例

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


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

示例1: Init


//.........这里部分代码省略.........
                        sideBar.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };

                    break;
                case "ContextMenu":
                    ContextMenu contextMenu = new ContextMenu(manager);
                    contextMenu.Init();

                    contextMenu.Name = Name;
                    contextMenu.Tag = this;
                    contextMenu.Passive = Passive;
                    contextMenu.Enabled = Enabled;

                    foreach (MenuItemEntry entry in Items)
                    {
                        MenuItem menuItem = new MenuItem(entry.Title);
                        menuItem.Enabled = entry.Enabled;

                        contextMenu.Items.Add(menuItem);
                    }

                    if (!string.IsNullOrEmpty(Parent))
                        contextMenu.Parent = parent.GetControl(Parent);
                    else
                        parent.Add(contextMenu);

                    break;

                case "ImageListBox":
                    ImageListBox listBox = new ImageListBox(manager);
                    listBox.Init();

                    SetProperties(listBox, parent, manager);

                    listBox.HideSelection = HideSelection;

                    if (!string.IsNullOrEmpty(ContextMenu))
                        listBox.ContextMenu = parent.GetControl(ContextMenu) as ContextMenu;

                    break;

                case "TechInfoButton":
                    TechInfoButton techInfo = new TechInfoButton(manager);
                    techInfo.Init();

                    SetProperties(techInfo, parent, manager);

                    if (!string.IsNullOrEmpty(TechName))
                        techInfo.Tech = Provider.GetTech(TechName);

                    break;
                case "PolicyButton":
                    PolicyButton policyButton = new PolicyButton(manager);
                    policyButton.Init();
开发者ID:mrommel,项目名称:MiRo.SimHexWorld,代码行数:66,代码来源:ControlItem.cs

示例2: SetProperties

        private void SetProperties(Control c, Control parent, Manager manager)
        {
            c.Name = Name;
            //c.Top = Top < 0 ? manager.GraphicsDevice.Viewport.Height + Top : Top;
            //c.Left = Left < 0 ? manager.GraphicsDevice.Viewport.Width + Left : Left;
            if (!string.IsNullOrEmpty(Parent))
            {
                c.Top = Top < 0 ? parent.GetControl(Parent).Height + Top : Top;
                c.Left = Left < 0 ? parent.GetControl(Parent).Width + Left : Left;
            }
            else
            {
                c.Top = Top < 0 ? parent.Height + Top : Top;
                c.Left = Left < 0 ? parent.Width + Left : Left;
            }

            c.Width = Width;
            c.Height = Height;

            c.StayOnBack = StayOnBack;
            c.StayOnTop = StayOnTop;
            c.Passive = Passive;
            c.Enabled = Enabled;

            if (TextColor != Color.Transparent)
                c.TextColor = TextColor;
            else
                c.TextColor = Color.White;

            if (BackColor != Color.Transparent)
                c.BackColor = BackColor;

            if (Color != Color.Transparent)
                c.Color = Color;

            c.Tag = this;
            c.Visible = Visible;

            if (!string.IsNullOrEmpty(ToolTip))
            {
                ToolTip = ToolTip.Trim();
                c.ToolTipType = typeof(EnhancedToolTip);
                c.ToolTip.Text = ToolTip;
                c.ToolTip.MaximumWidth = 240;
                c.ToolTip.MinimumWidth = 240;
                c.ToolTip.Height = ToolTip.Split(new char[] { '\n' }).Length * 20;
            }

            if (!string.IsNullOrEmpty(Parent))
                c.Parent = parent.GetControl(Parent);
            else
                parent.Add(c);
        }
开发者ID:mrommel,项目名称:MiRo.SimHexWorld,代码行数:53,代码来源:ControlItem.cs


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