Solved

Help with CODE....

Posted on 2006-11-05
8
231 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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 62

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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