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


C# Button.Layout方法代码示例

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


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

示例1: FetchForm

        public static void FetchForm(AbsoluteLayout Parent, System.Xml.Linq.XNode Nodes)
        {
            int cIndex = 0;
            int TabIndexes = ((System.Xml.Linq.XElement) Nodes).Elements().Count();
            foreach(XElement C in ((System.Xml.Linq.XElement) Nodes).Elements()) {
                if (C.Name == "Object") {
                    cIndex++;
                    if (true) {
                        if (C.Attribute("type").Value.StartsWith("System.Windows.Forms.PictureBox")) {
                            var CP = new Image();
                            foreach (XElement V in C.Elements()) {
                                if (V.Name == "Property") {
                                    switch (V.Attribute("name").Value) {
                                        case "Location":
                                            CP.ORect = new Rectangle(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)), CP.ORect.Width, CP.ORect.Height);
                                            CP.Layout(new Rectangle(
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY,
                                                CP.Width,
                                                CP.Height));
                                            Point pt = new Point(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY);
                                            break;
                                        case "Size":
                                            CP.ORect = new Rectangle(CP.ORect.Left, CP.ORect.Top, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)));
                                            CP.Layout(new Rectangle(CP.X, CP.Y, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX, Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY));
                                            break;
                                        case "SizeMode":
                                            if (V.Value == "StretchImage") {
                                                CP.Aspect = Aspect.Fill ;
                                            } else if (V.Value == "Zoom") {
                                                CP.Aspect = Aspect.AspectFill;
                                            } else if (V.Value == "Normal") {
                                                CP.Aspect = Aspect.AspectFit;
                                            }
                                            break;
                                        case "Image":
                                            string IMGData = String.Concat(V.Value);
                                            byte[] B = System.Convert.FromBase64String(IMGData);
                                            CP.Source = ImageSource.FromStream(() => new System.IO.MemoryStream(B));
                                            break;
                                        case "BackColor":
                                            CP.BackgroundColor = ColorExtensions.GetXColor(String.Concat(V.Nodes()));
                                            break;
                                        case "Tag":
                                            CP.ClassId = String.Concat(V.Nodes());
                                            break;
                                    }
                                }
                            }
                            CP.Aspect = Aspect.AspectFill;
                            Parent.Children.Add(CP, new Rectangle(CP.X, CP.Y, CP.Width, CP.Height), AbsoluteLayoutFlags.None);
                            Parent.LowerChild(CP);
                        } else if (C.Attribute("type").Value.StartsWith("System.Windows.Forms.Button")) {
                            var CP = new Button ();
                            foreach(XElement V in C.Elements()) {
                                if (V.Name == "Property") {
                                    switch (V.Attribute("name").Value) {
                                        case "Location":
                                            CP.ORect = new Rectangle(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)), CP.ORect.Width, CP.ORect.Height);
                                            CP.Layout(new Rectangle(
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY,
                                                CP.Width,
                                                CP.Height));
                                            Point pt = new Point(Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX,
                                                Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY);
                                            break;
                                        case "Size":
                                            CP.ORect = new Rectangle(CP.ORect.Left, CP.ORect.Top, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))), Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)));
                                            CP.Layout(new Rectangle(CP.X, CP.Y, Convert.ToInt32(String.Concat(V.Nodes()).Substring(0, String.Concat(V.Nodes()).IndexOf(","))) * App.ScaleFactorX, Convert.ToInt32(String.Concat(V.Nodes()).Substring(String.Concat(V.Nodes()).IndexOf(",") + 1)) * App.ScaleFactorY));
                                            break;
                                        case "Image":
                                            string IMGData = String.Concat(V.Value);
                                            byte[] B = System.Convert.FromBase64String(IMGData);
                                            var TempFile = System.IO.Path.GetTempFileName();
                                            System.IO.File.WriteAllBytes(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + System.IO.Path.GetFileName(TempFile), B);
                                            CP.Image = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + System.IO.Path.GetFileName(TempFile);
                                            break;
                                        case "ForeColor":
                                            CP.TextColor = ColorExtensions.GetXColor(String.Concat(V.Nodes()));
                                            break;
                                        case "BackColor":
                                            CP.BackgroundColor = ColorExtensions.GetXColor(String.Concat(V.Nodes()));
                                            break;
                                        case "Caption":
                                        case "Text":
                                            CP.Text = String.Concat(V.Nodes()).Replace("##", "\r\n");
                                            break;
                                        case "Tag":
                                            CP.ClassId = String.Concat(V.Nodes());
                                            break;
                                        case "Font":
                                            string[] UFont = String.Concat(V.Nodes()).Replace("style=", "").Replace("Microsoft Sans Serif", "Helvetica").Split(new[] {
                                                ","
                                            }, StringSplitOptions.RemoveEmptyEntries);
                                            CP.FontFamily = UFont[0];
                                            CP.FontSize = float.Parse(UFont[1].Replace("pt", ""));
                                            if (Array.IndexOf(UFont, " Bold") > -1) {
                                                CP.FontAttributes = CP.FontAttributes | FontAttributes.Bold;
//.........这里部分代码省略.........
开发者ID:MuffPotter,项目名称:XamarinDesigner,代码行数:101,代码来源:Parser.cs

示例2: 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


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