Esempio n. 1
0
 private void __SetBorder(TekFieldView p, TekField neighbour, TekFieldView.TekBorder border)
 {
     if (neighbour.Area == null)
     {
         if (p.Field.Area == null)
         {
             p.Borders[(int)border] = TekFieldView.TekBorderStyle.tbsNone;
         }
         else
         {
             p.Borders[(int)border] = TekFieldView.TekBorderStyle.tbsNone; // tbsExternal;
         }
     }
     else if (p.Field.Area == null)
     {
         p.Borders[(int)border] = TekFieldView.TekBorderStyle.tbsNone; // tbsExternal;
     }
     else
     {
         if (neighbour.Area.AreaNum == p.Field.Area.AreaNum)
         {
             p.Borders[(int)border] = TekFieldView.TekBorderStyle.tbsInternal;
         }
         else
         {
             p.Borders[(int)border] = TekFieldView.TekBorderStyle.tbsExternal;
         }
     }
 }
Esempio n. 2
0
 private void _toggleFieldNoteValue(TekFieldView view, int value, TekMoves Moves)
 {
     if (view != null)
     {
         Moves.PlayNote(view.Row, view.Col, value);
         view.Refresh();
     }
 }
Esempio n. 3
0
        public TekFieldView SelectField(int row, int col)
        {
            TekFieldView result = Selector.CurrentFieldView;

            if (row >= 0 && row < Board.Rows && col >= 0 && col < Board.Cols)
            {
                Selector.SelectCurrentField(_Panels[row, col]);
            }
            return(result);
        }
Esempio n. 4
0
 private void UpdateArea(TekArea area)
 {
     _view.SetAreaColors(Board);
     foreach (TekField field in area.Fields)
     {
         TekFieldView view = _view.GetField(field.Row, field.Col);
         _view.SetPanelColors(view);
         _view._SetBorders(view);
     }
     _view.Refresh();
 }
Esempio n. 5
0
        public void MoveSelected(int deltaR, int deltaC)
        {
            TekFieldView v = _view.Selector.CurrentFieldView;

            if (v == null)
            {
                return;
            }
            _view.SelectField(v.Field.Row + deltaR, v.Field.Col + deltaC);
            // v.Refresh();
        }
Esempio n. 6
0
        private void button12_Click(object sender, EventArgs e)
        {
            TekArea      area;
            TekFieldView field = View.Selector.CurrentFieldView;

            if (field != null)
            {
                area = View.SelectArea(field.Row, field.Col);
                View.DeleteArea(area);
                Refresh();
            }
        }
Esempio n. 7
0
        public void SetPanelColors(TekFieldView panel)
        {
            TekArea area = panel.Field.Area;

            if (area == null)
            {
                panel.NormalColor   = NoAreaColor;
                panel.SelectedColor = NoAreaSelectedColor;
            }
            else
            {
                panel.NormalColor   = AreaColors[AreaColorIndex[area.AreaNum]];
                panel.SelectedColor = SelectedAreaColors[AreaColorIndex[area.AreaNum]];
            }
        }
Esempio n. 8
0
        public void SetCurrentMode(SelectMode value)
        {
            if (CurrentMode == value)
            {
                return;
            }

            if (_currentFieldView != null)
            {
                switch (CurrentMode)
                {
                case SelectMode.smNone:
                    _currentFieldView.SetSelected(false);
                    _currentFieldView.SetMultiSelected(false);
                    break;

                case SelectMode.smSingle:
                    _currentFieldView.SetSelected(false);
                    break;

                case SelectMode.smMultiple:
                    _currentFieldView.SetMultiSelected(false);
                    break;
                }
            }
            _currentMode = value;
            if (_currentFieldView != null)
            {
                switch (CurrentMode)
                {
                case SelectMode.smNone:
                    _currentFieldView = null;
                    break;

                case SelectMode.smSingle:
                    SelectCurrentField(_currentFieldView);
                    break;

                case SelectMode.smMultiple:
                    _currentFieldView.SetSelected(true);
                    break;
                }
                if (_currentFieldView != null)
                {
                    _currentFieldView.Refresh();
                }
            }
        }
Esempio n. 9
0
        public void HighlightField(int row, int col, bool onoff)
        {
            TekFieldView field = GetField(row, col);

            if (onoff)
            {
                for (int b = 0; b < (int)TekFieldView.TekBorder.bdLast; b++)
                {
                    field.Borders[b] = TekFieldView.TekBorderStyle.tbsHighlight;
                }
            }
            else
            {
                _SetBorders(field);
            }
        }
Esempio n. 10
0
        public void SelectCurrentField(TekFieldView newfield)
        {
            if (newfield == null)
            {
                CurrentMode = SelectMode.smNone;
            }
            else
            {
                if (CurrentMode == SelectMode.smNone)
                {
                    _currentMode = SelectMode.smSingle;
                }
                switch (CurrentMode)
                {
                case SelectMode.smSingle:
                    if (_currentFieldView != null && _currentFieldView.IsSelected)
                    {
                        _currentFieldView.SetSelected(false);
                    }
                    newfield.SetSelected(!newfield.IsSelected);
                    foreach (TekFieldView field in MultiselectFieldView)
                    {
                        field.SetMultiSelected(false);
                    }
                    MultiselectFieldView.Clear();
                    break;

                case SelectMode.smMultiple:
                    newfield.SetMultiSelected(!newfield.IsMultiSelected);
                    if (!MultiselectFieldView.Contains(newfield))
                    {
                        MultiselectFieldView.Add(newfield);
                    }
                    else
                    {
                        MultiselectFieldView.Remove(newfield);
                    }
                    break;
                }
                _currentFieldView = newfield;
            }
        }
Esempio n. 11
0
        public void _SetBorders(TekFieldView p)
        {
            int row = p.Row;
            int col = p.Col;

            if (row == 0)
            {
                p.Borders[(int)TekFieldView.TekBorder.bdTop] = TekFieldView.TekBorderStyle.tbsBoard;
            }
            else
            {
                __SetBorder(p, Board.Fields[row - 1, col], TekFieldView.TekBorder.bdTop);
            }
            if (col == 0)
            {
                p.Borders[(int)TekFieldView.TekBorder.bdLeft] = TekFieldView.TekBorderStyle.tbsBoard;
            }
            else
            {
                __SetBorder(p, Board.Fields[row, col - 1], TekFieldView.TekBorder.bdLeft);
            }
            if (row == Board.Rows - 1)
            {
                p.Borders[(int)TekFieldView.TekBorder.bdBottom] = TekFieldView.TekBorderStyle.tbsBoard;
            }
            else
            {
                __SetBorder(p, Board.Fields[row + 1, col], TekFieldView.TekBorder.bdBottom);
            }
            if (col == Board.Cols - 1)
            {
                p.Borders[(int)TekFieldView.TekBorder.bdRight] = TekFieldView.TekBorderStyle.tbsBoard;
            }
            else
            {
                __SetBorder(p, Board.Fields[row, col + 1], TekFieldView.TekBorder.bdRight);
            }
            p.Invalidate();
        }
Esempio n. 12
0
        private void initializePanels()
        {
            var    clr1 = Color.DarkGray;
            var    clr2 = Color.White;
            Random R    = new Random();

            removeBoard();
            if (Board == null)
            {
                return;
            }

            data.TileSize = ComputeTileSize(this.ClientRectangle.Width, this.ClientRectangle.Height);

            _Panels = new TekFieldView[Board.Rows, Board.Cols];

            for (int r = 0; r < Board.Rows; r++)
            {
                for (int c = 0; c < Board.Cols; c++)
                {
                    TekFieldView newP = new TekFieldView();
                    ReSizeFieldView(newP, data.TileSize, r, c);

                    newP.Data  = data;
                    newP.Field = Board.Fields[r, c];
                    SetPanelColors(newP);

                    //newP.Click += new EventHandler(Panel_Click);
                    //newP.MouseClick += new MouseEventHandler(Panel_MouseClick);
                    newP.MouseClick += new MouseEventHandler(Panel_MouseDown);
                    //(newP as Control).KeyDown+= new EventHandler(Panel_KeyDown);

                    this.Controls.Add(newP);
                    _Panels[r, c] = newP;
                }
            }
            this.Width  = PADDING + Board.Cols * data.TileSize;
            this.Height = PADDING + Board.Rows * data.TileSize;
        }
Esempio n. 13
0
        public TekArea SelectArea(int row, int col)
        {
            TekFieldView view = _view.GetField(row, col);

            Selector.CurrentMode = TekSelect.SelectMode.smMultiple;
            Selector.MultiselectFieldView.Clear();
            if (view == null)
            {
                return(null);
            }
            TekArea area = view.Field.Area;

            if (area == null)
            {
                return(null);
            }
            foreach (TekField field in area.Fields)
            {
                Selector.SelectCurrentField(_view.GetField(field.Row, field.Col));
            }
            _view.Refresh();
            return(area);
        }
Esempio n. 14
0
 private void ReSizeFieldView(TekFieldView v, int TileSize, int r, int c)
 {
     v.Size     = new Size(TileSize, TileSize);
     v.Location = new Point(PADDING / 2 + data.TileSize * c, PADDING / 2 + data.TileSize * r);
 }
Esempio n. 15
0
 public void Reset()
 {
     CurrentMode       = SelectMode.smNone;
     _currentFieldView = null;
     MultiselectFieldView.Clear();
 }