Ejemplo n.º 1
0
        public void HandleOldTermTile(TermTile termTile, TermTile oldTermTile, Grid grid)
        {
            int oldRow     = Grid.GetRow(oldTermTile);
            int oldColumn  = Grid.GetColumn(oldTermTile);
            int oldRowSpan = Grid.GetRowSpan(oldTermTile);
            //oslobadjamo stare plocice gde se termin nekad prostirao :D
            List <Tuple <int, int> > oldCoordinates = TilesUtil.GetAllTermCoordinates(oldRow, oldColumn, oldRowSpan);
            var tilesToMark = TilesUtil.GetTiles(grid, oldCoordinates);

            TilesUtil.MarkTiles(tilesToMark, null);

            //ukoliko je stara plocica bila selektovana pre prevlacenja, nova mora biti isto
            if (oldTermTile.Equals(TermTile.LastSelectedTermTile))
            {
                TermTile.LastSelectedTermTile = termTile;
            }

            grid.Children.Remove(oldTermTile);
        }
Ejemplo n.º 2
0
        private void FillGridWithTerms()
        {
            foreach (Term t in ChosenClassroom.Terms)
            {
                Tuple <int, int> position = CalculatePosition(t);

                var tile = new TermTile()
                {
                    Term = t, TileText = t.Subject.Label
                };
                Grid.SetColumn(tile, position.Item2);
                Grid.SetRow(tile, position.Item1);
                Grid.SetRowSpan(tile, t.Length * 3);
                var coordinates = TilesUtil.GetAllTermCoordinates(position.Item1, position.Item2, Grid.GetRowSpan(tile));
                var tiles       = TilesUtil.GetTiles(grid, coordinates);
                TilesUtil.MarkTiles(tiles, tile);

                grid.Children.Add(tile);
                tile.TileColor = "Yellow";
            }
        }
Ejemplo n.º 3
0
 public void DeleteTerm(object sender, ExecutedRoutedEventArgs e)
 {
     TilesUtil.DeleteSelectedTile();
 }
Ejemplo n.º 4
0
        public void DoDrop(bool isNewTerm, DragEventArgs e)
        {
            //TODO postavi podatke
            Grid     grid = ((Grid)this.Parent);
            TermTile termTile;
            TermTile oldTermTile = null;

            if (!isNewTerm)
            {
                oldTermTile = (TermTile)e.Data.GetData("Object");
                termTile    = new TermTile(oldTermTile);
            }
            else
            {
                Term t = new Term();
                t.Subject = (Subject)e.Data.GetData("Object");

                if (t.Subject.NumRequiredTerms <= 0)
                {
                    MessageBox.Show("Nema vise termina za predmet.", "Obaveštenje", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                t.Subject.NumRequiredTerms = t.Subject.NumRequiredTerms - 1;
                t.Classroom       = (Classroom)e.Data.GetData("ChosenClassroom");
                termTile          = new TermTile();
                t.Length          = t.Subject.MinimalTermLength;
                termTile.TileText = t.Subject.Label;
                termTile.Term     = t;
            }

            int row    = Grid.GetRow(this);
            int column = Grid.GetColumn(this);

            int newTileRowspan = 3 * (termTile.Term.Length);

            if (row + newTileRowspan > (grid.RowDefinitions.Count))
            {
                MessageBox.Show("Nemoguce prevuci tu. Termin ce probiti limite.", "Obaveštenje", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            List <Tuple <int, int> > coordinates = TilesUtil.GetAllTermCoordinates(row, column, newTileRowspan);



            List <Tile> tilesToMark = TilesUtil.GetTiles(grid, coordinates);

            if (!TilesUtil.CheckAndMarkTiles(tilesToMark, termTile))
            {
                MessageBox.Show("Termini se ne mogu preklapati.", "Obaveštenje", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            Grid.SetRow(termTile, row);
            Grid.SetRowSpan(termTile, newTileRowspan);
            Grid.SetColumn(termTile, column);

            grid.Children.Add(termTile);
            if (oldTermTile != null)
            {
                HandleOldTermTile(termTile, oldTermTile, grid);
            }

            e.Effects = DragDropEffects.Move;
            //na osnovu pozicije plocice cemo da provalimo novi termin
            termTile.UpdateTerm();

            controller.CustomEvents.RaiseTutorialStepCompletedEvent(Steps.DRAG_AND_DROP_DONE);
        }