/// <summary> /// Przesłonięta metoda umożliwiająca poruszanie się i tworzenie pomniejszych przeciwników /// </summary> /// <param name="pictureBox">Graficzna reprezentacja przeciwnika</param> /// <param name="area">Obszar, po którym można się poruszać</param> public override void Dance(ref System.Windows.Forms.PictureBox enemy, System.Windows.Forms.Integration.ElementHost area) { for (int i = 0; i < speed; ++i) { System.Drawing.Point newLocation = new System.Drawing.Point { X = random.Next(-1 * speed, speed) + enemy.Location.X, Y = random.Next(-1 * speed, speed) + enemy.Location.Y }; if (newLocation.X < 0 || newLocation.X > area.Size.Width - enemy.Size.Width) { newLocation.X = enemy.Location.X; } if (newLocation.Y < 0 || newLocation.Y > area.Size.Height - enemy.Size.Height) { newLocation.Y = enemy.Location.Y; } enemy.Location = newLocation; enemy.Update(); } int canCreate = random.Next(0, 50); if (canCreate == 0) { createEnemy("pictureBoxBossCompanion"); } }
//Conjunction public bool Conjunction(System.Windows.Forms.PictureBox d, System.Windows.Forms.PictureBox b) { try { //when is splited if (Splited) { //initiate... ConjuctedBegin = true; SplitedBegin = false; RootConjuction = new Bitmap(RootWidth, RootHeight); index = imgarray.Count; //for evey items of list //Parallel.For(0, index, i => for (i = 0; i < index; i++) { Object O = new Object(); lock (O) { //create graphics of main empty image var graphics = Graphics.FromImage(RootConjuction); //store index int k = imgarrayindex[i][0]; int p = imgarrayindex[i][1]; //write picess on main image graphics.DrawImage(imgarray[i], new Rectangle(k, p, PiceX, PiceY), new Rectangle(0, 0, RootWidth, RootHeight), GraphicsUnit.Pixel); //Assign and prepair d.BackgroundImage = imgarray[i]; d.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; d.Refresh(); d.Update(); b.BackgroundImage = RootConjuction; b.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; b.Refresh(); b.Update(); graphics.Dispose(); } }//); //initiate Conjucted = true; Splited = false; imgarray.Clear(); } else//when is not ready return unsuccessfull { return(false); } } catch (Exception t) { //when there is an exeption return unsuccessfull return(false); } //return successfull return(true); }
public void drawShape(ref System.Windows.Forms.PictureBox pictureBox) { if (mBitmap == null) { mBitmap = getNewBitmap(); } mShape.drawShape(ref mBitmap, mColor, mAlgorithm); pictureBox.Image = this.mBitmap; pictureBox.Update(); }
public bool setPictureBox(Image image) { if (Picturebox != null) { Picturebox.Image = image; Size comicsize = new Size(image.Width, image.Height); Picturebox.Size = comicsize; Picturebox.Update(); return(true); } return(false); }
public void drawTemporary(ref System.Windows.Forms.PictureBox pictureBox) { if (mDraftBitmap == null) { mDraftBitmap = getNewBitmap(); } mDraftBitmap = (Bitmap)mBitmap.Clone(); mShape.drawShape(ref mDraftBitmap, mColor, mAlgorithm); pictureBox.Image = mDraftBitmap; pictureBox.Update(); }
/// <summary> /// Przesłonięta metoda umożliwiająca poruszanie się /// </summary> /// <param name="pictureBox">Graficzna reprezentacja przeciwnika</param> /// <param name="area">Obszar, po którym można się poruszać</param> public override void Dance(ref System.Windows.Forms.PictureBox enemy, System.Windows.Forms.Integration.ElementHost area) { System.Drawing.Point newLocation = new System.Drawing.Point { X = random.Next(-1 * speed, speed) + enemy.Location.X, Y = random.Next(-1 * speed, speed) + enemy.Location.Y }; if (newLocation.X < 0 || newLocation.X > area.Size.Width - enemy.Size.Width) { newLocation.X = enemy.Location.X; } if (newLocation.Y < 0 || newLocation.Y > area.Size.Height - enemy.Size.Height) { newLocation.Y = enemy.Location.Y; } enemy.Location = newLocation; enemy.Update(); }
//Split image to each pixel public bool Splitation(System.Windows.Forms.PictureBox d) { try { //when is ready if (Root != null) { //initiate... SplitedBegin = true; ConjuctedBegin = false; imgarray = new List <Image>(); index = 0; //for every width //Parallel.For(0, Root.Width, i => for (i = 0; i < Root.Width; i += PiceX) { //for every height //Parallel.For(0, Root.Height, j => for (j = 0; j < Root.Height; j += PiceY) { Object O = new Object(); lock (O) { //create a image of picex and picey to an image imgarray.Add(new Bitmap(PiceX, PiceY)); //increase index++; //write pices to an empty image var graphics = Graphics.FromImage(imgarray[imgarray.Count - 1]); graphics.DrawImage(Root, new Rectangle(0, 0, PiceX, PiceY), new Rectangle(i, j, PiceX, PiceY), GraphicsUnit.Pixel); graphics.Dispose(); //show image on main picture box d.BackgroundImage = imgarray[imgarray.Count - 1]; d.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; d.Refresh(); d.Update(); //add index int[] a = new int[2]; a[0] = i; a[1] = j; imgarrayindex.Add(a); } } //); } //); //set Splited = true; Conjucted = false; } else//when is not ready return unssuccessfull { return(false); } } catch (Exception t) { //when is exeption return unsuccessfull return(false); } //return successfull return(true); }