Exemple #1
0
        // run an alg runner each case once from the inputted subset in sequence
        private void RunSequentialButton_Click(object sender, EventArgs e)
        {
            try
            {
                List <int> algs;
                // if only one number given, start at that number and don't end until the entire alg set is complete
                if (int.TryParse(RangeBox.Text, out int startNum))
                {
                    algs = SubsetTools.GetListFromRange($"{startNum}-{Info.GetCube(Set).GetNumPositions() - 1}", Info.GetNumPositionsInSet(Set));
                }
                else
                {
                    algs = GetListFromAlgSet(Set, RangeBox.Text);
                    algs = algs.Distinct().ToList();
                }

                //var screen = new RunnerScreen(new AlgRunner(new ZbllCube(CubeSize), new SingleCycleGenerator(algs), new AlgsFromFile(new AlgFile("zbll.alg", AlgFileMode.Open, AlgFileAccess.Read))));
                var screen = new DefaultRunnerScreen(new AlgRunner(Info.GetCube(Set), new SequentialGenerator(algs), new AlgsFromFileStored(Info.GetAlgFileName(Set))), RunnerScreenCallback);
                screen.Text       = Set.ToString() + " algs";
                screen.KeyPreview = true;
                screen.Show();
                this.Hide();
                RecentSubsetFile.AddSet(RangeBox.Text.Trim(), Set);
                UpdateRecentSubsetSelector();
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("no cases selected");
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "invalid range", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public SubsetListScreen(AlgSet set)
        {
            StartPosition = FormStartPosition.CenterScreen;
            InitializeComponent();
            Set = set;
            int startX = 50;
            int startY = 80;
            int currY  = startY;


            File = new CustomSubsetFile("customSubsets.xml");
            var subsets = File.GetSubsets(Set);

            var originalFile = SubsetTools.GetXmlSubsetFile();
            var nameMap      = originalFile.GetNameMap(Set);

            for (int k = 0; k < subsets.Count; k++)
            {
                var control = new SubsetListEntry(subsets[k], File, nameMap)
                {
                    Location = new Point(startX, currY)
                };
                currY += HeightPerRow;
                this.Controls.Add(control);
            }
            this.AutoScroll = true;
        }
 private void AddButton_Click(object sender, EventArgs e)
 {
     try
     {
         var setName = NameBox.Text;
         // make sure set name is not same as a predefined set name
         var defaultFile = new XmlSubsetFile("subsets.xml");
         var nameMap     = defaultFile.GetNameMap(Set);
         if (nameMap.ContainsKey(setName))
         {
             throw new ArgumentException($"Subset name '{setName}' already exists");
         }
         CustomSubsetFile file = new CustomSubsetFile("customSubsets.xml");
         var rawText           = AlgListBox.Text;
         var newSet            = new CustomSubset(setName, rawText, Set);
         SubsetTools.ValidateAlgListInput(rawText, nameMap, Info.GetNumPositionsInSet(Set));
         file.AddSubset(newSet);
         MessageBox.Show("subset added", "success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #4
0
        private void ViewSelectedButton_Click(object sender, EventArgs e)
        {
            var nameMap = XmlSubsetFile.GetNameMap(Set);

            try
            {
                SubsetTools.ValidateAlgListInput(RangeBox.Text, nameMap, Info.GetNumPositionsInSet(Set), CustomSubsetFile.GetSubsets(Set));
                var screen = new SetInfoScreen(Set, RangeBox.Text, nameMap, CustomSubsetFile.GetSubsets(Set));
                screen.Text = RangeBox.Text;
                screen.Show();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void SaveButton_Click(object sender, EventArgs e)
 {
     try
     {
         var nameMap           = SubsetTools.GetXmlSubsetFile().GetNameMap(CustomSubset.AlgSet);
         var rangesWithSubsets = RangeListBox.Text;
         SubsetTools.ValidateAlgListInput(rangesWithSubsets, nameMap, Info.GetNumPositionsInSet(CustomSubset.AlgSet));
         CustomSubset.RangeStr = rangesWithSubsets;
         File.SaveSubset(CustomSubset);
         MessageBox.Show("subset saved", "success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show("An error occurred: " + ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #6
0
        /// <summary>
        /// Gets a mapping of subset names to number lists for an alg set
        /// </summary>
        /// <param name="set"></param>
        public Dictionary <string, List <int> > GetNameMap(AlgSet set)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(Name);
            string xPath       = "subsets/" + set.ToString();
            var    node        = doc.SelectSingleNode(xPath);
            var    subsetNodes = node.SelectNodes(".//subset");
            Dictionary <string, List <int> > names = new Dictionary <string, List <int> >();

            for (int k = 0; k < subsetNodes.Count; k++)
            {
                var        subsetNode = subsetNodes[k];
                var        key        = subsetNode.Attributes["name"].Value;
                var        rangeRext  = subsetNode.InnerText;
                List <int> posNums    = SubsetTools.GetListFromRanges(rangeRext, Info.GetNumPositionsInSet(set));
                names.Add(subsetNode.Attributes["name"].Value, posNums);
            }
            return(names);
        }
        private void ViewButton_Click(object sender, EventArgs e)
        {
            var screen = new SetInfoScreen(CustomSubset.AlgSet, CustomSubset.RangeStr, SubsetTools.GetXmlSubsetFile().GetNameMap(CustomSubset.AlgSet), setName: CustomSubset.Name);

            screen.Show();
            this.ParentForm.Close();
        }