コード例 #1
0
ファイル: ThemeManager.cs プロジェクト: zhamppx97/maui
        public static ESize GetTextBlockFormattedSize(this ELabel label)
        {
            var textPart = label.EdjeObject[ThemeConstants.Common.Parts.Text];

            if (textPart == null)
            {
                Log.Error("There is no elm.text part");
                return(new ESize(0, 0));
            }
            return(textPart.TextBlockFormattedSize);
        }
コード例 #2
0
ファイル: ThemeManager.cs プロジェクト: zhamppx97/maui
 public static double GetVerticalTextAlignment(this ELabel label)
 {
     return(label.GetVerticalTextAlignment(ThemeConstants.Common.Parts.Text));
 }
コード例 #3
0
        public ElmSharp.EvasObject GetContent(object data, string part)
        {
            var minimumHeight = PageHeight > 800 ? 96 : 76;

            if (part == "elm.swallow.content")
            {
                DataSource2  itemSource = (DataSource2)data;
                ElmSharp.Box mainBox    = new ElmSharp.Box(Forms.NativeParent);
                mainBox.BackgroundColor = Xamarin.Forms.Color.LightYellow.ToNative();
                mainBox.MinimumHeight   = minimumHeight;
                mainBox.IsHorizontal    = false;
                mainBox.SetAlignment(-1, -1);
                mainBox.Show();

                ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent);
                contentBox.MinimumHeight = minimumHeight;
                contentBox.IsHorizontal  = true;
                contentBox.SetAlignment(-1, -1);
                contentBox.Show();

                ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent);
                left.IsHorizontal = false;
                left.Show();
                left.SetWeight(4.0, 1);
                left.SetAlignment(-1, -1);
                contentBox.PackEnd(left);

                ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent);
                left.PackEnd(titleName);
                titleName.Show();
                titleName.Text         = $"<span font_size=34 font_style=italic color=#7F3300>   {itemSource.Name}</span>";
                titleName.MinimumWidth = 250;
                titleName.SetAlignment(-1, -1);

                ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent);
                left.PackEnd(titleCategory);
                titleCategory.Show();
                titleCategory.Text = $"<span align=center font_size=24 color=#008000>{itemSource.Category}</span>";
                titleCategory.SetAlignment(-1, -1);

                ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent);
                right.Show();
                right.MinimumWidth  = 96;
                right.MinimumHeight = minimumHeight;
                right.SetWeight(1, 1);
                right.SetAlignment(-1, 0);

                ElmSharp.Image image;

                if (itemSource.ImageFilename != "")
                {
                    image = new ElmSharp.Image(right);
                    image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + itemSource.ImageFilename + ".jpg");
                    image.SetAlignment(0.5, 0.5);
                    image.MinimumHeight = minimumHeight;
                    image.MinimumWidth  = minimumHeight;
                    image.Show();
                    right.PackEnd(image);
                }

                ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left);
                rec.MinimumHeight = 1;
                rec.MinimumWidth  = 400;
                rec.AlignmentX    = -1;
                rec.Color         = ElmSharp.Color.Gray;
                rec.Show();

                contentBox.PackEnd(right);

                mainBox.PackEnd(contentBox);
                mainBox.PackEnd(rec);

                return(mainBox);
            }
            return(null);
        }
コード例 #4
0
ファイル: ThemeManager.cs プロジェクト: zhamppx97/maui
 public static void SetVerticalTextAlignment(this ELabel label, double valign)
 {
     label.SetVerticalTextAlignment(ThemeConstants.Common.Parts.Text, valign);
 }
コード例 #5
0
        public override void Run(ElmSharp.Box parent)
        {
            var flyoutBox = new ElmSharp.Box(parent);
            var detailBox = new ElmSharp.Box(parent);

            var flyoutPage = new FlyoutPage(parent)
            {
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1,
                IsPresented = false,
                Flyout      = flyoutBox,
                Detail      = detailBox,
            };

            flyoutPage.DimArea.BackgroundColor = EColor.Blue;
            flyoutPage.DimArea.Opacity         = 100;

            var list = new GenList(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1
            };

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (data, part) =>
                {
                    return(data as string);
                }
            };

            for (int i = 0; i < 10; i++)
            {
                list.Append(defaultClass, $"Flyout List Item {i}");
            }

            list.Show();
            flyoutBox.PackEnd(list);

            var openLabel = new ElmSharp.Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = $"IsPresented: {flyoutPage.IsPresented}"
            };

            var gestureLabel = new ElmSharp.Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = $"IsGestureEnabled: {flyoutPage.IsGestureEnabled}"
            };

            var behaviorLabel = new ElmSharp.Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = $"FlyoutLayoutBehavior: {flyoutPage.FlyoutLayoutBehavior}"
            };

            var openButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Open Flyout"
            };

            var gestureButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Enable/Disable Gesture"
            };

            var behaviorButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Default/Split Behavior"
            };

            var sRatioButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Split ratio + 10"
            };

            var dRatioButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "popover ratio + 10"
            };

            var sRatioButton2 = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Split ratio - 10"
            };

            var dRatioButton2 = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "popover ratio - 10"
            };

            list.ItemSelected += (s, e) =>
            {
                flyoutPage.IsPresented = false;
            };

            flyoutPage.IsPresentedChanged += (s, e) =>
            {
                openLabel.Text = $"IsPresented: {flyoutPage.IsPresented}";
            };

            openButton.Clicked += (s, e) =>
            {
                flyoutPage.IsPresented = !flyoutPage.IsPresented;
            };

            gestureButton.Clicked += (s, e) =>
            {
                flyoutPage.IsGestureEnabled = !flyoutPage.IsGestureEnabled;
                gestureLabel.Text           = $"IsGestureEnabled: {flyoutPage.IsGestureEnabled}";
            };


            sRatioButton.Clicked += (s, e) =>
            {
                flyoutPage.SplitRatio += 0.1;
            };

            sRatioButton2.Clicked += (s, e) =>
            {
                flyoutPage.SplitRatio -= 0.1;
            };

            dRatioButton.Clicked += (s, e) =>
            {
                flyoutPage.PopoverRatio += 0.1;
            };

            dRatioButton2.Clicked += (s, e) =>
            {
                flyoutPage.PopoverRatio -= 0.1;
            };

            behaviorButton.Clicked += (s, e) =>
            {
                if (flyoutPage.FlyoutLayoutBehavior == FlyoutLayoutBehavior.Default)
                {
                    flyoutPage.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split;
                }
                else
                {
                    flyoutPage.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Default;
                }

                behaviorLabel.Text = $"FlyoutLayoutBehavior: {flyoutPage.FlyoutLayoutBehavior}";
                openLabel.Text     = $"IsPresented: {flyoutPage.IsPresented}";
            };


            openLabel.Show();
            gestureLabel.Show();
            behaviorLabel.Show();

            openButton.Show();
            gestureButton.Show();
            behaviorButton.Show();
            sRatioButton.Show();
            sRatioButton2.Show();
            dRatioButton.Show();
            dRatioButton2.Show();

            detailBox.PackEnd(openLabel);
            detailBox.PackEnd(gestureLabel);
            detailBox.PackEnd(behaviorLabel);

            detailBox.PackEnd(openButton);
            detailBox.PackEnd(gestureButton);
            detailBox.PackEnd(behaviorButton);
            detailBox.PackEnd(sRatioButton);
            detailBox.PackEnd(sRatioButton2);
            detailBox.PackEnd(dRatioButton);
            detailBox.PackEnd(dRatioButton2);

            flyoutBox.Show();
            detailBox.Show();
            flyoutPage.Show();
            parent.PackEnd(flyoutPage);
        }