Click here to Skip to main content
15,561,817 members
Home / Discussions / C#
   

C#

 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
Mycroft Holmes8-Feb-14 14:31
professionalMycroft Holmes8-Feb-14 14:31 
AnswerRe: how can i get min value in datatable with distinct items using loops Pin
Md Nazmoon Noor13-May-14 4:21
Md Nazmoon Noor13-May-14 4:21 
QuestionSSH Connection to Cisco Router Pin
sikas_Cisco8-Feb-14 5:36
sikas_Cisco8-Feb-14 5:36 
SuggestionRe: SSH Connection to Cisco Router Pin
Richard MacCutchan8-Feb-14 6:28
mveRichard MacCutchan8-Feb-14 6:28 
GeneralRe: SSH Connection to Cisco Router Pin
sikas_Cisco8-Feb-14 6:34
sikas_Cisco8-Feb-14 6:34 
GeneralRe: SSH Connection to Cisco Router Pin
Richard MacCutchan8-Feb-14 6:37
mveRichard MacCutchan8-Feb-14 6:37 
GeneralRe: SSH Connection to Cisco Router Pin
dharmegh9-Feb-14 20:23
dharmegh9-Feb-14 20:23 
QuestionAttributes Help: Defining an item list in an attribute Pin
helkhoury7-Feb-14 21:29
helkhoury7-Feb-14 21: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 20:06
Rupaswathi7-Feb-14 20:06 
AnswerRe: Using of Abstract class and Interface class Pin
Richard MacCutchan7-Feb-14 23:10
mveRichard MacCutchan7-Feb-14 23:10 
QuestionC# dll import Pin
Member 42110407-Feb-14 6:40
Member 42110407-Feb-14 6:40 
AnswerRe: C# dll import Pin
Richard Andrew x647-Feb-14 10:56
professionalRichard Andrew x647-Feb-14 10:56 
GeneralRe: C# dll import Pin
Member 42110407-Feb-14 11:19
Member 42110407-Feb-14 11:19 
AnswerRe: C# dll import Pin
Richard Andrew x647-Feb-14 13:41
professionalRichard Andrew x647-Feb-14 13:41 
QuestionIs it possible to impelement Voice Recognition in C# Web Applicaion? Pin
PALANI KUMAR.A6-Feb-14 23:25
PALANI KUMAR.A6-Feb-14 23:25 
AnswerRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Pete O'Hanlon7-Feb-14 0:06
mvaPete O'Hanlon7-Feb-14 0:06 
AnswerRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Snehasish_Nandy7-Feb-14 0:06
professionalSnehasish_Nandy7-Feb-14 0:06 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Marco Bertschi7-Feb-14 0:08
professionalMarco Bertschi7-Feb-14 0:08 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Snehasish_Nandy7-Feb-14 0:10
professionalSnehasish_Nandy7-Feb-14 0:10 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Marco Bertschi7-Feb-14 0:11
professionalMarco Bertschi7-Feb-14 0:11 
AnswerRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Keith Barrow7-Feb-14 0:11
professionalKeith Barrow7-Feb-14 0:11 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Pete O'Hanlon7-Feb-14 0:37
mvaPete O'Hanlon7-Feb-14 0:37 
GeneralRe: Is it possible to impelement Voice Recognition in C# Web Applicaion? Pin
Keith Barrow7-Feb-14 1:03
professionalKeith Barrow7-Feb-14 1:03 
Questionusb dongle software for c# Pin
Member 99539286-Feb-14 23:19
Member 99539286-Feb-14 23:19 
AnswerRe: usb dongle software for c# Pin
Marco Bertschi6-Feb-14 23:58
professionalMarco Bertschi6-Feb-14 23: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.