Exemplo n.º 1
0
        private void CreateOrderByContexMenu()
        {
            var contextMenuModel = new ContextMenuModel();

            contextMenuModel.Add(new ContextMenuItemModel()
            {
                Id = "firstname", Title = Helper.SdkWrapper.GetLabel("firstnameOrder"), IsSelected = true
            });
            contextMenuModel.Add(new ContextMenuItemModel()
            {
                Id = "lastname", Title = Helper.SdkWrapper.GetLabel("lastnameOrder")
            });
            contextMenuModel.Add(new ContextMenuItemModel()
            {
                Id = "company", Title = Helper.SdkWrapper.GetLabel("companyOrder")
            });

            OrderByContextMenu = new Controls.ContextMenu {
                AutomationId = "OrderByContextMenu", WidthRequest = 140
            };
            OrderByContextMenu.BindingContext = contextMenuModel;

            OrderByContextMenu.Command = new RelayCommand <object>(OrderByContextMenuCommand);

            Popup.Add(null, OrderByContextMenu, PopupType.ContextMenu);
        }
Exemplo n.º 2
0
        private void CreateFilterContexMenu()
        {
            var contextMenuModel = new ContextMenuModel();

            contextMenuModel.Add(new ContextMenuItemModel()
            {
                Id = "all", Title = Helper.SdkWrapper.GetLabel("allFilter"), IsSelected = true
            });
            contextMenuModel.Add(new ContextMenuItemModel()
            {
                Id = "online", Title = Helper.SdkWrapper.GetLabel("onlineFilter")
            });
            contextMenuModel.Add(new ContextMenuItemModel()
            {
                Id = "offline", Title = Helper.SdkWrapper.GetLabel("offlineFilter")
            });

            FilterContextMenu = new Controls.ContextMenu {
                AutomationId = "FilterContextMenu", WidthRequest = 140
            };
            FilterContextMenu.BindingContext = contextMenuModel;

            FilterContextMenu.Command = new RelayCommand <object>(FilterContextMenuCommand);

            Popup.Add(null, FilterContextMenu, PopupType.ContextMenu);
        }
        private void AddPopupButtonCommand(object obj)
        {
            if (!newPopupAdded)
            {
                if (dynamicContextMenuCounter % 3 == 2)
                {
                    contextMenuModel = new ContextMenuModel();
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "firstname", Title = Helper.SdkWrapper.GetLabel("firstnameOrder")
                    });
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "lastname", Title = Helper.SdkWrapper.GetLabel("lastnameOrder")
                    });
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "company", Title = Helper.SdkWrapper.GetLabel("companyOrder")
                    });

                    dynamicContextMenu = new Controls.ContextMenu {
                        AutomationId = "DynamicContextMenu", WidthRequest = 140
                    };
                    dynamicContextMenu.BindingContext = contextMenuModel;
                }
                else if (dynamicContextMenuCounter % 3 == 1)
                {
                    Color  color;
                    String colorHex;
                    String imageSourceId;

                    contextMenuModel = new ContextMenuModel();

                    color    = Helper.GetResourceDictionaryById <Color>("ColorConversationStreamMessageOtherUserFont");
                    colorHex = color.ToHex();

                    imageSourceId = "Font_PencilAlt|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "edit", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("edit")
                    });

                    imageSourceId = "Font_FileDownload|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "download", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("download")
                    });

                    imageSourceId = "Font_Reply|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "reply", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("replyToMessage")
                    });

                    imageSourceId = "Font_ArrowRight|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "forward", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("forwardMessage")
                    });

                    imageSourceId = "Font_Copy|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "copy", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("copy")
                    });

                    imageSourceId = "Font_TrashAlt|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "delete", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("delete")
                    });

                    imageSourceId = "Font_CloudDownloadAlt|" + colorHex;
                    contextMenuModel.Add(new ContextMenuItemModel()
                    {
                        Id = "save", ImageSourceId = imageSourceId, Title = Helper.SdkWrapper.GetLabel("save")
                    });

                    dynamicContextMenu = new Controls.ContextMenu {
                        AutomationId = "DynamicContextMenu", WidthRequest = 180, StoreSelection = false
                    };
                    dynamicContextMenu.BindingContext = contextMenuModel;
                }
                else if (dynamicContextMenuCounter % 3 == 0)
                {
                    Color  color;
                    Color  backgroundColor;
                    String title;
                    String label;
                    String imageSourceId;

                    ContextMenuItemModel messageUrgencyModelItem;

                    String urgencyType;

                    contextMenuModel = new ContextMenuModel();

                    urgencyType = UrgencyType.High.ToString();
                    Helper.GetUrgencyInfo(urgencyType, out backgroundColor, out color, out title, out label, out imageSourceId);
                    messageUrgencyModelItem = new ContextMenuItemModel()
                    {
                        Id = urgencyType, ImageSourceId = imageSourceId, Title = title, Description = label, TextColor = color
                    };
                    contextMenuModel.Add(messageUrgencyModelItem);

                    urgencyType = UrgencyType.Middle.ToString();
                    Helper.GetUrgencyInfo(urgencyType, out backgroundColor, out color, out title, out label, out imageSourceId);
                    messageUrgencyModelItem = new ContextMenuItemModel()
                    {
                        Id = urgencyType, ImageSourceId = imageSourceId, Title = title, Description = label, TextColor = color
                    };
                    contextMenuModel.Add(messageUrgencyModelItem);

                    urgencyType = UrgencyType.Low.ToString();
                    Helper.GetUrgencyInfo(urgencyType, out backgroundColor, out color, out title, out label, out imageSourceId);
                    messageUrgencyModelItem = new ContextMenuItemModel()
                    {
                        Id = urgencyType, ImageSourceId = imageSourceId, Title = title, Description = label, TextColor = color
                    };
                    contextMenuModel.Add(messageUrgencyModelItem);

                    urgencyType = UrgencyType.Std.ToString();
                    Helper.GetUrgencyInfo(urgencyType, out backgroundColor, out color, out title, out label, out imageSourceId);
                    messageUrgencyModelItem = new ContextMenuItemModel()
                    {
                        Id = urgencyType, ImageSourceId = imageSourceId, Title = title, Description = label, TextColor = color
                    };
                    contextMenuModel.Add(messageUrgencyModelItem);

                    dynamicContextMenu = new Controls.ContextMenu {
                        AutomationId = "DynamicContextMenu", WidthRequest = 280
                    };
                    dynamicContextMenu.BindingContext = contextMenuModel;
                }

                // Increase counter
                dynamicContextMenuCounter++;

                if (dynamicContextMenu != null)
                {
                    dynamicContextMenu.Command = ContextMenuCommand;

                    Popup.Add(this, dynamicContextMenu, PopupType.ContextMenu);
                    newPopupAdded = !newPopupAdded;
                }
            }
            else
            {
                Popup.Remove(this, "DynamicContextMenu");
                newPopupAdded = !newPopupAdded;

                dynamicContextMenu = null;
            }

            UpdateLabel();
            DisplayPopupButton.IsEnabled     = newPopupAdded;
            UpdatePopupModelButton.IsEnabled = newPopupAdded;
        }