|
The thing is that the PictureBoxExtended brings only one event (MouseMoveOverImage), and I needed to create another (MouseClickedImage), but its really easy:
This is what it brings:
public delegate void MouseMoveOverImageHandler(object sender, MouseEventArgs e);
public event MouseMoveOverImageHandler MouseMoveOverImage;
And I added the following
public delegate void MouseClickedImageHandler(object sender, MouseEventArgs e);
public event MouseMoveOverImageHandler MouseClickedImage;
And then go down to the protected methods part and create a method that overrides the OnMouseClick method of the base class PictureBox,
so:
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (Image != null)
{
if (MouseClickedImage != null)
{
Point p = TranslatePointToImageCoordinates(e.Location);
if (p.X >= 0 && p.X < Image.Width && p.Y >= 0 && p.Y < Image.Height)
{
MouseEventArgs ne = new MouseEventArgs(e.Button, e.Clicks, p.X, p.Y, e.Delta);
MouseClickedImage(this, ne);
}
}
}
}
And what I wrote here is just like the code within the OnMouseMove method... so I didn't had to think anything... Look that i'm calling to the base method also, so you can still use the MouseClick event normally
Cya!
|
|
|
|
|
Thanks for your help!
Appreciate it.
|
|
|
|
|
Hi All,
If you have a ListBox that is populated with many items, the listbox will display a small portion of the list and provide a scroll bar to roll the list Up/Down to view the remainder of the list.
What I would like to do is:
1. Return a collection/Reference to the items that are within the visible part of the list.
2. Return an index to the item that is at the top of the visible part of the list.
3. Trap an event when the list scroll Up/Down and the visible items changes.
The ListBox control doesn't appear to have any properties or events to deal with anay of the above conditions. Does anyone have any suggestions/thoughts/ideas on how I do these things? -Thanks
Regards,
Gavin...
|
|
|
|
|
Take a look at this[^] as a possible solution to the OnScroll problem.
For something with a little more explanation try Getting Scroll Events for a Listbox[^] from here on CodeProject.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Tuesday, July 14, 2009 7:19 PM
|
|
|
|
|
Thanks for that Henry, That was exactly what I was looking for. It hasn't solve all my problems, but it did steer me in the right direction and I now know how to proceed. -Cheers
|
|
|
|
|
Hi ,
I've created an 8bpp grayscale bitmap file using Bitmap.Save().
The dimensions are 504 x 480 pixels.
504 x 480 = 241920 , so I'd expect the file on the system to be at least 241920 bytes ( 8bpp )
but it's less than 1/3 that size (80,045 bytes).
Can anyone explain this to me please, it's twisting my melon man.
|
|
|
|
|
You've saved it as a bitmap, not a jpg ? I would wonder if, even though you called it a .bmp, the system has defaulted to some other format.
Because, a bitmap would be three times the size you're calculating. There's no 8 bit BMP format that I know of, I thought it still stores as raw RGB data.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Im using the "Bitmap" class, and would have expected that to save it as a bitmap, I've read in the raw bytes, and it does seem to have an odd header (no 66,77 at the start) but it does have the grayscale RGB palette in there.
There is a PixelFormat of 8bppIndexed , but does that just relate to ImageFormat.GIF perhaps ?
|
|
|
|
|
What is curious though is that if I use windows explorer to look at the file I created, It shows a beautiful thumbnail ..... even though the file extension is BMP..... so the fole format must be OK.... wouldn't work if it was in GIF format.
|
|
|
|
|
Ah ... curious...I renamed it to BLAH.GIF and it still shows the thumbnail, I guess Bitmap.Save() default to GIF then.
|
|
|
|
|
It defaults to PNG actually. That it still works is because the extension is not actually taken into account that much - the decoder will be chosen based on the actual format, not the extension.
|
|
|
|
|
The Bitmap class really has nothing to do with bmp files - it's an in-memory representation that is based on pixels (hence the name)
If you call Save on it then the ImageFormat parameter will determine the file type (and with that I mean the actual contents of the file, not the file extension)
If you call Save without an ImageFormat it will end up as a PNG image, easily identifiable by the ‰PNG at the beginning. I think that might be what you did..
|
|
|
|
|
It's a bitmap. That means it's an image, not a BMP. There is no JPEG class, you specify you want the JPEG format, and save the bitmap from the Bitmap class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I'm looking at some code like this (sorry for the formatting):
public static OracleDataReader GetDynamicQueryReader (
OracleConnection con,
string sql,
out string msg)
{
sql = Regex.Replace(sql, @"\s+", " ");
try
{
using(OracleCommand cmd = new OracleCommand(sql, con))
{
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
msg = "Successful";
return dr;
}
}
catch (Exception ex)
{
msg = ex.Message;
con.Close();
return null;
}
}
This little chunk (not mine) is called several thousand times, and from the profiler I am using it is the generation of a new OracleCommand object costing the most. And this object can have its parameters set after instantiation.
Normally I would make this a static, but since I am supposed to instantiate it with a using statement to deal with the disposal of unmanaged references, Im not sure I can. Can I? If I determine that there are no memory leaks with a profiler by creating and disposing some unmanaged reference, can I safely make this static? Or should I really just put up with the poor performance?
|
|
|
|
|
using and static are incompatible. In fact, if it's static, there's only ever one, and it will be disposed of when your app closes, which means there is no issue.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I create one instance of a Command as a field of a class and then re-use it as needed. I don't worry about disposing it.
|
|
|
|
|
hi friends
i want to use a one richtextbox and one webbrowser instead of a html/text editor because i dednt find any editor control that can be used in windows application,
i try to change "DocumentText" property of webBrowser control and set it with richtextbox value when user press specify button but in first time below code works correctly but in next times this property of webBrowser has not changed!!! do u know why? please tell me the solution
webBrowser1.DocumentText = richTextBox1.Text;
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
Hello Mr. Mohsen,
I replied to your original post.
but you should use the WebBrowser.Document.Body.InnerHtml to set the HTML of the document.
|
|
|
|
|
oh no man i test your code and the result is like previouse code
in other hand both code have same result and in first time work correctly and in next times does not work
please check it to understand the problem
thank you
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
This is very strange because i just created a new project and am not experiencing your issue.
here is the sample code from my windows forms test.
public class Form1 : Form<br />
{<br />
<br />
private System.ComponentModel.IContainer components = null;<br />
<br />
protected override void Dispose(bool disposing)<br />
{<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
<br />
private void InitializeComponent()<br />
{<br />
this.webBrowser1 = new System.Windows.Forms.WebBrowser();<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.textBox1 = new System.Windows.Forms.TextBox();<br />
this.button2 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Bottom;<br />
this.webBrowser1.Location = new System.Drawing.Point(0, 127);<br />
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);<br />
this.webBrowser1.Name = "webBrowser1";<br />
this.webBrowser1.Size = new System.Drawing.Size(461, 257);<br />
this.webBrowser1.TabIndex = 0;<br />
this.button1.Dock = System.Windows.Forms.DockStyle.Top;<br />
this.button1.Location = new System.Drawing.Point(0, 0);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(461, 23);<br />
this.button1.TabIndex = 1;<br />
this.button1.Text = "button1";<br />
this.button1.UseVisualStyleBackColor = true;<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.textBox1.Location = new System.Drawing.Point(22, 30);<br />
this.textBox1.Name = "textBox1";<br />
this.textBox1.Size = new System.Drawing.Size(377, 20);<br />
this.textBox1.TabIndex = 2;<br />
this.button2.Location = new System.Drawing.Point(0, 56);<br />
this.button2.Name = "button2";<br />
this.button2.Size = new System.Drawing.Size(461, 23);<br />
this.button2.TabIndex = 3;<br />
this.button2.Text = "button2";<br />
this.button2.UseVisualStyleBackColor = true;<br />
this.button2.Click += new System.EventHandler(this.button2_Click);<br />
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />
this.ClientSize = new System.Drawing.Size(461, 384);<br />
this.Controls.Add(this.button2);<br />
this.Controls.Add(this.textBox1);<br />
this.Controls.Add(this.button1);<br />
this.Controls.Add(this.webBrowser1);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
this.PerformLayout();<br />
<br />
}<br />
<br />
#endregion<br />
<br />
private System.Windows.Forms.WebBrowser webBrowser1;<br />
private System.Windows.Forms.Button button1;<br />
private System.Windows.Forms.TextBox textBox1;<br />
private System.Windows.Forms.Button button2;<br />
<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
this.webBrowser1.Navigate("about:blank");<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
this.webBrowser1.Document.Body.InnerHtml += "<br />Clicked!";<br />
}<br />
<br />
private void button2_Click(object sender, EventArgs e)<br />
{<br />
this.webBrowser1.Document.Body.InnerHtml += "<br />" + this.textBox1.Text;<br />
}<br />
}
All i did was add the WebBrowser control the form, i then added 2 buttons and a textbox.
when the user clicks the button "Clicked!" is appended to the text when they click the other button the text in the text box is inserted.
If you want to test it just add a new class your existing project and paste all the sample code in there then set it as your startup object.
|
|
|
|
|
thank you my friend
your code work correctly
the problem is i didnt call navigate methode of webBrowser with about:blank value parameter
thank you very mutch
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
Guess I should have mentioned that.
Well good to hear you got it working.
|
|
|
|
|
Hey All,
I am experiencing a strange issue, i have built and tested my RegEx in Expresso but when I call it from my code (C#) I am not getting any matches. If i step through and grab the values from the variables and put those in Expresso it works ....
RegEx:
Lead\sID\sNumber:\s*(?<LeadNumber>[^\r\n]*)(?:\r\n)+<br />
Prospect\sName:.*(?:\r\n)+<br />
Prospect\sContact:.*(?:\r\n)+<br />
Prospect\sPhone:.*(?:\r\n)+<br />
Marketing\sCampaign:.*(?:\r\n)+<br />
Prospect\sInformation:\s*(?:\r\n)+<br />
===============\s(?:\r\n)+<br />
(?<Company>[^\r\n]*)(?:\r\n)+<br />
(?<Address1>[^,]*),\s(?<Address2>[^\r\n]*)(?:\r\n)+<br />
(?<City>[^,]*),\s(?<State>[^\r\n]*)(?:\r\n)+<br />
(?<Country>[^,]*),\s(?<Zip>[^\r\n]*)(?:\r\n)+<br />
Contact\sName:\s*(?<FirstName>[^\s]*)\s(?<LastName>[^\r\n]*)(?:\r\n)+<br />
Contact\sPhone:\s*(?<Phone>[^\r\n]*)(?:\r\n)+
C#:
<br />
MatchCollection myMatches = Regex.Matches([Text], [RegEx], RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);<br />
[Text] = the body of an email
[RegEx] = the above pattern
Any input or ideas would be greatly appreciated.
|
|
|
|
|
If you can provide some sample text that this Regex should match, it might help.
|
|
|
|
|
Thank you for you reply,
Here is a sample of the text to match.
<br />
Lead Overview: <br />
=========== <br />
Lead ID Number: 1234567 <br />
Prospect Name: Some Prospect<br />
Prospect Contact: Some Contact<br />
Prospect Phone: 1234567890 <br />
<br />
Marketing Campaign: Marketing Campaign Example<br />
<br />
Prospect Information: <br />
=============== <br />
Company Name<br />
Address1, Address2 <br />
New York, NY <br />
United States, 12345 <br />
<br />
Contact Name: Some Contact <br />
Contact Phone: 1234567890 <br />
Company Email: contact@email.com <br />
|
|
|
|