Esempio n. 1
0
        public void readConfig()
        {
            string configFilePath = Application.StartupPath + "\\res\\config_user.xml";

            if (SettingsUtil.isPerAppSettingsEnabled && SettingsUtil.perAppSettingsDefault.HasValue &&
                SettingsUtil.perAppSettingsDefault.Value.enabled)
            {
                configFilePath = Path.GetFullPath(Path.Combine(SettingsUtil.perAppSettingsProfileDir,
                                                               SettingsUtil.perAppSettingsDefault.Value.profile));
            }

            HNStruct.devTypeString =
                Marshal.PtrToStringAuto(
                    HuionDriverDLL.hnp_get_tablet_image((HnConst.HNTabletType)HNStruct.globalInfo.tabletInfo.devType));
            HNStruct.tabletTextInfo = HNStruct.globalInfo.bOpenedTablet
                ? ResourceCulture.GetString("FormHuionTablet_lbOpenTabletText")
                : ResourceCulture.GetString("FormHuionTablet_lbCloseTabletText");
            if (!HNStruct.globalInfo.bOpenedTablet)
            {
                return;
            }
            IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(configFilePath);

            Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));
            IntPtr num = HuionDriverDLL.hnx_read_config(ref HNStruct.globalInfo.tabletInfo, coTaskMemAuto);

            config = (HNStruct.HNConfigXML)Marshal.PtrToStructure(num, typeof(HNStruct.HNConfigXML));
            this.SetLayoutTablet(num);
            Marshal.FreeHGlobal(coTaskMemAuto);
            HuionDriverDLL.hnx_free_PHNConfig(num);
            this.SetLayoutPen();
            this.SetConfig(config);
        }
Esempio n. 2
0
 public static void defaultConfigClick(object sender, EventArgs e)
 {
     if (MessageBox.Show(ResourceCulture.GetString("FormInfo_RemindMessageText"),
                         ResourceCulture.GetString("FormInfo_remindText"), MessageBoxButtons.OKCancel,
                         MessageBoxIcon.Question) == DialogResult.OK)
     {
         try
         {
             IntPtr coTaskMemAuto =
                 Marshal.StringToCoTaskMemAuto(Application.StartupPath + "\\res\\config_default.xml");
             Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));
             IntPtr num1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNTabletInfo)));
             Marshal.StructureToPtr((object)HNStruct.globalInfo.tabletInfo, num1, false);
             IntPtr num2 = HuionDriverDLL.hnx_read_config(ref HNStruct.globalInfo.tabletInfo, coTaskMemAuto);
             TabletConfigUtils.config =
                 (HNStruct.HNConfigXML)Marshal.PtrToStructure(num2, typeof(HNStruct.HNConfigXML));
             new TabletConfigUtils().SetConfig(TabletConfigUtils.config);
             Marshal.FreeHGlobal(coTaskMemAuto);
             Marshal.FreeHGlobal(num1);
             HuionDriverDLL.hnx_free_PHNConfig(num2);
         }
         catch (Exception ex)
         {
             HuionLog.saveLog("默认配置", ex.Message);
         }
     }
 }
Esempio n. 3
0
 public static void OpenDevice()
 {
     try
     {
         DeviceStatusUtils.reconnection = true;
         if (mDeviceCallback == null)
         {
             mDeviceCallback =
                 new DeviceStatusUtils.OpenDeviceCallbcak(new DeviceStatusUtils().openDeviceCallback);
         }
         if (HNStruct.globalInfo.bOpenedTablet || !DeviceStatusUtils.reconnection)
         {
             return;
         }
         string s1             = Application.StartupPath + "\\res\\config_user.xml";
         string s2             = Application.StartupPath + "\\res\\layout_tablet.xml";
         IntPtr coTaskMemAuto1 = Marshal.StringToCoTaskMemAuto(s1);
         IntPtr coTaskMemAuto2 = Marshal.StringToCoTaskMemAuto(s2);
         int    num            = (int)HuionDriverDLL.hnd_open(mDeviceCallback, coTaskMemAuto1, coTaskMemAuto2);
         Marshal.FreeCoTaskMem(coTaskMemAuto1);
         Marshal.FreeCoTaskMem(coTaskMemAuto2);
     }
     catch (Exception ex)
     {
         HuionLog.saveLog("open devices api", ex.Message);
     }
 }
Esempio n. 4
0
        private static void onRead()
        {
            int num1 = (int)HuionDriverDLL.timeBeginPeriod(1U);

            while (reading)
            {
                HNStruct.HNPenData p = new HNStruct.HNPenData();
                try
                {
                    HuionDriverDLL.hndh_get_cursor(ref p);
                }
                catch (Exception ex)
                {
                    HuionLog.saveLog("Get Touch Info", ex.Message);
                    HuionLog.saveLog("Get Touch Info", ex.StackTrace);
                }

                if (p.btn > (byte)0)
                {
                    if (touchInfoListener != null)
                    {
                        touchInfoListener(p);
                    }
                    IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNPenData)));
                    Marshal.StructureToPtr((object)p, num2, false);
                    HuionDriverDLL.PostMessage(mHandle, 1064, num2, IntPtr.Zero);
                    Marshal.FreeHGlobal(num2);
                }

                Thread.Sleep(1);
            }

            int num3 = (int)HuionDriverDLL.timeEndPeriod(1U);
        }
Esempio n. 5
0
        private void pictureBoxPressCurve_Paint(object sender, PaintEventArgs e)
        {
            int      num1     = 0;
            int      num2     = this.pictureBoxPressCurve.Height;
            Graphics graphics = e.Graphics;
            Pen      pen1     = new Pen(Color.DarkGray, 2f);
            Pen      pen2     = new Pen(Color.DarkGray, 1f);

            graphics.DrawRectangle(pen1, 0, 0, this.pictureBoxPressCurve.Width, this.pictureBoxPressCurve.Height);
            uint   width = (uint)this.pictureBoxPressCurve.Width;
            IntPtr num3  = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));

            Marshal.StructureToPtr((object)TabletConfigUtils.config, num3, true);
            for (int index = 0; index < this.pictureBoxPressCurve.Width; ++index)
            {
                graphics.DrawLine(pen2, (float)num1, (float)num2, (float)index,
                                  (float)((long)this.pictureBoxPressCurve.Height -
                                          (long)HuionDriverDLL.hnc_calibrate_press_tablet(num3, ref HNStruct.globalInfo.tabletInfo,
                                                                                          (uint)index, width)));
                num1 = index;
                num2 = (int)((long)this.pictureBoxPressCurve.Height -
                             (long)HuionDriverDLL.hnc_calibrate_press_tablet(num3, ref HNStruct.globalInfo.tabletInfo,
                                                                             (uint)index, width));
            }

            Marshal.FreeHGlobal(num3);
            pen1.Dispose();
            pen2.Dispose();
        }
Esempio n. 6
0
        private static void Main(string[] args)
        {
            HNStruct.OemType = DeployConfig.getOemType();
            HuionLog.listenGlobalCrashLog();
            ResourceCulture.init();
            TimerSession.startListenUserOperation();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool flag = false;

            try
            {
                flag = Utils.isAppRunning();
            }
            catch
            {
                Utils.runAsAdmin(true);
                return;
            }

            if (new Mutex(true, "OnlyRun").WaitOne(0, false))
            {
                Application.Run((Form) new HuionTalbet());
            }
            else
            {
                if (Utils.isStartup(args) ||
                    HuionDriverDLL.PostMessage(HuionDriverDLL.FindWindow((string)null, Fixer4Main.FormTitle()), 1054,
                                               IntPtr.Zero, IntPtr.Zero) != 0)
                {
                    return;
                }
                Utils.runAsAdmin(true);
            }
        }
Esempio n. 7
0
        public static void exportConfigClick(object sender, EventArgs e)
        {
            Directory.CreateDirectory(SettingsUtil.perAppSettingsProfileDir);
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Path.GetFullPath(SettingsUtil.perAppSettingsProfileDir);
            saveFileDialog.Filter           = ResourceCulture.GetString("FormInfo_TextFile") + "|*.xml";
            saveFileDialog.FilterIndex      = 2;
            saveFileDialog.RestoreDirectory = true;
            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName       = saveFileDialog.FileName;
            string s              = Application.StartupPath + "\\res\\config_user.xml";
            IntPtr coTaskMemAuto1 = Marshal.StringToCoTaskMemAuto(fileName);
            IntPtr coTaskMemAuto2 = Marshal.StringToCoTaskMemAuto(s);
            IntPtr num1           = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));

            Marshal.StructureToPtr((object)TabletConfigUtils.config, num1, true);
            IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNTabletInfo)));

            Marshal.StructureToPtr((object)HNStruct.globalInfo.tabletInfo, num2, true);
            int num3 = (int)HuionDriverDLL.hnx_save_config(num1, num2, coTaskMemAuto2, coTaskMemAuto1);

            HuionDriverDLL.hnd_notify_config_changed();
            Marshal.FreeHGlobal(coTaskMemAuto1);
            Marshal.FreeHGlobal(coTaskMemAuto2);
            Marshal.FreeHGlobal(num2);
            Marshal.FreeHGlobal(num1);
            saveFileDialog.Dispose();
        }
Esempio n. 8
0
 public static void applayClick(object sender, EventArgs e)
 {
     try
     {
         IntPtr coTaskMemAuto =
             Marshal.StringToCoTaskMemAuto(Application.StartupPath + "\\res\\config_user.xml");
         IntPtr num1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));
         for (int index = 0; index < (int)TabletConfigUtils.config.ctxEkeys[0].ctxMek[0].eks[0].num; ++index)
         {
             TabletConfigUtils.config.ctxEkeys[0].ctxMek[0].eks[0].mekid = (char[])null;
         }
         TabletConfigUtils.config.ctxEkeys[0].ctxMek[0].eks[0].mekid = (char[])null;
         TabletConfigUtils.config.ctxEkeys[0].ctxMek[0].eks[1].mekid = (char[])null;
         Marshal.StructureToPtr((object)TabletConfigUtils.config, num1, false);
         IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNTabletInfo)));
         Marshal.StructureToPtr((object)HNStruct.globalInfo.tabletInfo, num2, false);
         int num3 = (int)HuionDriverDLL.hnx_save_config(num1, num2, coTaskMemAuto, coTaskMemAuto);
         HuionDriverDLL.hnd_notify_config_changed();
         Marshal.FreeHGlobal(num2);
         Marshal.FreeHGlobal(num1);
         Marshal.FreeHGlobal(coTaskMemAuto);
     }
     catch (Exception ex)
     {
         HuionLog.saveLog("保存接口", ex.Message);
     }
 }
Esempio n. 9
0
 public static void importConfigClick(object sender, EventArgs e)
 {
     if (MessageBox.Show(ResourceCulture.GetString("FormInfo_RemindImportMessageText"),
                         ResourceCulture.GetString("FormInfo_remindText"), MessageBoxButtons.OKCancel,
                         MessageBoxIcon.Question) == DialogResult.OK)
     {
         Directory.CreateDirectory(SettingsUtil.perAppSettingsProfileDir);
         OpenFileDialog openFileDialog = new OpenFileDialog();
         openFileDialog.InitialDirectory = Path.GetFullPath(SettingsUtil.perAppSettingsProfileDir);
         openFileDialog.Filter           = ResourceCulture.GetString("FormInfo_TextFile") + "|*.xml";
         openFileDialog.RestoreDirectory = true;
         openFileDialog.FilterIndex      = 1;
         HNStruct.HNConfigXML hnConfigXml = new HNStruct.HNConfigXML();
         if (openFileDialog.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         IntPtr        coTaskMemAuto = Marshal.StringToCoTaskMemAuto(Path.GetFullPath(openFileDialog.FileName));
         StringBuilder stringBuilder = new StringBuilder(Path.GetFullPath(openFileDialog.FileName));
         Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));
         IntPtr num = HuionDriverDLL.hnx_read_config(ref HNStruct.globalInfo.tabletInfo, coTaskMemAuto);
         TabletConfigUtils.config = hnConfigXml;
         TabletConfigUtils.config =
             (HNStruct.HNConfigXML)Marshal.PtrToStructure(num, typeof(HNStruct.HNConfigXML));
         new TabletConfigUtils().SetConfig(TabletConfigUtils.config);
         Marshal.FreeHGlobal(coTaskMemAuto);
         Marshal.FreeHGlobal(num);
         openFileDialog.Dispose();
     }
 }
Esempio n. 10
0
 public static Image getPenImage()
 {
     return((Image)HuionRender.blowupImage(
                ImageHelper.getDllImage(Marshal.PtrToStringUni(
                                            HuionDriverDLL.hnp_get_pen_image((HnConst.HNTabletType)HNStruct.globalInfo.tabletInfo.devType))),
                DpiHelper.getInstance().XDpi));
 }
Esempio n. 11
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     this.isRunning = 0;
     HuionDriverDLL.SystemParametersInfo(114, 0, ref this.isRunning, 0);
     if (this.curIsRunning == this.isRunning)
     {
         return;
     }
     this.curIsRunning = this.isRunning;
     HuionDriverDLL.hnd_set_screenSaverRunning(this.isRunning);
 }
Esempio n. 12
0
        public static uint calibratePressVal(HNStruct.HNConfigXML cfg, uint psVal, uint maxP)
        {
            try
            {
                switch (cfg.pressFactor)
                {
                case -4:
                    int num1 = (int)HuionDriverDLL.hnc_equation_power((double)psVal, 0.125, (double)maxP);
                    return(HuionDriverDLL.hnc_equation_power((double)psVal, 0.125, (double)maxP));

                case -3:
                    int num2 = (int)HuionDriverDLL.hnc_equation_power((double)psVal, 0.25, (double)maxP);
                    return(HuionDriverDLL.hnc_equation_power((double)psVal, 0.25, (double)maxP));

                case -2:
                    int num3 = (int)HuionDriverDLL.hnc_equation_circle((double)psVal, (double)maxP,
                                                                       (double)maxP, 1);
                    return(HuionDriverDLL.hnc_equation_circle((double)psVal, (double)maxP, (double)maxP, 1));

                case -1:
                    int num4 = (int)HuionDriverDLL.hnc_equation_circle((double)psVal, (double)(2U * maxP),
                                                                       (double)maxP, 1);
                    return(HuionDriverDLL.hnc_equation_circle((double)psVal, (double)(2U * maxP), (double)maxP,
                                                              1));

                case 1:
                    int num5 = (int)HuionDriverDLL.hnc_equation_circle((double)psVal, (double)(2U * maxP),
                                                                       (double)maxP, 0);
                    return(HuionDriverDLL.hnc_equation_circle((double)psVal, (double)(2U * maxP), (double)maxP,
                                                              0));

                case 2:
                    int num6 = (int)HuionDriverDLL.hnc_equation_circle((double)psVal, (double)maxP,
                                                                       (double)maxP, 0);
                    return(HuionDriverDLL.hnc_equation_circle((double)psVal, (double)maxP, (double)maxP, 0));

                case 3:
                    int num7 = (int)HuionDriverDLL.hnc_equation_power((double)psVal, 4.0, (double)maxP);
                    return(HuionDriverDLL.hnc_equation_power((double)psVal, 4.0, (double)maxP));

                case 4:
                    int num8 = (int)HuionDriverDLL.hnc_equation_power((double)psVal, 8.0, (double)maxP);
                    return(HuionDriverDLL.hnc_equation_power((double)psVal, 8.0, (double)maxP));
                }
            }
            catch (Exception ex)
            {
                HuionLog.saveLog("calibratePressValue", ex.Message);
                HuionLog.saveLog("calibratePressValue", ex.StackTrace);
            }

            return(psVal);
        }
Esempio n. 13
0
 public static void closeDevice(object obj)
 {
     try
     {
         DeviceStatusUtils.reconnection = false;
         HuionDriverDLL.hnd_close();
     }
     catch (Exception ex)
     {
         HuionLog.printLog("", ex.Message);
         HuionLog.printLog("", ex.StackTrace);
     }
 }
Esempio n. 14
0
        public static int getPenPressValue()
        {
            try
            {
                HuionDriverDLL.hndh_get_cursor(ref HNStruct.globalInfo.penData);
            }
            catch (Exception ex)
            {
                HuionLog.saveLog("get press value", ex.Message);
                HuionLog.saveLog("get press value", ex.StackTrace);
            }

            return((int)HNStruct.globalInfo.penData.ps);
        }
Esempio n. 15
0
 public static void stopListen()
 {
     reading           = false;
     touchInfoListener = (ReadTouchInfoCallback)null;
     try
     {
         HuionDriverDLL.hndh_uninit_cursor();
     }
     catch (Exception ex)
     {
         HuionLog.saveLog("stop draw line", ex.Message);
         HuionLog.saveLog("stop draw line", ex.StackTrace);
     }
 }
Esempio n. 16
0
        public static HNStruct.HNPenData getTouchInfo()
        {
            HNStruct.HNPenData p = new HNStruct.HNPenData();
            try
            {
                HuionDriverDLL.hndh_get_cursor(ref p);
            }
            catch (Exception ex)
            {
                HuionLog.saveLog("Get Touch Info", ex.Message);
                HuionLog.saveLog("Get Touch Info", ex.StackTrace);
            }

            return(p);
        }
Esempio n. 17
0
        public static void startListen(IntPtr handle)
        {
            mHandle = handle;
            reading = true;
            HNStruct.HNRect r = new HNStruct.HNRect();
            try
            {
                HuionDriverDLL.hndh_init_cursor(ref r);
            }
            catch (Exception ex)
            {
                HuionLog.saveLog("start draw line", ex.Message);
                HuionLog.saveLog("start draw line", ex.StackTrace);
            }

            mReadThread = new Thread(new ThreadStart(onRead));
            mReadThread.Start();
        }
Esempio n. 18
0
        private void btnDefault_Click(object sender, EventArgs e)
        {
            TabletConfigUtils.config.bCalibrated = (byte)0;
            IntPtr num1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));

            Marshal.StructureToPtr((object)TabletConfigUtils.config, num1, true);
            IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNTabletInfo)));

            Marshal.StructureToPtr((object)HNStruct.globalInfo.tabletInfo, num2, true);
            IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(sourcePath);
            int    num3          = (int)HuionDriverDLL.hnx_save_config(num1, num2, coTaskMemAuto, coTaskMemAuto);

            HuionDriverDLL.hnd_notify_config_changed();
            Marshal.FreeHGlobal(num2);
            Marshal.FreeHGlobal(coTaskMemAuto);
            Marshal.FreeHGlobal(num1);
            this.Close();
            this.Dispose();
        }
Esempio n. 19
0
 public static void autoOpenDevice(object obj)
 {
     try
     {
         string s1             = Application.StartupPath + "\\res\\config_user.xml";
         string s2             = Application.StartupPath + "\\res\\layout_tablet.xml";
         IntPtr coTaskMemAuto1 = Marshal.StringToCoTaskMemAuto(s1);
         IntPtr coTaskMemAuto2 = Marshal.StringToCoTaskMemAuto(s2);
         if (mConfigCallback == null)
         {
             mConfigCallback = new OpenDeviceCallbcak(deviceConfigCallback);
         }
         int num = (int)HuionDriverDLL.hnd_open(mConfigCallback, coTaskMemAuto1, coTaskMemAuto2);
         Marshal.FreeCoTaskMem(coTaskMemAuto1);
         Marshal.FreeCoTaskMem(coTaskMemAuto2);
     }
     catch (Exception ex)
     {
         HuionLog.saveLog("", ex.Message);
         HuionLog.saveLog("", ex.StackTrace);
     }
 }
Esempio n. 20
0
        public void SetLayoutPen()
        {
            Marshal.PtrToStringAuto(
                HuionDriverDLL.hnp_get_pen_node((HnConst.HNTabletType)HNStruct.globalInfo.tabletInfo.devType));
            IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(Application.StartupPath + "\\res\\layout_pen.xml");

            Marshal.AllocHGlobal(Marshal.SizeOf((object)new HNStruct.HNLayoutPen()));
            IntPtr num1 = HuionDriverDLL.hnx_read_layout_pen(ref HNStruct.globalInfo.tabletInfo, coTaskMemAuto);

            HNStruct.globalInfo.layoutPen =
                (HNStruct.HNLayoutPen)Marshal.PtrToStructure(num1, typeof(HNStruct.HNLayoutPen));
            HNStruct.globalInfo.penLayouts = new HNStruct.HNLayoutEkey[(int)HNStruct.globalInfo.layoutPen.ekNum];
            int num2 = 0;

            foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>(
                         HNStruct.globalInfo.layoutPen.ekLayouts, (int)HNStruct.globalInfo.layoutPen.ekNum))
            {
                HNStruct.globalInfo.penLayouts[num2++] = hnLayoutEkey;
            }
            Marshal.FreeHGlobal(coTaskMemAuto);
            HuionDriverDLL.hnx_free_PHNLayoutPen(num1);
        }
Esempio n. 21
0
 private void saveCalibrate(IntPtr ptr)
 {
     try
     {
         IntPtr num1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));
         Marshal.StructureToPtr((object)TabletConfigUtils.config, num1, true);
         IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNTabletInfo)));
         Marshal.StructureToPtr((object)HNStruct.globalInfo.tabletInfo, num2, true);
         IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(sourcePath);
         HuionDriverDLL.hnc_calibrate_monitor(num2, num1, ptr);
         int num3 = (int)HuionDriverDLL.hnx_save_config(num1, num2, coTaskMemAuto, coTaskMemAuto);
         HuionDriverDLL.hnd_notify_config_changed();
         Marshal.FreeHGlobal(coTaskMemAuto);
         Marshal.FreeHGlobal(num2);
         Marshal.FreeHGlobal(num1);
     }
     catch (Exception ex)
     {
         HuionLog.printSaveLog("", ex.Message);
         HuionLog.printSaveLog("", ex.StackTrace);
     }
 }
Esempio n. 22
0
 private void FormCalibrate_Load(object sender, EventArgs e)
 {
     this.Location = new Point(this.mScreenRect.Left, this.mScreenRect.Top);
     this.Size     = new Size(this.mScreenRect.Right - this.mScreenRect.Left,
                              this.mScreenRect.Bottom - this.mScreenRect.Top);
     this.btnDefault.Text     = ResourceCulture.GetString("CalibrationDefault");
     this.btnStart.Text       = ResourceCulture.GetString("CalibrationStart");
     this.btnStop.Text        = ResourceCulture.GetString("CalibrationStop");
     this.labelHint.Text      = ResourceCulture.GetString("CalibrationHint");
     this.btnDefault.Location = new Point((this.Width - this.btnDefault.Width) / 2, this.btnDefault.Location.Y);
     this.btnStart.Location   = new Point((this.Width - this.btnStart.Width) / 2, this.btnStart.Location.Y);
     this.btnStop.Location    = new Point((this.Width - this.btnStop.Width) / 2, this.btnStop.Location.Y);
     this.labelHint.Location  = new Point((this.Width - this.labelHint.Width) / 2,
                                          (this.Height / 2 - this.labelHint.Height) / 2);
     this.mUserPoints         = new HNStruct.HNPoint[9];
     this.mDisplayPoints      = new Point[9];
     this.mDisplayPoints[0].X = this.Width / 20;
     this.mDisplayPoints[0].Y = this.Height / 20;
     this.mDisplayPoints[1].X = this.Width * 10 / 20;
     this.mDisplayPoints[1].Y = this.mDisplayPoints[0].Y;
     this.mDisplayPoints[2].X = this.Width * 19 / 20;
     this.mDisplayPoints[2].Y = this.mDisplayPoints[0].Y;
     this.mDisplayPoints[3].X = this.mDisplayPoints[0].X;
     this.mDisplayPoints[3].Y = this.Height * 10 / 20;
     this.mDisplayPoints[4].X = this.mDisplayPoints[1].X;
     this.mDisplayPoints[4].Y = this.mDisplayPoints[3].Y;
     this.mDisplayPoints[5].X = this.mDisplayPoints[2].X;
     this.mDisplayPoints[5].Y = this.mDisplayPoints[3].Y;
     this.mDisplayPoints[6].X = this.mDisplayPoints[0].X;
     this.mDisplayPoints[6].Y = this.Height * 19 / 20;
     this.mDisplayPoints[7].X = this.mDisplayPoints[1].X;
     this.mDisplayPoints[7].Y = this.mDisplayPoints[6].Y;
     this.mDisplayPoints[8].X = this.mDisplayPoints[2].X;
     this.mDisplayPoints[8].Y = this.mDisplayPoints[6].Y;
     HuionDriverDLL.hnd_start_calibrate();
 }
Esempio n. 23
0
        public void SetLayoutTablet(IntPtr pconfig)
        {
            IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(Application.StartupPath + "\\res\\layout_tablet.xml");

            Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNLayoutTablet)));
            IntPtr num1 =
                HuionDriverDLL.hnx_read_layout_tablet(ref HNStruct.globalInfo.tabletInfo, pconfig, coTaskMemAuto);

            HNStruct.HNLayoutTablet hnLayoutTablet = new HNStruct.HNLayoutTablet();
            HNStruct.HNLayoutTablet structure      =
                (HNStruct.HNLayoutTablet)Marshal.PtrToStructure(num1, typeof(HNStruct.HNLayoutTablet));
            HNStruct.globalInfo.layoutTablet = structure;
            HNStruct.globalInfo.hbtnLayouts  = new HNStruct.HNLayoutEkey[(int)structure.hbtnNum];
            int num2 = 0;

            Console.WriteLine("sizeof(HNLayoutTablet)={0}", (object)Marshal.SizeOf(typeof(HNStruct.HNLayoutTablet)));
            foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>(
                         structure.hbtnLayouts, (int)structure.hbtnNum))
            {
                HNStruct.globalInfo.hbtnLayouts[num2++] = hnLayoutEkey;
            }
            HNStruct.globalInfo.sbtnLayouts = new HNStruct.HNLayoutEkey[(int)structure.sbtnNum];
            int num3 = 0;

            foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>(
                         structure.sbtnLayouts, (int)structure.sbtnNum))
            {
                HNStruct.globalInfo.sbtnLayouts[num3++] = hnLayoutEkey;
            }
            HNStruct.globalInfo.mekeyLayouts = new HNStruct.HNLayoutEkey[(int)structure.mekeyNum];
            int num4 = 0;

            foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>(
                         structure.mekeyLayouts, (int)structure.mekeyNum))
            {
                if (!HNStruct.globalInfo.tabletInfo.sDevType.Equals("HUION_M182"))
                {
                    HNStruct.globalInfo.mekeyLayouts[num4++] = hnLayoutEkey;
                }
                else
                {
                    break;
                }
            }

            HNStruct.globalInfo.mekeyNames = new HNStruct.HNMEkeyName[(int)structure.mekeyNum];
            int index1 = 0;

            foreach (HNStruct.HNMEkeyName hnmEkeyName in MarshalPtrToStructArray <HNStruct.HNMEkeyName>(
                         structure.mekeyNames, (int)structure.mekeyNum))
            {
                Console.WriteLine(HNStruct.globalInfo.tabletInfo.sDevType);
                if (!HNStruct.globalInfo.tabletInfo.sDevType.Equals("HUION_M182"))
                {
                    HNStruct.globalInfo.mekeyNames[index1] = hnmEkeyName;
                    HNStruct.globalInfo.names = new string[(int)HNStruct.globalInfo.mekeyNames[index1].num];
                    IntPtr ptr = HNStruct.globalInfo.mekeyNames[index1].names;
                    for (int index2 = 0; (long)index2 < (long)HNStruct.globalInfo.mekeyNames[0].num; ++index2)
                    {
                        switch (IntPtr.Size)
                        {
                        case 4:
                            HNStruct.globalInfo.names[index2] =
                                Marshal.PtrToStringAuto(new IntPtr((int)Marshal.PtrToStructure(ptr, typeof(int))));
                            ptr = new IntPtr(ptr.ToInt64() + 4L);
                            break;

                        case 8:
                            HNStruct.globalInfo.names[index2] =
                                Marshal.PtrToStringAuto(
                                    new IntPtr((long)Marshal.PtrToStructure(ptr, typeof(long))));
                            ptr = new IntPtr(ptr.ToInt64() + 8L);
                            break;
                        }
                    }

                    ++index1;
                }
                else
                {
                    break;
                }
            }

            HNStruct.globalInfo.ekLayouts = new HNStruct.HNLayoutEkey[(int)structure.ekNum];
            int num5 = 0;

            foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>(
                         structure.ekLayouts, (int)structure.ekNum))
            {
                HNStruct.globalInfo.ekLayouts[num5++] = hnLayoutEkey;
            }
            HNStruct.HNRect      penArea = structure.penArea;
            HNStruct.HNSize      size    = structure.size;
            HNStruct.HNRectRatio hnRectRatio;
            hnRectRatio.l = (float)penArea.left / (float)size.cx;
            hnRectRatio.r = (float)penArea.right / (float)size.cx;
            hnRectRatio.t = (float)penArea.top / (float)size.cy;
            hnRectRatio.b = (float)penArea.bottom / (float)size.cy;
            HNStruct.globalInfo.penareaRatio = hnRectRatio;
            Marshal.FreeHGlobal(coTaskMemAuto);
            HuionDriverDLL.hnx_free_PHNLayoutTablet(num1);
        }
Esempio n. 24
0
 private string onKeyChangedListener(HuionKeyEventArgs keyEvent)
 {
     SettingsUtil.ShowUIShortcut = keyEvent;
     HuionDriverDLL.PostMessage(this.mMainFormHandle, 1064, IntPtr.Zero, IntPtr.Zero);
     return(KBTable.getKBTable8Keys(keyEvent.KeyCode).KeyName);
 }
Esempio n. 25
0
        private void onDelayCallback(object o)
        {
            uint   num = (uint)o;
            string currentDirectory = Environment.CurrentDirectory;

            try
            {
                IntPtr tabletInfo = HuionDriverDLL.hnd_get_tablet_info();
                HNStruct.globalInfo.tabletInfo =
                    (HNStruct.HNTabletInfo)Marshal.PtrToStructure(tabletInfo, typeof(HNStruct.HNTabletInfo));
                if (HNStruct.globalInfo.tabletInfo.devType != 0U)
                {
                    Console.Write(HNStruct.globalInfo.tabletInfo.devType.ToString());

                    HNStruct.OemType = getActualOemType();
                    switch (HNStruct.OemType)
                    {
                    case OEMType.HUION:
                        HNStruct.globalInfo.bOpenedTablet =
                            TabletConfigUtils.isHuionTablet(HNStruct.globalInfo.tabletInfo.devType);
                        Console.WriteLine(HNStruct.globalInfo.bOpenedTablet.ToString());
                        if (HNStruct.globalInfo.tabletInfo.devType == 19U)
                        {
                            HNStruct.globalInfo.tabletInfo.maxP = (ushort)4095;
                            break;
                        }

                        break;

                    case OEMType.GAOMON:
                        HNStruct.globalInfo.bOpenedTablet =
                            TabletConfigUtils.isGaomonTablet(HNStruct.globalInfo.tabletInfo.devType);
                        break;

                    case OEMType.YINENG:
                        HNStruct.globalInfo.bOpenedTablet =
                            TabletConfigUtils.isYinengTablet(HNStruct.globalInfo.tabletInfo.devType);
                        break;

                    case OEMType.YOUSHANG:
                        HNStruct.globalInfo.bOpenedTablet =
                            TabletConfigUtils.isYoushangTablet(HNStruct.globalInfo.tabletInfo.devType);
                        break;

                    case OEMType.SHIJUN:
                        HNStruct.globalInfo.bOpenedTablet =
                            TabletConfigUtils.isShijunTablet(HNStruct.globalInfo.tabletInfo.devType);
                        break;

                    case OEMType.KJC:
                        HNStruct.globalInfo.bOpenedTablet =
                            TabletConfigUtils.isKJCTablet(HNStruct.globalInfo.tabletInfo.devType);
                        break;

                    default:
                        HNStruct.globalInfo.bOpenedTablet = false;
                        break;
                    }

                    if (HNStruct.globalInfo.bOpenedTablet)
                    {
                        new TabletConfigUtils().readConfig();
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(new WaitCallback(TabletConfigUtils.closeDevice));
                    }
                    MiddleModule.PostMessage((object)this, (object)num);
                }
                else
                {
                    HNStruct.globalInfo.bOpenedTablet = false;
                    MiddleModule.PostMessage((object)this, (object)0);
                }
            }
            catch (Exception ex)
            {
                HuionLog.printSaveLog("open device callback", ex.Message);
                HuionLog.printSaveLog("当前路径", currentDirectory);
                HuionLog.printSaveLog("open device callback", ex.StackTrace);
                HNStruct.globalInfo.bOpenedTablet = false;
                MiddleModule.PostMessage((object)this, (object)0);
            }
        }
Esempio n. 26
0
 private static void invokePostConnectionMessage()
 {
     HuionDriverDLL.PostMessage(mMainForm.Handle, 1044, IntPtr.Zero, IntPtr.Zero);
 }
Esempio n. 27
0
 private void FormCalibrate_FormClosed(object sender, FormClosedEventArgs e)
 {
     HuionDriverDLL.hnd_end_calibrate();
 }
Esempio n. 28
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     HuionDriverDLL.SetClassLong(this.Handle, -26, HuionDriverDLL.GetClassLong(this.Handle, -26) | 131072);
 }
Esempio n. 29
0
        private void handleFocusChange(string processFileName)
        {
            if (!HNStruct.globalInfo.bOpenedTablet)
            {
                // Too early, driver not loaded
                return;
            }
            if (this.currentSettings != null &&
                (processFileName.Equals(Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName.ToLower())) ||
                 SettingsUtil.excludedApplications.Contains(processFileName)))
            {
                // Excluded app
                return;
            }

            HNStruct.PerAppSetting appSetting;
            if (this.perAppSettings.ContainsKey(processFileName) && this.perAppSettings[processFileName].enabled)
            {
                appSetting = this.perAppSettings[processFileName];
            }
            else if (this.perAppSettingsDefault.HasValue && this.perAppSettingsDefault.Value.enabled)
            {
                appSetting = this.perAppSettingsDefault.Value;
            }
            else
            {
                // No setting found
                return;
            }

            if (appSetting.profile.Equals(this.currentSettings))
            {
                HuionLog.printLog("FocusChanged", "Error: already active");
                // already active
                return;
            }

            string path = Path.GetFullPath(Path.Combine(this.perAppSettingsProfileDir, appSetting.profile));

            if (!File.Exists(path))
            {
                HuionLog.printLog("FocusChanged", "Error: file not found");
                return;
            }

            HuionLog.printLog("FocusChanged", "Info: loading profile");


            IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(path);

            Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNConfigXML)));
            IntPtr num = HuionDriverDLL.hnx_read_config(ref HNStruct.globalInfo.tabletInfo, coTaskMemAuto);

            TabletConfigUtils.config =
                (HNStruct.HNConfigXML)Marshal.PtrToStructure(num, typeof(HNStruct.HNConfigXML));
            new TabletConfigUtils().SetConfig(TabletConfigUtils.config);
            Marshal.FreeHGlobal(coTaskMemAuto);
            Marshal.FreeHGlobal(num);
            currentSettings = appSetting.profile;
            Fixer4Main.applayClick(null, null);

            HuionLog.printLog("FocusChanged", "Info: profile loaded");

            this.notifyIcon1.ShowBalloonTip(3, "Profile switched",
                                            Path.GetFileNameWithoutExtension(appSetting.profile), ToolTipIcon.Info);
            this.notifyIcon1.Text = $"{ResourceCulture.GetString("FormHuionTabletNotifyIconText")}" +
                                    $" ({Path.GetFileNameWithoutExtension(appSetting.profile)})";


            // Refresh Info
            if (this.panelWindow.Controls.Count > 0)
            {
                this.mTabType = TabType.TabWorkArea;
                this.buttonInfo_Click(null, null);
            }
            this.ResumeLayout(false);
        }