Example #1
0
        private void LoadStageLayoutFile(string newStageLayoutPath)
        {
            // Try to load the stage layout file
            if (newStageLayoutPath != null)
            {
                try
                {
                    using (Stream stageLayoutStream = File.OpenRead(newStageLayoutPath))
                    {
                        stageLayout     = new StageLayout(stageLayoutStream);
                        stageLayoutPath = newStageLayoutPath;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    stageLayout     = null;
                    stageLayoutPath = null;
                }
            }
            else
            {
                stageLayout     = null;
                stageLayoutPath = null;
            }

            // Update model viewer
            reloadOnNextRedraw = true;
            glControlModel.Invalidate();
        }
Example #2
0
        public static IEnumerable <Sorting.ISwitch[][]> ToSwitchBlockSets(
            this StageLayout stageLayout,
            Sorting.StagedSorterDef stagedSorterDef)
        {
            IEnumerable <Sorting.ISwitch[][]> switchBlockSets = Enumerable.Empty <Sorting.Switch[][]>();

            switch (stageLayout)
            {
            case StageLayout.Single:
                switchBlockSets = Sorting.StageLayout.LayoutStagedSorterSingle(stagedSorterDef);
                break;

            case StageLayout.Loose:
                switchBlockSets = Sorting.StageLayout.LayoutStagedSorterLoose(stagedSorterDef);
                break;

            case StageLayout.Tight:
                switchBlockSets = Sorting.StageLayout.LayoutStagedSorterTight(stagedSorterDef);
                break;

            case StageLayout.Undefined:
                switchBlockSets = Enumerable.Empty <Sorting.ISwitch[][]>();
                break;

            default:
                throw new Exception($"{stageLayout} not handled");
            }

            return(switchBlockSets);
        }
Example #3
0
        private void LoadStageLayoutFile(string newStageLayoutPath)
        {
            // Try to load the stage layout file
            if (newStageLayoutPath != null)
            {
                try {
                    using (Stream stageLayoutStream = File.OpenRead(newStageLayoutPath)) {
                        StageLayout     = new StageLayout(stageLayoutStream);
                        StageLayoutPath = newStageLayoutPath;
                        paneStageLayout.UpdateStageLayoutTree();
                    }
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    StageLayout     = null;
                    StageLayoutPath = null;
                }
            }
            else
            {
                StageLayout     = null;
                StageLayoutPath = null;
            }

            // Update model viewer
            paneStageViewer.InvalidateGL();
        }
Example #4
0
 public static IEnumerable <Sorting.ISwitch[][]> ToPaddedSwitchBlockSets(
     this StageLayout stageLayout,
     Sorting.StagedSorterDef stagedSorterDef,
     int frontPad, int backPad)
 {
     foreach (var swb in Sorting.StageLayout.LayoutEmptyStages.Take(frontPad))
     {
         yield return(swb);
     }
     foreach (var swb in stageLayout.ToSwitchBlockSets(stagedSorterDef))
     {
         yield return(swb);
     }
     foreach (var swb in Sorting.StageLayout.LayoutEmptyStages.Take(backPad))
     {
         yield return(swb);
     }
 }