示例#1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (Items.Count == 0)          //even if IncludeAll, we still don't want it to show.
            {
                return;
            }
            _formComboPicker              = new FormComboPicker();
            _formComboPicker.FormClosing += _formComboPicker_FormClosing;
            List <string> listStrings     = new List <string>();
            List <string> listAbbrevs     = new List <string>();
            List <int>    selectedIndices = new List <int>();
            int           indexOffset     = 0;

            if (IncludeAll)
            {
                listStrings.Add("All");
                listAbbrevs.Add("All");
                indexOffset = 1;
                if (IsAllSelected)
                {
                    selectedIndices.Add(0);
                }
            }
            for (int i = 0; i < _listSelectedIndices.Count; i++)
            {
                selectedIndices.Add(_listSelectedIndices[i] + indexOffset);
            }
            for (int i = 0; i < Items.Count; i++)
            {
                listStrings.Add(Items.GetTextShowingAt(i));
                listAbbrevs.Add(Items.GetAbbrShowingAt(i));
            }
            _formComboPicker.ListStrings    = listStrings;
            _formComboPicker.ListAbbrevs    = listAbbrevs;
            _formComboPicker.PointInitialUR = this.PointToScreen(new Point(this.Width, 0));
            _formComboPicker.MinimumSize    = new Size(15, 15);
            _formComboPicker.Width          = this.Width;
            if (SelectionModeMulti)
            {
                _formComboPicker.IsMultiSelect   = true;
                _formComboPicker.SelectedIndices = selectedIndices;
            }
            else
            {
                if (selectedIndices.Count == 0)
                {
                    _formComboPicker.SelectedIndex = -1;
                    _formComboPicker.OverrideText  = _overrideText;
                }
                else
                {
                    _formComboPicker.SelectedIndex = selectedIndices[0];
                }
            }
            _formComboPicker.Show();
        }
示例#2
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (ShowLabel && e.X < _widthLabelArea)
     {
         return;
     }
     if (_selectedClinicNoPermission != null)
     {
         if (Security.IsAuthorized(Permissions.UnrestrictedSearch, true))
         {
             //Clinic is hidden, but user is allowed to move this object (e.g. patient) to different clinic
             //FormComboPicker will come up, and the displayed Abbr will disappear because form has no access to the hidden clinic.  That's ok.
             //If user then selects a non-hidden clinic, _selectedClinicNoPermission will get set to null.
         }
         else
         {
             MsgBox.Show(this, "Not allowed");
             return;
         }
     }
     _formComboPicker                = new FormComboPicker();
     _formComboPicker.FormClosing   += _formComboPicker_FormClosing;
     _formComboPicker.ListStrings    = _listClinics.Select(x => x.Abbr).ToList();
     _formComboPicker.ListAbbrevs    = _listClinics.Select(x => x.Abbr).ToList();
     _formComboPicker.PointInitialUR = this.PointToScreen(new Point(this.Width, 0));
     _formComboPicker.MinimumSize    = new Size(15, 15);
     if (ShowLabel)
     {
         _formComboPicker.Width = this.Width - _widthLabelArea;
     }
     else
     {
         _formComboPicker.Width = this.Width;
     }
     //SelectedIndices and SelectedIndex effectively set each other
     if (SelectionModeMulti)
     {
         _formComboPicker.IsMultiSelect   = true;
         _formComboPicker.SelectedIndices = _listSelectedIndices;
     }
     else
     {
         _formComboPicker.SelectedIndex = _selectedIndex;
     }
     _formComboPicker.Show();
 }