|
Hello!
I would like to know how to beautify the Progress Bar? e.g. use gradient color or image for the progression index. Any sample coding here?
fm Softair
|
|
|
|
|
Owner-draw it yourself. The ProgressBar in .NET is actually a wrapper class for a progress bar common control in Windows. There's only so much you can do with it before it's easier to do your own.
It's not hard, though. It's just (usually) a rectangle with a certain drawing region that's a percentage, such as value / max + min . There were some great articles by a certain person that went commercial and took all his articles with him...and after he used CP to help beta-test his code.
So, you can either P/Invoke code and try to override the functionality afforded by Windows for the ProgressBar wrapper, or just write your own. Again, it isn't hard. You can use the ControlPaint class to assist (i.e., do all the work) in drawing the correct 3D borders for a rectangle and draw whatever you like in the client area inside the borders (if you want borders, that is). Just use some similar functionality as the progress bar, which is basically a min, max, and value property, and a step method to increment the value (or use value++ and have the property's setter force a repaint). The OnPaint override should do all the drawing (using the ControlPaint for borders, and using the current min, max, and value properties to correctly draw the progress meter). You should also use Control.SetStyle to set the AllPaintingInWmPaint , UserPaint , DoubleBuffer , ResizeRedraw , and Opaque ControlStyles since you'll be handling all the drawing yourself.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello!
I would like to beautify my menuitem for the SystemTray Example, does it possible? But it always show "int numOldMenu = myMenu.Count;" has problem? Why?
The coding of SystemTrayExample is listed as following:
using System;
using System.Drawing;
using System.Resources;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading ;
using Utility.NiceMenu;
namespace Demo
{
public class SystemTray : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon WSNotifyIcon;
private System.ComponentModel.IContainer components;
private Icon mDirIcon = new Icon(typeof(SystemTray).Assembly.GetManifestResourceStream("SystemTrayExample.FLGUSA02.ICO"));
//private NiceMenu myMenu ;
public SystemTray()
{
//constructor for the form
InitializeComponent();
//keep the form hidden
this.Hide();
//OnMyMenu();
//InitializeNotifyIcon();
NiceMenu myNiceMenu = new NiceMenu();
myNiceMenu.UpdateMenu (this.ContextMenu ,new NiceMenuClickEvent (InitializeNotifyIcon));
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.WSNotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
//
// WSNotifyIcon
//
this.WSNotifyIcon.Text = "";
this.WSNotifyIcon.Visible = true;
//this.WSNotifyIcon.MouseDown += new System.Windows.Forms.MouseEventHandler(this.WSNotifyIcon_MouseDown);
//
// SystemTray
//
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(8, 7);
this.ControlBox = false;
this.Enabled = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SystemTray";
this.Opacity = 0;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new SystemTray());
}
public void ExitControlForm(object sender, EventArgs e)
{
//Hide the NotifyIcon.
WSNotifyIcon.Visible=false;
this.Close();
}
//private void InitializeNotifyIcon()
private void InitializeNotifyIcon(object sender, System.EventArgs e)
{
//setup the Icon
NotifyIcon WSNotifyIcon = new NotifyIcon();
WSNotifyIcon.Icon = mDirIcon;
WSNotifyIcon.Text = "System Tray Example";
WSNotifyIcon.Visible = true;
//Create the submenus - any number will do
MenuItem[] subMnuItems1 = new MenuItem[3];
subMnuItems1[0] = new MenuItem("Submenu 1", new EventHandler(this.ExitControlForm));
subMnuItems1[1] = new MenuItem("Submenu 2", new EventHandler(this.ExitControlForm));
subMnuItems1[2] = new MenuItem("Submenu 3", new EventHandler(this.ExitControlForm));
//Create the MenuItem objects and add them to
//the context menu of the NotifyIcon.
MenuItem[] mnuItems = new MenuItem[3];
//create the menu items array
mnuItems[0] = new MenuItem("Sub Menu Items");
mnuItems[0].MenuItems.AddRange(subMnuItems1);
mnuItems[0].DefaultItem=true;
mnuItems[1] = new MenuItem("-");
mnuItems[2] = new MenuItem("Exit", new EventHandler(this.ExitControlForm));
//add the menu items to the context menu of the NotifyIcon
ContextMenu notifyIconMenu = new ContextMenu(mnuItems);
WSNotifyIcon.ContextMenu=notifyIconMenu;
}
}
}
fm Softair
|
|
|
|
|
To what "problems" are you referring? Specifics are important. If an exception is being thrown, what exception is it and what is its message?
Also, please post only relevent code to the forums.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i was wondering if anyone could give me some good information on shell programming...im intrested in tieing my C# program into the right click menu. i want it to be easily uninstallable (like winzip does) any ideas or suggestions ?
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
Best suggestion - don't use C#. Until "Longhorn" is released, the OS is still written in C/C++. Besides, if you use a .NET language like C#, you're going to have to redefine a lot of shell interfaces that you'll need like IShellExtInit , IContextMenu , and IDataObject (not the one in .NET's BCL) as well as a lot of structures like HMENU , ITEMIDLIST . You'll spend more time redefining everything that's easy to get through headers in C/C++ than writing your functionality, but go for it if you like doing such things.
And if you didn't catch it, there's the list of interfaces you'll need: IShellExtInit and IContextMenu .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I was wondering. Is alot of long horn wrote in C# or with .net in mind ? Also when is it supposed to come out ? Thanks alot for your comments.
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
Any good ideas?
Slickman
|
|
|
|
|
I thought I remembered seeing a starter kit on www.asp.net[^]
|
|
|
|
|
The Community starter kit at http://www.asp.net/Default.aspx?tabindex=9&tabid=47[^] offers some ideas on all kinds of stuff including discussion boards. You could also look in the asp.net controls section here http://www.asp.net/ControlGallery/default.aspx?Category=34&tabindex=2[^] for forum controls.
If you decided to build your own, a simple design could include a table for Forums, one for Topics, and one for Comments with one-to-many relationships between each (many Topics to one Forum, many Comments to one Topic). It would be pretty standard C# data access code to select/insert data to/from the tables, and a DataGrid or Repeater control would work nicely for display in an ASP.NET page.
Then get more sophisticated by adding user logins...
All in all, this isn't a bad type of project if you're learning C#.
|
|
|
|
|
Anyone know how to get a cusor to load from an array of bytes? I have a byte[] in a resorce file that is a custom cursor. I need to load a System.Windows.Forms.Cursor from it. I don't have to use a resource file for it, but it needs to be embeded in the exe some how and not on disk. Thanks in advance.
|
|
|
|
|
It's easier if you don't embed it in a ResX file. Instead, add the .cur file to your project and change it's Build Action (in the properties displayed when you click on the file) to "Embedded Resource".
To get the Cursor (Icons work this way, too), either use Assembly.GetManifestResourceStream or - easier - use this particular Cursor constructor:
Cursor cur = new Cursor(typeof(SomeClass), "MyCursor.cur"); ...where SomeClass is a Type that scopes the resource (provides both the assembly reference and the namespace to find the embedded resource by name). For more information, see the aforementioned constructor.
Basically, if SomeClass exists in the namespace MyCompany.MyProject , the example would look for an embedded resource named "MyCompany.MyProject.MyCursor.cur".
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath. I ended up doing it this way. I added it to the project and used a resourcemanager to pull it out. It works great this way. Resources are one spot in .net that I find lacking. MS didn't even provide a good resource editor. All I can find on the net don't work with custom cursors. I had one that was an adding for vs02 but lost it and can't find it again. It worked great.
|
|
|
|
|
Why did you use the ResourceManager ? You simply grab the manifest resource stream. The ResourceManager is for ResX files.
VS.NET has a great resource editor, far better than VS6. It still handles cursors, icons, and bitmaps internally. Instead of string resources, you're supposed to use ResX files. The great thing is that you can embed any file as an embedded resource. If you right-click, you can select "Open with..." to open ANY resource with ANY program (and keep a cached list of programs you use). In VS6, if the resource wasn't understood / handled by the IDE, you had to export the resource, browse to it and open it with the associated application (or open the application then open the file). That was a pain.
In any case, 'tis far easier to just embed the .cur file as an embedded resource and use the Cursor constructor I mentioned, not the ResourceManager . Besides, binary files are stored as bse64 encodings by default. The ResourceManager has overhead for setting things up, then has to find the resource and decode it. The other way is quick and is closer to how it would be done in Win32 when loading a cursor from a persistent file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Do someone know where can i find the source code of Sqrt() method or where can i read some theory about this subject
thanks for help
|
|
|
|
|
It simply returns the positive result, if the input is negative it returns a NaN which can be detected with IsNan. Is that what you were looking for?
|
|
|
|
|
LOL, of cause not i am looking for the source code of sqeare root method. but thank u any way
|
|
|
|
|
Bisection and Newton-Raphson are commonly used algorithms for this.
|
|
|
|
|
and where can i find them??
|
|
|
|
|
Took me under 10 seconds, but if you're too stupid to use google, it's unlikely you'd be able to understand them.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
i wrote in my first message that i was looking for the source code of Sqrt() method.
Brian Gideon wrote me the names of the algorithm he knows, so i asked him where can i find them because i expected to find the source code of this algorithms too.
first: i did not ask you.
second: what are you doing here if can find everything in google.
third: think before you want to write something.
fourth: never write stuipid to the people u do not know, got this
i think that u would never say something like this to someone directly, cause this someone would break u f***in face for this ... . got this
have your sickness any name?
|
|
|
|
|
u r ? damn ass ? ( I think you mean dumb ass ) ur ? cause ? ( I think you mean because )
I see I underestimated your stupidity. How did you figure out how to turn your computer on ? Or do people in the sheltered workshop help you ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I love it when weak minded pussies edit their posts to change completely what they said. I should have recognised you for a wimp and quoted you in my reply.....
oOomen wrote:
so i asked him where can i find them because i expected to find the source code of this algorithms too.
Yeah, which makes you an idiot. All you need to do is google. If you can't turn any of the explanations I found in seconds into source code, then you should not be let near anything that resembles source code, you should go and try to work out HTML or something instead.
oOomen wrote:
first: i did not ask you.
You asked on a public forum
oOomen wrote:
second: what are you doing here if can find everything in google.
Helping people who ask questions that are not so easy to google. And advising idiots like you to search for yourself.
oOomen wrote:
third: think before you want to write something.
Most people who read my articles here think that I do. Why don't you try thinking at all ?
oOomen wrote:
fourth: never write stuipid to the people u do not know, got this
Every post you make convinces me further of your stupidity.
oOomen wrote:
i think that u would never say something like this to someone directly, cause this someone would break u f***in face for this
Well, I guess you don't know me that well.
oOomen wrote:
have your sickness any name?
Yeah, sick of idiots.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
save ur remarks for u cause u need it ok
|
|
|
|
|
you have to learn how to recognize in the cases like this that you are wrong!
|
|
|
|