private void modifyCanvasSize(int newWidth, int newHeight) { if ((newWidth > 4000 && newHeight > 4000) || newWidth < 1 || newHeight < 1) { return; //De width en height mogen niet te groot of te klein worden } Schets existingSchets = App.currentSchetsWindow.currentSchetsControl.schets; //Neem de bestaande schets Schets newSchets = new Schets(existingSchets.imageName, new System.Drawing.Size(newWidth, newHeight)); //Maak een nieuwe schets van deze, maar dan met andere width en height newSchets.imagePath = existingSchets.imagePath; //Neem de actions etc over van oude schets newSchets.actions = existingSchets.actions; newSchets.actionDrawLimit = existingSchets.actionDrawLimit; App.currentSchetsWindow.currentSchetsControl.schets = newSchets; //Zeg dat de schets = nieuwe schets App.currentSchetsWindow.currentSchetsControl.schets.TekenFromActions(App.currentSchetsWindow.currentSchetsControl); //Tekenen van de actions App.currentSchetsWindow.MetroWindow_SizeChanged_1(null, null); }
private Bitmap overlayBitmap; //Declareren overlayBitmap die later gebruikt wordt #endregion Fields #region Constructors public SchetsControl(string imageName) { schets = new Schets(imageName, new Size(600, 500)); //Aanmaken van nieuw schetsobject currentTool = App.availableTools[0]; //Zeggen dat currentTool een pen is (standaard bij openen) currentAction = new PenAction(); //Ook gelijk de penAction hierbij aanroepen this.DoubleBuffered = true; //Voorkomen van flikkeren van scherm tijdens tekenen this.Paint += this.teken; this.Resize += this.veranderAfmeting; this.MouseDown += (object o, MouseEventArgs mea) => { isDirty = true; muisVast = true; //Zeggen dat muisVast true is, zodra je muis indrukt overlayBitmap = new Bitmap(schets.imageSize.Width, schets.imageSize.Height); //Zetten van overlayBitmap met de width en height setAction(); Point translatedPoint = translateMouseCoordinates(mea.Location); //Pak de muis-coördinaten currentTool.MuisVast(this, translatedPoint); //Gebruiken muiscoördinaten bij aanroepen methode muisVast currentAction.onMouseDown(this, translatedPoint.X, translatedPoint.Y, 3, schets.primaryColor); }; this.MouseMove += (object o, MouseEventArgs mea) => { if (muisVast) //Doe dit alleen indien muis is ingedrukt { Point translatedPoint = translateMouseCoordinates(mea.Location); //Houdt telkens bij welke punten je over gaat currentTool.MuisDrag(this, translatedPoint); //Aanroepen methode muisdrag met deze muiscoördinaten currentAction.onMouseMove(translatedPoint.X, translatedPoint.Y); } }; this.MouseUp += (object o, MouseEventArgs mea) => { muisVast = false; //Boolean muisVast op false zetten aangezien muis nu los is Point translatedPoint = translateMouseCoordinates(mea.Location); //Bekijken op welke coördinaten dit gebeurde currentTool.MuisLos(this, translatedPoint); //Aanroepen methode muislos met deze coördinaten if (currentAction != null) //Indien er een action was gebruikt voeg dit dan toe aan de action list en update de historyBox { currentAction.onMouseUp(translatedPoint.X, translatedPoint.Y); App.currentSchetsWindow.currentSchetsControl.schets.actions.Add(App.currentSchetsWindow.currentSchetsControl.currentAction); App.historyWindow.updateHistoryList(); } }; this.KeyPress += (object o, KeyPressEventArgs kpea) => { if (kpea.KeyChar > 32) { currentTool.Letter(this, kpea.KeyChar); if (currentAction is TextAction) { ((TextAction)currentAction).enteredText += kpea.KeyChar; //Voeg de letter toe aan de enteredTExt indien het textAction was } } }; }