Click here to Skip to main content
15,867,686 members
Home / Discussions / C#
   

C#

 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
Mycroft Holmes8-Feb-14 13:31
professionalMycroft Holmes8-Feb-14 13:31 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
Md Nazmoon Noor13-May-14 3:21
Md Nazmoon Noor13-May-14 3:21 
QuestionSSH Connection to Cisco Router Pin
sikas_Cisco8-Feb-14 4:36
sikas_Cisco8-Feb-14 4:36 
SuggestionRe: SSH Connection to Cisco Router Pin
Richard MacCutchan8-Feb-14 5:28
mveRichard MacCutchan8-Feb-14 5:28 
GeneralRe: SSH Connection to Cisco Router Pin
sikas_Cisco8-Feb-14 5:34
sikas_Cisco8-Feb-14 5:34 
GeneralRe: SSH Connection to Cisco Router Pin
Richard MacCutchan8-Feb-14 5:37
mveRichard MacCutchan8-Feb-14 5:37 
GeneralRe: SSH Connection to Cisco Router Pin
dharmegh9-Feb-14 19:23
dharmegh9-Feb-14 19:23 
QuestionAttributes Help: Defining an item list in an attribute Pin
helkhoury7-Feb-14 20:29
helkhoury7-Feb-14 20:29 
I am writing a program which will connect to a I2C to USB controller. I am using WPF.
I decided to create a Device class to contain the hardware description and all its attributes so I can use them to display properties and have the end user modify the settings of the hardware.
I have most of the above working, except 2 attributes.
Most attributes are strings or int or byte, etc... so they are easy to work with, like the example below:
C#
private string _name;
       [Category("General")]
       [ReadOnly(false)]
       [DisplayName("Module Name")]
       [Description("Enter descriptive string ")]
       public string Name { get { return _name; } set { _name = value; OnPropertyChanged("Module Name"); } }


The 2 attributes I am having a hard time with need to have a list to populate.
So I read the hardware setting, and it returns that it supports I2C, SPI, and UART.
Now I want to be able to pass those to the "CommunicationType" attribute, and have it display as a list in the properties window.
To see if my program is working, I created the following class:
C#
public class CommunicationType : IItemsSource
{
    public ItemCollection GetValues()
    {
        ItemCollection sizes = new ItemCollection();
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.I2C, "I2C");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.ISSP, "ISSP");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.JTAG, "JTAG");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.SPI, "SPI");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.SWD, "SWD");
        sizes.Add((int)PP_COM_Wrapper.enumInterfaces.SWD_SWV, "SWD SWV");
        return sizes;
    }
}

Then in the attribute, I have the following:
C#
private int _comtype;
       [Category("Settings")]
       [ReadOnly(false)]
       [ItemsSource(typeof(CommunicationType))]
       [DisplayName("Communication Type")]
       public int CommunicationType { get { return _comtype; } set { _comtype = value; OnPropertyChanged("Communication Type"); } }


So when I run it, it gives the user the possibility to select from a drop down, one of the communication types.
Now the question is, how do I populate it programmatically. Some of the hardware only supports I2C and SPI, so I only want to populate the list with 2 items based on the hardware.

Any guidance or examples are greatly appreciated.
Thanks,
H-

modified 8-Feb-14 2:56am.

QuestionUsing of Abstract class and Interface class Pin
Rupaswathi7-Feb-14 19:06
Rupaswathi7-Feb-14 19:06 
AnswerRe: Using of Abstract class and Interface class Pin
Richard MacCutchan7-Feb-14 22:10
mveRichard MacCutchan7-Feb-14 22:10 
QuestionC# dll import Pin
Member 42110407-Feb-14 5:40
Member 42110407-Feb-14 5:40 
AnswerRe: C# dll import Pin
Richard Andrew x647-Feb-14 9:56
professionalRichard Andrew x647-Feb-14 9:56 
GeneralRe: C# dll import Pin
Member 42110407-Feb-14 10:19
Member 42110407-Feb-14 10:19 
AnswerRe: C# dll import Pin
Richard Andrew x647-Feb-14 12:41
professionalRichard Andrew x647-Feb-14 12:41 
QuestionIs it possible to impelement Voice Recognition in C# Web Applicaion? Pin
PALANI KUMAR.A6-Feb-14 22:25
PALANI KUMAR.A6-Feb-14 22:25 
AnswerRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Pete O'Hanlon6-Feb-14 23:06
subeditorPete O'Hanlon6-Feb-14 23:06 
AnswerRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Snehasish_Nandy6-Feb-14 23:06
professionalSnehasish_Nandy6-Feb-14 23:06 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Marco Bertschi6-Feb-14 23:08
protectorMarco Bertschi6-Feb-14 23:08 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Snehasish_Nandy6-Feb-14 23:10
professionalSnehasish_Nandy6-Feb-14 23:10 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Marco Bertschi6-Feb-14 23:11
protectorMarco Bertschi6-Feb-14 23:11 
AnswerRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Keith Barrow6-Feb-14 23:11
professionalKeith Barrow6-Feb-14 23:11 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Pete O'Hanlon6-Feb-14 23:37
subeditorPete O'Hanlon6-Feb-14 23:37 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Keith Barrow7-Feb-14 0:03
professionalKeith Barrow7-Feb-14 0:03 
Questionusb dongle software for c# Pin
Member 99539286-Feb-14 22:19
Member 99539286-Feb-14 22:19 
AnswerRe: usb dongle software for c# Pin
Marco Bertschi6-Feb-14 22:58
protectorMarco Bertschi6-Feb-14 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.