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


C# Label.SetAlignment方法代码示例

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


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

示例1: Main

    public static void Main(string[] args)
    {
        if(args.Length != 1) {
            Console.WriteLine("Usage: gtkHelloWorld num, where num is 1, 2, or 3");
            return(1);
        }

        int which = Convert.ToInt32(args[0]);
        var window = new Window("packingdemo");
        window.DeleteEvent += Delete_Event;
        window.BorderWidth = 10;

        var box1 = new VBox(false, 0);

        switch(which) {
            case 1:
                var label = new Label("gtk_hbox_new(FALSE, 0);");
                var box2 = new HBox(false, 0);
                label.SetAlignment(0, 0);
                box1.PackStart(label, false, false, 0);
                label.Show();

                box2 = MakeBox(false, 0, false, false, 0);
                box1.PackStart(box2, false, false, 0);
                box2.Show();

                box2 = MakeBox(false, 0, true, false, 0);
                box1.PackStart(box2, false, false, 0);
                box2.Show();

                box2 = MakeBox(false, 0, true, true, 0);
                box1.PackStart(box2, false, false, 0);
                box2.Show();

                var separator = new HSeparator();

                box1.PackStart(separator, false, true, 5);
                separator.Show();

                box1 = new VBox(true, 0);
                label = new Label("gtk_hbox_new(TRUE, 0);");
                label.SetAlignment(0, 0);
                box1.PackStart(label, false, false, 0);
                label.Show();

                box2 = MakeBox(true, 0, true, true, 0);
                box1.PackStart(box2, false, false, 0);
                box2.Show();

                box2 = MakeBox(true, 0, true, true, 0);
                box1.PackStart(box2, false, false, 0);
                box2.Show();

                separator = new HSeparator();

                box1.PackStart(separator, false, true, 5);
                separator.Show();
                break;
            case 2:
                break;
        }
    }
开发者ID:rnowley,项目名称:buildcs,代码行数:62,代码来源:gtkHelloWorld.cs

示例2: CreateWidget

    Widget CreateWidget(string optName, string type, string defolt, string desc, bool required)
    {
        if (type == "bool") {
            CheckButton button = new CheckButton (optName);
            button.TooltipText = desc;
            if (defolt.ToLower () == "true")
                button.Active = true;
            return button;
        } else if (type == "string" || type == "address" || type == "port" || type == "integer" || type == "raw" || type == "path" || type == "enum") {
            Entry textbox = new Entry (defolt);
            textbox.WidthRequest = 150;
            textbox.TooltipText = optName;
            HBox box = new HBox ();
            Label optNameLabel = new Label (optName + " *");
            optNameLabel.TooltipText = desc;
            optNameLabel.SetAlignment (0f, 0.5f);
            optNameLabel.WidthRequest = 200;
            box.PackStart (optNameLabel, false, false, 0);
            box.PackStart (textbox, false, false, 10);

            return box;
        } else {
            MessageDialog md = new MessageDialog (this,
                                   DialogFlags.DestroyWithParent,
                                   MessageType.Warning,
                                   ButtonsType.Close, "Don't know type: " + type + ". Please file a bug report with this information.");

            md.Run ();
            md.Destroy ();
            return null;
        }
    }
开发者ID:subTee,项目名称:metafang2,代码行数:32,代码来源:MainWindow.cs

示例3: CreatePropertyWidgets

    private void CreatePropertyWidgets(string title)
    {
        VBox box = new VBox();
        tooltips = new Tooltips();

        Label titleLabel = new Label();
        titleLabel.Xalign = 0;
        titleLabel.Xpad = 12;
        titleLabel.Ypad = 6;
        titleLabel.Markup = "<b>" + title + "</b>";
        box.PackStart(titleLabel, true, false, 0);

        // iterate over all fields and properties
        Type type = Object.GetType();
        fieldTable.Clear();
        List<Widget> editWidgets = new List<Widget>();
        foreach(FieldOrProperty field in FieldOrProperty.GetFieldsAndProperties(type)) {
            CustomSettingsWidgetAttribute customSettings = (CustomSettingsWidgetAttribute)
                field.GetCustomAttribute(typeof(CustomSettingsWidgetAttribute));
            if(customSettings != null) {
                Type customType = customSettings.Type;
                ICustomSettingsWidget customWidget = (ICustomSettingsWidget) CreateObject(customType);
                customWidget.Object = Object;
                customWidget.Field = field;
                editWidgets.Add(customWidget.Create(this));
                continue;
            }

            LispChildAttribute ChildAttrib = (LispChildAttribute)
                field.GetCustomAttribute(typeof(LispChildAttribute));
            if(ChildAttrib == null)
                continue;

            PropertyPropertiesAttribute propertyProperties = (PropertyPropertiesAttribute)
                field.GetCustomAttribute(typeof(PropertyPropertiesAttribute));

            if ((propertyProperties != null) && (propertyProperties.Hidden))
                continue;

            if(field.Type == typeof(string) || field.Type == typeof(float)
                || field.Type == typeof(int)) {
                Entry entry = new Entry();
                entry.Name = field.Name;
                object val = field.GetValue(Object);
                if(val != null)
                    entry.Text = val.ToString();
                fieldTable[field.Name] = field;
                entry.Changed += OnEntryChanged;
                editWidgets.Add(entry);
                AddTooltip(propertyProperties, entry);
            } else if(field.Type == typeof(bool)) {
                CheckButton checkButton = new CheckButton(field.Name);
                checkButton.Name = field.Name;
                checkButton.Active = (bool) field.GetValue(Object);
                fieldTable[field.Name] = field;
                checkButton.Toggled += OnCheckButtonToggled;
                editWidgets.Add(checkButton);
                AddTooltip(propertyProperties, checkButton);
            } else if(field.Type.IsEnum) {
                // Create a combobox containing all the names of enum values.
                ComboBox comboBox = new ComboBox(Enum.GetNames(field.Type));
                // Set the name of the box.
                comboBox.Name = field.Name;
                // FIXME: This will break if:
                //        1) the first enum isn't 0 and/or
                //        2) the vaules are not sequential (0, 1, 3, 4 wouldn't work)
                object val = field.GetValue(Object);
                if (val != null)
                    comboBox.Active = (int)val;
                fieldTable[field.Name] = field;
                comboBox.Changed += OnComboBoxChanged;
                editWidgets.Add(comboBox);
                // FIXME: Why doesn't this work for the ComboBox?
                AddTooltip(propertyProperties, comboBox);
            }

        }

        Table table = new Table((uint) editWidgets.Count, 2, false);
        table.ColumnSpacing = 6;
        table.RowSpacing = 6;
        table.BorderWidth = 12;
        for(uint i = 0; i < editWidgets.Count; ++i) {
            Widget widget = editWidgets[(int) i];
            if(widget is CheckButton) {
                table.Attach(widget, 0, 2, i, i+1,
                             AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0);
            } else {
                Label label = new Label(widget.Name + ":");
                label.SetAlignment(0, 1);
                table.Attach(label, 0, 1, i, i+1,
                             AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
                table.Attach(widget, 1, 2, i, i+1,
                             AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0);
            }
        }
        box.PackStart(table, true, true, 0);

        // TODO add a (!) image in front of the label (and hide/show it depending
        // if there was an error)
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:101,代码来源:PropertiesView.cs

示例4: OnSignupEvent

    private void OnSignupEvent( Hashtable form )
    {
        if( ((string)form[ "action" ]).Equals( "msg" ) )
        {
            new AlertDialog( this.MainWindow, AlertType.Info,
                             (string)form[ "title" ],
                             (string)form[ "msg" ] );
        }
        else
        {
            this.signupdata = form;

            Dialog dlg = new Dialog();
            dlg.Modal = true;
            dlg.Title = (string)form[ "title" ];
            dlg.SetSizeRequest( 500, -1 );

            HBox split = new HBox();
            dlg.VBox.Add( split );
            VBox left = new VBox( true, 0 );
            VBox right = new VBox( true, 0 );
            split.PackStart( left, false, false, 5 );
            split.PackEnd( right, true, true, 10 );

            NameValueCollection fields =
                (NameValueCollection)form[ "fields" ];
            Hashtable data = (Hashtable)form[ "data" ];

            foreach( string Key in fields.AllKeys )
            {
                Hashtable fd = (Hashtable)data[ Key ];

                string Name = Key.Substring( 0, 1 ).ToUpper() +
                              Key.Substring( 1 ) + ":";

                Label lbl = new Label( Name );
                lbl.SetAlignment( 0, (float)0.5 );
                left.PackStart( lbl, false, false, 5 );

                if( fields[ Key ].Equals( "TextEditView" ) )
                {
                    Entry ent = new Entry();
                    ent.Name = Key;
                    ent.ActivatesDefault = true;
                    if( fd[ "isPassword" ] != null )
                        ent.Visibility = false;
                    if( fd[ "value" ] != null )
                        ent.Text = (string)fd[ "value" ];
                    right.PackStart( ent, false, false, 5 );
                }
                else if( fields[ Key ].Equals( "PopupButtonView" ) )
                {
                    ComboBox cbox = ComboBox.NewText();
                    cbox.WrapWidth = 5;
                    cbox.Name = Key;
                    if( fd[ "menuItems" ] != null )
                    {
                        string menuItems = (string)fd[ "menuItems" ];
                        foreach( string Value in menuItems.Split( ',' ) )
                            cbox.AppendText( Value );
                        if( fd[ "value" ] != null &&
                            (string)fd[ "value" ] != String.Empty )
                        {
                            cbox.Active = Convert.ToInt32( fd[ "value" ] ) - 1;
                        }
                        else
                        {
                            cbox.Active = 0;
                        }
                    }
                    right.PackStart( cbox, false, false, 5 );
                }
                else if( fields[ Key ].Equals( "ComboControlView" ) )
                {
                    ComboBoxEntry cboxe = ComboBoxEntry.NewText();
                    cboxe.WrapWidth = 5;
                    cboxe.Name = Key;
                    if( fd[ "menuItems" ] != null )
                    {
                        string menuItems = (string)fd[ "menuItems" ];
                        foreach( string Value in menuItems.Split( ',' ) )
                            cboxe.AppendText( Value );
                    }
                    if( fd[ "value" ] != null )
                        ((Entry)cboxe.Child).Text = (string)fd[ "value" ];
                    right.PackStart( cboxe, false, false, 5 );
                }
                else if( fields[ Key ].Equals( "CheckboxView" ) )
                {
                    CheckButton cbtn = new CheckButton();
                    cbtn.Name = Key;
                    if( fd[ "value" ] != null &&
                        (string)fd[ "value" ] != String.Empty )
                    {
                        int v = Convert.ToInt32( (string)fd[ "value" ] );
                        cbtn.Active = v == 1;
                    }
                    right.PackStart( cbtn, false, false, 5 );
                }
            }
//.........这里部分代码省略.........
开发者ID:kidaa,项目名称:aur,代码行数:101,代码来源:SharpMusique.cs


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