|
Caveat: I haven't used NAudio. These suggestions are based on the apparent use of MEF for the plugins. I have not tried any of this. (I am not an MEF guru.)
First: some things that seem clearly wrong.
RecordingPanelPlugin.ConnectionString() (besides having a very misleading name) collects all of the CustomerName column values into a single string. There's nothing keeping them as individual values.
The RecordingPanelPlugin.Name property just returns all of the names concatenated together.
MEF is Importing and creating a single instance of your RecordingPanelPlugin .
You seem to need a "parent" class which creates all of the instances of the RecordingPanelPlugin you want.
Create an interface that MEF can use to instantiate the class that creates the individual instances of RecordingPanelPlugin :
public interface IPluginFactory
{
List<INAudioPlugin> GetAudioPlugins();
}
Simplify the class RecordingPanelPlugin :
[PartNotDiscoverable]
[Export(typeof(INAudioPlugin))]
public class RecordingPanelPlugin : AudioPlugin
{
public RecordingPanelPlugin (string name)
{
this.Name = name;
}
public string Name { get; private set; }
public Control CreatePanel()
{
return new RecordingPanel();
}
}
Then create a class which implements IPluginFactory for the RecordingPanelPlugin :
[Export(typeof(IPluginFactory))]
public class RecordingPanelPluginFactory
{
private public List<INAudioPlugin> AllRecordingPanelPlugins;
public List<INAudioPlugin> GetAudioPlugins()
{
if (AllRecordingPanelPlugins == null)
{
AllRecordingPanelPlugins = new List<INAudioPlugin>();
using (var conn = new SqlCeConnection("Data Source=MyDatabase.sdf;Password=pass;Persist Security Info=True"))
{
conn.Open();
var comm = new SqlCeCommand("SELECT * FROM main", conn);
SqlCeDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
AllRecordingPanelPlugins.Add(new RecordingPanelPlugin((string)(reader["CustomerName"])));
}
}
}
return AllRecordingPanelPlugins;
}
}
Now change the MainForm to have MEF give it all of the IPluginFactory s:
[ImportingConstructor]
public MainForm([ImportMany] IEnumerable<IPluginFactory> factories)
{
InitializeComponent();
listBox.DisplayMember = "Name";
foreach (var factory in factories)
{
foreach (var plugin in factory.GetAudioPlugins())
{
listBox.Items.Add(plugin);
}
}
}
Good luck!
(Remember my caveat above! )
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
That option didn't work either as the plugin was expecting a different variable type and I wasn't able to implicitly or explicitly convert. So, I decided after almost three days, it was time to rethink my logic. What I decided to do was put my query in my mainform which then displayed the listbox correctly. Then I modified my SelectedIndexChanged event in my mainform so instead of referencing the plugin directly I'm passing the listbox variable to the recordingpanel.cs instead. Everything is working great as expected using my new logic.
Thanks for your response and suggestion though.
|
|
|
|
|
how can I create circular shape button? plz reply
|
|
|
|
|
What technology? WPF? ASP.NET? Windows Forms?
|
|
|
|
|
|
why cant you use an image and click can put click events for that..
more over i think for the circle shaped button we need a lot of discussion about the libraries
|
|
|
|
|
Well, I would normally use the power of WPF to do this. The person who asked the question, however, has no idea that you replied.
|
|
|
|
|
you mean my answer should be elaborated??
|
|
|
|
|
I mean you should give your answer to the person who actually asked the question.
|
|
|
|
|
common friend here we post this to be seen by everyone..
|
|
|
|
|
We do. However, as you are posting against a question that someone has asked, the polite thing to do is to reply to them so that they get notified that there is an answer. By replying to me, I see the notification, but the person who asked the question doesn't.
|
|
|
|
|
OK ok my friend sorry for u and for not replying to him
|
|
|
|
|
Google is your friend; be nice and visit him often...
There are a huge number of examples out there of round buttons, some good, some bad.
A quick google restricted to just this site found nearly 4000 examples: round button c# site:codeproject.com[^]
Try this: Custom Button Control with Gradient Colors and Extra Image (VB.NET)[^] It's VB, but you can just use the code in a DLL.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
how to disable combobox if another combobox is selected in c# windows form application
diviya murali
|
|
|
|
|
The simplistic answer would be to set the Enabled state of the ComboBox from the other ComboBox by handling the GotFocus and LostFocus events on that ComboBox .
|
|
|
|
|
You can write it in Select_Index_Change of First DropDown
EX:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Enabled = false;
}
|
|
|
|
|
That doesn't solve the OP's problem.
|
|
|
|
|
As Pete said, it does not help the OP with his problem. He wants to disable the combo box when it is selected, not when an item is selected...
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Note the OP is intending to do this for c# windows form application and not for ASP.NET Applications.
|
|
|
|
|
you can use the Click event of the second combobox to enable/disable the first combobox
private void comboBox2_Click(object sender, EventArgs e)
{
comboBox1.Enabled = false;
}
http://freaksofdeveloper.blogspot.co.at/
|
|
|
|
|
Is this event fired if the user tabs into the combobox?
|
|
|
|
|
The simplistic answer would be to set the Enabled state of the ComboBox from the other ComboBox by handling the GotFocus and LostFocus events on that ComboBox.
|
|
|
|
|
|
It's a good answer. Take you long to come up with it?
|
|
|
|
|
By using Jquery u can do this in web
for windows u need handle in code
Thanks & Regards
Anant Shetty
|
|
|
|