|
I would like to have a designer property which is a collection of a complex object, a little like the Columns property for the ListView control.
I have looked for articles but to no avail.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
|
I am attempting to add plugin support to a program I wrote.
I have found many articles on Code Project, each showing how you can create objects from an assembly loaded at runtime. This is great, however, my original design made extensive use of inheritance.
Now I'm trying to figure out how I can expose a "parent class" to a plugin.
For example: Button inherits from Surface. Surface needs to be something that can be re-written by plugin developers, so that Button will now inherit the version of Surface in the plugin.
Can this even be done?
-Mike.
|
|
|
|
|
I don't think you can do that (or even want to do that; plugins should have very limited set of functionality avalible to them; inserting them into the core of a aplication is not the best choice...)...
But please correct me if I am wrong.
--------------------------------------------------------
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Hello,
This can be done, although it is not an easy road you want to travel.. Here late binding is not enough, but you also need to create code at runtime. I don't know exactly how to do this. Also several problems arise: what if more than one replacement for the surface class is found? What to do with errors that the plugin might cause? Etc.
But I wonder, why do you want to give complete control over your application to some third party?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
FillEllipse and FillRectangle don't seem to work with a height or width of 1. That's too bad. I need it to draw a line or pixel when one or both are 1. It seems I have to put extra code in there just for that.
"If only one person knows the truth, it is still the truth." - Mahatma Gandhi Web - Blog - RSS - Math
|
|
|
|
|
If memory serves me correctly, the fill functions won't touch the border; so hypothetically, if after you FillEllipse, you DrawEllipse with a pen like your brush, it should create the necessary shape.
Then again, I haven't done GDI in years.
--
I've killed again, haven't I?
|
|
|
|
|
I'll add DrawEllipse. Currently, I'm doing fill without it.
"If only one person knows the truth, it is still the truth." - Mahatma Gandhi Web - Blog - RSS - Math
|
|
|
|
|
|
If that's the case, why does a height or width of two work? Aren't they drawing both sides with a minimum of 1 pixel each?
"If only one person knows the truth, it is still the truth." - Mahatma Gandhi Web - Blog - RSS - Math
|
|
|
|
|
I've got a class that uses a System.Threading.ReaderWriterLock .
class MyClass
{
int myReadLockCount;
int myWriteLockCount;
void DoSomeReads()
{
this.AcquireReaderLock();
try
{
...
}
finally
{
this.ReleaseReaderLock();
}
}
void DoSomeWrites() {...}
void AcquireReaderLock()
{
myRWLock.AcquireReaderLock(...);
Interlocked.Increment(ref myReadLockCount);
}
void AcquireWriterLock() {...};
void ReleaseReaderLock() {...};
void ReleaseWriterLock() {...};
}
During the course of running and debugging this application, I receive scenarios where myWriteLockCount variable is greater than 1! How can this be; isn't ReaderWriterLock supposed to allow one writer at a time?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Judah Himango wrote: void ReleaseWriterLock() {...}; // releases the writer, decrements myWriteLockCount.
Just a guess, but shouldnt you be decrementing before releasing. You dont show the code, but the comment points to a possible cause.
|
|
|
|
|
Leppie, turns out a piece of my code was acquiring the writer lock multiple times from the same thread. So it was a coding mistake on my part, as I suspected. Anyways, thanks for the reply.
|
|
|
|
|
I have an appication that requires me to have a folder treeview simlar to
this[^]
Hpw do I make the same thing? I found a similar thing on planet source code, but it just gave me a treeview displaying folders. How can I get a control that allows me to select folders in the exact same way as in the screenshot.
|
|
|
|
|
Set the TreeView.CheckBoxes property to true.
|
|
|
|
|
I created a custom tab control and tab pages are added with a CollectionEditor. The CollectionEditor will add code and remove code when the add and remove buttons are used, but if the control is deleted on the form then the source code for the tab pages does not get removed. What needs to be done in order to remove the collections when the control is destroyed?
|
|
|
|
|
I have a small application. Is there any way I could cause my application to restart in the event of a crash instead of just closing?
|
|
|
|
|
I'm looking for an answer for the same question, but I'm checking now if I can use the event log in Windows to check if this application is closed by the user or in the event of crash, I'll keep searching and answer you if i got the answer, you can look for the same subject.
With my best hopes:
============--------
Mr.Jocker
--------============
|
|
|
|
|
Take a look at this, written by Tom Archer, a CPian.
Ed
|
|
|
|
|
You could do as Microsoft did and create a service(HangReporting Tool.) Just have the service look to see if the program exited anyway other than an exit code. You could have the program send the service a code saying it shutdown ok too.
|
|
|
|
|
I am trying to do a drag and drop. The idea is to drag from a listbox and create an instance of a label or a class that contains a label as a member, and drop the label to a panel to drop. Once on the panel the label need to moveable (drag and drop) in the panel. I also need to be able to store the x and y location of the label reletive to the panel. I can wait on the x and y stuff for now. I mainly need to get the label to appear in the panel with the text of the associate listbox item. Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MullinsReqStar
{
public partial class Form1 : Form
{
Image bkgrnd_image;
Label[] lblList = new Label[25];
int count = 0;
public Form1()
{
InitializeComponent();
this.Text = "Mullins ReqStar";
}
private void lbItems_MouseDown(object sender, MouseEventArgs e)
{
lbItems.DoDragDrop(lbItems.Items[lbItems.SelectedIndex].ToString(), DragDropEffects.Copy | DragDropEffects.Move);
}
private void pnlImageBorder_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
//string strTest = lbItems.Items[lbItems.SelectedIndex].ToString();
//lblList[lbItems.SelectedIndex].Text = lbItems.Items[lbItems.SelectedIndex].ToString();
}
private void pnlImageBorder_DragDrop(object sender, DragEventArgs e)
{
//lblList[lbItems.SelectedIndex].Text = lbItems.Items[lbItems.SelectedIndex].ToString();
string strXTest = e.X.ToString();
string strYTest = e.Y.ToString();
lblList[lbItems.SelectedIndex].Location = new Point(e.X, e.Y);
}
}
}
Thanks
cbeasle1
|
|
|
|
|
|
I don't want to use any external programs or interfaces, i just need a solution without any user actions to obtain an image.
Thanks.
|
|
|
|
|
Hi,
I need to send right mouse click from within my program (C#.NET) to windows, so it will look like the user has right/left clicked with the mouse somewere on the desktop.
Any help will be highly appreciated
roy
|
|
|
|
|
I didn't try this, but it should look like:
<br />
[DllImport("user32.dll")]<br />
public static extern int SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam)<br />
...<br />
public const UInt32 WM_LBUTTONDOWN = 0x201;<br />
public const UInt32 WM_LBUTTONDOWN = 0x202;<br />
...<br />
private void FakeClick( Control TargetControl, Point MouseLocation )<br />
{<br />
SendMessage(TargetControl.Handle,WM_LBUTTONDOWN,0,(MouseLocation.Y * 0x10000) + MouseLocation.X);<br />
SendMessage(TargetControl.Handle,WM_LBUTTONUP,0,(MouseLocation.Y * 0x10000) + MouseLocation.X);<br />
}<br />
In case that you don't have target Control try:
<br />
...<br />
public const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;<br />
public const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;<br />
...<br />
[DllImport("user32.dll")]<br />
private static extern void mouse_event( UInt32 dwFlags,UInt32 dX,UInt32 dY,UInt32 dwData,IntPtr dwExtraInfo);<br />
...<br />
public static void FakeClick(Point MouseLocation )<br />
{<br />
Cursor.Position = MouseLocation;<br />
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, new System.IntPtr());<br />
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, new System.IntPtr());<br />
}<br />
|
|
|
|