AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 08.09.2017, 11:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
gideonvos: Doodle/Notes Control for AX7
Источник: https://gideonvos.wordpress.com/2016...ntrol-for-ax7/
==============

As I’m in the process of learning what can and can’t be done in AX7, I’ve started porting a cloud-based forms system over to AX. One item I require is the ability to allow users to digitally sign documents using a pen or mouse, which is then “stamped” into the PDF document they are signing.

This requires some interesting JavaScript usage within an AX7 Extensible Control and I’ve learned quite a lot about how the Extensible Control Framework hangs together while doing so. In building the signature control I thought I’d give something back to the AX community and created a control that will no doubt be used extensively during those exciting project implementation meetings – a doodle control. Feel free to embed this into your own module or hide it as an Easter Egg if you want.

The basic container form code is shown below, and does nothing but instantiate our control:

[Form] public class DoodleForm extends FormRun { DoodleControl doodle; public void init() { super(); doodle = this.design().addControlEx(classStr(DoodleControl),"DoodleControl1"); } }


The control itself is very simple as well, as shown below.

[FormControlAttribute("DoodleControl","resources/html/DoodleControl", classstr(FormBuildControl))] class DoodleControl extends FormTemplateControl { public void new(FormBuildControl _build, FormRun _formRun) { super(_build,_formRun); this.setTemplateId("DoodleControl"); this.setResourceBundleName("resources/html/DoodleControl"); } }


Finally, the HTML code which is stored as a resource contains the JavaScript where all the fun happens. As AX7 uses HTML5 we can use the canvas object for our drawing. I’ve embedded the CSS styling into the button, and instead of sticking the JavaScript into another resource file just embedded it at the end of the page WHICH WORKS FINE. The only trick I learned is in order for it all to work, all the HTML and JavaScript needs to be wrapped in the main control DIV element.

<div style="background:#ffffff;overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"> New $(document).ready(function () { var canvasWidth = 600; var canvasHeight = 400; var canvas = document.getElementById('canvas'); var context = canvas.getContext("2d"); var clickX = new Array(); var clickY = new Array(); var clickDrag = new Array(); var paint; canvas.addEventListener("mousedown", mouseDown, false); canvas.addEventListener("mousemove", mouseXY, false); document.body.addEventListener("mouseup", mouseUp, false); canvas.addEventListener("touchstart", mouseDown, false); canvas.addEventListener("touchmove", mouseXY, true); canvas.addEventListener("touchend", mouseUp, false); document.body.addEventListener("touchcancel", mouseUp, false); function draw() { context.clearRect(0, 0, canvas.width, canvas.height); context.strokeStyle = "#000000"; context.lineJoin = "miter"; context.lineWidth = 1; for (var i = 0; i <span style="color:#333333;">
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Navigate Into Success: Trick: Instantiating any control in a Control Add-in Blog bot Dynamics CRM: Blogs 0 19.08.2014 23:31
Navigate Into Success: Trick: Subscribing to any Control Add-in event through pure C/AL Blog bot Dynamics CRM: Blogs 0 04.08.2014 11:00
Axilicious:Hosting custom WPF calendar control in AX 2012 Blog bot DAX Blogs 0 20.05.2013 18:11
emeadaxsupport: AX for Retail 2012 R2: Adding a Custom User Control to the POS Blog bot DAX Blogs 0 27.02.2013 07:14
a33ik: CRM 2011: Playing with notes control Blog bot Dynamics CRM: Blogs 1 09.02.2012 10:17

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:49.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.