/**
         * @Method calls the Wacom Pad UI for signing and returns the sign data
         * @Return GraphSign if confirmed, null if cancel by the user
         */
        public GraphSign padSigning(Signer signer)
        {
            ILog Log;
            Log = LogManager.GetLogger(Properties.Settings.Default.logName);
            try
            {

                wgssSTU.UsbDevices usbDevices = new wgssSTU.UsbDevices();
                wgssSTU.IUsbDevice usbDevice = usbDevices[0]; // select a device

                WacomPadForm.PresingString = String.Format(Properties.Settings.Default.presingModel, signer.Nombre, signer.Nif);
                WacomPadForm demo = new WacomPadForm(usbDevice,this.minPoints);
                demo.Title = String.Format(Properties.Settings.Default.presingModel, signer.Nombre, signer.Nif);
                //WacomPadUtils.BringToFrontCustom(demo);
                demo.ShowDialog();
                GraphSign result = demo.getSign();
                demo.Dispose();
                return result;

            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return null;
            }
        }
        private void loadPads(wgssSTU.UsbDevices usbDevices)
        {
            for (int i = 0; i < m_padsControl.Count; i++)
            {
                UIPadHandle ph = new UIPadHandle(usbDevices[i].fileName, i, canvas);

                ph.ProductID = m_padsControl[i].getProductId();

                ph.BorderThickness = 0;
                ph.Width           = PadPixelWidth;
                ph.Height          = PadPixelHeight;
                ph.XOffset         = m_bitmapRes[ph.IDIndex].m_screen.m_pos.X;
                ph.YOffset         = m_bitmapRes[ph.IDIndex].m_screen.m_pos.Y;
                ph.MouseDown      += shape_MouseLeftButtonDown;
                ph.MouseMove      += shape_MouseMove;
                ph.MouseUp        += shape_MouseLeftButtonUp;

                ph.ImgSource     = m_bitmapRes[ph.IDIndex].m_img;
                ph.WarningSource = m_warning;
                ph.Selected      = false;
                ph.IdentifyState = false;

                ph.BorderThickness = m_selectThickness;

                m_padsUI.Add(ph);
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            int penDataType;
            List <wgssSTU.IPenDataTimeCountSequence> penTimeData = null;
            List <wgssSTU.IPenData> penData = null;

            wgssSTU.UsbDevices usbDevices = new wgssSTU.UsbDevices();
            if (usbDevices.Count != 0)
            {
                try
                {
                    wgssSTU.IUsbDevice usbDevice = usbDevices[0]; // select a device

                    SignatureForm demo = new SignatureForm(usbDevice, chkUseEncryption.Checked);
                    demo.ShowDialog();
                    penDataType = demo.penDataType;

                    if (penDataType == (int)PenDataOptionMode.PenDataOptionMode_TimeCountSequence)
                    {
                        penTimeData = demo.getPenTimeData();
                    }
                    else
                    {
                        penData = demo.getPenData();
                    }

                    if (penData != null || penTimeData != null)
                    {
                        // process penData here!

                        if (penData != null)
                        {
                            txtPenDataCount.Text = penData.Count.ToString();
                        }
                        else
                        {
                            txtPenDataCount.Text = penTimeData.Count.ToString();
                        }

                        wgssSTU.IInformation information = demo.getInformation();
                        wgssSTU.ICapability  capability  = demo.getCapability();
                    }
                    demo.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("No STU devices attached");
            }
        }
Beispiel #4
0
        public static void GetSignature()
        {
            int penDataType;
            List <wgssSTU.IPenDataTimeCountSequence> penTimeData = null;
            List <wgssSTU.IPenData> penData = null;

            wgssSTU.UsbDevices usbDevices = new wgssSTU.UsbDevices();
            if (usbDevices.Count != 0)
            {
                try
                {
                    wgssSTU.IUsbDevice usbDevice = usbDevices[0]; // select a device

                    SignatureForm demo = new SignatureForm(usbDevice, false);
                    demo.Text = "Salguero - Firma Báscula";
                    demo.ShowDialog();
                    penDataType = demo.penDataType;

                    if (penDataType == (int)PenDataOptionMode.PenDataOptionMode_TimeCountSequence)
                    {
                        penTimeData = demo.getPenTimeData();
                    }
                    else
                    {
                        penData = demo.getPenData();
                    }

                    if (penData != null || penTimeData != null)
                    {
                        // process penData here!

                        /*
                         * if (penData != null)
                         *  txtPenDataCount.Text = penData.Count.ToString();
                         * else
                         *  txtPenDataCount.Text = penTimeData.Count.ToString();
                         */
                        wgssSTU.IInformation information = demo.getInformation();
                        wgssSTU.ICapability  capability  = demo.getCapability();
                    }
                    demo.Dispose();
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("No STU devices attached");
            }
        }
Beispiel #5
0
        private void MainWindow_OnContentRendered(object sender, EventArgs e)
        {
            DPI = DpiInfo.GetDpi();
            DPI = 1.0f;

            timer           = new DispatcherTimer();
            timer.IsEnabled = false;
            timer.Interval  = TimeSpan.FromMilliseconds(350);
            timer.Tick     += OnEndResize;

            m_usbDevices = new wgssSTU.UsbDevices();
            m_padGui     = new UIPadsController(m_usbDevices, canvas, LayoutRoot, tbar, config, this);

            m_padGui.setMinSizesCanvas();
        }
        /**
         * @Method Checks if a Wacom Pad is connected and ready in the system
         * @Return true if Wacom Pad is available, false otherwise
         */
        public bool checkPadConnected()
        {
            ILog Log;
            Log = LogManager.GetLogger(Properties.Settings.Default.logName);

            try
            {
                wgssSTU.UsbDevices usbDevices = new wgssSTU.UsbDevices();
                return (usbDevices.Count != 0);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return false;
            }
        }
Beispiel #7
0
        public void updateDevicesList()
        {
            Thread.Sleep(50);
            var newUsbDevices = new wgssSTU.UsbDevices();

            for (int i = 0; i < newUsbDevices.Count; i++)
            {
                bool isNew = true;
                for (int j = 0; j < m_usbDevices.Count; j++)
                {
                    if (m_usbDevices[j].fileName == newUsbDevices[i].fileName)
                    {
                        isNew = false;
                        break;
                    }
                }
                if (isNew)
                {
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                           new Action <wgssSTU.IUsbDevice>(AddDevice), newUsbDevices[i]);
                }
            }
            for (int j = 0; j < m_usbDevices.Count; j++)
            {
                bool isRemoved = true;
                for (int i = 0; i < newUsbDevices.Count; i++)
                {
                    if (m_usbDevices[j].fileName == newUsbDevices[i].fileName)
                    {
                        isRemoved = false;
                        break;
                    }
                }
                if (isRemoved)
                {
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                           new Action <wgssSTU.IUsbDevice>(RemoveDevice), m_usbDevices[j]);
                }
            }
            m_usbDevices = newUsbDevices;
        }
        public void Lecture_signature()
        {
            Program.LogFich.Info("[Wacom_STU] Debut => Lecture_signature()");
            if (STU != null)
            {
                STU = null;
            }
            try
            {
                wgssSTU.UsbDevices usbDevices = new wgssSTU.UsbDevices();
                if (usbDevices.Count != 0)
                {
                    try
                    {
                        wgssSTU.IUsbDevice usbDevice = usbDevices[0]; // select a device

                        STU = new Form_Wacom_STU("Saisie de la signature", url, WebBrowser, this, usbDevice);

                        STU.ShowDialog();
                        Program.LogFich.Info("[Wacom_STU] Fin => Lecture_signature()");
                        this.ChangeLabelStatus("Status : None");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        Program.LogFich.Error("[Wacom_STU] Lecture_signature() = " + ex.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("No STU devices attached");
                    this.ChangeLabelStatus("Status : None");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No STU devices attached");
                Program.LogFich.Error("[Wacom_STU] Lecture_signature() (usbDevices.Count) = " + ex.ToString());
            }
        }
        DispatcherTimer timer; //this is a hack to be able to update the buttons correctly

        public UIPadsController(wgssSTU.UsbDevices m_usbDevices, Canvas lcanvas, Grid root, StackPanel tbar,
                                CONFIG config, Window w)
        {
            timer = new DispatcherTimer();
            timer.Stop();
            timer.Interval = TimeSpan.FromMilliseconds(30);
            timer.Tick    += UpdateButtons;

            PadPixelHeight = 117;
            PadPixelWidth  = 100;
            canvas         = lcanvas;
            LayoutRoot     = root;
            m_bitmapRes    = new List <BitmapResource>();
            m_padsUI       = new List <UIPadHandle>();
            m_padsControl  = new List <PadHandle>();

            tbar.Height = 60;
            //////////////////////////////////////////////
            m_identifyButton           = new RadioButton();
            m_identifyButton.GroupName = "Identify";
            m_identifyButton.Height    = tbar.Height - 6;

            Image       im  = new Image();
            BitmapImage bmp = new BitmapImage();

            bmp.BeginInit();
            bmp.UriSource = new Uri(@"pictures/move.png", UriKind.Relative);
            //bmp.DecodePixelHeight = (int)(m_identifyButton.Height * 2*DpiInfo.GetDpi());
            bmp.EndInit();

            im.SnapsToDevicePixels = true;
            im.UseLayoutRounding   = true;
            im.Source = bmp;

            m_identifyButton.Content     = im;
            m_identifyButton.MouseEnter += delegate { ButtonsHelper.RadioButtonUpdate(m_identifyButton); };
            m_identifyButton.MouseLeave += delegate { ButtonsHelper.RadioButtonUpdate(m_identifyButton); };

            tbar.Children.Add(m_identifyButton);

            m_identifyButton.Click  += delegate { IdentifyButtonClick(); };
            m_identifyButton.ToolTip = "Position and identify pads";

            ////////////////////////////////////////////////////////////////

            Separator sep = new Separator();

            sep.SetResourceReference(Control.StyleProperty, "VerticalSeparatorStyle");

            tbar.Children.Add(sep);


            /////////////////////////////////////////////
            m_singleModeButton = new RadioButton();
            //m_identifyButton.GroupName = "Selection Mode";
            m_singleModeButton.Height = tbar.Height - 6;


            m_singleModeButton.MouseEnter += delegate
            {
                ButtonsHelper.RadioButtonUpdate(m_singleModeButton);
                ButtonsHelper.RadioButtonUpdate(m_multipleModeButton);
            };
            m_singleModeButton.MouseLeave += delegate
            {
                ButtonsHelper.RadioButtonUpdate(m_singleModeButton);
                ButtonsHelper.RadioButtonUpdate(m_multipleModeButton);
            };

            RadioGifControl gifSingle = new RadioGifControl("pictures/select_singleBIG.gif", m_singleModeButton);

            m_singleModeButton.MouseEnter += delegate { gifSingle.Play(); };
            m_singleModeButton.MouseLeave += delegate { gifSingle.Stop(); };

            tbar.Children.Add(m_singleModeButton);

            m_singleModeButton.ToolTip = "Select single pad";
            m_singleModeButton.Click  += delegate
            {
                ChangeSelectionMode(m_singleModeButton, new EventArgs());
            };


            //////////////////////////////////////////////

            m_multipleModeButton = new RadioButton();
            //m_multipleModeButton.GroupName = "Selection Mode";
            m_multipleModeButton.Height = tbar.Height - 6;

            m_multipleModeButton.MouseEnter += delegate
            {
                ButtonsHelper.RadioButtonUpdate(m_multipleModeButton);
                ButtonsHelper.RadioButtonUpdate(m_singleModeButton);
            };
            m_multipleModeButton.MouseLeave += delegate
            {
                ButtonsHelper.RadioButtonUpdate(m_multipleModeButton);
                ButtonsHelper.RadioButtonUpdate(m_singleModeButton);
            };


            RadioGifControl gifMultiple = new RadioGifControl("pictures/select_multipleBIG.gif", m_multipleModeButton);

            m_multipleModeButton.MouseEnter += delegate { gifMultiple.Play(); };
            m_multipleModeButton.MouseLeave += delegate { gifMultiple.Stop(); };

            tbar.Children.Add(m_multipleModeButton);
            m_multipleModeButton.ToolTip = "Select multiple pads";


            m_multipleModeButton.Click += delegate
            {
                ChangeSelectionMode(m_multipleModeButton, new EventArgs());
            };

            ///////////////////////////////////////////////

            for (int i = 0; i < m_usbDevices.Count; i++)
            {
                m_padsControl.Add(new PadHandle(this, m_usbDevices[i], m_state, i));
            }

            loadBitmaps();

            if (m_usbDevices.Count != 0)
            {
                loadPads(m_usbDevices);
                noOverlappingOnStart();
            }

            m_state = AppState.Selection_Mode;
            m_singleModeButton.IsChecked = true;
            IdentifyButtonClick();
            SetConfig(config);
        }