Ejemplo n.º 1
0
        public static void InsertItemToComboBox(IconType iconType, string sValue, string sDesc, ImageComboBoxEdit cmbPath)
        {
            for (int i = cmbPath.Properties.Items.Count - 1; i > cmbPath.SelectedIndex; i--)
            {
                ImageComboBoxItem imageComboBoxItem = cmbPath.Properties.Items[i];
                if (imageComboBoxItem.ImageIndex != 2 && imageComboBoxItem.ImageIndex != 33)
                {
                    cmbPath.Properties.Items.RemoveAt(i);
                }
            }
            ImageComboBoxItem selectedItem = ControlAPI.InsertItemToComboBox(iconType, sValue, sDesc, cmbPath, cmbPath.SelectedIndex + 1);

            cmbPath.SelectedItem = selectedItem;
        }
Ejemplo n.º 2
0
 public static void InitPathComboBox(string sPath, ImageComboBoxEdit cmbPath, DataType type)
 {
     cmbPath.Properties.BeginUpdate();
     try
     {
         cmbPath.Properties.Items.Clear();
         bool flag = false;
         if (type != DataType.sde)
         {
             ControlAPI.AddItemToComboBox(IconType.Disk, ConstDef.PATH_DESKTOP, "桌面", cmbPath);
             DriveInfo[] drives = DriveInfo.GetDrives();
             DriveInfo[] array  = drives;
             for (int i = 0; i < array.Length; i++)
             {
                 DriveInfo driveInfo = array[i];
                 if (driveInfo.DriveType == DriveType.Fixed || driveInfo.DriveType == DriveType.Removable)
                 {
                     ControlAPI.AddItemToComboBox(IconType.Disk, driveInfo.Name, driveInfo.Name, cmbPath);
                 }
             }
         }
         if (type == DataType.all || (type & DataType.sde) == DataType.sde)
         {
             ImageComboBoxItem selectedItem = ControlAPI.AddItemToComboBox(IconType.SdeConnections, "数据库连接", "数据库连接", cmbPath);
             if (sPath == "数据库连接")
             {
                 cmbPath.SelectedItem = selectedItem;
                 return;
             }
         }
         if (!string.IsNullOrEmpty(sPath))
         {
             if (sPath.StartsWith(ConstDef.PATH_DESKTOP))
             {
                 cmbPath.SelectedIndex = 0;
             }
             else
             {
                 string[] array2 = sPath.Split(new char[]
                 {
                     '\\'
                 });
                 foreach (ImageComboBoxItem imageComboBoxItem in cmbPath.Properties.Items)
                 {
                     if (!(imageComboBoxItem.Description != array2[0] + "\\"))
                     {
                         ImageComboBoxItem imageComboBoxItem2 = imageComboBoxItem;
                         for (int j = 1; j < array2.Length; j++)
                         {
                             if (!string.IsNullOrEmpty(array2[j]))
                             {
                                 string text = array2[0];
                                 for (int k = 1; k <= j; k++)
                                 {
                                     text = text + "\\" + array2[k];
                                 }
                                 if (!Directory.Exists(text))
                                 {
                                     cmbPath.SelectedItem = imageComboBoxItem2;
                                     flag = true;
                                     break;
                                 }
                                 int iIndex = cmbPath.Properties.Items.IndexOf(imageComboBoxItem2) + 1;
                                 imageComboBoxItem2 = ControlAPI.InsertItemToComboBox(IconType.Folder, text, array2[j], cmbPath, iIndex);
                                 if (j == array2.Length - 1)
                                 {
                                     cmbPath.SelectedItem = imageComboBoxItem2;
                                     flag = true;
                                     break;
                                 }
                             }
                         }
                         if (!flag)
                         {
                             cmbPath.SelectedItem = imageComboBoxItem;
                             flag = true;
                         }
                         break;
                     }
                 }
                 if (!flag && cmbPath.Properties.Items.Count > 0)
                 {
                     cmbPath.SelectedIndex = 0;
                 }
             }
         }
     }
     finally
     {
         cmbPath.Properties.EndUpdate();
     }
 }