PastorHealer
New member
- Joined
- Jul 5, 2018
- Messages
- 2
- Programming Experience
- 10+
My next step in this code for me is to allow the user to move the pic from within the bounds of the circle
I would like the code to drive a mouse click and hold to move it
Then I want to have zoom functionality
Here is what I have so far...
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Sphere_Map
{
public partial class Form1 : Form
{
public Graphics gfx;
int radius = 300;
int y = 350;
int x = 350;
public Form1()
{
InitializeComponent();
gfx= this.CreateGraphics();
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap tmp = new Bitmap(2 * radius, 2 * radius);
Graphics g = Graphics.FromImage(tmp);
g.TranslateTransform(tmp.Width / 2, tmp.Height / 2);
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0 - radius, 0 - radius, 2 * radius, 2 * radius);
Region region = new Region(path);
g.SetClip(region, CombineMode.Replace);
Bitmap bmp = new Bitmap("C://C# Graphics/Earth.jpg");
g.DrawImage(bmp, new Rectangle(-radius, -radius, 2 * radius, 2 * radius), new Rectangle(x - radius, y - radius, 2 * radius, 2 * radius), GraphicsUnit.Pixel);
tmp.Save("c://C# Graphics/US Boundary Map2.jpg");
gfx.DrawImage(Bitmap.FromFile("c://C# Graphics/US Boundary Map2.jpg"),new Point(100,100));
}
private void btnExit_Click(object sender, EventArgs e)
{
if (System.Windows.Forms.Application.MessageLoop)
{
// WinForms app
System.Windows.Forms.Application.Exit();
}
else
{
// Console app
System.Environment.Exit(1);
}
}
}
}
Thank you for the assistance
I would like the code to drive a mouse click and hold to move it
Then I want to have zoom functionality
Here is what I have so far...
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Sphere_Map
{
public partial class Form1 : Form
{
public Graphics gfx;
int radius = 300;
int y = 350;
int x = 350;
public Form1()
{
InitializeComponent();
gfx= this.CreateGraphics();
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap tmp = new Bitmap(2 * radius, 2 * radius);
Graphics g = Graphics.FromImage(tmp);
g.TranslateTransform(tmp.Width / 2, tmp.Height / 2);
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0 - radius, 0 - radius, 2 * radius, 2 * radius);
Region region = new Region(path);
g.SetClip(region, CombineMode.Replace);
Bitmap bmp = new Bitmap("C://C# Graphics/Earth.jpg");
g.DrawImage(bmp, new Rectangle(-radius, -radius, 2 * radius, 2 * radius), new Rectangle(x - radius, y - radius, 2 * radius, 2 * radius), GraphicsUnit.Pixel);
tmp.Save("c://C# Graphics/US Boundary Map2.jpg");
gfx.DrawImage(Bitmap.FromFile("c://C# Graphics/US Boundary Map2.jpg"),new Point(100,100));
}
private void btnExit_Click(object sender, EventArgs e)
{
if (System.Windows.Forms.Application.MessageLoop)
{
// WinForms app
System.Windows.Forms.Application.Exit();
}
else
{
// Console app
System.Environment.Exit(1);
}
}
}
}
Thank you for the assistance