Commit 966a7a2c42eee12690aafefe47c20074449b80dd
1 parent
00de6fce
this is for erase functionality
Showing
2 changed files
with
55 additions
and
11 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
@@ -6408,15 +6408,55 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo | @@ -6408,15 +6408,55 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo | ||
6408 | 6408 | ||
6409 | 6409 | ||
6410 | 6410 | ||
6411 | - function OnPaintCanvasMouseMove(event) { | ||
6412 | 6411 | ||
6412 | + $rootScope.FreeStylePaint = function (e) { | ||
6413 | + | ||
6414 | + var annotationCanvas = document.getElementById("canvas"); | ||
6415 | + // document.getElementById("canvasPaint").addEventListener("mouseup", OnPaintBrushCanvasMouseUp); | ||
6416 | + | ||
6417 | + annotationCanvas.addEventListener('mousedown', $scope.OnPaintCanvasMouseDown, false); | ||
6413 | 6418 | ||
6419 | + annotationCanvas.addEventListener('mouseup', $scope.OnPaintBrushCanvasMouseUp, false); | ||
6414 | } | 6420 | } |
6421 | + $scope.OnPaintCanvasMouseDown = function (event) { | ||
6422 | + $rootScope.isMousedownOnPaintCanvas = true; | ||
6423 | + $scope.isStartPointDeleted = false; | ||
6424 | + var annotationCanvas = document.getElementById("canvas"); | ||
6425 | + $scope.startPageX = parseInt(event.clientX - ($("#canvas").offset().left)); | ||
6426 | + $scope.startPageY = parseInt(event.clientY - ($("#canvas").offset().top)); | ||
6427 | + | ||
6428 | + annotationCanvas.addEventListener('mousemove', $scope.OnPaintCanvasMouseMove, false); | ||
6415 | 6429 | ||
6416 | - $rootScope.FreeStylePaint = function (e) { | ||
6417 | 6430 | ||
6418 | 6431 | ||
6419 | } | 6432 | } |
6433 | + $scope.OnPaintCanvasMouseMove = function (event) { | ||
6434 | + | ||
6435 | + | ||
6436 | + $rootScope.xPage = parseInt(event.clientX - ($("#canvas").offset().left)); | ||
6437 | + $rootScope.yPage = parseInt(event.clientY - ($("#canvas").offset().top)); | ||
6438 | + | ||
6439 | + var btneraseBrushSizeValue = $("#btnBrushSize").val(); | ||
6440 | + $rootScope.eraseshapeSize = parseInt(btneraseBrushSizeValue); | ||
6441 | + | ||
6442 | + if ($rootScope.isEraseToolSelected == true && $rootScope.isMousedownOnPaintCanvas == true) { | ||
6443 | + | ||
6444 | + var sktch = $('#canvasPaint').sketch(); | ||
6445 | + $('#canvasPaint').sketch().actions = []; | ||
6446 | + var paintCanvas = document.getElementById("canvasPaint"); | ||
6447 | + var paintCanvasContext = paintCanvas.getContext('2d'); | ||
6448 | + if ($scope.isStartPointDeleted == false) { | ||
6449 | + | ||
6450 | + paintCanvasContext.clearRect($scope.startPageX, $scope.startPageY, $rootScope.eraseshapeSize, $rootScope.eraseshapeSize); | ||
6451 | + | ||
6452 | + $scope.isStartPointDeleted = true; | ||
6453 | + } | ||
6454 | + | ||
6455 | + paintCanvasContext.clearRect($rootScope.xPage, $rootScope.yPage, $rootScope.eraseshapeSize, $rootScope.eraseshapeSize); | ||
6456 | + | ||
6457 | + | ||
6458 | + } | ||
6459 | + } | ||
6420 | $scope.OnPaintBrushCanvasMouseDown = function (event) { | 6460 | $scope.OnPaintBrushCanvasMouseDown = function (event) { |
6421 | switch ($rootScope.shapeType) { | 6461 | switch ($rootScope.shapeType) { |
6422 | 6462 | ||
@@ -6445,7 +6485,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo | @@ -6445,7 +6485,8 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo | ||
6445 | } | 6485 | } |
6446 | } | 6486 | } |
6447 | $scope.OnPaintBrushCanvasMouseUp = function (event) { | 6487 | $scope.OnPaintBrushCanvasMouseUp = function (event) { |
6448 | - | 6488 | + $rootScope.isMousedownOnPaintCanvas = false; |
6489 | + $rootScope.isEraseToolSelected = false; | ||
6449 | 6490 | ||
6450 | // var canvasElement1 = document.getElementById("canvasPaint"); | 6491 | // var canvasElement1 = document.getElementById("canvasPaint"); |
6451 | // var ctx1 = canvasElement1.getContext("2d"); | 6492 | // var ctx1 = canvasElement1.getContext("2d"); |
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
@@ -62,7 +62,8 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", | @@ -62,7 +62,8 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", | ||
62 | $rootScope.TextRectangleArr = []; | 62 | $rootScope.TextRectangleArr = []; |
63 | $rootScope.rectDimension = []; | 63 | $rootScope.rectDimension = []; |
64 | 64 | ||
65 | - | 65 | + $rootScope.isEraseToolSelected = false; |
66 | + $rootScope.isMousedownOnPaintCanvas = false; | ||
66 | 67 | ||
67 | $rootScope.$on("$locationChangeSuccess", function () { | 68 | $rootScope.$on("$locationChangeSuccess", function () { |
68 | 69 | ||
@@ -440,14 +441,16 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", | @@ -440,14 +441,16 @@ AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", | ||
440 | $('#canvas').css("z-index", y); | 441 | $('#canvas').css("z-index", y); |
441 | } | 442 | } |
442 | $rootScope.EraseDrawing = function () { | 443 | $rootScope.EraseDrawing = function () { |
443 | - $rootScope.switchCanvasToPaintCanvas(); | ||
444 | - // $('#canvasPaint').sketch({ defaultColor: "yellow", defaultSize: 1 }); | ||
445 | - var sktch = $('#canvasPaint').sketch(); | ||
446 | - $('#canvasPaint').sketch().actions = []; // this line empties the actions. | ||
447 | - var myCanvas = document.getElementById("canvasPaint"); | ||
448 | - var ctx = myCanvas.getContext('2d'); | ||
449 | - ctx.clearRect(0, 0, myCanvas.width, myCanvas.height); | ||
450 | $rootScope.switchCanvas(); | 444 | $rootScope.switchCanvas(); |
445 | + $rootScope.isEraseToolSelected = true; | ||
446 | + //$rootScope.switchCanvasToPaintCanvas(); | ||
447 | + //// $('#canvasPaint').sketch({ defaultColor: "yellow", defaultSize: 1 }); | ||
448 | + //var sktch = $('#canvasPaint').sketch(); | ||
449 | + //$('#canvasPaint').sketch().actions = []; // this line empties the actions. | ||
450 | + //var myCanvas = document.getElementById("canvasPaint"); | ||
451 | + //var ctx = myCanvas.getContext('2d'); | ||
452 | + //ctx.clearRect(0, 0, myCanvas.width, myCanvas.height); | ||
453 | + //$rootScope.switchCanvas(); | ||
451 | 454 | ||
452 | } | 455 | } |
453 | 456 |