예제 #1
0
        /// <summary>
        /// Displays a multi selection dialog.
        /// </summary>
        /// <returns>List of items</returns>
        public static List<MultiSelectionItem> ShowMultiSelectionDialog(string heading, List<MultiSelectionItem> items)
        {
            List<MultiSelectionItem> result = new List<MultiSelectionItem>();

            if (items == null) return result;

            if (GUIGraphicsContext.form.InvokeRequired) {
                ShowMultiSelectionDialogDelegate d = ShowMultiSelectionDialog;
                return (List<MultiSelectionItem>)GUIGraphicsContext.form.Invoke(d, heading, items);
            }

            GUIWindow dlgMultiSelectOld = (GUIWindow)GUIWindowManager.GetWindow(2100);
            GUIDialogMultiSelect dlgMultiSelect = new GUIDialogMultiSelect();
            dlgMultiSelect.Init();
            GUIWindowManager.Replace(2100, dlgMultiSelect);

            try {
                //GUIDialogMultiSelect dlgMultiSelect = (GUIDialogMultiSelect)GUIWindowManager.GetWindow(2100);
                //if (dlgMultiSelect == null) return;

                dlgMultiSelect.Reset();

                dlgMultiSelect.SetHeading(heading);

                foreach (MultiSelectionItem multiSelectionItem in items) {
                    GUIListItem item = new GUIListItem();
                    item.Label = multiSelectionItem.ItemTitle;
                    item.Label2 = multiSelectionItem.ItemTitle2;
                    item.MusicTag = multiSelectionItem.Tag;
                    item.Selected = multiSelectionItem.Selected;

                    dlgMultiSelect.Add(item);
                }

                dlgMultiSelect.DoModal(GUIWindowManager.ActiveWindow);

                if (dlgMultiSelect.DialogModalResult == ModalResult.OK) {
                    for (int i = 0; i < items.Count; i++) {
                        MultiSelectionItem item = items[i];
                        MultiSelectionItem newMultiSelectionItem = new MultiSelectionItem();
                        newMultiSelectionItem.ItemTitle = item.ItemTitle;
                        newMultiSelectionItem.ItemTitle2 = item.ItemTitle2;
                        newMultiSelectionItem.ItemID = item.ItemID;
                        newMultiSelectionItem.Tag = item.Tag;
                        try {
                            newMultiSelectionItem.Selected = dlgMultiSelect.ListItems[i].Selected;
                        }
                        catch {
                            newMultiSelectionItem.Selected = item.Selected;
                        }

                        result.Add(newMultiSelectionItem);
                    }
                }
                else
                    return null;

                return result;
            }
            finally {
                GUIWindowManager.Replace(2100, dlgMultiSelectOld);
            }
        }
예제 #2
0
        public static List<MultiSelectionItem> getLanguageNamesForMultiSelection()
        {
            List<MultiSelectionItem> result = new List<MultiSelectionItem>();
            List<SettingsLanguage> allLanguages = getAllLanguages();

            foreach (SettingsLanguage settingsLanguage in allLanguages) {
                MultiSelectionItem multiSelectionItem = new MultiSelectionItem();
                multiSelectionItem.ItemID = settingsLanguage.LanguageCode;
                multiSelectionItem.ItemTitle = settingsLanguage.LanguageName;
                multiSelectionItem.Selected = settingsLanguage.Enabled;

                result.Add(multiSelectionItem);
            }

            return result;
        }