/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="option">An option for more menu list</param>
        /// <param name="deleteFunc">a function called when "Delete" option is selected</param>
        /// <param name="reorderFunc">a function called when "Reorder" option is selected</param>
        public MoreMenuDialog(MORE_MENU_OPTION option, Action <string> deleteFunc, Action <string> reorderFunc = null) : base()
        {
            if (option == MORE_MENU_OPTION.MORE_MENU_DELETE_AND_REORDER && reorderFunc == null)
            {
                System.Diagnostics.Debug.WriteLine("## ERROR ##");
                Toast.DisplayText("MoreMenuDialog() you need to pass reorderFunc when more than two cities are added to listview.");
                return;
            }

            HorizontalOption = LayoutOptions.Fill;
            Grid grid = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.White,//Color.FromHex("0A3DB9CC"),
                RowSpacing        = 5,
                ColumnDefinitions =
                {
                    new ColumnDefinition
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            // Menu : Delete
            Command      deleteCommand = new Command <string>(deleteFunc);
            MoreMenuItem itemDelete    = new MoreMenuItem
            {
                Text             = "Delete",
                Command          = deleteCommand,
                CommandParameter = "Delete",
            };

            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(itemDelete, FontWeight.Light);

            switch (option)
            {
            case MORE_MENU_OPTION.MORE_MENU_DELETE:
                grid.RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                };
                grid.Children.Add(itemDelete, 0, 0);
                break;

            case MORE_MENU_OPTION.MORE_MENU_DELETE_AND_REORDER:
                BoxView box = new BoxView
                {
                    Color             = Color.LightGray,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    HeightRequest     = 2,
                };
                // Menu : Reorder
                Command      reorderCommand = new Command <string>(reorderFunc);
                MoreMenuItem itemReorder    = new MoreMenuItem
                {
                    Text             = "Reorder",
                    Command          = reorderCommand,
                    CommandParameter = "Reorder",
                };
                // to meet To meet thin attribute for font, need to use custom feature
                FontFormat.SetFontWeight(itemReorder, FontWeight.Light);
                grid.RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                };
                grid.Children.Add(itemDelete, 0, 0);
                grid.Children.Add(box, 0, 1);
                grid.Children.Add(itemReorder, 0, 2);
                break;

            default:
                // Error case
                Toast.DisplayText("MoreMenuDialog() An error occurs");
                break;
            }

            Content = new StackLayout
            {
                BackgroundColor   = Color.FromHex("0A3DB9CC"),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 10,
                Children          = { grid },
                WidthRequest      = 720,
            };
        }
示例#2
0
        /// <summary>
        /// Constructor for this class.
        /// It defines left button-title-right button on top
        /// </summary>
        public TitleBar()
        {
            /// Sets height to 110 according to UX guide
            HeightRequest = 110;
            /// Fills horizontally
            HorizontalOptions = LayoutOptions.FillAndExpand;
            /// Needs to only take as much as HeightRequest
            /// Do not use FillAndExpand here to keep the HeightRequest
            VerticalOptions = LayoutOptions.Start;

            /// Create a new left button
            leftButton = new Button
            {
                WidthRequest  = 167,
                HeightRequest = 94,
                /// This style is based on UX guide
                /// This style is not available in other platforms so if you want to run
                /// this app on other than Tizen, this should be removed
            };
            VisualAttributes.SetThemeStyle(leftButton, "naviframe/title_left");

            /// Add button clicked event to left
            leftButton.Clicked += LeftButton_Clicked;

            /// Create a new right button
            rightButton = new Button
            {
                WidthRequest  = 167,
                HeightRequest = 94,
                /// This style is based on UX guide
                /// This style is not available in other platforms so if you want to run
                /// this app on other than Tizen, this should be removed
            };
            VisualAttributes.SetThemeStyle(rightButton, "naviframe/title_right");

            /// Create a title label
            titleLabel = new Label
            {
                WidthRequest = 720 - (32 + 130 + 14) * 2,
                // TODO-CHECK:
                HeightRequest           = 94 /*67*/,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize  = 30,
                TextColor = Color.FromHex("FFFAFAFA"),
            };
            // to meet To meet thin attribute for font, need to use custom feature
            FontFormat.SetFontWeight(titleLabel, FontWeight.Light);

            /// Add it to the layout
            Children.Add(leftButton,
                         Constraint.RelativeToParent((parent) => { return(8); }),
                         Constraint.RelativeToParent((parent) => { return((110 - 94) / 2); }));

            /// Add it to the layout
            Children.Add(rightButton,
                         Constraint.RelativeToParent((parent) => { return(720 - (167 + 8)); }),
                         Constraint.RelativeToParent((parent) => { return((110 - 94) / 2); }));

            /// Add it to the layout
            Children.Add(titleLabel,
                         Constraint.RelativeToParent((parent) => { return(32 + 130 + 14); }),
                         Constraint.RelativeToParent((parent) => { return((110 - 94) / 2); }));
        }