コード例 #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);
            }
        }
コード例 #2
0
        public static void BuildFromList(ClBuildList bl)
        {
            var obp   = new List <ClBuildProfile>();
            var octrl = new List <ClController>();


            for (int i = 0; i < bl.bp.Count; i++)
            {
                obp.Add(MdCore.Deserialize <ClBuildProfile>(MdConstant.profiles + MdConstant.pseparator + bl.bp[i]));
                octrl.Add(MdCore.Deserialize <ClController>(MdConstant.controllers + MdConstant.pseparator + bl.controller[i]));
                MdCore.BuildAnimus(obp[i], octrl[i], bl.animus[i], bl.mod[i], bl.output[i]);
            }
        }
コード例 #3
0
        private void BtnSelectControl_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter           = "Controller File | " + MdConstant.eControllers;
            dialog.Title            = "Select Controller";
            dialog.InitialDirectory = MdConstant.controllers;
            dialog.ShowDialog();
            if (dialog.FileName != "")
            {
                MdGlobal.selectedController = MdCore.Deserialize <ClController>(dialog.FileName);
            }
        }
コード例 #4
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            UpdateProfile();


            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter           = "Build Profile | " + MdConstant.eProfiles;
            dialog.Title            = "Save Build Profile";
            dialog.InitialDirectory = MdConstant.profiles;
            dialog.ShowDialog();
            if (dialog.FileName != "")
            {
                MdCore.Serialize <ClBuildProfile>(MdGlobal.profile, dialog.FileName);
            }
        }
コード例 #5
0
        public FmMain()
        {
            InitializeComponent();
            FlpPool.DragEnter  += PanelDragEnter;
            FlpHPins.DragEnter += PanelDragEnter;
            FlpVPins.DragEnter += PanelDragEnter;


            FlpPool.DragDrop  += PanelDragDrop;
            FlpHPins.DragDrop += PanelDragDrop;
            FlpVPins.DragDrop += PanelDragDrop;

            MdSetting.LoadSettings();
            TbAnimusPath.Text = MdSetting.setting.animusPath;
            TbModPath.Text    = MdSetting.setting.modPath;
            TbOutputPath.Text = MdSetting.setting.outputPath;

            //MdCore.Serialize<ClController>(ClController.ProMicro(), MdConstant.controllers + MdConstant.pseparator + "pro-micro.ukbct");
            MdCore.Serialize <ClBuildList>(ClBuildList.BuildAll(), MdConstant.root + MdConstant.pseparator + "build-all.ukbl");
        }
コード例 #6
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MdGlobal.init();
            MdGlobal.mainForm = new FmMain();
            List <string> largs = args.ToList();

            if (largs.Count == 1)
            {
                if (System.IO.File.Exists(largs[0]))
                {
                    ClBuildList.BuildFromList(MdCore.Deserialize <ClBuildList>(largs[0]));
                }
                Application.Exit();
            }
            else
            {
                Application.Run(MdGlobal.mainForm);
            }
        }
コード例 #7
0
ファイル: MdCore.cs プロジェクト: scauligi/animus-family
        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);
        }
コード例 #8
0
ファイル: MdSetting.cs プロジェクト: skempf/animus-family
 public static void SaveSettings()
 {
     MdCore.Serialize <MdSetting>(setting, MdConstant.settings);
 }
コード例 #9
0
ファイル: MdSetting.cs プロジェクト: skempf/animus-family
 public static void LoadSettings()
 {
     setting = MdCore.Deserialize <MdSetting>(MdConstant.settings);
 }
コード例 #10
0
 private void BtnBuild_Click(object sender, EventArgs e)
 {
     UpdateProfile();
     MessageBox.Show(MdCore.BuildAnimus(MdGlobal.profile, MdGlobal.selectedController, MdSetting.setting.animusPath, MdSetting.setting.modPath, MdSetting.setting.outputPath));
 }