Solved

Help with CODE....

Posted on 2006-11-05
8
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17877453
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
ID: 17877495
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
ID: 17877513
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 16

Expert Comment

by:muzzy2003
ID: 17877524
If it's Windows forms, try using:

Graphics g = this.CreateGraphics();

instead, and not using your Bitmap b at all.
0
 

Author Comment

by:schenkp
ID: 17877533
       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
ID: 17877542
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
ID: 17877559
Remove the g.Clear(Color.WhiteSmoke), and you'll just be drawing the ring onto the form.
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 300 total points
ID: 17877655
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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