Exemplo n.º 1
0
        public void GenerateStateSummary(List <List <Slot> > outputTimetables, IStateElementFactory factory)
        {
            ClearGui();
            var bg = CustomBackgroundWorker <List <List <Slot> >, StateTable> .RunAndShowLoadingScreen(StateTable.Parse,
                                                                                                       outputTimetables, "Calculating state table . . .");

            var stateTable = bg.GetResult();

            foreach (var cell in stateTable)
            {
                int paddedRowIndex = cell.RowIndex * _eachDayHaveHowManyRow + _paddingDueToTimeRow;
                int paddedColIndex = cell.ColumnIndex + _paddingDueToDayColumn;
                int colSpan        = StateCell.ColumnSpanOfEachCell;
                switch (cell.State)
                {
                case CellState.DefinitelyOccupied:
                    AddToGrid(factory.CreateDefinitelyOccupiedState(), paddedColIndex, paddedRowIndex, colSpan);
                    break;

                case CellState.MaybeUnoccupied:
                    AddToGrid(factory.CreateMaybeUnoccupiedState(cell), paddedColIndex, paddedRowIndex, colSpan);
                    break;

                case CellState.DefinitelyUnoccupied:
                    AddToGrid(factory.CreateDefinitelyUnoccupiedState(), paddedColIndex, paddedRowIndex, 1);
                    break;
                }
            }
        }
 public Window_StateSummary(List <Slot> inputSlots, List <List <Slot> > outputTimetables)
 {
     _inputSlots       = inputSlots;
     _outputTimetables = outputTimetables;
     _factory          = new RealStateElementFactory(Checked, Unchecked);
     InitializeComponent();
     TimeTableGui.GenerateStateSummary(_outputTimetables, _factory);
 }
Exemplo n.º 3
0
        public void RegenerateStateSummary(List <List <Slot> > outputTimetables, IStateElementFactory factory)
        {
            var bg = CustomBackgroundWorker <List <List <Slot> >, StateTable> .RunAndShowLoadingScreen(StateTable.Parse,
                                                                                                       outputTimetables, "Recalculating . . .");

            var stateTable = bg.GetResult();

            foreach (var cell in stateTable)
            {
                int paddedRowIndex = cell.RowIndex * _eachDayHaveHowManyRow + _paddingDueToTimeRow;
                int paddedColIndex = cell.ColumnIndex + _paddingDueToDayColumn;
                int colSpan        = StateCell.ColumnSpanOfEachCell;
                var element        =
                    Grid.Children
                    .Cast <UIElement>()
                    .First(e =>
                           Grid.GetRow(e) == paddedRowIndex &&
                           Grid.GetColumn(e) == paddedColIndex);
                if (element is ToggleButton)
                {
                    if (((ToggleButton)element).IsChecked.Value)
                    {
                        continue;
                    }
                }

                switch (cell.State)
                {
                case CellState.DefinitelyOccupied:
                    if (element != null)
                    {
                        Grid.Children.Remove(element);
                    }
                    AddToGrid(factory.CreateDefinitelyOccupiedState(), paddedColIndex, paddedRowIndex, colSpan);
                    break;

                case CellState.MaybeUnoccupied:
                    if (element != null)
                    {
                        Grid.Children.Remove(element);
                    }
                    AddToGrid(factory.CreateMaybeUnoccupiedState(cell), paddedColIndex, paddedRowIndex, colSpan);
                    break;

                case CellState.DefinitelyUnoccupied:
                    if (element != null)
                    {
                        Grid.Children.Remove(element);
                    }
                    AddToGrid(factory.CreateDefinitelyUnoccupiedState(), paddedColIndex, paddedRowIndex, 1);
                    break;
                }
            }
        }