Solved

Help with CODE....

Posted on 2006-11-05
8
227 Views
Last Modified: 2010-04-16
Hi
I am useing the following code to draw a ring, of light and its not working?

        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(710, 710);
            b.MakeTransparent(Color.Blue);
            Graphics g = Graphics.FromImage(b);
            g.Clear(Color.WhiteSmoke);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(Brushes.White, 6f), 5, 5, 700, 700);
            b.Save(new System.IO.FileStream(@"c:\temp\lightring.gif", System.IO.FileMode.Create), System.Drawing.Imaging.ImageFormat.Gif);
        }
0
Comment
Question by:schenkp
  • 4
  • 3
8 Comments
 
LVL 16

Expert Comment

by:muzzy2003
Comment Utility
This is drawing a white circle on a very pale background, and it is working. What is the problem you are trying to solve?
0
 

Author Comment

by:schenkp
Comment Utility
I am tring to have it display over the active form?  But for some reason its not or am i doing something wrong?
0
 
LVL 16

Expert Comment

by:muzzy2003
Comment Utility
All you're doing here is creating a graphic and saving it out to a file. There's nothing here to display it. Are you talking ASP.NET forms or Windows forms?
0
 
LVL 16

Expert Comment

by:muzzy2003
Comment Utility
If it's Windows forms, try using:

Graphics g = this.CreateGraphics();

instead, and not using your Bitmap b at all.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:schenkp
Comment Utility
       private void button1_Click(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(710, 710);
            b.MakeTransparent(Color.WhiteSmoke);
            //Graphics g = Graphics.FromImage(b);
            Graphics g = this.CreateGraphics();
            g.Clear(Color.WhiteSmoke);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(Brushes.White, 6f), 5, 5, 700, 700);
           // b.Save(new System.IO.FileStream(@"c:\temp\lightring.gif", System.IO.FileMode.Create), System.Drawing.Imaging.ImageFormat.Gif);
        }

0
 

Author Comment

by:schenkp
Comment Utility
How can i make the everything on the form transparent except for the ring?
0
 
LVL 16

Assisted Solution

by:muzzy2003
muzzy2003 earned 200 total points
Comment Utility
Remove the g.Clear(Color.WhiteSmoke), and you'll just be drawing the ring onto the form.
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 300 total points
Comment Utility
Hi schenkp;

This will make the form transparent except for the ring. I made the color of the ring to yellow because to many things are white and you may not see it.

      private void button1_Click(object sender, System.EventArgs e)
      {
            this.TransparencyKey = Color.WhiteSmoke;
            this.BackColor = Color.WhiteSmoke;
            this.Refresh();
            Graphics g = this.CreateGraphics();
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(Brushes.Yellow, 6f), 5, 5, 700, 700);
      }

Fernando
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now