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(); } }
public void SetConfig(HNStruct.HNConfigXML config) { HNStruct.globalInfo.hbtns = new HNStruct.HNEkey[(int)HNStruct.globalInfo.layoutTablet.hbtnNum]; HNStruct.globalInfo.sbtns = new HNStruct.HNEkey[(int)HNStruct.globalInfo.layoutTablet.sbtnNum]; HNStruct.globalInfo.pbtns = new HNStruct.HNEkey[(int)HNStruct.globalInfo.tabletInfo.pbtnNum]; HNStruct.globalInfo.mbtns = new HNStruct.HNEkey[16]; for (int index = 0; (long)index < (long)HNStruct.globalInfo.layoutTablet.hbtnNum; ++index) { HNStruct.globalInfo.hbtns[index] = config.ctxEkeys[0].hbtns[index]; } for (int index = 0; (long)index < (long)HNStruct.globalInfo.layoutTablet.sbtnNum; ++index) { HNStruct.globalInfo.sbtns[index] = config.ctxEkeys[0].sbtns[index]; } for (int index = 0; index < 3; ++index) { HNStruct.globalInfo.pbtns[index] = config.ctxEkeys[0].pbtns[index]; } for (int index1 = 0; index1 < (int)config.ctxEkeys[0].mmeksNum; ++index1) { config.ctxEkeys[0].ctxMek[index1] = config.ctxEkeys[0].ctxMek[index1]; config.ctxEkeys[0].ctxMek[index1].eks[0] = config.ctxEkeys[0].ctxMek[index1].eks[0]; for (int index2 = 0; index2 < (int)config.ctxEkeys[0].ctxMek[index1].eks[0].num; ++index2) { HNStruct.globalInfo.mbtns[index2] = config.ctxEkeys[0].ctxMek[index1].eks[0].eks[index2]; } } }
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); }
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); }