Пример #1
0
        /// <summary>
        /// Inserts the item to ComboBox.
        /// </summary>
        /// <param name="iconType">Type of the icon.</param>
        /// <param name="sValue">The s value.</param>
        /// <param name="sDesc">The s desc.</param>
        /// <param name="cmbPath">The CMB path.</param>
        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;
        }
Пример #2
0
 /// <summary>
 /// Initializes the path ComboBox.
 /// </summary>
 /// <param name="sPath">The  path.</param>
 /// <param name="cmbPath">The comobox.</param>
 /// <param name="type">The type.</param>
 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.FGDB, ConstDef.PATH_TEMP + @"\default.gdb", "default.gdb", cmbPath);
             ControlAPI.AddItemToComboBox(IconType.Disk, ConstDef.PATH_DESKTOP, AppMessage.MSG0110, 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, AppMessage.MSG0053, AppMessage.MSG0053, cmbPath);
             if (sPath == AppMessage.MSG0053)
             {
                 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();
     }
 }