|
Hmm, maybe it's not worth the effort. I was thinking there might be a way to layer them and then place them into a final bitmap for increased speed of the drawing. From the profiler I am using, I am getting something on the order of 140ms to draw the whole thing the way I am doing it now.
|
|
|
|
|
Hi David,
hmm. 140 msec is more than I anticipated, and it certainly would be too much to do on the GUI thread unless you apply double-buffering.
Maybe your code needs some optimization, without really changing the organizational aspects, the threading, etc. Are you creating new pens, brushes, fonts, rather than keeping existing ones around? Are you calling CreateGraphics? Are you creating any objects at all? The art of fast painting is by using existing objects, not creating new ones, as much as possible.
Also it is unclear to me what the small bitmaps are about, seems to be one for each string; do they need heavy computation?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Nice Luc, I have captured this conversation into a document. The reality of optimization is something that escapes most of the members of my group. This conversation goes into my collection of things that illustrate the subject. One of my favorites is the split loop pattern, are you familiar with it?
|
|
|
|
|
led mike wrote: the split loop pattern
I might, I might not. The name doesn't ring a bell, but I'm no good at pattern names. Show the world.
BTW: I did come up with some new patterns, the most famous one I called "upside-down programming"
which is a kind of extreme instruction scheduling at the level of very simple statements (say elementary C). Excellent for video processing and other very repetitive stuff that tends to be memory/cache latency bound.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
(answering just to test my knowledge) I believe (and hope) that Mike means changing this;
for (int x = 0; x <= 50; x++)
{
DoMethod1();
DoMethod2();
}
To something like this;
for (int x = 0; x <= 50; x++)
{
DoMethod1();
}
for (int y = 0; y <= 50; y++)
{
DoMethod2();
}
..which is counter-intuitive (for me at least), as I'm doing the loop twice in the latter example using more resources. The latter example would be easier to maintain, as it's more readable.
I are troll
|
|
|
|
|
OK thanks, I see. Yes I have been using it.
As far as performance goes, two comments:
1. "split loop pattern" makes sense if the data sets used by both halves are distinct and "locality of reference" is relevant, then the split reduces the load on the cache+memory system
2. the opposite ("merged loop pattern"?) makes much sense when both halves work on the same large data set (exceeding cache size), so merging makes the code walk the data just once. I happen to have the draft of an article (on finding primes) clearly demonstrating this. Due next month.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
how can i display mathematical equations like integral and sigma in a windows form label or any other user control?
Aspiring Techie,
Vishnu Nath
|
|
|
|
|
Hi Experts
Pls Help Me I am Making A user Control in side That i am using Some html Script.
Me i Have To Generate The HTML Page From C#.NEt Application i append The Html
script using String Builder But It Can't Parse The Code Like
But #hhh899 is Dynamic is set from a property Color when i append it will no take
string Like ""#hhh899"". show pls Help me How To How to generate The HTML
Page From C#.NEt Window From.
Thank U
Dinesh Sharma
Software Developer
|
|
|
|
|
Hi all,
I am developing an windows application(C#) in VS2005 and in that it must have a video player with all aspects like play, Pause, Stop, Rewind, Slow rewind, Forward, Slow forward . I have tried with media player and i am able to bring only Play, Pause, Stop and i was not able to brong other functionality so please help me as soon as possible. It's very urgent.
Regards
Mohan
|
|
|
|
|
1. Its not urgent. I checked with about 15 people and nobody thinks its urgent.
2. Have you tried google, there are loads of media player controls.
3. ITS BAD TO POST TO MULTIPLE FORUMS!!!!!!!!!
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi,
I have Windows Application in which i want to read cookie set in the browser i am also attaching my code with question.
What i am doing I am creating Windows user control which i place in ASP.Net application which read a cookie value from the client machine. But The User Control Display in the ASP.Net application can't read the cookie value. I am also attaching code which i am using in User Control ,
textBox1.Text = "Hello";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1");
//Uncomment the following statements to set up proxy, if have
//request.Proxy = new System.Net.WebProxy("http://yourproxyservername: portnumber");
//request.Proxy.Credentials = CredentialCache.DefaultCredentials;
//Define an empty CookieContainer class object
//before the HTTP request is sent
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Assign the Cookie property of the HttpWebResponse object to the original
//CookieContainer object in the HttpWebRequest object
response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
foreach (Cookie cky in response.Cookies)
{
Console.WriteLine(cky.Name + " = " + cky.Value);
MessageBox.Show(cky.Name + " = " + cky.Value);
}
Does any one have any idea about this?.. Please help
erwererewrewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
|
|
|
|
|
I have a project Developed in Windows(windows Control library) which read the data from the access database to a text box on button click.
I use the dll created from a windows application to my Web based project developed in Asp.net
I use Object tag in aspx page to call the dll to display the content of dll in my aspx page.
Applets gets loaded but when i click the button inside the applet to read the data from database it gives me an error message
Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Does anyone have any idea about it.? Please Help ...
modified on Sunday, March 29, 2009 1:06 AM
|
|
|
|
|
It looks like you're trying to use a Windows Forms control in a Web Forms app. Is this correct?? This question actually belongs in the ASP.NET forum.
Well, since the code is running in the browser (not on the server side), the browser will run the code in a heavily restricted sandbox. There are many, many things that the code will not be able to do unless the browser security is turned way down, and the .NET Framework on the machine is told to trust that assembly.
And since I've never done this, my experience is quite limited.
|
|
|
|
|
This is my given code below ,it has two buttons ADD and REMOVE and TABCONTROL .ADD button adds the tabpages.
REMOVE button removes the tabpages in the order the latest clicked tabpages .That is the order of
opening(clicking) the tabpages is preserved so that while removing the latest tabpage opened will be
removed first.Now, if u execute the program below, u will understand the functionality.
public partial class Form1 : Form
{
private static int pageNumber = 4;
List<tabpage> _cache = new List<tabpage>();
public Form1()
{
InitializeComponent();
this.tabControl1.Selected += new TabControlEventHandler(tabControl1_Selected);
}
void tabControl1_Selected(object sender, TabControlEventArgs e)
{
if (e.TabPage != null)
{
if (_cache.Contains(e.TabPage))
{
_cache.Remove(e.TabPage);
}
_cache.Add(e.TabPage);
}
}
private void button1_Click(object sender, EventArgs e)
{
TabPage page = new TabPage("TabPage" + pageNumber.ToString());
tabControl1.TabPages.Add(page);
this.tabControl1.SelectedTab = page;
pageNumber++;
}
private void button2_Click(object sender, EventArgs e)
{
if (_cache.Count > 0)
{
this.tabControl1.Selected -= new TabControlEventHandler(tabControl1_Selected);
this.tabControl1.TabPages.Remove(_cache[_cache.Count - 1]);
this.tabControl1.Selected += new TabControlEventHandler(tabControl1_Selected);
_cache.RemoveAt(_cache.Count - 1);
}
if (_cache.Count > 0)
{
this.tabControl1.SelectedTab = _cache[_cache.Count - 1];
}
}
Now, my given requirement is i need to set some color to each and every tabpage
added, i need to implment the color property in ADD button.I googled a lot but i couldnt implement it according to my program.So can u pls
send me any sample according to my program so that i could implement it.
Thanks in advance
|
|
|
|
|
swapna chow wrote: send me any sample
I won't do that, but I will suggest that you research OwnerDraw property value.
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.”
|
|
|
|
|
Hi,
I would like to find a report designer tool which permits the end user to create a report based on some predefined elements created by the application I want to build. So, the basic idea would be to extend an already existing tool to achieve this kind of functionality.
So, if any of you have some thoughts or recommendation to what kind of software could I use, please give me some hints. Thanks in advance.
|
|
|
|
|
I hate to say this but crystal reports.. I thought that's what it's designed for?
|
|
|
|
|
I thought Crystal was designed to weed out the suicidal programmers.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
Now my given program consists of two buttons ADD and REMOVE with the TabControl.Now the ADD button
to add the tabpages and REMOVE button to remove the tabpages in the order the latestly opened tabpage.That
is,the order of opening(clicking) the tabpages is preserved so,that while removing the tabpage last opened gets
removed first.If u exceute my program below will understand the functionality.
public partial class Form1 : Form
{
private static int pageNumber = 4;
List<tabpage> _cache = new List<tabpage>();
public Form1()
{
InitializeComponent();
this.tabControl1.Selected += new TabControlEventHandler(tabControl1_Selected);
}
void tabControl1_Selected(object sender, TabControlEventArgs e)
{
if (e.TabPage != null)
{
if (_cache.Contains(e.TabPage))
{
_cache.Remove(e.TabPage);
}
_cache.Add(e.TabPage);
}
}
private void button1_Click_1(object sender, EventArgs e)
{
TabPage page = new TabPage("TabPage" + pageNumber.ToString());
tabControl1.TabPages.Add(page);
this.tabControl1.SelectedTab = page;
pageNumber++;
}
private void button2_Click_1(object sender, EventArgs e)
{
if (_cache.Count > 0)
{
this.tabControl1.Selected -= new TabControlEventHandler(tabControl1_Selected);
this.tabControl1.TabPages.Remove(_cache[_cache.Count - 1]);
this.tabControl1.Selected += new TabControlEventHandler(tabControl1_Selected);
_cache.RemoveAt(_cache.Count - 1);
}
if (_cache.Count > 0)
{
this.tabControl1.SelectedTab = _cache[_cache.Count - 1];
}
}
Now,my problem is while removing the tabpages that is,when i click on the REMOVE button after TWO
seconds the tabpages should get removed,that is with the delay of two seconds the tabpage should get removed.That is i need to set the time in the REMOVE Button .Can,u pls help me out unable to fix it can u send me sample according to my program.
Thanks in advance.
modified on Wednesday, March 25, 2009 9:08 AM
|
|
|
|
|
|
Its working thanks fly904
|
|
|
|
|
As my subject says, I am trying to create a border function like excel in datagridview. I have been googling for few days, and it looks like there is no easy answer to set border color for selected cells. If anybody has any clue on how to do this, it will be much appreciated. Thank you very much!
Note: I have successfully created bold function and (modified with the color picker found from this site) color picker for backcolor and forecolor with saving the setting in an xml file. If anyone needs it, please let me know.
|
|
|
|
|
I think that if you research the CellPainting event, you might get some ideas on how to do this.
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.”
|
|
|
|
|
Hi,
iam in Developing Desktop application using c#..
i have to print data in Invoice Format. In MSDN i saw about "TabularReport" to print data in Invoice Format.
can anybody give information how can i desing "TabularReport" ?
how can i bind data into TabularReport ?
Thanks in Advance..
murali krishna
|
|
|
|
|