|
Please take a look at the ControlPaint.DrawReversibleFrame method. That will help you
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Hi,
This is one useful snippet I used.
private void DrawReversibleRect( Point p1, Point p2 )
{
Rectangle rc = new Rectangle();
if( p1.X < p2.X )
{
rc.X = p1.X;
rc.Width = p2.X - p1.X;
}
else
{
rc.X = p2.X;
rc.Width = p1.X - p2.X;
}
if( p1.Y < p2.Y )
{
rc.Y = p1.Y;
rc.Height = p2.Y - p1.Y;
}
else
{
rc.Y = p2.Y;
rc.Height = p1.Y - p2.Y;
}
Rectangle r = pictureBox1.RectangleToScreen(rc);
ControlPaint.DrawReversibleFrame(r,this.BackColor,FrameStyle.Dashed);
}
You can draw the reversiblerectangle in the MouseMove event.
HTH
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Hi Smitha,
Thanks for your reply. I already found something like that, by setting some Pen properties and drawing a rectangle with the Graphics.DrawRectangle method I got the same. But thanks nevertheless, this way is much easier.
But drawing the selectioncontrol isn't my main problem. My main problem is the resizing of the control and setting the cursors depending on where they are. For example, when the cursor is within the control, the cursor has to be set to the SizeAll cursor. But if the cursor is in the middle dotted line of the rectangle (on the little square), the cursor has to be set to SizeNS if the cursor is on the upper or the bottom line, and to SizeWE if the cursor is on the right or the left line. And the corners also have their own cursors. Setting the cursor every time when the MouseMove event is fired depending on where the mouse is requires a lot of if's and it will be way too slow. So do you have an idea how to get that working without making the program very slow?
By the way, I'm not a very experienced programmer. So it could be I ask dumb questions .
Thanks in advance,
Joost
|
|
|
|
|
My MyDUMeter article mite be of some help. I use painting for range selection on the report graph. I think you are having the same performance problems I had.
http://www.codeproject.com/useritems/MyDUMeter.asp[^]
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi leppie,
Thanks for your reply, I think I know enough about the drawing stuff. The only thing left is assigning the right cursors, but I'll try some things myself first. Still, any comments on assigning the cursors are welcome!
Thanks in advance,
Joost
|
|
|
|
|
Hi Joost,
I have not tried it that way. But do post about it, if you succeed assigning cursors to the selection. Good luck!
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Hello,
does anyone know how to align the Pen-Object correctly when drawing lines with the DrawLine() - Methode of the Graphics-Namespace?
The problem is, that when i draw a line with a width of e.g. 7 pixels from Point (0,10) to Point (100,10) the topmost/leftmost painted pixel is at (0,7) instead of (0,10). That is because the Pen-Object is positioned at the center of the line that should be drawn. But this behavior is bad when drawing borders of e.g. controls.
The PenAlignment-Property of the Pen-Object doesn't seem to work here, though it works with the DrawRectangle()-Methode. If i paint a rectangle with the startcorner at (0,10) and i set the PenAlignment to "Inset", the topmost/leftmost paintet pixel is at the "correct" location of (0,10).
Does anyone here know how to solve this problem?
Greetings
Armin
|
|
|
|
|
Line accuracy is troublesome when working in different mapping modes. Lines work fine when defining them in MM_TEXT (without scaling) but when using modes like MM_HIMETRIC and incorporating scaling, the MFC lines always insist on having the same screen coordinate width regardless of where they translate to from the mapping mode. Alignment problems because of this behaviour are most evident with endcaps when aligning horizontal and vertical lines. At different scales, a little overhang or underhang becomes evident. Consistency at all scales is nearly impossible to achieve.
Your question concerning the alignment can be approached by taking the line and offsetting it but you will find alignment with MFC Rectangles and Circles becomes problematic (especially with borders). I spent quite a few months addressing this issue and studying how other applications approach alignment and found that there are many schools of thought, all having pro's and con's.
When you need to leftalign and rightalign bottomalign and topalign geometric shapes, you will find that line thickness and your choice of righthanded, centered, and lefthanded lines complicate the process and will require some modifications to coordinates you feed to the drawing commands. I believe there are no "One size fits all" drawing routines that will accomodate every programmers needs. The MFC drawing commands are a good place to start but I would recommend calling those functions from within your own drawing functions that take your drawing approach into consideration.
|
|
|
|
|
I made Several userControls and one WinForm.
And I tried to attach userControls to WinForm from ToolBox at Design Time.
But, "System.NullReference Exception occurred"
When I did 'drag and drop' to do it.
I don't know Why it happened.
Is there anybody Help me??
|
|
|
|
|
Anyone had a look at COM+ from .NET using the Enterprise Services namspace?
I've been having a look, but when I override some of the functions in the ServicedComponent class (Construct & CanBePooled) from which I have to derive my new managed COM+ component, the compiler complains.
[Transaction(TransactionOption.Required)]
public class BusinessObject : ServicedComponent
{
public BusinessObject()
{
}
protected internal override bool CanBePooled()
{
return false;
}
protected internal override void Construct(string s)
{
}
public void DoWork()
{
ContextUtil.DeactivateOnReturn = true;
ContextUtil.MyTransactionVote = TransactionVote.Abort;
ContextUtil.MyTransactionVote = TransactionVote.Commit;
}
}
I've been looking at this example.on MSDN, but it uses the beta edition of VS.NET, and does not compile.
http://msdn.microsoft.com/msdnmag/issues/01/10/complus/default.aspx[^]
I managed to get the above compling by manually ammending the access modifiers, but it does not seem very slick, when you have the IDE overide a member, and create the code, to find it does not compile.
Changing to
protected override void Construct(string s)
{
}
works, but as I said not very slick. If this is the mest MS can do, then not much hope. .NET will only be of any use to code monkeys.
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
Hi, I need to store a word document in MSSQL database (in image field) from C# windows application!
How can I do it? I need to create some kind of binary readers or streams to get that file and then store it or I do not know?
|
|
|
|
|
Check out ADO.NET and BLOB fields on MSDN. BLOB standing for - binary large objects.
If your not familiar with ADO or ADO.NET.
You need to open a database connection, and then a Recordset (for ADO), or a DataAdapter and a DataSet for ADO.NET.
In ADO (native COM objects), an ADODB.Recorset object can be used to both open a table and a append or update records.
In ADO.NET this functionality is split between the DataAdapter (For speaking to the DB) and the DataSet objects (for programatically examining the data off line).
Good luck.
If your new use the ADO library, and the Recordset.Field.AppendChunk & GetChunk methods to load and extract binary data into an image field.
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
As you know, double clicking a word document (for example) will open MS Word and then open that document. If the document has no file associated to it, “open with” window will appear.
My question, is there a way in C# to imitate (or invoke) such functionality?
|
|
|
|
|
Not a good starting in this forum..I am still searcing and searching for an answer.. It seems I'll answer my self after few days (not bad!)..
|
|
|
|
|
Hi:
I am going to draw graphics in c#, and this process of drawing should be saved (probably with time and pixel). so later can replay the process of how the graphics to be drawn.
but i have no idea on that.
is there any solution or concept on doing this stuff?
very appreciate for your help
henry
|
|
|
|
|
I found a very nice mail server / client written entirely in C# (for .net sp2) with complete and well documented source code.
Has every component that goes into a complete mail server and client applications including MIME attachment handling, DNS, FTP, ICMP etc etc all broken separately for easy usage in other applications. The author states it's freeware.
I found it here originally:
http://www.c-sharpcorner.com/Code/2002/Nov/SMTPPOP3MailServer.asp[^]
But the most up to date version is on the author's site here:
http://www.lumisoft.ee/lsWWW/ENG/Products/Mail_Server/mail_index_eng.aspx?type=info[^]
Someone should convince them to post it to CodeProject, it's definitely worthy and illustrates many different useful concepts beyond the value of the code itself.
|
|
|
|
|
I've been using the Lumisoft mail server for over 6 months in a production environment using SqlServer2K as the mail store. It has been rock solid and is very simple to configure - highly recommended!
Jimmy
|
|
|
|
|
Actually since I posted this, I found several problems with it related to emails with attachments and it became unworkable in our business environment.
Everything was there and in general it worked fine at the time. It just needed to be more "fleshed out" to handle the variety of attachments, html email and globally used date formats correctly. (there was something else but I can't recall exactly what but it was something that would be minor for most but was a major problem for us with the business app I wanted to use it in)
I was going to extend it but ran out of time and had to opt for a commercial component instead (Chilkat).
I still think it's a very nicely written app and a good example of what you can do in C# with a real world application.
I'm curious if you have had any problems with attachments or if they have updated it since March 2003?
------------
Tomorrow is the same day as today was yesterday.
|
|
|
|
|
Hi there,
How can I reach my MySQL database on the net and fetch the datas to a windows form in C#??? Is there a class or library or whatever???
Thanx...
|
|
|
|
|
zamazula wrote:
Is there a class or library or whatever???
You will need ODBC.NET[^] and then also MyODBC[^].
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I needed to access a MySql dbase once, so I used dbProvider, it is a managed MySql C# DLL that uses all the same syntax and classes etc as the default SQL ones, I have had no problems with it what-so-ever.
|
|
|
|
|
I am looking for a good way to maintain a clean separation between the GUI, the business objects and the persistence mechanism. It seem as though the forms/asp environment is geared to directly couple the DB with fields on a form. In general, I try to have my GUIs stay dumb and only know about the underlying business objects. Then the business objects either know how to persist themselves, or what to use for a persistence mechanism.
What's the C# / dotNet best practice for keeping these layers distinct?
Thanks,
Bryan
|
|
|
|
|
Hi,
In my program I need after doing some job to be able to shut down the system.
So I wrote that code:
public event SessionEndedEventHandler ShutDown;
protected virtual void OnShutDown(SessionEndedEventArgs e)
{
ShutDown(this,e);
}
and then I wanted on a button click to raise the event:
private void button1_Click(object sender, System.EventArgs e)
{
OnShutDown(new SessionEndedEventArgs(SessionEndReasons.SystemShutdown));
}
But I always get System.NullReferenceException
Anyone has an idea how to solve this problem ?
Thanx in advance
Cheers,
Gogou
GAtanasov
|
|
|
|
|
Hi,
I think that OnShutDown should check that there is a handler for the event, i.e. the code should be:
if (ShutDown != null) ShutDown(this, e);
Chris Jobson
|
|
|
|
|
Hi, all:
I have a master-detail relationship in my MS Access DB. In my WinForm application, I also created same Master-Detail relationship in my dataset. When I delete a row in my datagrid, the entries in the detail table is also deleted in the dataset due to the relationship. After an user finishs editing the data, I call daMaster.Update and then daDetail.Update. I got the DBConcurrencyException when trying to update the detail table. I think the reason is as following: when the master table is updated, it deletes the row marked with "Deleted". Since the relationship is setup in the MS Access DB, it deletes the entries in the detail table of Access DB. When the second Update is called, the record is gone and exception is thrown.
How do I fix this problem? I can not change the order of update, otherwise it will break the new entries ( must exist in the Master table first ). I guess that if I take all the relationship out in the MS Access DB, it will work fine, but I think that probably is not good thing to do.
Please help. Thanks in advance.
Dion
|
|
|
|