Exemplo n.º 1
0
        private void panelCross_MouseUp(object sender, MouseEventArgs e)
        {
            if (mouseSelection == null)
            {
                return;
            }
            if (mouseSelection.Button != e.Button)
            {
                mouseSelection = null;
                //TODO partial invalidate need
                panelCross.Invalidate();
                return;
            }

            int x1 = Math.Min(mouseSelection.Begin.X, mouseSelection.End.X),
                x2 = Math.Max(mouseSelection.Begin.X, mouseSelection.End.X),
                y1 = Math.Min(mouseSelection.Begin.Y, mouseSelection.End.Y),
                y2 = Math.Max(mouseSelection.Begin.Y, mouseSelection.End.Y);

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    cross.SetCell(i, j, mouseSelection.NewCellState);
                }
            }

            cross.HistoryNextStep();
            mouseSelection = null;

            if (!editorMode)
            {
                //TODO need async update
                cross.CheckLines();
            }
            else
            {
                var oldSize = new Size(cross.MaxCountTop, cross.MaxCountLeft);
                cross.CalcLines();
                var newSize = new Size(cross.MaxCountTop, cross.MaxCountLeft);
                if (oldSize != newSize)
                {
                    UpdateSize();
                }
            }

            UpdateBtnState();
            //TODO partial invalidate need
            panelCross.Invalidate();
        }
Exemplo n.º 2
0
 private void btnUndo_Click(object sender, EventArgs e)
 {
     if (!editorMode || cross.IsHistoryUndo)
     {
         cross.HistoryUndo();
         if (!editorMode)
         {
             cross.CheckLines();
         }
         else
         {
             cross.CalcLines();
             UpdateSize();
         }
         UpdateBtnState();
         panelCross.Invalidate();
     }
     else if (editorMode && editorHistoryUndo.Any())
     {
         cross = editorHistoryUndo.Pop();
         cross.CalcLines();
         UpdateSize();
         UpdateBtnState();
         panelCross.Invalidate();
     }
 }
Exemplo n.º 3
0
 private void AddLines(int addLeft, int addRight, int addTop, int addDown)
 {
     editorHistoryUndo.Push(cross);
     cross = cross.CloneAdd(addLeft, addRight, addTop, addDown);
     cross.CalcLines();
     UpdateSize();
     UpdateBtnState();
     panelCross.Invalidate();
 }
Exemplo n.º 4
0
 private void AddLines(int addLeft, int addRight, int addTop, int addDown)
 {
     editorHistoryUndo.Push(cross);
     cross = cross.CloneAdd(addLeft, addRight, addTop, addDown);
     cross.CalcLines();
     UpdateSize();
     UpdateBtnState();
     panelCross.Invalidate();
 }
Exemplo n.º 5
0
        private void btnCrop_Click(object sender, EventArgs e)
        {
            if (!editorMode)
            {
                return;
            }
            var newCross = cross.CloneCrop();

            if (cross.LeftSize == newCross.LeftSize && cross.TopSize == newCross.TopSize)
            {
                return;
            }
            editorHistoryUndo.Push(cross);
            cross = newCross;
            cross.CalcLines();
            UpdateSize();
            UpdateBtnState();
            panelCross.Invalidate();
        }
Exemplo n.º 6
0
 private void btnUndo_Click(object sender, EventArgs e)
 {
     if (!editorMode || cross.IsHistoryUndo)
     {
         cross.HistoryUndo();
         if (!editorMode)
         {
             cross.CheckLines();
         }
         else
         {
             cross.CalcLines();
             UpdateSize();
         }
         UpdateBtnState();
         panelCross.Invalidate();
     }
     else if (editorMode && editorHistoryUndo.Any())
     {
         cross = editorHistoryUndo.Pop();
         cross.CalcLines();
         UpdateSize();
         UpdateBtnState();
         panelCross.Invalidate();
     }
 }
Exemplo n.º 7
0
 private void btnCrop_Click(object sender, EventArgs e)
 {
     if (!editorMode)
         return;
     var newCross = cross.CloneCrop();
     if (cross.LeftSize == newCross.LeftSize && cross.TopSize == newCross.TopSize)
         return;
     editorHistoryUndo.Push(cross);
     cross = newCross;
     cross.CalcLines();
     UpdateSize();
     UpdateBtnState();
     panelCross.Invalidate();
 }