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


C# Button.SetWidth方法代码示例

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


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

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            var mLayout = new FrameLayout(this);

            surface = UrhoSurface.CreateSurface(this, typeof(MySample));
            //surface.Background.SetAlpha(10);

            TextView txtView = new TextView(this);
            txtView.SetBackgroundColor(Color.Violet);
            txtView.SetWidth(10);
            txtView.SetHeight(10);

            txtView.Text = "HAHAH";
            //txtView.Text = surface.Background.ToString();
            Button btn = new Button(this);
            btn.SetBackgroundColor(Color.Transparent);
            btn.Text = "Button";
            btn.SetHeight(100);
            btn.SetWidth(100);
            btn.SetX(30);
            btn.SetY(30);
            btn.TextAlignment = TextAlignment.Center;
            mLayout.AddView(txtView);
            mLayout.AddView(btn);
            mLayout.AddView(surface);
            SetContentView(mLayout);
        }
开发者ID:ZENG-Yuhao,项目名称:Xamarin-CrossPlatform,代码行数:28,代码来源:GameActivity.cs

示例2: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			//SetContentView (Resource.Layout.SubCat);

			string mainCat = Intent.GetStringExtra ("mainCat") ?? "Subcategory";
			this.Title = mainCat;

			var layout = new LinearLayout(this)
			{
				Orientation = Orientation.Vertical,
				LayoutParameters =
					new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
			};
				
			for (int i = 0; i < 10; i++) {
				Button btn = new Button (this);
				btn.Text = i.ToString ();
				btn.SetWidth(50);
				layout.AddView (btn);
			}
			SetContentView (layout);
		}
开发者ID:sesurb,项目名称:InfoStash,代码行数:23,代码来源:SubCatActivity.cs

示例3: OnInitialize

    protected override void OnInitialize()
    {
        Vector2 winSize = new Vector3( 312.0f, 265.0f );
        maxSize = winSize;
        minSize = winSize;        

        autoRepaintOnSceneChange = true;

        m_root = new Control();
        m_root.SetSize( 100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage );
        m_root.AddDecorator( new StackContent() );

        AddChild( m_root );

        // Input object field
        m_original = new ObjectField( typeof( GameObject ), true, null, "Original" );
        m_original.SetHeight( 26.0f, Control.MetricsUnits.Pixel );
        m_original.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_original.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_original );

        // Rotation pivot point
        m_pivot = new Vector3Field( Vector3.zero, "Pivot:" );
        m_pivot.SetHeight( 40.0f, Control.MetricsUnits.Pixel );
        m_pivot.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_pivot.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_pivot );

        // Transform control
        m_transform = new TransformControl();
        m_transform.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_transform.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_transform );

        // Count field
        m_count = new IntField( 1, "Duplicate Count:" );
        m_count.SetHeight( 26.0f, Control.MetricsUnits.Pixel );
        m_count.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_count.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_count );

        // Space field
        m_space = new EnumDropdown( Space.World, "Space:" );
        m_space.SetHeight( 26.0f, Control.MetricsUnits.Pixel );
        m_space.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_space.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_space );

        // Duplicate button
        m_duplicate = new Button( "Duplicate" );
        m_duplicate.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_duplicate.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_duplicate.Enabled = false;
        m_root.AddChild( m_duplicate );

        // Events
        m_original.ValueChange += m_original_ValueChange;
        m_count.ValueChange += m_count_ValueChange;
        m_duplicate.Clicked += m_duplicate_Clicked;

        SceneView.onSceneGUIDelegate += SceneViewGUI;
    }
开发者ID:ChelseaLing,项目名称:UForms,代码行数:62,代码来源:DuplicateSpecial.cs

示例4: createUI

        private void createUI(List<MessageDB> message, List<UserDB> contact, string nameTitle, bool clear = false)
        {
            message.Reverse ();
            contact.Reverse ();
            int m = 0;
            string messager = "";
            bool dd = false;
            if (message != null && contact != null) {

                if (clear == false)
                    RunOnUiThread (() => listWrapper.RemoveAllViewsInLayout ());
                string othername = string.Empty;
                for (int i = 0; i < contact.Count; ++i) {
                    if (string.IsNullOrEmpty (nameTitle))
                        othername = contact [i].FirstName + " " + contact [i].LastName;
                    else
                        othername = nameTitle;
                    if (isMe != othername) {
                        RunOnUiThread (delegate {
                            Header.headertext = othername;
                            Header.fontsize = 36f;
                            ImageHelper.fontSizeInfo (header.Context);
                            header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
                            header.Text = Header.headertext;
                        });
                        break;
                    }
                }

                if (contact.Count > 1) {
                    string toReturn = "";
                    List<UserDB> sortedList = new List<UserDB> ();
                    sortedList = contact.OrderBy (s => s.LastName).OrderBy (s => s.FirstName).ToList ();
                    foreach (UserDB eachItem in sortedList)
                        toReturn += string.Format ("{0} {1}, ", eachItem.FirstName, eachItem.LastName);
                    int last = toReturn.LastIndexOf (", ");
                    toReturn = toReturn.Remove (last);
                    RunOnUiThread (delegate {
                        using (LinearLayout btnlayout = new LinearLayout (context)) {
                            btnlayout.Orientation = Android.Widget.Orientation.Vertical;
                            btnlayout.SetGravity (GravityFlags.Center);
                            btnlayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
                            btnlayout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context));

                            using (TextView name = new TextView(context)) {
                                name.Text = toReturn;
                                name.SetTextSize (Android.Util.ComplexUnitType.Dip, 18f);
                                name.SetTextColor (Color.Black);
                                btnlayout.AddView (name);
                            }

                            using (Button showAll = new Button (context)) {
                                showAll.Gravity = GravityFlags.CenterVertical;
                                showAll.Text = Application.Context.Resources.GetString (Resource.String.messageShowAllInConversation);
                                showAll.Click += (object sender, EventArgs e) => {
                                    showParticipants (sender, e, contact); };
                                showAll.SetWidth ((int)ImageHelper.convertDpToPixel (180f, context));
                                showAll.SetHeight ((int)ImageHelper.convertDpToPixel (30f, context));
                                showAll.SetBackgroundResource (Resource.Drawable.button);
                                btnlayout.AddView (showAll);
                            }
                            listWrapper.AddView (btnlayout);
                        }
                    });
                }

                if (getGuid != null)
                    getGuid.Clear ();

                RunOnUiThread (delegate {
                    foreach (MessageDB messages in message) {
                        string name = contact [m].FirstName + " " + contact [m].LastName;

                        ImageView random = null;
                        LinearLayout layout = new LinearLayout (context);
                        layout.Orientation = Android.Widget.Orientation.Horizontal;
                        layout.SetGravity (GravityFlags.CenterVertical);
                        layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context));
                        LinearLayout layout2 = new LinearLayout (context);
                        layout2.Orientation = Orientation.Vertical;
                        layout2.SetGravity (GravityFlags.Center);
                        if (name == isMe)
                            layout.AddView (contactUserInterface (messages, contact [m], true));
                        else
                            layout.AddView (contactUserInterface (messages, contact [m], false));

                        /*ImageView profilepic = new ImageView (context);
                        profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context));

                        if (contact == null)
                            profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage));
                        else {
                            profilepic.Tag = new Java.Lang.String ("profilepic_" + contact [m].AccountID);
                            profilepic.SetImageResource (Resource.Drawable.defaultuserimage);
                            layout.AddView (profilepic);
                            if (contact [m].Picture.Length == 0 && contact [m].HasProfileImage)
                                getGuid.Add (contact [m].AccountID);
                            else {
                                if (contact [m].Picture.Length > 0)
                                    LoadUserImage (contact [m], profilepic);
//.........这里部分代码省略.........
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:101,代码来源:MessageReceivedActivityUI.cs

示例5: GetSampleContent

		public override View GetSampleContent (Android.Content.Context con)
		{
			
			dlgAlert = new AlertDialog.Builder(con);

			dlgAlert.SetTitle("Results");
			dlgAlert.SetPositiveButton("OK", (object sender, DialogClickEventArgs e) => 
				{
				});
			dlgAlert.SetCancelable(true);

			Title.Add ("Software");
			Title.Add ("Banking");
			Title.Add ("Media");
			Title.Add ("Medical");
			spinners = new Spinner(con);
			spinners.DropDownWidth = 500;
			spinners.SetBackgroundColor(Color.Gray);

			ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
				(con, Android.Resource.Layout.SimpleSpinnerItem, Experience);
			dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
			spinners.Adapter = dataAdapter;

			Country.Add ("UAE");
			Country.Add ("Uruguay");
			Country.Add ("United States");
			Country.Add ("United Kingdom");
			Country.Add ("Ukraine");

			Experience.Add ("1");
			Experience.Add ("2");

			autoComplete1 = new SfAutoComplete(con);
			autoComplete2 = new SfAutoComplete(con);

			text1s = new TextView(con);
			text2s = new TextView(con);
			text3s = new TextView(con);
			text4s = new TextView(con);
			text6s = new TextView(con);

			text11 = new TextView(con);
			text22 = new TextView(con);
			text33 = new TextView(con);
			text44 = new TextView(con);
			text55 = new TextView(con);
			text66 = new TextView(con);
			text77 = new TextView(con);
			text88 = new TextView(con);

			buttons = new Button(con);
			buttons.SetWidth(ActionBar.LayoutParams.MatchParent);
			buttons.SetHeight(40);
			buttons.Text = "Search";
			buttons.SetTextColor(Color.White);
			buttons.SetBackgroundColor(Color.Gray);
			buttons.Click += (object sender, EventArgs e) => {
				GetResult();
				//dlgAlert.SetMessage(count + " Jobs Found");
				dlgAlert.SetMessage (cc + " Jobs Found");
				dlgAlert.Create ().Show ();
			};
			text11.SetHeight(10);
			text22.SetHeight(30);
			text33.SetHeight(10);
			text44.SetHeight(30);
			text55.SetHeight(10);
			text66.SetHeight(30);
			text77.SetHeight(10);
			text88.SetHeight(30);

			text1s.Text = "Job Search";
			text1s.TextSize = 30;
			text1s.Typeface = Typeface.DefaultBold;
			text2s.Text = "Country";
			text2s.TextSize = 16;
			text3s.Text = "Job Field";
			text3s.TextSize = 16;
			text4s.Text = "Experience";
			text4s.TextSize = 16;
			text6s.SetHeight(40);

			ArrayAdapter<String> adapters = new ArrayAdapter<String>(con,
				Android.Resource.Layout.SimpleListItem1, new Countrylist().Country);
			autoComplete1.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 60);
			autoComplete1.SetAutoCompleteSource(adapters);
			autoComplete1.SuggestionMode = SuggestionMode.StartsWith;
			autoComplete1.MaximumDropDownHeight = 200;
			autoComplete1.Watermark = "Enter a country name";

			ArrayAdapter<String> adapters1 = new ArrayAdapter<String>(con,
				Android.Resource.Layout.SimpleListItem1, Title);
			autoComplete2.SetAutoCompleteSource(adapters1);
			autoComplete2.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 60);
			autoComplete2.SuggestionMode = SuggestionMode.Contains;
			autoComplete2.MaximumDropDownHeight = 200;
			autoComplete2.Watermark = "Starts with ’S’, ‘M’ or ‘B’";

			ArrayAdapter<String> adapters2 = new ArrayAdapter<String>(con,
//.........这里部分代码省略.........
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:101,代码来源:AutoComplete.cs

示例6: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.Conversations);

            ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewUserHeader);
            TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader);
            RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1);
            ImageHelper.setupTopPanel (btns, header, relLayout, header.Context);
            context = header.Context;
            Header.headertext = Application.Context.Resources.GetString (Resource.String.converseMainTitle);
            Header.fontsize = 36f;
            ImageHelper.fontSizeInfo (header.Context);
            header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
            header.Text = Header.headertext;

            isMe = AndroidData.CurrentUser.FirstName + " " + AndroidData.CurrentUser.LastName;
            mmg = wowZapp.LaffOutOut.Singleton.mmg;
            dbm = wowZapp.LaffOutOut.Singleton.dbm;
            contentPackItems = new Dictionary<int,ContentPackItem> ();
            voiceFiles = new Dictionary<int,string> ();
            pollingSteps = new Dictionary<int,PollingStep> ();
            contacts = new Dictionary<Guid,ContactDB> ();

            mmg.MessageSendConfirmCompleted += MessageManager_MessageSendConfirmCompleted;
            wowZapp.LaffOutOut.Singleton.ReceivedMessages += AppDelegate_ReceivedMessages;

            ImageButton btnAdd = FindViewById<ImageButton> (Resource.Id.btnAdd);
            btnAdd.Tag = 2;
            ImageButton btnHome = FindViewById<ImageButton> (Resource.Id.btnHome);
            btnHome.Tag = 1;
            ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack);
            btnBack.Tag = 0;
            LinearLayout bottom = FindViewById<LinearLayout> (Resource.Id.bottomHolder);
            ImageButton[] buttons = new ImageButton[3];
            buttons [0] = btnBack;
            buttons [1] = btnHome;
            buttons [2] = btnAdd;
            ImageHelper.setupButtonsPosition (buttons, bottom, context);

            if (ConversationsUtil.userFrom != null) {
                UserDB lastFrom = ConversationInfo.GetSenderOfOldestMessage ();
                if (lastFrom == null)
                    lastFrom = ConversationInfo.GetAllConversationParticipants () [0];
                Header.headertext = ConversationInfo.GetConversationPartipantsNameTitle ();
                Header.fontsize = 36f;
                ImageHelper.fontSizeInfo (header.Context);
                header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
                header.Text = Header.headertext;
                LinearLayout ll4 = FindViewById<LinearLayout> (Resource.Id.linearLayout4);
                btnAdd.Visibility = ViewStates.Invisible;
                btnBack.Visibility = ViewStates.Invisible;
                Button btnAll = new Button (context);
                Rect rect = new Rect ();
                btnHome.GetDrawingRect (rect);
                int xLeft = rect.Left;
                int yTop = rect.Top;
                btnAll.Visibility = ViewStates.Invisible;
                btnAll.SetWidth (400);
                btnAll.SetHeight (200);
                btnAll.Gravity = GravityFlags.CenterVertical;
                btnAll.Layout (xLeft, yTop, 400, 200);
                btnAll.SetPadding (30, 20, 30, 20);
                btnAll.SetTextColor (Color.Black);
                btnAll.Text = Application.Context.Resources.GetString (Resource.String.converseShowAllBtn);
                btnAll.Click += new EventHandler (btnAll_Click);
                ll4.AddView (btnAll);
                ll4.Invalidate ();
            }

            RunOnUiThread (delegate {
                contacts = dbm.GetAllContactsForOwner (AndroidData.CurrentUser.AccountID.ToString ()).ToDictionary (s => s.ContactAccountID, s => s);
                GetMessageRows ();
            });
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:75,代码来源:ConversationActivity.cs

示例7: CreateMessagesUI

        private void CreateMessagesUI()
        {
            List<UserDB> participants = new List<UserDB>();
            bool moreThanOne = false, isCurrentMe = false;

            if (MessageConversations.clearView)
            {
                listWrapper.RemoveAllViewsInLayout();
                MessageConversations.clearView = false;
            }

            if (Contacts.SelectContactsUtil.selectedContacts.Count != 0)
                Contacts.SelectContactsUtil.selectedContacts.Clear();

            if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList.Count > 1)
            {
                moreThanOne = true;
                for (int m = 0; m < MessageConversations.currentConversationMessages[0].MessageRecipientDBList.Count; ++m)
                {
                    if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid != AndroidData.CurrentUser.AccountID.ToString())
                    {
                        UserDB userDetails = dbm.GetUserWithAccountID(MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid);
                        participants.Add(userDetails);
                        ContactDB contact = new ContactDB();
                        contact.ContactUser = new LOLAccountManagement.User();
                        contact.ContactUser.AccountID = userDetails.AccountID;
                        Contacts.SelectContactsUtil.selectedContacts.Add(contact);
                    } else
                    {
                        UserDB userDetails = UserDB.ConvertFromUser(AndroidData.CurrentUser);
                        participants.Add(userDetails);
                    }
                }
            }

            if (moreThanOne)
            {
                string toReturn = "";
                List<UserDB> sortedList = new List<UserDB>();
                sortedList = participants.OrderBy(s => s.LastName).OrderBy(s => s.FirstName).ToList();
                foreach (UserDB eachItem in sortedList)
                    toReturn += string.Format("{0} {1}, ", eachItem.FirstName, eachItem.LastName);
                int last = toReturn.LastIndexOf(", ");
                toReturn = toReturn.Remove(last);

                using (LinearLayout btnlayout = new LinearLayout (context))
                {
                    btnlayout.Orientation = Android.Widget.Orientation.Vertical;
                    btnlayout.SetGravity(GravityFlags.Center);
                    btnlayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
                    btnlayout.SetPadding((int)ImageHelper.convertDpToPixel(5f, context), 0, (int)ImageHelper.convertDpToPixel(5f, context), (int)ImageHelper.convertDpToPixel(10f, context));

                    using (TextView name = new TextView(context))
                    {
                        name.Text = toReturn;
                        name.SetTextSize(Android.Util.ComplexUnitType.Dip, 18f);
                        name.SetTextColor(Color.Black);
                        RunOnUiThread(() => btnlayout.AddView(name));
                    }

                    using (Button showAll = new Button (context))
                    {
                        showAll.Gravity = GravityFlags.CenterVertical;
                        showAll.Text = Application.Context.Resources.GetString(Resource.String.messageShowAllInConversation);
                        showAll.Click += (object sender, EventArgs e) => {
                            showParticipants(sender, e, participants); };
                        showAll.SetWidth((int)ImageHelper.convertDpToPixel(180f, context));
                        showAll.SetHeight((int)ImageHelper.convertDpToPixel(30f, context));
                        showAll.SetBackgroundResource(Resource.Drawable.button);
                        RunOnUiThread(() => btnlayout.AddView(showAll));
                    }
                    RunOnUiThread(() => listWrapper.AddView(btnlayout));
                }
            }
            myView = null;
            LayoutInflater factory = LayoutInflater.From(this);

            foreach (MessageDB message in MessageConversations.currentConversationMessages)
            {
                if (message != null)
                {
                    if (!moreThanOne)
                        myView = factory.Inflate(Resource.Layout.lstConversation, null);
                    else
                        myView = factory.Inflate(Resource.Layout.lstConversationMulti, null);

                    isCurrentMe = message.FromAccountID != AndroidData.CurrentUser.AccountID ? false : true;
                    LinearLayout shell = new LinearLayout(context);

                    shell.Orientation = Orientation.Horizontal;
                    shell.SetGravity(GravityFlags.CenterVertical);
                    shell.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
                    shell.SetPadding(0, 0, 0, (int)ImageHelper.convertDpToPixel(5f, context));
                    RunOnUiThread(() => shell.AddView(myView));

                    UserDB whoAmI = new UserDB();
                    whoAmI = message.FromAccountID != AndroidData.CurrentUser.AccountID ? dbm.GetUserWithAccountID(message.FromAccountGuid) : UserDB.ConvertFromUser(AndroidData.CurrentUser);

                    ImageView userImage = shell.FindViewById<ImageView>(Resource.Id.imgProfile1);
                    if (Contacts.ContactsUtil.contactFilenames.Contains(message.FromAccountGuid))
//.........这里部分代码省略.........
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:101,代码来源:MessageListUI.cs


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