示例#1
0
        /// <summary>
        /// Fills the combo box entry.
        /// </summary>
        /// <param name='combo'>
        /// Combo.
        /// </param>
        /// <param name='items'>
        /// Items.
        /// </param>
        /// <param name='currentValue'>
        /// Current value.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        public static void FillComboBoxEntry(Gtk.ComboBoxEntry combo, List<string> items, string currentValue,bool isDecimal,bool editable)
        {
            combo.Model = new ListStore(typeof(string));

            var resultItems = new List<string>();
            if (editable)
            {
                    // searching for value
                    var present = false;
                    foreach (var value in items)
                    {
                        if (
                                (isDecimal && (SupportMethods.ToDecimal(value) == SupportMethods.ToDecimal(currentValue)))
                                ||
                               	(!isDecimal && (value == currentValue))
                           )
                        {
                            present = true;
                            break;
                        }
                    }

                // adding missing to first pos
                if (!present)
                {
                    resultItems.Add(currentValue);
                }

                foreach (var value in items)
                    resultItems.Add(value);
            } else
            {
                    resultItems.Add(currentValue);
            }

            var index = 0;
            foreach (var value in resultItems)
            {
                combo.AppendText(value);

                if (
                                (isDecimal && (SupportMethods.ToDecimal(value) == SupportMethods.ToDecimal(currentValue)))
                                ||
                               	(!isDecimal && (value == currentValue))
                    )
                {
                    combo.Active = index;
                }
                index++;
            }
        }
示例#2
0
        public static void FillComboBoxEntry(Gtk.ComboBoxEntry combo, Dictionary<decimal,string> items, decimal currentValue,bool editable)
        {
            combo.Model = new ListStore(typeof(string));

            var resultItems = new Dictionary<decimal,string>();

            if (editable)
            {
                // adding missing to first pos
                if (!items.ContainsKey(currentValue))
                {
                    resultItems.Add(currentValue,currentValue.ToString());
                }

                foreach (var kvp in items)
                    resultItems.Add(kvp.Key,kvp.Value);
            } else
            {
                    resultItems.Add(currentValue,currentValue.ToString());
            }

            var index = 0;
            foreach (var kvp in resultItems)
            {
                combo.AppendText(kvp.Value);

                if (kvp.Key == currentValue)
                {
                    combo.Active = index;
                }
                index++;
            }
        }
示例#3
0
        /// <summary>
        /// Fills the combo box.
        /// </summary>
        /// <param name='combo'>
        /// Combo.
        /// </param>
        /// <param name='items'>
        /// Items.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        /// <param name='currentValue'>
        /// Current value.
        /// </param>
        public static void FillComboBox(Gtk.ComboBox combo, Type enumType, bool editable, int currentValue)
        {
            // clear combo
            combo.Model = new ListStore(typeof(string));

            // adding all items
            var index=0;
                foreach (var item in Enum.GetNames(enumType))
                {
                    if (editable || (index == currentValue))
                    {
                        combo.AppendText(item);

                        if (!editable) combo.Active = 0;
                        else
                        if (index == currentValue) combo.Active = index;

                    }
                    index++;

                }
        }
示例#4
0
        /// <summary>
        /// Fills the combo box.
        /// </summary>
        /// <param name='combo'>
        /// Combo.
        /// </param>
        /// <param name='items'>
        /// Items.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        /// <param name='currentValue'>
        /// Current value.
        /// </param>
        public static void FillComboBox(Gtk.ComboBox combo, List<string> items, bool editable, string currentValue)
        {
            // clear combo
            combo.Model = new ListStore(typeof(string));

            // adding all items
            var index=0;
            if (editable)
            {
                foreach (var item in items)
                {
                    combo.AppendText(item);
                    if (item == currentValue)
                    combo.Active = index;

                    index++;
                }
            }
            else
            {
                combo.AppendText(currentValue);
                combo.Active = 0;
            }
        }
示例#5
0
 private void FillComboboxWithStrings(Gtk.ComboBox box, string[] strings)
 {
     ((Gtk.ListStore)(box.Model)).Clear();
     for (int i=0;i<strings.Length;i++){
         box.AppendText(strings[i]);
     }
     box.Active=0;
     box.Sensitive=(strings.Length>1);
 }
示例#6
0
    protected void LoadHostList(Gtk.ComboBox HostList)
    {
        ClearList(HostList);

        try
        {
            string[] hostsArr = System.IO.Directory.GetDirectories("/sys/class/scsi_host");
            foreach(string hostName in hostsArr)
            {
                if(!System.IO.File.Exists(hostName + "/scan")) continue;
                HostList.AppendText(System.IO.Path.GetFileName(hostName));
            }
            HostList.Active = 0;
        }
        catch { }
    }
示例#7
0
    protected void LoadDevList(Gtk.ComboBox DeviceList)
    {
        ClearList(DeviceList);

        try
        {
            string[] devArr = System.IO.Directory.GetFiles("/dev");
            foreach(string devPath in devArr)
            {
                string devName = System.IO.Path.GetFileName(devPath);
                if(devName.Length < 3) continue;
                if(devName.Substring(0,2) != "sd") continue;
                DeviceList.AppendText(devName);
            }
            DeviceList.Active = 0;
        }
        catch { }
    }