Beispiel #1
0
 //exact copy
 private void TableLayoutPanel_MouseMove(object sender, MouseEventArgs e)
 {
     if (panning)
     {
         int xLocation = e.Location.X;
         if (e.Location.X < 0)
         {
             xLocation = 0;
         }
         if (e.Location.X > tableLayoutPanel.Width)
         {
             xLocation = tableLayoutPanel.Width;
         }
         int yLocation = e.Location.Y;
         if (e.Location.Y < 0)
         {
             yLocation = 0;
         }
         if (e.Location.Y > tableLayoutPanel.Height)
         {
             yLocation = tableLayoutPanel.Height;
         }
         movingPoint = new Point(xLocation - startingPoint.X,
                                 yLocation - startingPoint.Y);
         tableLayoutPanel.Invalidate();
         var openForms = Application.OpenForms.OfType <ExampleForm>().Where(display => !GetHashCode().Equals(display.GetHashCode())).ToList();
         foreach (var mapRunnerDisplay in openForms)
         {
             mapRunnerDisplay.UpdateMapPosition(movingPoint);
         }
     }
 }
Beispiel #2
0
 protected override void OnPaint(PaintEventArgs e)
 {
     Unlocked = room.Stat.CurrentEnergyLimit;
     Active   = room.Stat.CurrentEnergy;
     if (room.Type == RoomType.Generator)
     {
         Active = ship.Stats.FullEnergy - ship.Stats.CurrentEnergy;
     }
     for (int i = 0; i < Active; i++)
     {
         cells[i].state = 2;
     }
     for (int i = Active; i < Unlocked; i++)
     {
         cells[i].state = 1;
     }
     for (int i = Unlocked; i < Max; i++)
     {
         cells[i].state = 0;
     }
     base.OnPaint(e);
     table.Invalidate(true);
     //foreach (var cell in cells)
     //	cell.Invalidate();
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 public void EditCurrentKey()
 {
     LoadKeyInEditor(iModel.Profiles[iCurrentProfileIndex].Keys[iCurrentKeyIndex]);
     // Make sure we show our current key highlight properly
     // We will need to redraw our table then
     iTableLayoutPanelStreamDeck.Invalidate();
 }
Beispiel #4
0
        private void ConnectionChanged(CheckBox checkBox, bool horizontal)
        {
            var dynamicEntryPuzzle = (IDynamicEntryPuzzle)CurrentPuzzle;

            (int x, int y) = ((int, int))checkBox.Tag;
            int xmod              = horizontal ? 1 : 0,
                ymod              = horizontal ? 0 : 1,
                dim               = horizontal ? x : y,
                dimSize           = horizontal ? GridSize.Width : GridSize.Height,
                cellValuePosition = (horizontal || dynamicEntryPuzzle.OneEntryPerCell()) ? 0 : 1;

            CheckBox[,] connectSame = horizontal ? ConnectRight : ConnectDown,
            connectOther            = horizontal ? ConnectDown : ConnectRight;
            // adjust minimum and maximum values of entries whose size has changed
            foreach (int c in Enumerable.Range(dim, 2))
            {
                ICollection <Point> entry = GetEntry(new Point(horizontal ? c : x, horizontal ? y : c), horizontal || !dynamicEntryPuzzle.LinearEntries(), !horizontal || !dynamicEntryPuzzle.LinearEntries());
                foreach (Point cell in entry)
                {
                    CellsValues[cell.Y, cell.X, cellValuePosition].Enabled = false;
                    CellsValues[cell.Y, cell.X, cellValuePosition].Minimum = dynamicEntryPuzzle.MinEntryValue(entry.Count);
                    CellsValues[cell.Y, cell.X, cellValuePosition].Maximum = dynamicEntryPuzzle.MaxEntryValue(entry.Count);
                    CellsValues[cell.Y, cell.X, cellValuePosition].Enabled = true;
                }
            }
            // control whether affected cells are writable or can belong to perpendicular entries
            if (dynamicEntryPuzzle.LinearEntries())
            {
                if (dynamicEntryPuzzle.OneEntryPerCell())
                {
                    foreach (int cx in Enumerable.Range(x - ymod, 2))
                    {
                        foreach (int cy in Enumerable.Range(y - xmod, 2))
                        {
                            int cDim = horizontal ? cx : cy;
                            if (cx >= 0 && cx < GridSize.Width - ymod && cy >= 0 && cy < GridSize.Height - xmod)
                            {
                                connectOther[cy, cx].Enabled =
                                    (cDim == dimSize - 1 || !connectSame[cy, cx].Checked) &&
                                    (cDim == 0 || !connectSame[cy - ymod, cx - xmod].Checked) &&
                                    (cDim == dimSize - 1 || !connectSame[cy + xmod, cx + ymod].Checked) &&
                                    (cDim == 0 || !connectSame[cy + (horizontal ? 1 : -1), cx + (horizontal ? -1 : 1)].Checked);
                            }
                        }
                    }
                }
                else
                {
                    CellsValues[y, x, cellValuePosition].Enabled = checkBox.Checked || (dim > 0 && connectSame[y - ymod, x - xmod].Checked);
                    CellsValues[y + ymod, x + xmod, cellValuePosition].Enabled = checkBox.Checked || (dim < dimSize - 2 && connectSame[y + ymod, x + xmod].Checked);
                }
            }
            // if the cell has been made part of an entry, the entry takes its value
            if (checkBox.Checked)
            {
                CellsValues[y + ymod, x + xmod, cellValuePosition].Value = CellsValues[y, x, cellValuePosition].Value;
            }
            GridTable.Invalidate(Cells[y, x].Region);
        }
Beispiel #5
0
        private void TableLayoutPanel_DragDrop(object sender, DragEventArgs e)
        {
            TableLayoutPanel tlp      = (TableLayoutPanel)sender;
            Rectangle        formSize = RectangleToScreen(this.ClientRectangle);
            Point            p        = new Point(e.X - this.Location.X - tlp.Location.X - (formSize.Left - this.Left), e.Y - this.Location.Y - tlp.Location.Y - (formSize.Top - this.Top));
            int   cellWidth           = tlp.Width / tlp.ColumnCount;
            int   cellHeight          = tlp.Height / tlp.RowCount;
            Point targetCell          = new Point(p.X / cellWidth, p.Y / cellHeight);

            currentCell  = targetCell;
            newCell      = true;
            CurrentBoard = int.Parse(tlp.Tag.ToString());
            tlp.Invalidate();

            PictureBox pb = (PictureBox)tlp.GetControlFromPosition(targetCell.X, targetCell.Y);

            if (e.Data.GetDataPresent(typeof(Hero))) //if drag data is hero
            {
                Hero h = ((Hero)e.Data.GetData(typeof(Hero)));
                if (pb.Tag != null) //if target pb has a hero
                {
                    ad.SwapHeroes(h, (Hero)pb.Tag);
                }
                else //if target pb is empty
                {
                    ad.SetHeroPositionSmart(h.player, h.index, targetCell.X, targetCell.Y);
                }
            }


            else if (e.Data.GetDataPresent(typeof(Item)))
            {
                Item i        = ((Item)e.Data.GetData(typeof(Item)));
                int  tlpindex = int.Parse(tlp.Tag.ToString());
                if (tlpindex / 2 == 0) // if target tlp is a hero table
                {
                    if (pb.Tag != null)
                    {
                        for (int j = 0; j < itemLists[i.player, 0].Count(); j++)
                        {
                            if (itemLists[i.player, 0][j].UID == ((Hero)pb.Tag).UID)
                            {
                                ad.SetItemHolder(i.player, j, 0);
                            }
                        }

                        ad.SetItemHolder(i.player, i.index, ((Hero)pb.Tag).UID);
                        Console.WriteLine("nice");
                    }
                    else
                    {
                        ad.SetItemHolder(i.player, i.index, 0);
                    }
                }
            }
        }
Beispiel #6
0
        public void RefreshCardsForGame()
        {
            var playerCards = mainForm.Game.FirstPlayer.ChoosedCardsForGame;

            foreach (var cardPanel in cardsOnPanel)
            {
                cardsTable.Controls.Remove(cardPanel);
            }

            cardsOnPanel.Clear();
            for (var i = 0; i < playerCards.Count; i++)
            {
                var cardPanel = CreateCardPanel(playerCards[i]);
                cardsTable.Controls.Add(cardPanel, i, 0);
                cardsOnPanel.Add(cardPanel);
            }

            cardsTable.Invalidate();
        }
Beispiel #7
0
 public override void Resize()
 {
     // this is just so that all of the properties' controls' update visually upon resize.
     tlp.Invalidate();
     foreach (Control c in tlp.Controls)
     {
         c.Invalidate();
         foreach (Control c2 in c.Controls)
         {
             c2.Invalidate();
             foreach (Control c3 in c2.Controls)
             {
                 c3.Invalidate();
                 foreach (Control c4 in c3.Controls)
                 {
                     c4.Invalidate();
                 }
             }
         }
     }
 }
        private void ResizeBoardDisplay(float newRectSize)
        {
            //tableLayoutPanel1.Scale(new SizeF(newSize, newSize));
            int newSize = (int)newRectSize;


            // this system assumes a square board with square cells
            if (newSize > tableBoardPanel.MaximumSize.Height)
            {
                newSize = tableBoardPanel.MaximumSize.Height;
            }
            else if (newSize < tableBoardPanel.MinimumSize.Height)
            {
                newSize = tableBoardPanel.MinimumSize.Height;
            }

            Console.WriteLine("Resizing cells to " + currentBoardSize);
            tableBoardPanel.SuspendLayout();

            int oldSize = tableBoardPanel.Height;

            tableBoardPanel.Height = newSize;
            tableBoardPanel.Width  = newSize;

            // to center the zoom lets adjust the board position equally in each direction

            int sizeDiff = oldSize - newSize;

            tableBoardPanel.Top  += sizeDiff / 2;
            tableBoardPanel.Left += sizeDiff / 2;

            tableBoardPanel.Invalidate();
            tableBoardPanel.ResumeLayout();

            currentBoardSize = newSize;
        }