Ejemplo n.º 1
0
        /// <summary>
        /// To initialize the application layout
        /// </summary>
        /// <param name="screenWidth">screen width</param>
        /// <param name="screenHeight">screen height</param>
        void InitializeComponent(int screenWidth, int screenHeight)
        {
            Children.Add(
                new Image
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Margin            = new Thickness(0),

                Source = "bar_apps.png",
                Aspect = Aspect.Fill,
            },
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }));

            _applications = new ApplicationContentLayout(screenWidth, screenHeight);

            /// For application list
            Children.Add(
                _applications,
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.5265);
            }));

            var executeButton = new CustomImageButton
            {
                Source = "execute_button.jpg",
            };

            executeButton.Clicked += (s, e) =>
            {
                ((MainViewModel)BindingContext).ExecuteSelectedApplication();
            };

            /// For execute button
            Children.Add(
                executeButton,
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.7589);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }));

            var killButton = new CustomImageButton
            {
                Source = "kill_button.jpg",
            };

            killButton.Clicked += (s, e) =>
            {
                ((MainViewModel)BindingContext).KillSelectedApplication();
            };

            /// For kill button
            Children.Add(
                killButton,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.7589);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// To initialize the application layout
        /// </summary>
        void InitializeComponent(int screenWidth, int screenHeight)
        {
            Children.Add(
                new Image
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Margin            = new Thickness(0),

                Source = "bar_apps.png",
                Aspect = Aspect.Fill,
            },
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }));

            var applications = new ApplicationContentLayout(screenWidth, screenHeight);

            applications.ItemSelected += (s, e) =>
            {
                var item         = (ApplicationListItem)e.SelectedItem;
                var selectedItem = ((MainViewModel)BindingContext).SelectedItem;
                if (selectedItem != null)
                {
                    selectedItem.BlendColor = Color.Gray;
                }

                ((MainViewModel)BindingContext).SelectedItem = item;
            };

            BindingContextChanged += (s, e) =>
            {
                if (BindingContext == null)
                {
                    return;
                }

                applications.ItemsSource = ((MainViewModel)BindingContext).Applications;
            };

            /// For application list
            Children.Add(
                applications,
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.5265);
            }));

            var executeButton = new ImageButton
            {
                Source = "execute_button.jpg",
            };

            executeButton.Clicked += (s, e) =>
            {
                ((MainViewModel)BindingContext).ExecuteSelectedApplication();
            };

            /// For execute button
            Children.Add(
                executeButton,
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.7589);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }));

            var killButton = new ImageButton
            {
                Source = "kill_button.jpg"
            };

            killButton.Clicked += (s, e) =>
            {
                ((MainViewModel)BindingContext).KillSelectedApplication();
            };

            /// For kill button
            Children.Add(
                killButton,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.7589);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2411);
            }));
        }