示例#1
0
        //-------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        private void DoShowDlgComboChoice()
        {
            List <DlgComboChoiceItem> listItem           = new List <DlgComboChoiceItem>();
            DlgComboChoiceItem        selectedBeforeItem = null;

            // create some object
            List <string> listString = new List <string>();

            listString.Add("dog");
            listString.Add("cat");
            listString.Add("horse");
            listString.Add("duck");

            foreach (string s in listString)
            {
                var item = new DlgComboChoiceItem(s, s);
                listItem.Add(item);

                // select the first item
                //if (selectedBeforeItem == null)
                //    selectedBeforeItem = item;
            }

            DlgComboChoiceItem selected;
            CommonDlgResult    res = AppCtrlProvider.AppCtrl.CommonDlg.ShowDlgComboChoice("Choose it", listItem, selectedBeforeItem, out selected);

            if (res == CommonDlgResult.Ok)
            {
                AppCtrlProvider.AppCtrl.CommonDlg.ShowInformation("Selected item:\n " + selected.Object.ToString() + ".");
            }
            else
            {
                AppCtrlProvider.AppCtrl.CommonDlg.ShowWarning("Aborted!");
            }
        }
示例#2
0
        //=====================================================================
        #region Public Show dlg ComboChoice, List Multi-Choice.

        /// <summary>
        /// Show a dialog box with a combobox to selection/choice an item.
        /// only one item can be selected or any.
        /// </summary>
        /// <param name="dlgTitle"></param>
        /// <param name="listObject"></param>
        /// <param name="selectIt"></param>
        /// <param name="selected"></param>
        /// <returns></returns>
        public CommonDlgResult ShowDlgComboChoice(string dlgTitle, List <DlgComboChoiceItem> listObject, DlgComboChoiceItem selectIt, out DlgComboChoiceItem selected)
        {
            // create and define the dlgBox
            DlgComboChoiceVM dlgVM = new DlgComboChoiceVM(_coreSystem);

            dlgVM.Title = dlgTitle;

            // fourni la liste de la combox
            dlgVM.ListItem     = listObject;
            dlgVM.SelectedItem = selectIt;

            // to close the dlgBox, like this, because its a WPF/MVVM implementation
            dlgVM.DoCloseView = () => DoCloseDlgComboChoice();

            _dlgComboChoice             = new DlgComboChoice();
            _dlgComboChoice.Owner       = _parent;
            _dlgComboChoice.DataContext = dlgVM;

            // open the dlgBox, is modal/synchronized, wait the close of the dlg
            _dlgComboChoice.ShowDialog();
            selected = dlgVM.SelectedItem;

            // get the result
            return(dlgVM.DlgResult);
        }