public static bool op_Inequality(TableLayoutPanelCellPosition p1, TableLayoutPanelCellPosition p2)
 {
 }
        public void TableLayoutPanelCellPosition_ToString_Invoke_ReturnsExpected()
        {
            var position = new TableLayoutPanelCellPosition(1, 2);

            Assert.Equal("1,2", position.ToString());
        }
 public void SetCellPosition(Control control, TableLayoutPanelCellPosition position)
 {
 }
Exemple #4
0
        /// <summary>
        /// When the DataGridView is visible for the first time a panel is created.
        /// The DataGridView is then removed from the parent control and added as
        /// child to the newly created panel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void changeParent()
        {
            if (!DesignMode && Parent != null)
            {
                summaryControl.InitialHeight = this.refBox.Height;
                summaryControl.Height        = summaryControl.InitialHeight;
                summaryControl.BackColor     = this.RowHeadersDefaultCellStyle.BackColor;
                summaryControl.ForeColor     = Color.Transparent;
                summaryControl.RightToLeft   = this.RightToLeft;
                panel.Bounds    = this.Bounds;
                panel.BackColor = this.BackgroundColor;

                panel.Dock        = this.Dock;
                panel.Anchor      = this.Anchor;
                panel.Padding     = this.Padding;
                panel.Margin      = this.Margin;
                panel.Top         = this.Top;
                panel.Left        = this.Left;
                panel.BorderStyle = this.BorderStyle;

                Margin  = new Padding(0);
                Padding = new Padding(0);
                Top     = 0;
                Left    = 0;

                summaryControl.Dock = DockStyle.Bottom;
                this.Dock           = DockStyle.Fill;

                if (this.Parent is TableLayoutPanel)
                {
                    int rowSpan, colSpan;

                    TableLayoutPanel             tlp     = this.Parent as TableLayoutPanel;
                    TableLayoutPanelCellPosition cellPos = tlp.GetCellPosition(this);

                    rowSpan = tlp.GetRowSpan(this);
                    colSpan = tlp.GetColumnSpan(this);

                    tlp.Controls.Remove(this);
                    tlp.Controls.Add(panel, cellPos.Column, cellPos.Row);
                    tlp.SetRowSpan(panel, rowSpan);
                    tlp.SetColumnSpan(panel, colSpan);
                }
                else
                {
                    Control parent = this.Parent;
                    //remove DataGridView from ParentControls
                    parent.Controls.Remove(this);
                    parent.Controls.Add(panel);
                }

                this.BorderStyle = BorderStyle.None;

                panel.BringToFront();


                hScrollBar.Top   = refBox.Height + 2;
                hScrollBar.Width = this.Width;
                hScrollBar.Left  = this.Left;

                summaryControl.Controls.Add(hScrollBar);
                hScrollBar.BringToFront();
                panel.Controls.Add(this);

                spacePanel           = new Panel();
                spacePanel.BackColor = panel.BackColor;
                spacePanel.Height    = summaryRowSpace;
                spacePanel.Dock      = DockStyle.Bottom;

                panel.Controls.Add(spacePanel);
                panel.Controls.Add(summaryControl);

                resizeHScrollBar();
                adjustSumControlToGrid();
                adjustScrollbarToSummaryControl();

                resizeHScrollBar();
            }
        }
Exemple #5
0
        private void LoadTable()
        {
            TableUtility      tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook);
            List <AssetClass> assetClasses = tableUtility.ConvertRangesToObjects <AssetClass>(tableUtility.ReadAllRows(AssetClass.GetDefaultValue().GetTableName()));
            List <Currency>   currencies   = tableUtility.ConvertRangesToObjects <Currency>(tableUtility.ReadAllRows(Currency.GetDefaultValue().GetTableName()));
            int numberOfColumns            = assetClasses.Count + 1;
            int numberOfRows = currencies.Count + 1;

            tableLayoutPanel1.ColumnCount = numberOfColumns + 1;
            tableLayoutPanel1.RowCount    = numberOfRows + 1;

            // First cell, should be empty
            tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>(string.Empty, null), 0, 0);

            Padding padding = Padding.Empty;

            // Add column labels for asset classes
            for (int col = 1; col < numberOfColumns; col++)
            {
                AssetClass assetClass  = assetClasses[col - 1];
                Label      columnLabel = GenerateLabel(assetClass.Name, assetClass);
                tableLayoutPanel1.Controls.Add(columnLabel, col, 0);
            }

            // Add total column
            tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("Total", null), numberOfColumns, 0);

            // Add row labels for currencies
            for (int row = 1; row < numberOfRows; row++)
            {
                Currency currency = currencies[row - 1];
                Label    rowLabel = GenerateLabel(currency.IsoCode, currency);
                tableLayoutPanel1.Controls.Add(rowLabel, 0, row);
            }

            // Add total row
            tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("Total", null), 0, numberOfRows);

            // Add text boxes
            for (int row = 1; row < numberOfRows; row++)
            {
                for (int col = 1; col < numberOfColumns; col++)
                {
                    TextBox textBox = new TextBox
                    {
                        AutoSize    = false,
                        Width       = 200,
                        Height      = 50,
                        Margin      = new Padding(1, 0, 0, 0),
                        BorderStyle = BorderStyle.None,
                        TextAlign   = HorizontalAlignment.Right
                    };
                    textBox.KeyUp += (tb, keyUp) =>
                    {
                        TableLayoutPanelCellPosition position = tableLayoutPanel1.GetPositionFromControl(tb as TextBox);
                        Label  totalAssetClass = tableLayoutPanel1.GetControlFromPosition(position.Column, numberOfRows) as Label;
                        Label  totalCurrency   = tableLayoutPanel1.GetControlFromPosition(numberOfColumns, position.Row) as Label;
                        Label  total           = tableLayoutPanel1.GetControlFromPosition(numberOfColumns, numberOfRows) as Label;
                        double rowSum          = GetRowSum(position.Row);
                        double columnSum       = GetColumnSum(position.Column);
                        totalCurrency.Text   = rowSum.ToString();
                        totalAssetClass.Text = columnSum.ToString();
                        double totalSum = GetTotalSum();
                        total.Text = totalSum.ToString();
                    };
                    textBox.KeyUp += (tb, keyUp) =>
                    {
                        TextBox t = tb as TextBox;
                        bool    cellContentIsNumber = double.TryParse(t.Text, out _);
                        if (!cellContentIsNumber)
                        {
                            t.Clear();
                        }
                    };
                    tableLayoutPanel1.Controls.Add(textBox);
                }
            }

            // Add total labels in last column
            for (int row = 1; row < numberOfRows + 1; row++)
            {
                tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("", null), numberOfColumns, row);
            }

            // Add total labels in last row
            for (int col = 1; col < numberOfColumns; col++)
            {
                tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("", null), col, numberOfRows);
            }
        }
Exemple #6
0
        private void HandleSimpleUIntControlEvent(object sender, SUICEventArgs e)
        {
            Control UIntControl = sender as Control;
            TableLayoutPanelCellPosition pos = TableLayoutPanel.GetCellPosition(UIntControl);

            if (EventHandler != null)
            {
                switch (e.Message)
                {
                case SUICMessage.Return:
                    EventHandler(this, new UITableEventArgs(UITableMessage.Return));
                    break;

                case SUICMessage.ValueChanged:
                    EventHandler(this, new UITableEventArgs(UITableMessage.ValueChanged));
                    break;

                case SUICMessage.Left:
                    if (pos.Column > 0)
                    {
                        pos.Column--;
                    }
                    else if (pos.Column == 0 && pos.Row > 0)
                    {
                        pos.Column = TableLayoutPanel.ColumnCount - 1;
                        pos.Row--;
                    }
                    TableLayoutPanel.GetControlFromPosition(pos.Column, pos.Row).Select();
                    break;

                case SUICMessage.Right:
                    if (pos.Column < TableLayoutPanel.ColumnCount - 1)
                    {
                        pos.Column++;
                    }
                    else if (pos.Column == TableLayoutPanel.ColumnCount - 1 && pos.Row < TableLayoutPanel.RowCount - 1)
                    {
                        pos.Column = 0;
                        pos.Row++;
                    }
                    TableLayoutPanel.GetControlFromPosition(pos.Column, pos.Row).Select();
                    break;

                case SUICMessage.Up:
                    if (pos.Row > 0)
                    {
                        pos.Row--;
                    }
                    TableLayoutPanel.GetControlFromPosition(pos.Column, pos.Row).Select();
                    break;

                case SUICMessage.Down:
                    if (pos.Row < TableLayoutPanel.RowCount - 1)
                    {
                        pos.Row++;
                    }
                    TableLayoutPanel.GetControlFromPosition(pos.Column, pos.Row).Select();
                    break;

                case SUICMessage.Pos1:
                    TableLayoutPanel.GetControlFromPosition(0, 0).Select();
                    break;
                }
            }
        }
        public void TableLayoutSettings_SetCellPosition_ValidControl_GetReturnsExpected(TableLayoutSettings settings, TableLayoutPanelCellPosition value)
        {
            var control = new ScrollableControl();

            settings.SetCellPosition(control, value);
            Assert.Equal(value, settings.GetCellPosition(control));
        }
Exemple #8
0
 public static bool isStart(this TableLayoutPanelCellPosition pos, DateTime date)
 => pos.Column == 6
     ? (int)date.DayOfWeek == 0
     : (int)date.DayOfWeek == pos.Column + 1;
Exemple #9
0
        private async void Start(int num)
        {
            Reset();
            await Task.Delay(500);

            TableLayoutPanelCellPosition p = new TableLayoutPanelCellPosition(0, 3);

            Control[] controls = panel4.Controls.Find("chara", true);
            foreach (PictureBox con in controls)
            {
                Chara = con;
            }

            //前に進む
            if (p.Row != 0)
            {
                p.Row -= 1;
                field.SetCellPosition(Chara, p);
                field.Controls.Add(CreateLine(1), p.Column, p.Row + 1);
                await Task.Delay(1000);
            }

            //右に進む
            //Chara.Image = Rotate(Chara, 1);
            Chara.Image = Image.FromFile(FilePath + "\\images\\L4\\charaR.gif");
            await Task.Delay(1000);

            for (int r = 0; r < 3; r++)
            {
                if (p.Column != 3)
                {
                    p.Column += 1;
                    field.SetCellPosition(Chara, p);
                    if (r == 0)
                    {
                        field.Controls.Add(CreateLine(3), p.Column - 1, p.Row);
                    }
                    else
                    {
                        field.Controls.Add(CreateLine(2), p.Column - 1, p.Row);
                    }
                    await Task.Delay(1000);
                }
            }
            //左に進む
            Chara.Image = Image.FromFile(FilePath + "\\images\\L4\\chara.gif");
            await Task.Delay(1000);

            for (int l = 0; l < 2; l++)
            {
                if (p.Row != 0)
                {
                    p.Row -= 1;
                    field.SetCellPosition(Chara, p);
                    if (l == 0)
                    {
                        field.Controls.Add(CreateLine(4), p.Column, p.Row + 1);
                    }
                    else
                    {
                        field.Controls.Add(CreateLine(1), p.Column, p.Row + 1);
                    }
                    await Task.Delay(1000);
                }
            }
            if (num == 1)
            {
                PictureBox yes = new PictureBox();
                yes.Name     = "yes";
                yes.Size     = new Size(1228, 593);
                yes.SizeMode = PictureBoxSizeMode.StretchImage;
                yes.Image    = Image.FromFile(FilePath + "\\images\\seikai.gif");
                yes.Parent   = panel4;
                panel4.Controls.Add(yes);
                yes.BringToFront();
                await Task.Delay(2800);

                Control[] c = panel4.Controls.Find("yes", true);
                foreach (Control con in c)
                {
                    panel4.Controls.Remove(con);
                }
            }
            else
            {
                PictureBox no = new PictureBox();
                no.Name     = "no";
                no.Size     = new Size(1228, 593);
                no.SizeMode = PictureBoxSizeMode.StretchImage;
                no.Image    = Image.FromFile(FilePath + "\\images\\matigai.gif");
                no.Parent   = panel4;
                panel4.Controls.Add(no);
                no.BringToFront();
                await Task.Delay(2800);

                Control[] c = panel4.Controls.Find("no", true);
                foreach (Control con in c)
                {
                    panel4.Controls.Remove(con);
                }
            }
        }
Exemple #10
0
 public static bool isEnd(this TableLayoutPanelCellPosition pos)
 => pos.Column == 0;
Exemple #11
0
        public static TableLayoutPanelCellPosition GetCellPosotion(TableLayoutPanel panel)//wyznacza pozycje kursora szchownicy - znalezione w necie
        {
            //mouse position
            Point p = panel.PointToClient(Control.MousePosition);
            //Cell position
            TableLayoutPanelCellPosition pos = new TableLayoutPanelCellPosition(0, 0);
            //Panel size.
            Size size = panel.Size;
            //average cell size.
            SizeF cellAutoSize = new SizeF(size.Width / panel.ColumnCount, size.Height / panel.RowCount);

            //Get the cell row.
            //y coordinate
            float y = 0;

            for (int i = 0; i < panel.RowCount; i++)
            {
                //Calculate the summary of the row heights.
                SizeType type   = panel.RowStyles[i].SizeType;
                float    height = panel.RowStyles[i].Height;
                switch (type)
                {
                case SizeType.Absolute:
                    y += height;
                    break;

                case SizeType.Percent:
                    y += height / 100 * size.Height;
                    break;

                case SizeType.AutoSize:
                    y += cellAutoSize.Height;
                    break;
                }
                //Check the mouse position to decide if the cell is in current row.
                if ((int)y > p.Y)
                {
                    pos.Row = i;
                    break;
                }
            }

            //Get the cell column.
            //x coordinate
            float x = 0;

            for (int i = 0; i < panel.ColumnCount; i++)
            {
                //Calculate the summary of the row widths.
                SizeType type  = panel.ColumnStyles[i].SizeType;
                float    width = panel.ColumnStyles[i].Width;
                switch (type)
                {
                case SizeType.Absolute:
                    x += width;
                    break;

                case SizeType.Percent:
                    x += width / 100 * size.Width;
                    break;

                case SizeType.AutoSize:
                    x += cellAutoSize.Width;
                    break;
                }
                //Check the mouse position to decide if the cell is in current column.
                if ((int)x > p.X)
                {
                    pos.Column = i;
                    break;
                }
            }

            //return the mouse position.
            return(pos);
        }
 public void SetCellPosition(object control, TableLayoutPanelCellPosition cellPosition)
 {
 }
Exemple #13
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (GameOver == true)
            {
                timer1.Enabled = false;
                DialogResult   = MessageBox.Show(string.Format("Your Sore is {0}. Dou you want to restart the game ", snake.Count), "Game Over", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (DialogResult == DialogResult.Cancel)
                {
                    SaveSore(labelLen.Text);
                    Application.Exit();
                }
                else
                {
                    SaveSore(labelLen.Text);
                    Application.Restart();
                }
            }
            else
            {
                label4.Text     = Convert.ToString(Convert.ToDouble((10000 / timer1.Interval)) + " mph");
                labelSpeed.Text = Convert.ToString(tableLayoutPanel1.GetPositionFromControl(panelHead));
                defX            = tableLayoutPanel1.GetColumn(panelHead);
                defY            = tableLayoutPanel1.GetRow(panelHead);
                TableLayoutPanelCellPosition newPos;
                if (KeyVal == 'D' || KeyVal == 'd')
                {
                    if (tableLayoutPanel1.GetColumn(snake[0]) == tableLayoutPanel1.ColumnCount - 1)
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = 0, Row = defY
                        }
                    }
                    ;
                    else
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = defX + 1, Row = defY
                        }
                    };
                    move(newPos);
                }

                if (KeyVal == 'S' || KeyVal == 's')
                {
                    if (tableLayoutPanel1.GetRow(snake[0]) == tableLayoutPanel1.RowCount - 1)
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = defX, Row = 0
                        }
                    }
                    ;
                    else
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = defX, Row = defY + 1
                        }
                    };
                    move(newPos);
                }

                if (KeyVal == 'A' || KeyVal == 'a')
                {
                    if (tableLayoutPanel1.GetColumn(snake[0]) == 0)
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = tableLayoutPanel1.ColumnCount - 1, Row = defY
                        }
                    }
                    ;
                    else
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = defX - 1, Row = defY
                        }
                    };
                    move(newPos);
                }
                if (KeyVal == 'W' || KeyVal == 'w')
                {
                    if (tableLayoutPanel1.GetRow(snake[0]) == 0)
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = defX, Row = tableLayoutPanel1.RowCount - 1
                        }
                    }
                    ;
                    else
                    {
                        newPos = new TableLayoutPanelCellPosition()
                        {
                            Column = defX, Row = defY - 1
                        }
                    };
                    move(newPos);
                }

                if (Convert.ToInt32(labelLen.Text) >= (25) && Convert.ToInt32(labelLen.Text) <= 45)
                {
                    timer1.Interval = 100;
                }
                else if (Convert.ToInt32(labelLen.Text) >= (45) && Convert.ToInt32(labelLen.Text) <= 65)
                {
                    timer1.Interval = 80;
                }
                else if (Convert.ToInt32(labelLen.Text) >= (65) && Convert.ToInt32(labelLen.Text) <= 90)
                {
                    timer1.Interval = 75;
                }
                else if (Convert.ToInt32(labelLen.Text) >= (90) && Convert.ToInt32(labelLen.Text) <= 120)
                {
                    timer1.Interval = 65;
                }
            }
        }
Exemple #14
0
 private void SelectCell(TableLayoutPanelCellPosition pos)
 {
     vm.Cells[vm.Selected.Column, vm.Selected.Row].BackColor = GetCellBgColor(vm.Selected.Column, vm.Selected.Row);
     vm.Selected = pos;
     vm.Cells[vm.Selected.Column, vm.Selected.Row].BackColor = Color.White;
 }