473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

cut operation +C#

14
public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

Bitmap = new Bitmap(SystemInformation.WorkingArea.Width, SystemInformation.WorkingArea.Height); //editted

grfx = Graphics.FromImage(Bitmap); //Editted


}



private void Form1_Load(object sender, EventArgs e)

{

GraphicsPath path = new GraphicsPath();

path.AddRectangle(new Rectangle(10, 10, 100, 50));

this.pathes.Add(path);



path = new GraphicsPath();

path.AddPolygon(new Point[] {

new Point(50, 150), new Point(100, 100), new Point(150, 150) });

this.pathes.Add(path);



path = new GraphicsPath();

path.AddEllipse(new Rectangle(160, 70, 100, 100));

this.pathes.Add(path);



this.Paint += new PaintEventHandler(Form1_Paint);

this.MouseClick += new MouseEventHandler(Form1_MouseClick);



//menu

this.menu.Items.Add("Copy");

this.menu.Items.Add("Cut");

this.menu.Items.Add("Paste");

this.menu.Items[2].Enabled = false;

this.menu.ItemClicked += new ToolStripItemClickedEventHandler(menu_ItemClicked) ;

}



List<GraphicsPath> pathes = new List<GraphicsPath>();

GraphicsPath selectedPath = null;

ContextMenuStrip menu = new ContextMenuStrip();



void menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)

{

switch (e.ClickedItem.Text)

{

case "Copy":

if (this.selectedPath != null)

{

Clipboard.SetDataObject(new GraphicsPathObject(this.selectedPath));

this.menu.Items[2].Enabled = true;

}

break;

case "Cut":

if (this.selectedPath != null)

{

GraphicsPathObject pathObject =

new GraphicsPathObject(this.selectedPath);

Clipboard.SetDataObject(pathObject);

this.pathes.Remove(this.selectedPath);

this.selectedPath = null;

this.Invalidate();

this.menu.Items[2].Enabled = true;

}

break;

case "Paste":

{

IDataObject data = Clipboard.GetDataObject();



GraphicsPathObject pathObject = data.GetData(

Clipboard.GetDataObject().GetFormats()[0])

as GraphicsPathObject;



GraphicsPath path = new GraphicsPath(pathObject.Points,

pathObject.Bytes);



this.pathes.Add(path);

this.Invalidate();

this.menu.Items[2].Enabled = false;

}

break;

}

}

protected override void OnPaint(PaintEventArgs pe)

{
Graphics g = pe.Graphics;

g.DrawImage(Bitmap, this.AutoScrollPosition.X, this.AutoScrollPosition.Y,Bitmap.Width,Bitmap.Heig ht); //editted
base.OnPaint(pe);
}





My doubt is how can i remove selected path while cut operation using this Bitmap


Regards,

ALGATES..
Apr 7 '08 #1
0 656

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marcus | last post by:
Hi I have a very complex sql query and a explain plan. I found there is a full table scan in ID=9 9 8 TABLE ACCESS (FULL) OF 'F_LOTTXNHIST' (Cost=84573 Card=185892...
4
by: Hardy Wang | last post by:
Hi, I have a win form application, when a button is clicked, a lengthy operation will be triggered. During the time program is still running, this application seems not to be able to response to...
0
by: John Jenkins | last post by:
Hi, any help on this would be greatly apprciated. I have been given a wsdl file from a customer generated by Oracle 10g Web Services tools. When I use wsdl.exe to attempt to produce proxy classes I...
1
by: Laurent Lequenne | last post by:
Hello There, I just converted a VS 2003 C++ Project into VS 2005. I already made some changes in my headers files, has I had compilations errors with enums declarations. Now everything compiles...
0
by: relaxedrob | last post by:
Hi All, I have a portType such as this: <portType name="CMLeJobSoapGetEmpBrand"> <operation name="EJobGetEmpBrand"> <input message="tns:EJobEmpBrdReq" name="EJobEmpBrdReq"/> <output...
8
by: Pieter | last post by:
Hi, I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item...
6
by: Cerebrus99 | last post by:
Hi all, I'm making a Windows application that does some lengthy retrieval operations from a database and possibly from a internet resource. I want to show that the operation is going on, by...
3
by: JuHui | last post by:
I wrote a script to get 100 pages from a server. like below: 1:import httplib 2:conns = httplib.HTTPConnection("www.mytest.com") 3:conn.request("GET", "/") sometimes a socket error was...
2
by: Robinson | last post by:
I can start an Asynchronous operation against a data source with SQLCommand.BeginExecuteReader, allowing me to loop, checking for user cancellation before the operation has completed, but how then...
0
by: Default User | last post by:
I work on creating test cases for a SOAP-based set of servers, using soapUI. I received and updated set of WSDL and schema files, and when I made new tests and mock server operations, all of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.