Esempio n. 1
0
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter           = "Build Profile | " + MdConstant.eProfiles;
            dialog.Title            = "Select Build Profile";
            dialog.InitialDirectory = MdConstant.profiles;
            dialog.ShowDialog();
            if (dialog.FileName != "")
            {
                BtnResetPins.PerformClick();
                BtnResetMod.PerformClick();
                ClBuildProfile bp      = MdCore.Deserialize <ClBuildProfile>(dialog.FileName);
                List <string>  pinpool = FlpPool.Controls.Cast <Button>().Select(btn => btn.Text).ToList();
                List <string>  modpool = LbModPool.Items.Cast <string>().ToList();
                foreach (string str in bp.hpins)
                {
                    if (pinpool.Contains(str))
                    {
                        AddPin(str, FlpHPins);
                        RemovePin("bt_" + str, FlpPool);
                    }
                    else
                    {
                        MessageBox.Show("The current controller does not contain pin " + str + "\nWhich is part of the list of horizontal pins\nAs such it is not added to the hpin pool");
                    }
                }
                foreach (string str in bp.vpins)
                {
                    if (pinpool.Contains(str))
                    {
                        AddPin(str, FlpVPins);
                        RemovePin("bt_" + str, FlpPool);
                    }
                    else
                    {
                        MessageBox.Show("The current controller does not contain pin " + str + "\nWhich is part of the list of vertical pins\nAs such it is not added to the vpin pool");
                    }
                }

                foreach (string str in bp.mods)
                {
                    if (modpool.Contains(str))
                    {
                        LbMods.Items.Add(str);
                        LbModPool.Items.Remove(str);
                    }
                }


                TbBuild.Text     = bp.driver_build;
                TbName.Text      = bp.name;
                TbVariant.Text   = bp.variant;
                NudRefresh.Value = Convert.ToDecimal(bp.refresh);
            }
        }
Esempio n. 2
0
 public static void init()
 {
     _selectedController = new ClController();
     profile             = new ClBuildProfile();
 }
Esempio n. 3
0
        public static string BuildAnimus(ClBuildProfile bp, ClController controller, string animusPath, string modPath, string outputPath)
        {
            string output = "";

            if (animusPath.EndsWith(MdConstant.pseparator.ToString()))
            {
                //donothing
            }
            else
            {
                animusPath = animusPath + MdConstant.pseparator;
            }

            if (modPath.EndsWith(MdConstant.pseparator.ToString()))
            {
                //donothing
            }
            else
            {
                modPath = modPath + MdConstant.pseparator;
            }

            if (outputPath.EndsWith(MdConstant.pseparator.ToString()))
            {
                //donothing
            }
            else
            {
                outputPath = outputPath + MdConstant.pseparator;
            }

            if (bp.name.Contains("\"") || bp.name.Contains("\\") ||
                bp.driver_build.Contains("\"") || bp.driver_build.Contains("\\") ||
                bp.variant.Contains("\"") || bp.variant.Contains("\\"))
            {
                output = "Error: name, build, or variant contains illegal characters.";
                return(output);
            }

            if (bp.hpins.Count < 1 || bp.vpins.Count < 1)
            {
                output = "Error: you need at least 1 pin per column and row.";
                return(output);
            }

            if (!File.Exists(animusPath + MdConstant.pseparator + "animus.ino"))
            {
                output = "Error: animus.ino missing, animus path is invalid";
                return(output);
            }

            if (!Directory.Exists(modPath))
            {
                output = "Error: mod folder missing, mod path is invalid.";
                return(output);
            }

            var cmr = bp.CheckMods(controller, modPath);


            if (cmr == ClBuildProfile.CheckModResponse.DirectoryDoesNotExist)
            {
                output = "Error: mod directory does not exist.";
                return(output);
            }
            else if (cmr == ClBuildProfile.CheckModResponse.ModDoesNotExist)
            {
                output = "Error: mod not found.";
                return(output);
            }
            else if (cmr == ClBuildProfile.CheckModResponse.ModNamingError)
            {
                output = "Error: mod naming error, mod file name and mod name does not match.";
                return(output);
            }
            else if (cmr == ClBuildProfile.CheckModResponse.PinConflictError)
            {
                output = "Error: Pin conflict error, a pin is used more than once.";
                return(output);
            }
            else if (cmr == ClBuildProfile.CheckModResponse.PinDoesNotExist)
            {
                output = "Error: Pin does not exist for the selected controller.";
                return(output);
            }
            else if (cmr == ClBuildProfile.CheckModResponse.EEPROMConflictError)
            {
                output = "Error: EEPROM conflict.";
                return(output);
            }
            else if (cmr == ClBuildProfile.CheckModResponse.AllClear)
            {
                // vars
                string ofolder = outputPath + bp.bp_name + MdConstant.pseparator + Path.GetFileNameWithoutExtension(animusPath) + MdConstant.pseparator + "animus";
                Console.WriteLine(ofolder);
                string mafile = ofolder + MdConstant.pseparator + "animus.ino";
                string mmfile = ofolder + MdConstant.pseparator + "mod.ino";

                // copy main animus files
                MdCore.DirectoryCopy(animusPath, ofolder);

                // edit main animus file
                MdCore.SetFileAttribute(mafile, MdConstant.bRow, bp.vpins.Count.ToString());
                MdCore.SetFileAttribute(mafile, MdConstant.bCol, bp.hpins.Count.ToString());

                MdCore.SetFileAttribute(mafile, MdConstant.bName, "\"" + bp.name + "\"");

                MdCore.SetFileAttribute(mafile, MdConstant.bVariant, "\"" + bp.variant + "\"");

                MdCore.SetFileAttribute(mafile, MdConstant.bBuild, "\"" + bp.driver_build + "\"");

                MdCore.SetFileAttribute(mafile, MdConstant.bVPins, ListStringToString(bp.vpins));

                MdCore.SetFileAttribute(mafile, MdConstant.bHPins, ListStringToString(bp.hpins));

                MdCore.SetFileAttribute(mafile, MdConstant.bRefresh, bp.refresh);

                // edit main mod file

                MdCore.SetFileAttribute(mmfile, MdConstant.bMStart, GenerateModMethodString(bp.mods, MdConstant.bMEStartup));
                MdCore.SetFileAttribute(mmfile, MdConstant.bMPreCoord, GenerateModMethodString(bp.mods, MdConstant.bMEPreCoord));
                MdCore.SetFileAttribute(mmfile, MdConstant.bMPrePress, GenerateModMethodString(bp.mods, MdConstant.bMEPrePress));
                MdCore.SetFileAttribute(mmfile, MdConstant.bMKDown, GenerateModMethodString(bp.mods, MdConstant.bMEKDown));
                MdCore.SetFileAttribute(mmfile, MdConstant.bMKUp, GenerateModMethodString(bp.mods, MdConstant.bMEKUp));
                MdCore.SetFileAttribute(mmfile, MdConstant.bMLoop, GenerateModMethodString(bp.mods, MdConstant.bMELoop));
                MdCore.SetFileAttribute(mmfile, MdConstant.bMSerial, GenerateModMethodString(bp.mods, MdConstant.bMESerial));

                // copy mod files
                List <string> modpaths = bp.mods.Select(str => modPath + str).ToList();
                foreach (string str in modpaths)
                {
                    DirectoryCopy(str, ofolder, false);
                    string modName = str.Substring(modPath.Length);
                    string modFile = ofolder + MdConstant.pseparator + "mod_" + modName + ".ino";
                    EnsureMethodExists(modFile, MdConstant.bMFPreCoord);
                    EnsureMethodExists(modFile, MdConstant.bMFPrePress);
                }
            }
            else
            {
                output = "Error: Unknown build error.";
                return(output);
            }

            /*
             * List<string> modpool = new List<string>();
             * modpool = Directory.GetDirectories(MdSetting.setting.modPath).Select(str => Path.GetFileNameWithoutExtension(str)).ToList();
             * foreach (string mod in bp.mods)
             * {
             *  if (modpool.Contains(mod))
             *  {
             *
             *  }
             *  else
             *  {
             *      output = "Error: mod " + mod + " missing from the mod path.";
             *      return output;
             *  }
             * }
             */

            output = "Build Completed for " + bp.name;
            return(output);
        }