예제 #1
0
		public void ColumnIndex ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (-1, c.ColumnIndex, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (0, dgv.Rows[0].Cells[0].ColumnIndex, "A2");
		}
예제 #2
0
        public void DefaultNewRowValue()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(null, c.DefaultNewRowValue, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(null, dgv.Rows[0].Cells[0].DefaultNewRowValue, "A2");
        }
예제 #3
0
        public void ColumnIndex()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(-1, c.ColumnIndex, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(0, dgv.Rows[0].Cells[0].ColumnIndex, "A2");
        }
예제 #4
0
        public void OwningRow()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(null, c.OwningRow, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreSame(dgv.Rows[0], dgv.Rows[0].Cells[0].OwningRow, "A2");
        }
예제 #5
0
        public void IsInEditMode()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(false, c.IsInEditMode, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(false, dgv.Rows[0].Cells[0].IsInEditMode, "A2");
        }
    /// <summary>
    /// 用该manager时都需要初始化
    /// </summary>
    /// <param name="baseCell">需要创建的cell的obj</param>
    public void Init(BaseCell baseCell)
    {
        originCellObj = baseCell;
        cellHeight   += originCellObj.GetCellHeight() + spacing.y;
        cellWidth    += originCellObj.GetCellWidth() + spacing.x;

        Vector3[] corners = new Vector3[4];
        scrollRect.transform.GetComponent <RectTransform>().GetLocalCorners(corners);
        viewHeight = corners[1].y + cellHeight;

        startPos = new Vector3(cellWidth / 2, -cellHeight / 2);

        if (cellHeight == 0 || cellWidth == 0)
        {
            Debug.LogError("cell宽或高不能为0");
        }
    }
예제 #7
0
        public void TryToStep(Direction direction)
        {
            RememberLast = false;
            BaseCell cellToMove = null;

            var hero = Player.GetPlayer;

            switch (direction)
            {
            case Direction.Up:
                cellToMove = this[hero.Coordinates.X, hero.Coordinates.Y - 1];
                break;

            case Direction.Right:
                cellToMove = this[hero.Coordinates.X + 1, hero.Coordinates.Y];
                break;

            case Direction.Down:
                cellToMove = this[hero.Coordinates.X, hero.Coordinates.Y + 1];
                break;

            case Direction.Left:
                cellToMove = this[hero.Coordinates.X - 1, hero.Coordinates.Y];
                break;
            }

            if (cellToMove?.TryToStep() ?? false)
            {
                hero.Coordinates = cellToMove.Coordinates;
            }

            if (Cells[Cells.FindIndex(n => n.Coordinates.X == hero.Coordinates.X & n.Coordinates.Y == hero.Coordinates.Y)].Skin == ExitCell.Skin())
            {
                LastExitX        = hero.Coordinates.X;
                LastExitY        = hero.Coordinates.Y;
                hero.Coordinates = Cells[0].Coordinates;
                GenerateNew      = true;
            }

            if (Cells[Cells.FindIndex(n => n.Coordinates.X == hero.Coordinates.X & n.Coordinates.Y == hero.Coordinates.Y)].Skin == LastMazeCell.Skin())
            {
                hero.Coordinates = Cells[0].Coordinates;
                RememberLast     = true;
            }
        }
예제 #8
0
    /// <summary>
    /// 检查输入
    /// </summary>
    void HandleInput()
    {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

        if (hit.transform != null)
        {
            switch (activeType)
            {
            case PathCellMark.StartPos:

                BaseCell lastStartCell = CellManager.Instance.GetCellByID(m_StartCellId);
                //if (lastStartCell != null)
                //    lastStartCell.GetComponent<SpriteRenderer>().color = types[2];

                var startCell = hit.transform.GetComponent <BaseCell>();
                if (startCell != null)
                {
                    m_StartCellId = startCell.ID;
                }

                break;

            case PathCellMark.EndPos:

                BaseCell lastEndCell = CellManager.Instance.GetCellByID(m_EndCellId);
                //if (lastEndCell != null)
                //    lastEndCell.GetComponent<SpriteRenderer>().color = types[2];

                var endCell = hit.transform.GetComponent <BaseCell>();
                if (endCell != null)
                {
                    m_EndCellId = endCell.ID;
                }
                break;

            case PathCellMark.Block:
                MapManager.Instance.PathFinder.SetBlock(hit.transform.GetComponent <BaseCell>().ID);
                break;

            default:
                break;
            }
            EditCell(gridSystem.GetCellByPos(CellManager.Instance.cellShape, hit.point));
        }
    }
예제 #9
0
    private IEnumerator StartAction(float actionTime,
                                    DragAndDropParam dragAndDropParam,
                                    Action <DragAndDropParam> action)
    {
        BaseCell  dropCell      = dragAndDropParam.dragCell;
        BaseCell  dragCell      = dragAndDropParam.dropCell;
        BasePanel dragFromPanel = dragAndDropParam.dragFromPanel;
        BasePanel dragToPanel   = dragAndDropParam.dragToPanel;

        isAction = true;
        if (actionTime <= 0)
        {
            isAction = false;
        }
        // Cloase Old Panel
        if (panelAction != null)
        {
            Destroy(panelAction);
        }
        // Create Action Panel
        panelAction = Instantiate(panelActionPrefab, UIBuilder.GetCanvasTransform());
        float actionDelta = actionTime;

        while (isAction)
        {
            actionDelta -= Time.deltaTime;
            if (actionDelta <= 0)
            {
                isAction = false;
            }
            // Get Action Time
            float percent  = actionTime / 100;
            float doneTime = actionTime - actionDelta;
            float timer    = (doneTime / percent) / 100;
            panelAction.GetComponent <PanelAction>().SetTimer(timer);
            yield return(null);
        }
        Destroy(panelAction);
        dragAndDropParam.dragCell      = dragCell;
        dragAndDropParam.dropCell      = dropCell;
        dragAndDropParam.dragToPanel   = dragToPanel;
        dragAndDropParam.dragFromPanel = dragFromPanel;
        action?.Invoke(dragAndDropParam);
        isAction = false;
    }
예제 #10
0
    public override IEnumerator Update(bool playAnimation, Action onComplete = null)
    {
        m_isGenerating = true;

        m_cellList = new List <BaseCell> ();

        if (playAnimation)
        {
            yield return(null);
        }

        m_cellList.Add(new BaseCell(0, 0, m_mazeGenerator));

        BaseCell  cellCache      = null;
        Direction directionCache = Direction.None;
        int       randomCache    = 0;

        while (m_cellList.Count != 0)
        {
            randomCache    = UnityEngine.Random.Range(0, m_cellList.Count);
            cellCache      = m_cellList[randomCache];
            directionCache = cellCache.GetRandomDirection();

            if (directionCache != Direction.None)
            {
                if (playAnimation)
                {
                    yield return(null);
                }

                m_cellList.Add(new BaseCell(cellCache, directionCache, m_mazeGenerator));
            }
            else
            {
                m_cellList.RemoveAt(randomCache);
            }
        }

        m_isGenerating = false;

        if (null != onComplete)
        {
            onComplete();
        }
    }
예제 #11
0
파일: Enemy.cs 프로젝트: Team-on/TriJam-62
    void Update()
    {
        if (currTarget == null && Player.instance.cells.Count != 0)
        {
            currTarget = Player.instance.cells.Random();
        }

        if (currTarget != null)
        {
            Vector3 newPos = currTarget.transform.position - transform.position;
            float   angle  = Mathf.Atan2(newPos.y, newPos.x) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle - 90));

            transform.Translate(transform.up * speed * Time.deltaTime, Space.World);
        }

        hpSlider.transform.parent.localRotation = Quaternion.Euler(-transform.rotation.eulerAngles);
    }
예제 #12
0
        /// <summary>
        /// Name:PropertyChanged
        /// Description:property changed function checks if the cell is = or not and if its = 'it knows that its pointing to something else
        /// </summary>
        /// <param name="sender">object( the cell)</param>
        /// <param name="e">event argument</param>
        public void PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Text Property Changed")
            {
                BaseCell baseCell = sender as BaseCell;
                string   name     = baseCell.ColIndex.ToString() + baseCell.RowIndex.ToString();

                this.DeleteRefrence(name);

                if (baseCell.Text != string.Empty && baseCell.Text[0] == '=' && baseCell.Text.Length > 1)
                {
                    ExpressionTree tree = new ExpressionTree(baseCell.Text.Substring(1));
                    this.SetRefrence(name, tree.GetVariable());
                }

                this.DetermineCellValue(sender as Cell);
            }
        }
예제 #13
0
        /// <summary>
        /// Cell property changed event handler. change of a value of a cell.
        /// </summary>
        /// <param name="sender">Sender of event</param>
        /// <param name="e">What is changed.</param>
        private void HandleCellPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            BaseCell changedCell = sender as BaseCell;

            if (spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].Text[0] != '=')
            {
                string newValue = spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].Text;
                spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].ChangeValue(newValue);
            }
            else
            {
                string formula          = (changedCell.Text.Substring(0)).Trim();
                int    copyCellColIndex = Convert.ToInt32(changedCell.Text[1]) - 65;
                int    copyCellRowIndex = Convert.ToInt32(changedCell.Text.Substring(2)) - 1;
                spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].ChangeValue(spreadSheet[copyCellRowIndex, copyCellColIndex].Text);
            }
            sender = spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex];
        }
예제 #14
0
    public void DoWalk()
    {
        SetWalkState(WalkState.Walk);

        if (m_Path == null)
        {
            StopWalk();
            return;
        }

        int idx = m_Path.IndexOf(m_CurrentCellId);

        for (int i = idx; i >= 0; i--)
        {
            m_Path.RemoveAt(i);
        }

        Vector3 targetPos;

        if (m_Path.Count == 0)
        {
            BaseCell endPointCell = MapManager.Instance.GridSystem.GetCellByPos(CellShape.SquareWithWall, m_EndPosition);

            if (endPointCell.ID == CurrentCellId && ((Vector2)GetHostGameObject().transform.position - m_EndPosition).magnitude > m_StopRadius)
            {
                targetPos = m_EndPosition;
            }
            else
            {
                StopWalk();
                return;
            }
        }
        else
        {
            targetPos = CellManager.Instance.GetCellByID(m_Path[0]).transform.position;
        }

        var moveDir = (targetPos - transform.position).normalized * m_MoveSpeed;

        SetVelocity(new Vector2(moveDir.x, moveDir.y));

        transform.Translate(moveDir);
    }
예제 #15
0
    public void RefreshCellG()
    {
        List <EntityBaseController> characters = SoldierManager.Instance.GetCharacters();

        if (characters == null || characters.Count == 0)
        {
            return;
        }

        foreach (var cell in cells)
        {
            cell.ResetPassableDifficulty();
        }

        foreach (var character in characters)
        {
            if (character == null)
            {
                continue;
            }

            BaseCell cell = GetCellByID(character.CurrentCellId);
            if (cell == null)
            {
                continue;
            }

            float passableDifficulty = 0;
            if (m_PassableDifficulty == EPassableDifficulty.High)
            {
                passableDifficulty = GameBlackBoard.CELL_PASSABLE_DIFFICULTY_ADD_PER_CHARACTER_HIGH;
            }
            else if (m_PassableDifficulty == EPassableDifficulty.Medium)
            {
                passableDifficulty = GameBlackBoard.CELL_PASSABLE_DIFFICULTY_ADD_PER_CHARACTER_MEDIUM;
            }
            else if (m_PassableDifficulty == EPassableDifficulty.Low)
            {
                passableDifficulty = GameBlackBoard.CELL_PASSABLE_DIFFICULTY_ADD_PER_CHARACTER_LOW;
            }

            cell.SetPassableDifficulty(cell.PassableDifficulty + passableDifficulty);
        }
    }
예제 #16
0
    private int CalF(int targetCellID, int presentCellID)
    {
        BaseCell presentCell = CellManager.Instance.GetCellByID(presentCellID);

        if (presentCell == null)
        {
            Debug.LogError("当前网格ID不合法");
            return(-1);
        }
        int g = presentCell.CalG();
        int h = CalH(targetCellID, presentCellID);

        if (h == -1)
        {
            return(-1);
        }

        return(g + h);
    }
예제 #17
0
    private BaseCell OnSearchStart(int startCellId)
    {
        m_SearchState = SearchState.Searching;

        m_CellsSearched.Clear();
        m_CellsToSearch.Clear();
        m_CellsToSearchBackup.Clear();
        m_Path.Clear();

        BaseCell searchingCell = CellManager.Instance.GetCellByID(startCellId); // Cell To Search Right Now

        if (searchingCell != null)
        {
            searchingCell.SetParent(-1);
            m_CellsToSearch.Add(searchingCell);
        }

        return(searchingCell);
    }
    public override IEnumerator Update(bool playAnimation, Action onComplete = null)
    {
        m_isGenerating = true;

        m_cellStack = new Stack <BaseCell> ();

        if (playAnimation)
        {
            yield return(null);
        }

        m_cellStack.Push(new BaseCell(0, 0, m_mazeGenerator));

        BaseCell  cellCache      = null;
        Direction directionCache = Direction.None;

        while (m_cellStack.Count != 0)
        {
            cellCache      = m_cellStack.Peek();
            directionCache = cellCache.GetRandomDirection();

            if (directionCache != Direction.None)
            {
                if (playAnimation)
                {
                    yield return(null);
                }

                m_cellStack.Push(new BaseCell(cellCache, directionCache, m_mazeGenerator));
            }
            else
            {
                m_cellStack.Pop();
            }
        }

        m_isGenerating = false;

        if (null != onComplete)
        {
            onComplete();
        }
    }
예제 #19
0
 private CellType CellTypeMapper(BaseCell cell)
 {
     if (cell is Wall)
     {
         return(CellType.Wall);
     }
     else if (cell is Ground)
     {
         return(CellType.Road);
     }
     else if (cell is Gold)
     {
         return(CellType.Gold);
     }
     else
     {
         throw new Exception("Uknown type of cell");
     }
 }
예제 #20
0
    public virtual float CalG()
    {
        BaseCell parentCell = CellManager.Instance.GetCellByID(parentID);

        //if (parentCell == null)
        //{
        //    // 无父节点
        //    return 0;
        //}
        //gVal = parentCell.gVal + 1;
        //return gVal;

        if (parentCell == null)
        {
            // 无父节点
            return(PassableDifficulty);
        }
        return(parentCell.CalG() + PassableDifficulty);
    }
예제 #21
0
        public void ToolTipText()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(string.Empty, c.ToolTipText, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(string.Empty, dgv.Rows[0].Cells[0].ToolTipText, "A2");

            dgv.Rows[0].Cells[0].ToolTipText = "bob";
            Assert.AreEqual("bob", dgv.Rows[0].Cells[0].ToolTipText, "A3");
        }
예제 #22
0
        public void ValueType()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(typeof(object), c.ValueType, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(typeof(object), dgv.Rows[0].Cells[0].ValueType, "A2");

            dgv.Rows[0].Cells[0].ValueType = typeof(bool);
            Assert.AreEqual(typeof(bool), dgv.Rows[0].Cells[0].ValueType, "A3");
        }
예제 #23
0
        public void HasStyle()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(false, c.HasStyle, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(false, dgv.Rows[0].Cells[0].HasStyle, "A2");

            dgv.Rows[0].Cells[0].Style.BackColor = Color.Orange;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].HasStyle, "A3");
        }
예제 #24
0
        public void Value2()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(null, c.Value, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(null, dgv.Rows[0].Cells[0].Value, "A2");

            dgv.Rows[0].Cells[0].Value = "bob";
            Assert.AreEqual("bob", dgv.Rows[0].Cells[0].Value, "A3");
        }
예제 #25
0
        public void Frozen()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(false, c.Frozen, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(false, dgv.Rows[0].Cells[0].Frozen, "A2");

            dgv.Columns[0].Frozen = true;
            dgv.Rows[0].Frozen    = true;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Frozen, "A3");
        }
예제 #26
0
        public static void InitializeNeighbourhood(BaseCell cell, ICell[] cells, int cellBoardLength)
        {
            int neighbourhoodWidth = cell.neighbourhoodSize.Neighbourhood1DRadius();

            bool firstCell = cell.x < 0 + neighbourhoodWidth;
            bool lastCell  = cell.x > cellBoardLength - 1 - neighbourhoodWidth;
            bool safeCell  = !firstCell && !lastCell;

            if (safeCell)
            {
                Safe1DInitialize(cell, cells, neighbourhoodWidth);
            }
            else if (firstCell)
            {
                Left1DInitializer(cell, cells, neighbourhoodWidth, cellBoardLength);
            }
            else if (lastCell)
            {
                Right1DInitializer(cell, cells, neighbourhoodWidth, cellBoardLength);
            }
        }
예제 #27
0
        /// <summary>
        /// Cell property changed event handler. change of a value of a cell.
        /// </summary>
        /// <param name="sender">Sender of event.</param>
        /// <param name="e">What is changed.</param>
        private void HandleCellPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            BaseCell changedCell = sender as BaseCell;

            // if the text of changedcell is not =
            if (this.spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].Text[0] != '=')
            {
                // change the cell value to newvalue.
                string newValue = this.spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].Text;
                this.spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].ChangeValue(newValue);
            }
            else
            {
                string formula          = changedCell.Text.Substring(0).Trim();
                int    copyCellColIndex = Convert.ToInt32(changedCell.Text[1]) - 65;
                int    copyCellRowIndex = Convert.ToInt32(changedCell.Text.Substring(2)) - 1;
                this.spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex].ChangeValue(this.spreadSheet[copyCellRowIndex, copyCellColIndex].Text);
            }

            sender = this.spreadSheet[changedCell.RowIndex, changedCell.ColumnIndex];
        }
예제 #28
0
        public void Resizable()
        {
            DataGridViewCell c = new BaseCell();

            Assert.AreEqual(false, c.Resizable, "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Resizable, "A2");

            dgv.Rows[0].Resizable = DataGridViewTriState.False;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Resizable, "A3");

            dgv.Columns[0].Resizable = DataGridViewTriState.False;
            Assert.AreEqual(false, dgv.Rows[0].Cells[0].Resizable, "A4");

            dgv.Columns[0].Resizable = DataGridViewTriState.True;
            dgv.Rows[0].Resizable    = DataGridViewTriState.True;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Resizable, "A5");

            dgv.AllowUserToResizeColumns = false;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Resizable, "A6");

            dgv.AllowUserToResizeRows = false;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Resizable, "A7");

            dgv.Columns[0].Resizable = DataGridViewTriState.NotSet;
            Assert.AreEqual(true, dgv.Rows[0].Cells[0].Resizable, "A8");

            dgv.Rows[0].Resizable = DataGridViewTriState.NotSet;
            Assert.AreEqual(false, dgv.Rows[0].Cells[0].Resizable, "A9");
        }
예제 #29
0
        public void MethodGetErrorIconBounds()
        {
            Bitmap   b = new Bitmap(1, 1);
            Graphics g = Graphics.FromImage(b);

            BaseCell c = new BaseCell();

            Assert.AreEqual(Rectangle.Empty, c.PublicGetErrorIconBounds(g, c.Style, c.RowIndex), "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(Rectangle.Empty, (dgv.Rows[0].Cells[0] as BaseCell).PublicGetErrorIconBounds(g, dgv.Rows[0].Cells[0].InheritedStyle, dgv.Rows[0].Cells[0].RowIndex), "A2");
            g.Dispose();
            b.Dispose();
        }
예제 #30
0
        public void MethodGetErrorText()
        {
            Bitmap   b = new Bitmap(1, 1);
            Graphics g = Graphics.FromImage(b);

            BaseCell c = new BaseCell();

            Assert.AreEqual(string.Empty, c.PublicGetErrorText(c.RowIndex), "A1");

            DataGridView dgv = new DataGridView();

            dgv.Columns.Add("hi", "there");

            DataGridViewRow row = new DataGridViewRow();

            row.Cells.Add(c);
            dgv.Rows.Add(row);

            Assert.AreEqual(string.Empty, (dgv.Rows[0].Cells[0] as BaseCell).PublicGetErrorText(dgv.Rows[0].Cells[0].RowIndex), "A2");
            g.Dispose();
            b.Dispose();
        }
예제 #31
0
    //創建資料主程式
    public override void Update()
    {
        //將模式設為創建中
        m_isGenerating = true;

        m_cellStack = new Stack <BaseCell>();

        //將新創建物件加入至堆疊 並呼叫最初始的 BaseCell
        m_cellStack.Push(new BaseCell(0, 0, m_mazeGenerator));

        BaseCell cellCache      = null;
        int      directionCache = 0;

        //執行到迷宮創建完成
        while (m_cellStack.Count != 0)
        {
            //取得堆疊最上面的 BaseCell
            cellCache = m_cellStack.Peek();

            //取得 cellCache 的隨機牆壁方向
            directionCache = cellCache.GetRandomDirection();

            //判斷 cellCache 的牆壁所有方向是不是不空的
            if (directionCache != 0)
            {
                m_cellStack.Push(new BaseCell(cellCache, directionCache, m_mazeGenerator));
            }
            else
            {
                m_cellStack.Pop();
            }
        }

        //迷宮創建結束
        m_isGenerating = false;

        //Debug
        //m_mazeGenerator.maze.TestMaze();
    }
예제 #32
0
    void Awake()
    {
        switch (GetComponent<BaseCell>().celltype) {
            case CellType.STEM_CELL:
                m_baseCell = GetComponent<StemCell>();
                break;
            case CellType.HEAT_CELL:
                m_baseCell = GetComponent<HeatCell>();
                break;
            case CellType.COLD_CELL:
                m_baseCell = GetComponent<ColdCell>();
                break;
            case CellType.HEAT_CELL_TIRE2:
                m_baseCell = GetComponent<Tier2HeatCell>();
                break;
            case CellType.COLD_CELL_TIRE2:
                m_baseCell = GetComponent<Tier2ColdCell>();
                break;
            case CellType.ACIDIC_CELL:
                m_baseCell = GetComponent<AcidicCell>();
                break;
            case CellType.ALKALI_CELL:
                m_baseCell = GetComponent<AlkaliCell>();
                break;
            case CellType.CANCER_CELL:
                m_baseCell = GetComponent<CancerCell>();
                break;
            case CellType.NERVE_CELL:
                m_baseCell = GetComponent<NerveCell>();
                break;
            default:
                break;
        }

        m_visionRange = GetComponent<BaseCell>().fovRadius;
        unitLayerMask = 1 << LayerMask.NameToLayer("Unit");
    }
예제 #33
0
		public void Resizable ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (false, c.Resizable, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A2");

			dgv.Rows[0].Resizable = DataGridViewTriState.False;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A3");

			dgv.Columns[0].Resizable = DataGridViewTriState.False;
			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Resizable, "A4");

			dgv.Columns[0].Resizable = DataGridViewTriState.True;
			dgv.Rows[0].Resizable = DataGridViewTriState.True;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A5");

			dgv.AllowUserToResizeColumns = false;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A6");

			dgv.AllowUserToResizeRows = false;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A7");

			dgv.Columns[0].Resizable = DataGridViewTriState.NotSet;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A8");

			dgv.Rows[0].Resizable = DataGridViewTriState.NotSet;
			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Resizable, "A9");
		}
예제 #34
0
		public void IsInEditMode ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (false, c.IsInEditMode, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (false, dgv.Rows[0].Cells[0].IsInEditMode, "A2");
		}
예제 #35
0
		public void OwningRow ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.OwningRow, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreSame (dgv.Rows[0], dgv.Rows[0].Cells[0].OwningRow, "A2");
		}
예제 #36
0
		public void InheritedState ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (DataGridViewElementStates.ResizableSet, c.InheritedState, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A2");

			dgv.Rows[0].Selected = true;
			Assert.AreEqual (DataGridViewElementStates.Selected | DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A3");

			dgv.Rows[0].Selected = false;
			dgv.Columns[0].Selected = true;
			Assert.AreEqual (DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A4");
		}
예제 #37
0
		public void InheritedStyle ()
		{
			DataGridViewCell c = new BaseCell ();
			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (SystemColors.Window, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A1");

			dgv.DefaultCellStyle.BackColor = Color.Firebrick;
			Assert.AreEqual (Color.Firebrick, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A2");

			dgv.Columns[0].DefaultCellStyle.BackColor = Color.FloralWhite;
			Assert.AreEqual (Color.FloralWhite, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A3");

			dgv.RowsDefaultCellStyle.BackColor = Color.DeepPink;
			Assert.AreEqual (Color.DeepPink, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A4");

			dgv.Rows[0].DefaultCellStyle.BackColor = Color.DeepSkyBlue;
			Assert.AreEqual (Color.DeepSkyBlue, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A5");

			dgv.Rows[0].Cells[0].Style.BackColor = Color.DodgerBlue;
			Assert.AreEqual (Color.DodgerBlue, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A6");
		}
예제 #38
0
		public void Value2 ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.Value, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (null, dgv.Rows[0].Cells[0].Value, "A2");

			dgv.Rows[0].Cells[0].Value = "bob";
			Assert.AreEqual ("bob", dgv.Rows[0].Cells[0].Value, "A3");
		}
예제 #39
0
		public void MethodGetErrorIconBounds ()
		{
			Bitmap b = new Bitmap (1, 1);
			Graphics g = Graphics.FromImage (b);

			BaseCell c = new BaseCell ();
			c.ErrorText = "Yo!";
			Assert.AreEqual (Rectangle.Empty, c.PublicGetErrorIconBounds (g, c.Style, c.RowIndex), "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.HeaderCell = c;
			dgv.Rows.Add (row);

			Assert.AreEqual (Rectangle.Empty, (dgv.Rows[0].HeaderCell as BaseCell).PublicGetErrorIconBounds (g, dgv.Rows[0].HeaderCell.InheritedStyle, dgv.Rows[0].HeaderCell.RowIndex), "A2");

			dgv.Rows[0].ErrorText = "Danger!";
			Assert.AreEqual (new Rectangle (24, 5, 12, 11), (dgv.Rows[0].HeaderCell as BaseCell).PublicGetErrorIconBounds (g, dgv.Rows[0].HeaderCell.InheritedStyle, dgv.Rows[0].HeaderCell.RowIndex), "A3");
			Assert.AreEqual ("Danger!", (dgv.Rows[0].HeaderCell as BaseCell).PublicGetErrorText (dgv.Rows[0].HeaderCell.RowIndex), "A4");

			g.Dispose ();
			b.Dispose ();
		}
예제 #40
0
		public void MethodGetInheritedContextMenuStrip ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.GetInheritedContextMenuStrip (c.RowIndex), "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (null, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A2");

			ContextMenuStrip cms1 = new ContextMenuStrip ();
			cms1.Items.Add ("Moose");
			dgv.ContextMenuStrip = cms1;

			Assert.AreSame (cms1, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A3");

			ContextMenuStrip cms2 = new ContextMenuStrip ();
			cms2.Items.Add ("Moose");
			dgv.Columns[0].ContextMenuStrip = cms2;

			Assert.AreSame (cms2, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A4");

			dgv.Rows[0].ContextMenuStrip = cms1;
			Assert.AreSame (cms1, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A5");

			dgv.Rows[0].Cells[0].ContextMenuStrip = cms2;
			Assert.AreSame (cms2, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A6");
		}
예제 #41
0
 public void DeselectCell(BaseCell _in)
 {
     _in.isSelected = false;
     selectedUnits.Remove(_in);
 }
예제 #42
0
		public void MethodBorderWidths ()
		{
			BaseCell c = new BaseCell ();

			DataGridViewAdvancedBorderStyle style = new DataGridViewAdvancedBorderStyle ();
			style.Bottom = DataGridViewAdvancedCellBorderStyle.Inset;
			style.Left = DataGridViewAdvancedCellBorderStyle.InsetDouble;
			style.Top = DataGridViewAdvancedCellBorderStyle.None;
			//style.Right = DataGridViewAdvancedCellBorderStyle.NotSet;

			Assert.AreEqual (new Rectangle (2, 0, 0, 1), c.PublicBorderWidths (style), "A1");

			style.Bottom = DataGridViewAdvancedCellBorderStyle.Outset;
			style.Left = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
			style.Right = DataGridViewAdvancedCellBorderStyle.OutsetPartial;
			style.Top = DataGridViewAdvancedCellBorderStyle.Single;

			Assert.AreEqual (new Rectangle (2, 1, 1, 1), c.PublicBorderWidths (style), "A2");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			dgv.Rows[0].DividerHeight = 3;
			dgv.Columns[0].DividerWidth = 5;

			Assert.AreEqual (new Rectangle (2, 1, 6, 4), (dgv.Rows[0].Cells[0] as BaseCell).PublicBorderWidths (style), "A3");
		}
예제 #43
0
		public void MethodGetErrorText ()
		{
			Bitmap b = new Bitmap (1, 1);
			Graphics g = Graphics.FromImage (b);

			BaseCell c = new BaseCell ();
			Assert.AreEqual (string.Empty, c.PublicGetErrorText (c.RowIndex), "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (string.Empty, (dgv.Rows[0].Cells[0] as BaseCell).PublicGetErrorText (dgv.Rows[0].Cells[0].RowIndex), "A2");
			g.Dispose ();
			b.Dispose ();
		}
		public void FormattedValueType ()
		{
			BaseCell c = new BaseCell ();
			Assert.AreEqual (typeof (bool), c.FormattedValueType, "A1");
			
			c.ThreeState = true;
			Assert.AreEqual (typeof (CheckState), c.FormattedValueType, "A2");
		}
예제 #45
0
파일: Map.cs 프로젝트: MinZhu/Defence
        //public void Draw(Canvas canvas)
        //{
        //    if (_mapCells == null) { throw new Exception("没有加载地图。"); }
        //}
        public bool Load(string filePathName)
        {
            releaseMapBitmap();
            // 加载地图图片。
            _mapBitmap = new Bitmap(filePathName);
            if (_mapBitmap.Width < Cols || _mapBitmap.Height < Rows) { return false; }

            for (int x = 0; x < Cols; x++)
            {
                for (int y = 0; y < Rows; y++)
                {
                    System.Drawing.Color c = _mapBitmap.GetPixel(x, y);
                    if (c.R == 255 && c.G == 255 && c.B == 255)	// 白色,地面
                    {
                        _mapCanvas.Children.Add(new LandCell(x,y));
                    }
                    else
                    {
                        if (c.R == 0 && c.G == 255 && c.B == 0)	// 绿色,树
                        {
                            _mapCanvas.Children.Add(new TreeCell(x,y));
                        }
                        else
                        {
                            if (c.R == 0 && c.G == 0 && c.B == 255)	// 蓝色,怪物进攻路线
                            {
                                _mapCanvas.Children.Add(new PathCell(x,y));
                            }
                            else
                            {
                                if (c.R == 0 && c.G == 0 && c.B == 0)	// 黑色,基地
                                {
                                    //if (_pathCells[x] != null) { throw new Exception("地图设计错误,基地只能有一个。"); }
                                    _baseCell = new BaseCell(x,y);
                                    _mapCanvas.Children.Add(_baseCell);
                                }
                                else
                                {
                                    if (c.R == 255 && c.G == 0 && c.B == 0)	// 红色,怪物入口
                                    {
                                        //if (x != 0||_pathCells[0]!=null) { throw new Exception("地图设计错误,怪物入口必须在最左侧且只能有一个入口。"); }
                                        _entryCell = new PathCell(x, y);
                                        _mapCanvas.Children.Add(_entryCell);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            initPathCells();
            initGunCells();
            return true;
        }
예제 #46
0
    public void AddNewCell(BaseCell _in)
    {
        if (PhotonNetwork.connected && !_in.gameObject.GetPhotonView().isMine)
        {
            allSelectableTargets.Add(_in.gameObject);
        }
        else if (_in.isSinglePlayer && !_in.isMine && !allSelectableTargets.Contains(_in.gameObject))
        {
            allSelectableTargets.Add(_in.gameObject);
        }
        else if (!allSelectableUnits.Contains(_in) && _in.isMine)
        {

            _in.isSelected = true;
            if (!_in.transform.FindChild("FriendlySelector(Clone)"))
            {
                GameObject tFriendlySelector = GameObject.Instantiate(friendlySelector, _in.transform.position, Quaternion.Euler(90.0f, 0.0f, 0.0f)) as GameObject;
                tFriendlySelector.transform.parent = _in.transform;
            }
            allSelectableUnits.Add(_in);
            selectedUnits.Add(_in);
            CheckSelectedUnits();
        }
    }
예제 #47
0
		public void Style ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (DataGridViewContentAlignment.NotSet, c.Style.Alignment, "A1");
			Assert.AreEqual (Color.Empty, c.Style.BackColor, "A2");
			Assert.AreEqual (DBNull.Value, c.Style.DataSourceNullValue, "A3");
			Assert.AreEqual (null, c.Style.Font, "A4");
			Assert.AreEqual (Color.Empty, c.Style.ForeColor, "A5");
			Assert.AreEqual (string.Empty, c.Style.Format, "A6");
			Assert.AreEqual (Thread.CurrentThread.CurrentCulture, c.Style.FormatProvider, "A7");
			Assert.AreEqual (true, c.Style.IsDataSourceNullValueDefault, "A8");
			Assert.AreEqual (true, c.Style.IsFormatProviderDefault, "A9");
			Assert.AreEqual (true, c.Style.IsNullValueDefault, "A10");
			Assert.AreEqual (string.Empty, c.Style.NullValue, "A11");
			Assert.AreEqual (Padding.Empty, c.Style.Padding, "A12");
			Assert.AreEqual (Color.Empty, c.Style.SelectionBackColor, "A13");
			Assert.AreEqual (Color.Empty, c.Style.SelectionForeColor, "A14");
			Assert.AreEqual (null, c.Style.Tag, "A15");
			Assert.AreEqual (DataGridViewTriState.NotSet, c.Style.WrapMode, "A16");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			// Style does not change based on parent
			// (InheritedStyle does)
			Assert.AreEqual (DataGridViewContentAlignment.NotSet, c.Style.Alignment, "A17");
			Assert.AreEqual (Color.Empty, c.Style.BackColor, "A18");
			Assert.AreEqual (DBNull.Value, c.Style.DataSourceNullValue, "A19");
			Assert.AreEqual (null, c.Style.Font, "A20");
			Assert.AreEqual (Color.Empty, c.Style.ForeColor, "A21");
			Assert.AreEqual (string.Empty, c.Style.Format, "A22");
			Assert.AreEqual (Thread.CurrentThread.CurrentCulture, c.Style.FormatProvider, "A23");
			Assert.AreEqual (true, c.Style.IsDataSourceNullValueDefault, "A24");
			Assert.AreEqual (true, c.Style.IsFormatProviderDefault, "A25");
			Assert.AreEqual (true, c.Style.IsNullValueDefault, "A26");
			Assert.AreEqual (string.Empty, c.Style.NullValue, "A27");
			Assert.AreEqual (Padding.Empty, c.Style.Padding, "A28");
			Assert.AreEqual (Color.Empty, c.Style.SelectionBackColor, "A29");
			Assert.AreEqual (Color.Empty, c.Style.SelectionForeColor, "A30");
			Assert.AreEqual (null, c.Style.Tag, "A31");
			Assert.AreEqual (DataGridViewTriState.NotSet, c.Style.WrapMode, "A32");
		}
예제 #48
0
		public void Frozen ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (false, c.Frozen, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Frozen, "A2");

			dgv.Columns[0].Frozen = true;
			dgv.Rows[0].Frozen = true;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Frozen, "A3");
		}
예제 #49
0
		public void ToolTipText ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (string.Empty, c.ToolTipText, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (string.Empty, dgv.Rows[0].Cells[0].ToolTipText, "A2");

			dgv.Rows[0].Cells[0].ToolTipText = "bob";
			Assert.AreEqual ("bob", dgv.Rows[0].Cells[0].ToolTipText, "A3");
		}
예제 #50
0
		public void HasStyle ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (false, c.HasStyle, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (false, dgv.Rows[0].Cells[0].HasStyle, "A2");

			dgv.Rows[0].Cells[0].Style.BackColor = Color.Orange;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].HasStyle, "A3");
		}
예제 #51
0
		public void ValueType ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (typeof (object), c.ValueType, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (typeof (object), dgv.Rows[0].Cells[0].ValueType, "A2");

			dgv.Rows[0].Cells[0].ValueType = typeof (bool);
			Assert.AreEqual (typeof (bool), dgv.Rows[0].Cells[0].ValueType, "A3");
		}
예제 #52
0
		public void PreferredSize ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (new Size (-1, -1), c.PreferredSize, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (new Size (-1, -1), dgv.Rows[0].Cells[0].PreferredSize, "A2");
			
			// Always returns (-1, -1)
			dgv.Rows[0].Cells[0].Value = "bob";
			Assert.AreEqual (new Size (-1, -1), dgv.Rows[0].Cells[0].PreferredSize, "A3");
		}
예제 #53
0
		public void Visible ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (false, c.Visible, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Visible, "A2");

			dgv.Columns[0].Visible = false;
			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Visible, "A3");

			dgv.Columns[0].Visible = true;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Visible, "A4");

			dgv.Rows[0].Visible = false;
			Assert.AreEqual (false, dgv.Rows[0].Cells[0].Visible, "A5");

			dgv.Rows[0].Visible = true;
			Assert.AreEqual (true, dgv.Rows[0].Cells[0].Visible, "A6");
		}
예제 #54
0
		public void DefaultNewRowValue ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.DefaultNewRowValue, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (null, dgv.Rows[0].Cells[0].DefaultNewRowValue, "A2");
		}
예제 #55
0
		public void MethodGetErrorIconBounds ()
		{
			Bitmap b = new Bitmap (1, 1);
			Graphics g = Graphics.FromImage (b);

			BaseCell c = new BaseCell ();
			Assert.AreEqual (Rectangle.Empty, c.PublicGetErrorIconBounds (g, c.Style, c.RowIndex), "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			Assert.AreEqual (Rectangle.Empty, (dgv.Rows[0].Cells[0] as BaseCell).PublicGetErrorIconBounds (g, dgv.Rows[0].Cells[0].InheritedStyle, dgv.Rows[0].Cells[0].RowIndex), "A2");
			g.Dispose ();
			b.Dispose ();
		}
예제 #56
0
		public void EditedFormattedValue ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.EditedFormattedValue, "A1");
		}
예제 #57
0
		public void MethodKeyEntersEditMode ()
		{
			string result = string.Empty;
			string expected = string.Empty;
			
			DataGridViewCell c = new BaseCell ();

			foreach (Keys k in Enum.GetValues (typeof (Keys)))
				if (c.KeyEntersEditMode (new KeyEventArgs (k)))
					result += ((int)k).ToString () + ";";

			Assert.AreEqual (expected, result, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			result = string.Empty;

			foreach (Keys k in Enum.GetValues (typeof (Keys)))
				if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
					result += ((int)k).ToString () + ";";

			Assert.AreEqual (expected, result, "A2");

			result = string.Empty;
			dgv.EditMode = DataGridViewEditMode.EditOnEnter;

			foreach (Keys k in Enum.GetValues (typeof (Keys)))
				if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
					result += ((int)k).ToString () + ";";

			Assert.AreEqual (expected, result, "A3");

			result = string.Empty;
			dgv.EditMode = DataGridViewEditMode.EditOnF2;

			foreach (Keys k in Enum.GetValues (typeof (Keys)))
				if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
					result += ((int)k).ToString () + ";";

			Assert.AreEqual (expected, result, "A4");

			result = string.Empty;
			dgv.EditMode = DataGridViewEditMode.EditOnKeystroke;

			foreach (Keys k in Enum.GetValues (typeof (Keys)))
				if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
					result += ((int)k).ToString () + ";";

			Assert.AreEqual (expected, result, "A5");

			result = string.Empty;
			dgv.EditMode = DataGridViewEditMode.EditProgrammatically;

			foreach (Keys k in Enum.GetValues (typeof (Keys)))
				if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
					result += ((int)k).ToString () + ";";

			Assert.AreEqual (expected, result, "A6");
		}
예제 #58
0
		public void FormattedValueType ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (typeof (string), c.FormattedValueType, "A1");
		}
예제 #59
0
		public void ContextMenuStrip ()
		{
			DataGridViewCell c = new BaseCell ();
			Assert.AreEqual (null, c.ContextMenuStrip, "A1");

			DataGridView dgv = new DataGridView ();
			dgv.Columns.Add ("hi", "there");

			DataGridViewRow row = new DataGridViewRow ();
			row.Cells.Add (c);
			dgv.Rows.Add (row);

			ContextMenuStrip cms1 = new ContextMenuStrip ();
			cms1.Items.Add ("hey");

			ContextMenuStrip cms2 = new ContextMenuStrip ();
			cms2.Items.Add ("yo");

			dgv.Rows[0].ContextMenuStrip = cms1;
			Assert.AreEqual (null, dgv.Rows[0].Cells[0].ContextMenuStrip, "A2");

			dgv.Rows[0].Cells[0].ContextMenuStrip = cms2;
			Assert.AreSame (cms2, dgv.Rows[0].Cells[0].ContextMenuStrip, "A3");
		}
예제 #60
0
 public void RemoveDeadCell(BaseCell _in)
 {
     _in.isSelected = false;
     allSelectableUnits.Remove(_in);
     selectedUnits.Remove(_in);
     CheckSelectedUnits();
 }