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


C# Controls.ResumeLayout方法代码示例

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


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

示例1: CreateActorEditingControls


//.........这里部分代码省略.........
                }

                /* Set control properties */
                item.ControlType.GetProperty("Dock").SetValue(ctrl, DockStyle.Fill, null);
                item.ControlType.GetProperty("Tag").SetValue(ctrl, item, null);
                item.ControlType.GetProperty("Name").SetValue(ctrl, item.Usage.ToString(), null);

                /* ControlType-specific settings */
                if (item.ControlType == typeof(ComboBox))
                {
                    /* Set ComboBox */
                    item.ControlType.GetProperty("DropDownStyle").SetValue(ctrl, ComboBoxStyle.DropDownList, null);
                    item.ControlType.GetProperty("DisplayMember").SetValue(ctrl, "Description", null);

                    if (!individual && (item.Usage == Definition.Item.Usages.NextRoomBack || item.Usage == Definition.Item.Usages.NextRoomFront) && (tag is List<HeaderCommands.Rooms.RoomInfoClass>))
                    {
                        /* Item usage is room number in transition actor; get room listing from function tag */
                        item.Options = new List<Definition.Item.Option>();
                        foreach (HeaderCommands.Rooms.RoomInfoClass ric in (tag as List<HeaderCommands.Rooms.RoomInfoClass>))
                            item.Options.Add(new Definition.Item.Option() { Description = ric.Description, Value = ric.Number });
                    }

                    if (item.Options.Count > 0)
                    {
                        item.ControlType.GetProperty("DataSource").SetValue(ctrl, item.Options, null);
                        item.ControlType.GetProperty("SelectedItem").SetValue(ctrl, item.Options.Find(x => x.Value == (Convert.ToUInt64(val) & item.Mask)), null);
                        (ctrl as ComboBox).SelectedIndexChanged += new EventHandler((s, ex) =>
                        {
                            SetValueInActor(item, ac, ((Definition.Item.Option)((ComboBox)s).SelectedItem).Value);
                        });
                    }
                }
                else if (item.ControlType == typeof(CheckBox))
                {
                    /* Set CheckBox */
                    item.ControlType.GetProperty("Checked").SetValue(ctrl, Convert.ToBoolean(val), null);
                    item.ControlType.GetProperty("Text").SetValue(ctrl, item.Description, null);
                    tlpex.SetColumnSpan(ctrl as Control, 2);
                    (ctrl as CheckBox).CheckedChanged += new EventHandler((s, ex) =>
                    {
                        ChangeBitInActor(item, ac, item.Mask, ((CheckBox)s).Checked);
                    });
                }
                else
                {
                    /* Fallback */
                    if (item.ControlType.GetProperty("Text") != null)
                    {
                        string fstr = "{0}";
                        switch (item.DisplayStyle)
                        {
                            case Definition.Item.DisplayStyles.Hexadecimal: fstr = "0x{0:X}"; break;
                            case Definition.Item.DisplayStyles.Decimal: fstr = "{0:D}"; break;
                        }
                        item.ControlType.GetProperty("Text").SetValue(ctrl, string.Format(fstr, val), null);
                        (ctrl as Control).TextChanged += new EventHandler((s, ex) =>
                        {
                            object newval = Activator.CreateInstance(item.ValueType);
                            System.Reflection.MethodInfo mi = item.ValueType.GetMethod("Parse", new Type[] { typeof(string), typeof(System.Globalization.NumberStyles) });
                            if (mi != null)
                            {
                                /* Determine NumberStyle to use */
                                System.Globalization.NumberStyles ns =
                                    (item.DisplayStyle == Definition.Item.DisplayStyles.Hexadecimal ? System.Globalization.NumberStyles.HexNumber : System.Globalization.NumberStyles.Integer);

                                /* Hex number; is text long enough? */
                                if (ns == System.Globalization.NumberStyles.HexNumber && ((Control)s).Text.Length < 2) return;

                                /* Get value string, depending on NumberStyle */
                                string valstr = (ns == System.Globalization.NumberStyles.HexNumber ? ((Control)s).Text.Substring(2) : ((Control)s).Text);

                                /* Proper value string found? */
                                if (valstr != null && valstr != "")
                                {
                                    try
                                    {
                                        /* Invoke Parse function and get parsed value */
                                        newval = mi.Invoke(newval, new object[] { valstr, ns });

                                        /* Set new value in actor; if usage is ActorNumber, also do callback */
                                        SetValueInActor(item, ac, newval);
                                        if (item.Usage == Definition.Item.Usages.ActorNumber && numberchanged != null) numberchanged();
                                    }
                                    catch (TargetInvocationException tiex)
                                    {
                                        if (tiex.InnerException is FormatException)
                                        {
                                            /* Ignore; happens with ex. malformed hex numbers (i.e. "0xx0") */
                                        }
                                    }
                                }
                            }
                        });
                    }
                }
            }

            /* Done */
            tlpex.ResumeLayout();
        }
开发者ID:kskjer,项目名称:SceneNavi,代码行数:101,代码来源:XMLActorDefinitionReader.cs


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