Esempio n. 1
0
        /// <summary>Initializes a new instance of the <see cref="ListItemRenderer"/> class.</summary>
        /// <param name="control">The control that owns this renderer.</param>
        /// <param name="defaultImage">The default image for each item.</param>
        public ListItemRenderer(ListControl control, Image defaultImage)
        {
            if (control == null) throw new ArgumentNullException("control");

            _control = control;
            _defaultImage = defaultImage;
        }
Esempio n. 2
0
        public static void SetSelectedListControlItem(ListControl ctrl, string PropertyName, object ValueToSelect)
        {
            bool iscbox = false;
            bool islbox = false;
            if ((ctrl as ComboBox) != null)
                iscbox = true;
            if ((ctrl as ListBox) != null)
                islbox = true;

            if (iscbox)
            {
                foreach (var item in (ctrl as ComboBox).Items)
                {
                    if (ObjectInspector.GetObjectPropertyValue(item, PropertyName).Equals(ValueToSelect))
                    {
                        (ctrl as ComboBox).SelectedItem = item;
                        break;
                    }
                }
            }

            if (islbox)
            {
                foreach (var item in (ctrl as ListBox).Items)
                {
                    if (ObjectInspector.GetObjectPropertyValue(item, PropertyName).Equals(ValueToSelect))
                    {
                        (ctrl as ComboBox).SelectedItem = item;
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
 private void Rebind(ListControl control, IList datasource)
 {
     // HACK: Rebinding the datasource like this is dirty, a better approach is to use the BindingSource Class [http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx]
     // Sopme drawbacks are that you can only add 1 item at a time, since it does not expose a AddRange Method. As well as it forces the code to talk to the winforms controls directly.
     control.DataSource = null;
     control.DataSource = datasource;
 }
 public static void DataBind(Type enumType, ListControl control, object targetObject, string propertyName)
 {
     if (enumType == null)
     {
         throw new ArgumentNullException("enumType");
     }
     if (control == null)
     {
         throw new ArgumentNullException("control");
     }
     if (targetObject == null)
     {
         throw new ArgumentNullException("targetObject");
     }
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new ArgumentNullException(propertyName);
     }
     IList dataSource = EnumHelper.ToList(enumType);
     control.DataSource = dataSource;
     control.DisplayMember = "Value";
     control.ValueMember = "Key";
     PropertyInfo propInfo = targetObject.GetType().GetProperty(propertyName);
     if (propInfo == null)
     {
         throw new ApplicationException("The targetObject doesn't contains a property named " + propertyName);
     }
     control.SelectedValue = propInfo.GetValue(targetObject, null);
     control.SelectedValueChanged += delegate(object sender, EventArgs e)
     {
         propInfo.SetValue(targetObject, control.SelectedValue, null);
     };
 }
Esempio n. 5
0
 public static void addItem(ListControl list, string text)
 {
     if (list == null || text == null || text == "") return;
     if (list.InvokeRequired)
         list.Invoke(new textHandler(uaddItem), list, text);
     else uaddItem(list, text);
 }
        public ToolStripOptionsToolbarSection(ListControl listControl)
            : base(listControl)
        {
            _listControl = listControl;

            _toolStrip = new ToolStrip();
            _toolStrip.AutoSize = true;
            _toolStrip.Visible = false;
            _toolStrip.Anchor = AnchorStyles.None;
            _toolStrip.Dock = DockStyle.None;
            _toolStrip.GripStyle = ToolStripGripStyle.Hidden;
            _toolStrip.TabIndex = 0;
            _toolStrip.Text = "List options";
            _toolStrip.CanOverflow = true;
            _toolStrip.Renderer = new MyRenderer();
            _toolStrip.BackColor = Color.Transparent;
            _toolStrip.Layout += _toolStrip_Layout;
            AddDefaultToolStripButtons();
            _toolStrip.CreateControl();

            listControl.Controls.Add(_toolStrip);

            listControl.Columns.GroupedItems.DataChanged += GroupedItems_DataChanged;
            HandleEnablingGroupButtons();
        }
Esempio n. 7
0
 public static void LoadMineName(ListControl lb, String selectedText
     = "")
 {
     var mines = Mine.FindAll();
     if (mines != null)
         DataBindListControl(lb, mines, "name",
      "id", selectedText);
 }
Esempio n. 8
0
 public static void LoadHorizontalName(ListControl lb, int mineId,
     String selectedText = "")
 {
     var horizontals = Horizontal.FindAllByProperty("mine.id", mineId);
     if (horizontals != null)
         DataBindListControl(lb, horizontals, "name",
             "id", selectedText);
 }
Esempio n. 9
0
 public static void LoadTunnelName(ListControl lb, int workingFaceId,
     String selectedText = "")
 {
     var tunnels = Tunnel.FindAllByProperty("workingface.id", workingFaceId);
     if (tunnels != null)
         DataBindListControl(lb, tunnels, "name", "id",
             selectedText);
 }
Esempio n. 10
0
 public static void LoadWorkingFaceName(ListControl lb, int
     miningAreaId, String selectedText = "")
 {
     var workingFaces =
         Workingface.FindAllByProperty("mining_area.id", miningAreaId);
     if (workingFaces != null)
         DataBindListControl(lb, workingFaces, "name",
             "id", selectedText);
 }
Esempio n. 11
0
        private void BindUsersToListBox(ListControl listBox)
        {
            listBox.DataSource = null;
            listBox.DataSource = UsersServiceHelper.UpdateAndGetUsers();
            listBox.DisplayMember = "Login";
            listBox.ValueMember = "Id";

            grpUserInfo.Enabled = UsersServiceHelper.SelectedUser != null && UsersServiceHelper.SelectedUser.IsDeleted == "False";
        }
Esempio n. 12
0
 public static void LoadMiningAreaName(ListControl lb, int
     horizontalId, string selectedText = "")
 {
     var miningAreas =
         MiningArea.FindAllByProperty("horizontal.id", horizontalId);
     if (miningAreas != null)
         DataBindListControl(lb, miningAreas, "name",
             "id", selectedText);
 }
Esempio n. 13
0
        private static void SetCombo(ListControl combo, string culture)
        {
            combo.SelectedValue = culture;

            // best match
            if (combo.SelectedValue == null)
            {
                combo.SelectedValue = culture.Split('-')[0];
            }
        }
Esempio n. 14
0
 public ListSection( ListControl listControl )
     : base(listControl)
 {
     _headerSection = Host.SectionFactory.CreateHeaderSection( listControl, listControl.Columns.VisibleItems );
     _headerSection.LayoutController = this;
     listControl.Columns.GroupedItems.DataChanged += GroupedItems_DataChanged;
     Host.FocusedSection = this; // we handle row focus manually from here.
     Children.Add( _headerSection );
     ExcludeFirstChildrenFromVScroll = 1;
     listControl.SelectedItems.DataChanged += SelectedItems_DataChanged;
 }
Esempio n. 15
0
 public void BindControl(System.Windows.Forms.ListControl ctl)
 {
     myControl = ctl;
     if (ctl is ComboBox)
     {
         ComboBox cbo = (ComboBox)ctl;
         if (this.BoxSize.Height > 0)
         {
             cbo.DrawMode     = DrawMode.OwnerDrawVariable;
             cbo.MeasureItem += new MeasureItemEventHandler(HandleMeasureItem);
             cbo.DrawItem    += new DrawItemEventHandler(HandleDrawItem);
             cbo.ItemHeight   = this.BoxSize.Height + 5;
         }
         else
         {
             cbo.DrawMode = DrawMode.Normal;
         }
         System.Collections.IEnumerable items = this.GetItems();
         if (items != null)
         {
             foreach (object obj in items)
             {
                 cbo.Items.Add(obj);
             }
         }
     }
     else if (ctl is ListBox)
     {
         ListBox lst = (ListBox)ctl;
         if (this.BoxSize.Height > 0)
         {
             lst.DrawMode     = DrawMode.OwnerDrawVariable;
             lst.ItemHeight   = this.BoxSize.Height + 5;
             lst.MeasureItem += new MeasureItemEventHandler(HandleMeasureItem);
             lst.DrawItem    += new DrawItemEventHandler(HandleDrawItem);
         }
         else
         {
             lst.DrawMode = DrawMode.Normal;
         }
         System.Collections.IEnumerable items = this.GetItems();
         if (items != null)
         {
             foreach (object obj in items)
             {
                 lst.Items.Add(obj);
             }
         }
     }
 }
Esempio n. 16
0
        private void lstWebServiceEndpoint_SelectedIndexChanged(object sender, EventArgs e)
        {
            System.Windows.Forms.ListControl realSender = (System.Windows.Forms.ListControl)sender;
            string selectedUri       = realSender.Text;
            WebServiceCollection wsc = _mySession.WebServicesCollectionsHydrated[new Uri(selectedUri)];

            this._currentWsc = wsc;
            this.lstWebServices.Items.Clear();
            this.lstMethods.Items.Clear();
            this.lstParameters.Items.Clear();
            foreach (WebService ws in wsc.WebServices)
            {
                this.lstWebServices.Items.Add(ws.Name);
            }
        }
Esempio n. 17
0
 private static void BindList(Win.ListControl listControl, MDataTable source)
 {
     try
     {
         if (source.Columns.Count > 0)
         {
             listControl.DataSource    = new MDataView(ref source);
             listControl.ValueMember   = source.Columns[0].ColumnName;
             listControl.DisplayMember = source.Columns[source.Columns.Count > 1 ? 1 : 0].ColumnName;
         }
     }
     catch (Exception err)
     {
         Log.WriteLogToTxt(err);
     }
 }
Esempio n. 18
0
        //*************************************************************************
        //  Method: PopulateWithEnumValues()
        //
        /// <summary>
        /// Populates a ListControl with all values in an enumeration.
        /// </summary>
        ///
        /// <param name="oListControl">
        /// ListControl to populate.
        /// </param>
        ///
        /// <param name="oEnumType">
        /// Enumeration to populate the ListControl with.
        /// </param>
        ///
        /// <param name="bFormatForUser">
        /// If true, spaces are inserted between each word in the enum values, and
        /// the values are sorted alphabetically.  The value
        /// "DaysActiveInNewsgroup" gets displayed as "Days active in newsgroup",
        /// for example.  If false, the values are displayed as is
        /// ("DaysActiveInNewsgroup", for example), and no sorting is done.
        /// </param>
        ///
        /// <remarks>
        /// This method populates a ListControl with all values in an enumeration.
        /// The user sees the string version of each value in the list.  The
        /// <see cref="ListControl.SelectedValue" /> property returns the selected
        /// value in the enumeration.
        /// </remarks>
        //*************************************************************************
        public static void PopulateWithEnumValues(
            ListControl oListControl,
            Type oEnumType,
            Boolean bFormatForUser
            )
        {
            Debug.Assert(oListControl != null);

            // Get an array of values in the enumeration.

            Array aoEnumValues = Enum.GetValues(oEnumType);
            Int32 iEnumValues = aoEnumValues.Length;

            // Create an array of ObjectWithText objects.

            ArrayList oObjectWithText = new ArrayList(iEnumValues);

            for (Int32 i = 0; i < iEnumValues; i++)
            {
            Object oEnumValue = aoEnumValues.GetValue(i);
            String sEnumString = oEnumValue.ToString();

            if (bFormatForUser)
            {
                sEnumString = EnumUtil.SplitName(sEnumString,
                    EnumSplitStyle.FirstWordStartsUpperCase);
            }

            oObjectWithText.Add( new ObjectWithText(oEnumValue, sEnumString) );
            }

            if (bFormatForUser)
            oObjectWithText.Sort();

            // Tell the ListControl which properties on the objects in the array
            // should be used.

            oListControl.DisplayMember = "Text";
            oListControl.ValueMember = "Object";

            // Populate the ListControl.

            oListControl.DataSource = oObjectWithText;
        }
Esempio n. 19
0
 private static void applyNewDataSource(ListControl container, object dataSource, int count)
 {
     int index = container.SelectedIndex;
     container.DataSource = null;
     container.DataSource = dataSource;
     if (count == 0)
     {
         index = -1;
     }
     else if (index < 0)
     {
         index = 0;
     }
     else if (index >= count)
     {
         index = count - 1;
     }
     container.SelectedIndex = index;
 }
Esempio n. 20
0
        private void lstMethods_SelectedIndexChanged(object sender, EventArgs e)
        {
            System.Windows.Forms.ListControl realSender = (System.Windows.Forms.ListControl)sender;
            string name = realSender.Text;
            Method ws   = null;

            foreach (Method myMethod in this._currentWs.Methods)
            {
                if (name.Equals(myMethod.Name))
                {
                    this._currentMethod = myMethod;
                    this.lstParameters.Items.Clear();
                    foreach (Parameter p in myMethod.Parameters)
                    {
                        lstParameters.Items.Add(p.ToString());
                    }
                }
            }
        }
Esempio n. 21
0
        private void lstWebServices_SelectedIndexChanged(object sender, EventArgs e)
        {
            System.Windows.Forms.ListControl realSender = (System.Windows.Forms.ListControl)sender;
            string     name = realSender.Text;
            WebService ws   = null;

            foreach (WebService myWs in this._currentWsc.WebServices)
            {
                if (name.Equals(myWs.Name))
                {
                    this._currentWs = myWs;
                    this.lstMethods.Items.Clear();
                    this.lstParameters.Items.Clear();
                    foreach (Method m in myWs.Methods)
                    {
                        lstMethods.Items.Add(m.Name);
                    }
                }
            }
        }
    InitializeListControl
    (
        ListControl listControl
    )
    {
        Debug.Assert(listControl != null);

        ListControlUtil.PopulateWithObjectsAndText(listControl,
            new Object [] {

            ImageFormat.Bmp, "BMP (.bmp)",
            ImageFormat.Gif, "GIF (.gif)",
            ImageFormat.Jpeg, "JPEG (.jpg)",
            ImageFormat.Png, "PNG (.png)",
            ImageFormat.Tiff, "TIFF (.tif)"
            }

            );

        listControl.SelectedValue = ImageFormat.Jpeg;
    }
 // this adds the string of values to a single dropdown
 private void PopulateControl(List<string> values, ListControl target)
 {
     if (target is ListBox)
     {
         ListBox control = (ListBox)target;
         foreach (string value in values)
             control.Items.Add(value);
     }
     else
     {
         ComboBox control = (ComboBox)target;
         foreach (string value in values)
             control.Items.Add(value);
     }
 }
Esempio n. 24
0
				public ObjectComparer (ListControl owner)
				{
					this.owner = owner;
				}
        private List<string> GetValuesFromDB(string query, ListControl control)
        {
            List<string> values = new List<string>();

            if (control is ComboBox)
                values.Add("");

            using (OdbcConnection conn = new OdbcConnection(connectionString))
            {
                conn.Open();

                OdbcCommand comm = new OdbcCommand(query, conn);

                OdbcDataReader reader = comm.ExecuteReader();

                while (reader.Read())
                {
                    switch (Type.GetTypeCode(reader.GetFieldType(0)))
                    {
                        case TypeCode.Decimal:
                            values.Add(reader.GetDecimal(0).ToString());
                            break;
                        case TypeCode.Double:
                            values.Add(reader.GetDouble(0).ToString());
                            break;
                        case TypeCode.String:
                            values.Add(reader.GetString(0).ToString());
                            break;
                        case TypeCode.Int32:
                            values.Add(reader.GetInt32(0).ToString());
                            break;
                    }
                }
            }

            return values;
        }
Esempio n. 26
0
 public ItemArray(ListControl listControl)
 {
     _listControl = listControl;
     _entries     = new List <Entry>();
 }
Esempio n. 27
0
				public ObjectComparer(ListControl owner)
				{
					this.owner = owner;
				}
Esempio n. 28
0
        /// <summary>
        /// Gets the item data.
        /// </summary>
        /// <param name="lstControl">The list control instance.</param>
        /// <param name="index">The index.</param>
        /// <returns>The item data.</returns>
#if TargetF2
        public static int GetItemData(System.Windows.Forms.ListControl lstControl, int index)
Esempio n. 29
0
        /// <summary>
        /// Adds the item.
        /// </summary>
        /// <param name="lstControl">The list control instance.</param>
        /// <param name="value">The value.</param>
#if TargetF2
        public static void AddItem(System.Windows.Forms.ListControl lstControl, string value)
Esempio n. 30
0
        /// <summary>将实体信息添充至ListControl</summary>
        /// <param name="entity"></param>
        /// <param name="field"></param>
        /// <param name="control"></param>
        private void SetListControl(IEntity entity, FieldItem field, ListControl control)
        {
            Type type = field.Type;
            Object value = entity[field.Name];

            if (type == typeof(int))
                control.SelectedIndex = (int)value;
            else
            {
                control.SelectedValue = value;

                if (control.SelectedIndex == -1)
                {
                    if (control is ListBox)
                    {
                        (control as ListBox).SelectedItem = value;
                    }
                    else if (control is ComboBox)
                    {
                        (control as ComboBox).SelectedItem = value;
                    }
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Sets the item data.
        /// </summary>
        /// <param name="lstControl">The list control instance.</param>
        /// <param name="index">The index.</param>
        /// <param name="value">The value.</param>
#if TargetF2
        public static void SetItemData(System.Windows.Forms.ListControl lstControl, int index, int value)
Esempio n. 32
0
 public ItemArray(ListControl listControl)
 {
     _listControl = listControl;
 }
Esempio n. 33
0
 protected int CrossThreadGetSelectedIndex(ListControl c)
 {
     if (this.InvokeRequired)
     {
         CrossThreadGetSelectedIndexDelegate d = new CrossThreadGetSelectedIndexDelegate(this.CrossThreadGetSelectedIndex);
         return (int)this.Invoke(d, new Object[] { c });
     }
     else
     {
         return c.SelectedIndex;
     }
 }
Esempio n. 34
0
        void AddItem(TextBox tb, ListControl lb)
        {
            IList items = null;

            if (Properties.Resources.IsWindowsMobileStandard)
            {
                items = ((ComboBox)lb).Items;
            }
            else
            {
                items = ((ListBox)lb).Items;
            }

            lb.SelectedIndex = items.Add(tb.Text);
        }
Esempio n. 35
0
 /// <summary>
 /// 下拉字典控件的绑定
 /// </summary>
 /// <param name="tab">控件关联数据源</param>
 /// <param name="ctrl">下拉控件</param>
 /// <param name="fld">控件关联字段</param>
 /// <param name="dictsrc">字典数据源</param>
 /// <param name="dicttxt">字典显示值</param>
 /// <param name="dictval">字典Value值</param>
 private void bindctrl(DataTable tab, ListControl ctrl, string fld, DataTable tabdict, string dicttxt, string dictval)
 {
     if (null == tab || null == ctrl || string.IsNullOrEmpty(fld))
         return;
     if (null == tabdict || (string.IsNullOrEmpty(dictval) && string.IsNullOrEmpty(dicttxt)))
     {
         ctrl.DataBindings.Add("Text", tab, fld);
         return;
     }
     ctrl.DataSource = tabdict;
     ctrl.ValueMember = string.IsNullOrEmpty(dictval) ? dicttxt : dictval;
     ctrl.DisplayMember = string.IsNullOrEmpty(dicttxt) ? dictval : dicttxt;
     ctrl.DataBindings.Add("SelectedValue", tab, fld);
 }
Esempio n. 36
0
 public ItemArray(ListControl listControl)
 {
     this.listControl = listControl;
 }
Esempio n. 37
0
 public ItemArray(ListControl listControl) {
     this.listControl = listControl;
 }
Esempio n. 38
0
        /// <summary>
        /// Gets the new index.
        /// </summary>
        /// <param name="lstControl">The list control instance.</param>
        /// <returns>The new index.</returns>
#if TargetF2
        public static int GetNewIndex(System.Windows.Forms.ListControl lstControl)
Esempio n. 39
0
 protected OptionsToolbarSection(ListControl listControl)
     : base(listControl)
 {
 }
Esempio n. 40
0
 public static void removeItem(ListControl list, string text)
 {
     if (list == null) return;
     if (list.InvokeRequired)
         list.Invoke(new textHandler(uremoveItem), list, text);
     else uremoveItem(list, text);
 }
Esempio n. 41
0
 /// <summary>获取ListControl填充实体类</summary>
 /// <param name="entity"></param>
 /// <param name="field"></param>
 /// <param name="control"></param>
 private void GetListControl(IEntity entity, FieldItem field, ListControl control)
 {
     Object v = control.SelectedValue;
     if (v == null)
         v = control.Text;
     if (!Object.Equals(entity[field.Name], v)) SetEntityItem(entity, field, v);
 }
Esempio n. 42
0
        /// <summary>
        /// Sets the list item.
        /// </summary>
        /// <param name="lstControl">The list control instance.</param>
        /// <param name="index">The index.</param>
        /// <param name="value">The value.</param>
#if TargetF2
        public static void SetListItem(System.Windows.Forms.ListControl lstControl, int index, string value)
Esempio n. 43
0
 private static IList ListControlItemsFor(ListControl listControl) {
     if (listControl is ListBox)
         return ((ListBox) listControl).Items;
     else if (listControl is CheckedListBox)
         return ((CheckedListBox) listControl).Items;
     else if (listControl is ComboBox)
         return ((ComboBox) listControl).Items;
     return null;
 }
Esempio n. 44
0
        /// <summary>
        /// Gets the list item.
        /// </summary>
        /// <param name="lstControl">The List control instance.</param>
        /// <param name="index">The index.</param>
        /// <returns>The list item.</returns>
#if TargetF2
        public static string GetListItem(System.Windows.Forms.ListControl lstControl, int index)
Esempio n. 45
0
 public GroupSection( ListControl listControl, RowIdentifier ri, HeaderSection headerSection, int position, int groupIndentWidth )
     : base(listControl, ri, headerSection, position)
 {
     Debug.Assert( ri is ListSection.GroupIdentifier );
     _groupIndentWidth = groupIndentWidth;
 }
Esempio n. 46
0
        /// <summary>
        /// Removes the item.
        /// </summary>
        /// <param name="lstControl">The list control instance.</param>
        /// <param name="index">The index.</param>
#if TargetF2
        public static void RemoveItem(System.Windows.Forms.ListControl lstControl, int index)