From 966a7a2c42eee12690aafefe47c20074449b80dd Mon Sep 17 00:00:00 2001 From: Mukul Date: Mon, 12 Dec 2016 19:38:45 +0530 Subject: [PATCH] this is for erase functionality --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 19 +++++++++++-------- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index cf77512..a16c909 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -6408,15 +6408,55 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo - function OnPaintCanvasMouseMove(event) { + $rootScope.FreeStylePaint = function (e) { + + var annotationCanvas = document.getElementById("canvas"); + // document.getElementById("canvasPaint").addEventListener("mouseup", OnPaintBrushCanvasMouseUp); + + annotationCanvas.addEventListener('mousedown', $scope.OnPaintCanvasMouseDown, false); + annotationCanvas.addEventListener('mouseup', $scope.OnPaintBrushCanvasMouseUp, false); } + $scope.OnPaintCanvasMouseDown = function (event) { + $rootScope.isMousedownOnPaintCanvas = true; + $scope.isStartPointDeleted = false; + var annotationCanvas = document.getElementById("canvas"); + $scope.startPageX = parseInt(event.clientX - ($("#canvas").offset().left)); + $scope.startPageY = parseInt(event.clientY - ($("#canvas").offset().top)); + + annotationCanvas.addEventListener('mousemove', $scope.OnPaintCanvasMouseMove, false); - $rootScope.FreeStylePaint = function (e) { } + $scope.OnPaintCanvasMouseMove = function (event) { + + + $rootScope.xPage = parseInt(event.clientX - ($("#canvas").offset().left)); + $rootScope.yPage = parseInt(event.clientY - ($("#canvas").offset().top)); + + var btneraseBrushSizeValue = $("#btnBrushSize").val(); + $rootScope.eraseshapeSize = parseInt(btneraseBrushSizeValue); + + if ($rootScope.isEraseToolSelected == true && $rootScope.isMousedownOnPaintCanvas == true) { + + var sktch = $('#canvasPaint').sketch(); + $('#canvasPaint').sketch().actions = []; + var paintCanvas = document.getElementById("canvasPaint"); + var paintCanvasContext = paintCanvas.getContext('2d'); + if ($scope.isStartPointDeleted == false) { + + paintCanvasContext.clearRect($scope.startPageX, $scope.startPageY, $rootScope.eraseshapeSize, $rootScope.eraseshapeSize); + + $scope.isStartPointDeleted = true; + } + + paintCanvasContext.clearRect($rootScope.xPage, $rootScope.yPage, $rootScope.eraseshapeSize, $rootScope.eraseshapeSize); + + + } + } $scope.OnPaintBrushCanvasMouseDown = function (event) { switch ($rootScope.shapeType) { @@ -6445,7 +6485,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } } $scope.OnPaintBrushCanvasMouseUp = function (event) { - + $rootScope.isMousedownOnPaintCanvas = false; + $rootScope.isEraseToolSelected = false; // var canvasElement1 = document.getElementById("canvasPaint"); // var ctx1 = canvasElement1.getContext("2d"); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 1022e65..355ab0a 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -62,7 +62,8 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", $rootScope.TextRectangleArr = []; $rootScope.rectDimension = []; - + $rootScope.isEraseToolSelected = false; + $rootScope.isMousedownOnPaintCanvas = false; $rootScope.$on("$locationChangeSuccess", function () { @@ -440,14 +441,16 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", $('#canvas').css("z-index", y); } $rootScope.EraseDrawing = function () { - $rootScope.switchCanvasToPaintCanvas(); - // $('#canvasPaint').sketch({ defaultColor: "yellow", defaultSize: 1 }); - var sktch = $('#canvasPaint').sketch(); - $('#canvasPaint').sketch().actions = []; // this line empties the actions. - var myCanvas = document.getElementById("canvasPaint"); - var ctx = myCanvas.getContext('2d'); - ctx.clearRect(0, 0, myCanvas.width, myCanvas.height); $rootScope.switchCanvas(); + $rootScope.isEraseToolSelected = true; + //$rootScope.switchCanvasToPaintCanvas(); + //// $('#canvasPaint').sketch({ defaultColor: "yellow", defaultSize: 1 }); + //var sktch = $('#canvasPaint').sketch(); + //$('#canvasPaint').sketch().actions = []; // this line empties the actions. + //var myCanvas = document.getElementById("canvasPaint"); + //var ctx = myCanvas.getContext('2d'); + //ctx.clearRect(0, 0, myCanvas.width, myCanvas.height); + //$rootScope.switchCanvas(); } -- libgit2 0.21.4