コード例 #1
0
        /// <summary>
        /// Write Joy Assignment Status to KeyMappingGridCell.
        /// </summary>
        public string KeyMappingPreviewPOV(KeyAssgn keyAssign)
        {
            string result = "";

            for (int i = 0; i < pov.Length; i++)
            {
                for (int ii = 0; ii < pov[i].direction.Length; ii++)
                {
                    string direction = pov[i].GetDirection(ii);
                    for (int iii = 0; iii < 2; iii++)
                    {
                        if (pov[i].direction[ii].GetCallback((Pinky)iii) == "SimDoNothing")
                        {
                            continue;
                        }
                        if (keyAssign.GetCallback() != pov[i].direction[ii].GetCallback((Pinky)iii))
                        {
                            continue;
                        }
                        if (result != "")
                        {
                            result += "\n";
                        }
                        result += " POV" + (i + 1) + "." + direction;
                        if (iii == 1) //PRESS + SHIFT
                        {
                            result += " SHFT";
                        }
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Write Joy Assignment Status to KeyMappingGridCell.
        /// </summary>
        public string KeyMappingPreviewDX(KeyAssgn keyAssign)
        {
            string result;

            result = "";

            for (int i = 0; i < dx.Length; i++)
            {
                for (int ii = 0; ii < dx[i].assign.Length; ii++)
                {
                    if (dx[i].assign[ii].GetCallback() == "SimDoNothing")
                    {
                        continue;
                    }
                    if (keyAssign.GetCallback() != dx[i].assign[ii].GetCallback())
                    {
                        continue;
                    }
                    if (result != "")
                    {
                        result += "\n";
                    }

                    result += " DX" + (i + 1);

                    if (ii == CommonConstants.DX_PRESS_SHIFT)
                    {
                        result += " SHIFT";
                    }
                    if (ii == CommonConstants.DX_RELEASE)
                    {
                        result += " RELEASE";
                    }
                    if (ii == CommonConstants.DX_RELEASE_SHIFT)
                    {
                        result += " RELEASE SHIFT";
                    }

                    if (dx[i].assign[ii].GetInvoke() == Invoke.Down && ii != CommonConstants.DX_RELEASE && ii != CommonConstants.DX_RELEASE_SHIFT)
                    {
                        result += " HOLD";
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        public KeyFile(string Filename, AppRegInfo appReg)
        {
            string stParentName = Path.GetDirectoryName(Filename);

            // Do BMS - FULL.key file exists at User/Config?
            if (File.Exists(Filename) == false)
            {
                MessageBoxResult result = MessageBox.Show
                                              ("App could not find " + Filename, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            string[] lines = File.ReadAllLines(Filename, Encoding.UTF8);

            keyAssign = new KeyAssgn[lines.Length];

            int i = -1;

            foreach (string stBuffer in lines)
            {
                string[] stArrayData = stBuffer.Split(' ');

                if (stArrayData.Length < 7)
                {
                    continue;
                }
                if (stBuffer.Substring(0, 1) == "#")
                {
                    continue;
                }
                if (stArrayData[3] == "-2" | stArrayData[3] == "-3")
                {
                    continue;
                }

                // Okay now this line is confirmed to be a line that shows keyboard assignment.

                i           += 1;
                keyAssign[i] = new KeyAssgn(stBuffer);

                // What if the line format was broken?

                if (keyAssign[i].CheckFileCollapsing() == false)
                {
                    continue;
                }

                MessageBoxResult result = MessageBox.Show
                                              ("App found " + appReg.getKeyFileName() + " broken\nWould you like to restore it to the default?", "Error", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);
                if (result == MessageBoxResult.OK)
                {
                    string fnamestock = appReg.GetInstallDir() + "\\Docs\\Key Files & Input\\" + appReg.getKeyFileName();
                    string fname      = appReg.GetInstallDir() + "\\User\\Config\\" + appReg.getKeyFileName();
                    if (File.Exists(fnamestock))
                    {
                        File.Copy(fnamestock, fname, true);
                        Application.Current.Shutdown();
                        Process.Start(Application.ResourceAssembly.Location);
                        return;
                    }
                    MessageBox.Show("App could not find " + appReg.getKeyFileName() + " at\nDocs\\Key Files & Input\\", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Application.Current.Shutdown();
                    return;
                }
                Application.Current.Shutdown();
                return;
            }
            Array.Resize(ref keyAssign, i + 1);
        }