Example #1
0
 private void trackBar1_Scroll(object sender, EventArgs e)
 {
     TabletConfigUtils.config.pressFactor = this.trackBar1.Value;
     this.pictureBoxPressCurve.Refresh();
     if (!DeployConfig.isNewUI)
     {
         return;
     }
     Fixer4Main.applayClick((object)null, (EventArgs)null);
 }
Example #2
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);
        }