473,782 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

custom midi background

when painting the background of a mdi app window
how can i resolve the flicker when it paints
from darker to lighter colors

below is the code i wrote
private void ShellWindow_Gra dient(object sender, PaintEventArgs e)
{

Graphics oGraphics = (Graphics)e.Gra phics;
//enum i Defined
if (this.StyleType == NetToolsUI.Wind owStyle.Solid)
{

this.oMdi.BackC olor = this.SolidColor ; //.RoyalBlue;
//.FromArgb(35,7, 143); //.Brushes.AliceB lue;

}
else if (this.StyleType == NetToolsUI.Wind owStyle.Gradien t)
{
Rectangle rect = oMdi.ClientRect angle;
rect.Inflate(2, 2);// to completely fill the client area

LinearGradientB rush filler = new LinearGradientB rush(
rect,
this.SolidColor ,
this.LightColor ,
90,true); //this._angle);
oGraphics.FillR ectangle(filler , rect);
filler.Dispose( );
}
//Draw Some Text On the Window
// Create string to draw.
//e.MeasureString (drawString, this.Font);
// Create font and brush.
System.Drawing. SizeF TxtSize = oGraphics.Measu reString(Header ,
this.HeaderFont );
SolidBrush GreyBrush = new SolidBrush(this .ShadowColor);
SolidBrush BlackBrush = new SolidBrush(this .HeaderColor);
// Create point for upper-left corner of drawing.
//x=widht
//y=height
//centers
//float x = (this.ClientSiz e.Width / 2) - (TxtSize.Width / 2);
//float y = (this.ClientSiz e.Height / 2) - (TxtSize.Height / 2);
float x = (oMdi.ClientSiz e.Width / 2) - (TxtSize.Width / 2);
float y = ((float)(oMdi.C lientSize.Heigh t
/this.HeaderLoca tion)) - (float)(TxtSize .Height/HeaderLocation );
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.Form atFlags =
StringFormatFla gs.MeasureTrail ingSpaces;
//draw Shadow
oGraphics.DrawS tring(Header, this.HeaderFont , GreyBrush, x + 3,
y + 3, drawFormat);
// Draw string to screen.

oGraphics.DrawS tring(Header, this.HeaderFont , BlackBrush, x, y,
drawFormat);
//draw Owner Notice bottom Right
BlackBrush = new SolidBrush(this .FooterColor);
TxtSize = oGraphics.Measu reString(Footer , this.FooterFont );

//text
oGraphics.DrawS tring(Footer, this.FooterFont , BlackBrush,
oMdi.ClientSize .Width - (TxtSize.Width+ 10),
oMdi.ClientSize .Height
- (TxtSize.Height +10), drawFormat);
}

Thanks DaveL
Nov 6 '08 #1
2 2081
Dave,

Well, you are doing quite a bit of work there in the method.
Specifically, I see three brushes (which should have Dispose called on them,
btw) which you are creating each time that method is called. The paint
event can be fired a number of times, so I would recommend that you create
filler, blackbrush, greybrush, etc, etc outside of the paint method, and
then change them when needed (when you change the color in your
preferences). That way, you are not constantly allocating those objects.

You would then dispose those brushes when the appropriate preferences
change, or when the application terminates.

You might also want to cache the StringFormat instance (or better yet,
create it once for the lifetime of your app, since it doesn't seem like it
is dependent on anything in it).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"DaveL" <dv*****@sbcglo bal.netwrote in message
news:7L******** ********@flpi14 4.ffdc.sbc.com. ..
when painting the background of a mdi app window
how can i resolve the flicker when it paints
from darker to lighter colors

below is the code i wrote
private void ShellWindow_Gra dient(object sender, PaintEventArgs e)
{

Graphics oGraphics = (Graphics)e.Gra phics;
//enum i Defined
if (this.StyleType == NetToolsUI.Wind owStyle.Solid)
{

this.oMdi.BackC olor = this.SolidColor ; //.RoyalBlue;
//.FromArgb(35,7, 143); //.Brushes.AliceB lue;

}
else if (this.StyleType == NetToolsUI.Wind owStyle.Gradien t)
{
Rectangle rect = oMdi.ClientRect angle;
rect.Inflate(2, 2);// to completely fill the client area

LinearGradientB rush filler = new LinearGradientB rush(
rect,
this.SolidColor ,
this.LightColor ,
90,true); //this._angle);
oGraphics.FillR ectangle(filler , rect);
filler.Dispose( );
}
//Draw Some Text On the Window
// Create string to draw.
//e.MeasureString (drawString, this.Font);
// Create font and brush.
System.Drawing. SizeF TxtSize = oGraphics.Measu reString(Header ,
this.HeaderFont );
SolidBrush GreyBrush = new SolidBrush(this .ShadowColor);
SolidBrush BlackBrush = new SolidBrush(this .HeaderColor);
// Create point for upper-left corner of drawing.
//x=widht
//y=height
//centers
//float x = (this.ClientSiz e.Width / 2) - (TxtSize.Width / 2);
//float y = (this.ClientSiz e.Height / 2) - (TxtSize.Height /
2);
float x = (oMdi.ClientSiz e.Width / 2) - (TxtSize.Width / 2);
float y = ((float)(oMdi.C lientSize.Heigh t
/this.HeaderLoca tion)) - (float)(TxtSize .Height/HeaderLocation );
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.Form atFlags =
StringFormatFla gs.MeasureTrail ingSpaces;
//draw Shadow
oGraphics.DrawS tring(Header, this.HeaderFont , GreyBrush, x + 3,
y + 3, drawFormat);
// Draw string to screen.

oGraphics.DrawS tring(Header, this.HeaderFont , BlackBrush, x, y,
drawFormat);
//draw Owner Notice bottom Right
BlackBrush = new SolidBrush(this .FooterColor);
TxtSize = oGraphics.Measu reString(Footer , this.FooterFont );

//text
oGraphics.DrawS tring(Footer, this.FooterFont , BlackBrush,
oMdi.ClientSize .Width - (TxtSize.Width+ 10),

oMdi.ClientSize .Height - (TxtSize.Height +10), drawFormat);
}

Thanks DaveL


Nov 6 '08 #2
Thanks alot....will clean it up better

DaveL

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Dave,

Well, you are doing quite a bit of work there in the method.
Specifically, I see three brushes (which should have Dispose called on
them, btw) which you are creating each time that method is called. The
paint event can be fired a number of times, so I would recommend that you
create filler, blackbrush, greybrush, etc, etc outside of the paint
method, and then change them when needed (when you change the color in
your preferences). That way, you are not constantly allocating those
objects.

You would then dispose those brushes when the appropriate preferences
change, or when the application terminates.

You might also want to cache the StringFormat instance (or better yet,
create it once for the lifetime of your app, since it doesn't seem like it
is dependent on anything in it).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"DaveL" <dv*****@sbcglo bal.netwrote in message
news:7L******** ********@flpi14 4.ffdc.sbc.com. ..
>when painting the background of a mdi app window
how can i resolve the flicker when it paints
from darker to lighter colors

below is the code i wrote
private void ShellWindow_Gra dient(object sender, PaintEventArgs e)
{

Graphics oGraphics = (Graphics)e.Gra phics;
//enum i Defined
if (this.StyleType == NetToolsUI.Wind owStyle.Solid)
{

this.oMdi.BackC olor = this.SolidColor ; //.RoyalBlue;
//.FromArgb(35,7, 143); //.Brushes.AliceB lue;

}
else if (this.StyleType == NetToolsUI.Wind owStyle.Gradien t)
{
Rectangle rect = oMdi.ClientRect angle;
rect.Inflate(2, 2);// to completely fill the client area

LinearGradientB rush filler = new LinearGradientB rush(
rect,
this.SolidColor ,
this.LightColor ,
90,true); //this._angle);
oGraphics.FillR ectangle(filler , rect);
filler.Dispose( );
}
//Draw Some Text On the Window
// Create string to draw.
//e.MeasureString (drawString, this.Font);
// Create font and brush.
System.Drawing. SizeF TxtSize = oGraphics.Measu reString(Header ,
this.HeaderFon t);
SolidBrush GreyBrush = new SolidBrush(this .ShadowColor);
SolidBrush BlackBrush = new SolidBrush(this .HeaderColor);
// Create point for upper-left corner of drawing.
//x=widht
//y=height
//centers
//float x = (this.ClientSiz e.Width / 2) - (TxtSize.Width / 2);
//float y = (this.ClientSiz e.Height / 2) - (TxtSize.Height /
2);
float x = (oMdi.ClientSiz e.Width / 2) - (TxtSize.Width / 2);
float y = ((float)(oMdi.C lientSize.Heigh t
/this.HeaderLoca tion)) - (float)(TxtSize .Height/HeaderLocation );
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.Form atFlags =
StringFormatFl ags.MeasureTrai lingSpaces;
//draw Shadow
oGraphics.DrawS tring(Header, this.HeaderFont , GreyBrush, x +
3, y + 3, drawFormat);
// Draw string to screen.

oGraphics.DrawS tring(Header, this.HeaderFont , BlackBrush, x,
y, drawFormat);
//draw Owner Notice bottom Right
BlackBrush = new SolidBrush(this .FooterColor);
TxtSize = oGraphics.Measu reString(Footer , this.FooterFont );

//text
oGraphics.DrawS tring(Footer, this.FooterFont , BlackBrush,
oMdi.ClientSiz e.Width - (TxtSize.Width+ 10),

oMdi.ClientSiz e.Height - (TxtSize.Height +10), drawFormat);
}

Thanks DaveL



Nov 6 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2108
by: Max M | last post by:
If anybody is interrested in Midi, but are not on the Python Midi list, I will just notify that I have released the first version of a high level midi package for Python. It is fully functional. It reads and writes midi files! It is *very* easy to write your own event handlers to make midi files do whatever you want them to. It uses the same general ideas as the Sax parser for xml.
2
427
by: Mad Scientist Jr | last post by:
any sample code or information would be most appreciated i have been wanting to learn MIDI programming but would rather learn it in my current language (either vb.net or c#)
11
2749
by: Kuba Araszkiewicz | last post by:
Hello! I have to write a program, which would convert midi files to notes, notes to midi files and which would make one MIDI file from two different. I'm totally lame in C (and any other programming language), but my whole college education depends on this project. Maybe someone has simillar program or could give me some hints how to do it. best regards - borat
0
1750
by: tom | last post by:
Hallo, I need help on MIDI file, and precisely about retrieving few note values (mainly the "Velocity" value, corrisponding to the intensity of a played note) while the MIDI is playing.
1
2105
by: tim | last post by:
Someone using Python Midi Package from http://www.mxm.dk/products/public/ lately? I want to do the following : write some note events in a midi file then after doing that, put some controllers at the beginning of the midifile (because I want to be able to make those dependant on what notes were just written)
4
2699
by: sreekant | last post by:
Hi folks I hope someone here might be able to help. I scavenged some info and even code from the net and am trying to write a module that reads a text file and spits out a midi file. So far I managed to make it work to the level of reading a text file with appropriate notes, octaves, transposing, volume, aftertouch, polyphony, channeltouch etc.
9
3499
by: outstretchedarm | last post by:
How exactly does HTML/Javascript handle playing midi files? Does it have a player imbedded in it? Or does it borrow from the computer's midi player? How could you make a webpage play certain chosen notes via midi? Is there an existing library for such a thing?
6
4934
by: Massi | last post by:
Hi everyone, I'm searching for "something" which allows me to write scripts which handle midi files. I'm totally a newbie in audio manipulation, therefore any suggestion or link related to this field is welcome. Thanks in advance.
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.