Beispiel #1
0
 internal AndroidJavaObject ConvertToMpInstallType(InstallType installType)
 {
     return(installTypeClass.CallStatic <AndroidJavaObject>("valueOf", installType.ToString()));
 }
Beispiel #2
0
        /// <summary>
        /// Creates the context menu from CmItemList
        /// </summary>
        private void CreateContextMenu()
        {
            ContextMenu contextMenu = new ContextMenu();

            this.ContextMenu = contextMenu;
            this.ContextMenu.PlacementTarget = this;
            this.ContextMenu.Placement       = Placement;
            this.ContextMenu.SetValue(AutomationProperties.AutomationIdProperty, (string)this.GetValue(AutomationProperties.AutomationIdProperty) + ".ContextMenu");

            this.ContextMenu.Opened += ((sender, routedEventArgs) => IsContextMenuOpen = true);
            this.ContextMenu.Closed += ((sender, routedEventArgs) => IsContextMenuOpen = false);

            // Replace the context menu labels by the localised labels
            if (LocalisedMenuLabels.Count > 0)
            {
                for (int i = 0; i < CmItemList.Count; i++)
                {
                    CmItemList[i].Label = LocalisedMenuLabels[i].Text;
                }
            }

            foreach (ContextMenuItemContent item in CmItemList)
            {
                if (item.Label != "Indeterminate")
                {
                    InstallType type         = (InstallType)item.Index;
                    string      instVersion  = InstalledVersion;
                    string      availVersion = AvailableVersion;
                    bool        canMigrate   = CanMigrate;
                    bool        isEnabled    = GetContextMenuEnableState(type, instVersion, availVersion, canMigrate);

                    var menuItem = new MenuItem();
                    menuItem.Header            = item.Label;
                    menuItem.VerticalAlignment = VerticalAlignment.Center;
                    menuItem.Icon      = isEnabled ? item.Icon : item.IconDisabled;
                    menuItem.IsEnabled = isEnabled;
                    menuItem.SetValue(AutomationProperties.AutomationIdProperty, "SelectionTreeControl.MenuButton.ContextMenu." + type.ToString());
                    menuItem.Click += new RoutedEventHandler(OnContextMenuItem_Clicked);
                    contextMenu.Items.Add(menuItem);
                }
            }
        }