Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     dt = DateTime.Parse(dt.ToShortDateString()).AddMonths(-1);
     table.Controls.Clear();
     table.Refresh();
     tablePrint();
 }
Esempio n. 2
0
        public static void RemoveRow(this TableLayoutPanel tableLayoutPanel, int rowNumber)
        {
            ArrayList controls = new ArrayList(tableLayoutPanel.Controls);

            foreach (Control control in controls)
            {
                int row = tableLayoutPanel.GetRow(control);
                if (row == rowNumber)
                {
                    tableLayoutPanel.Controls.Remove(control);
                }
            }
            tableLayoutPanel.RowStyles.RemoveAt(rowNumber);
            foreach (Control control in tableLayoutPanel.Controls)
            {
                int row = tableLayoutPanel.GetRow(control);
                if (row > rowNumber)
                {
                    tableLayoutPanel.SetRow(control, row - 1);
                }
            }
            tableLayoutPanel.PerformLayout();
            tableLayoutPanel.ResumeLayout(true);
            tableLayoutPanel.Refresh();
        }
Esempio n. 3
0
        private void drawTable(TableLayoutPanel table, bool solve = false)
        {
            table.RowCount    = rowscount;
            table.ColumnCount = columnscount;

            this.Height = table.Height / table.RowCount;

            for (int i = 0; i < table.RowCount; i++)
            {
                table.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, (float)this.Height));
            }



            this.Width = table.Width / table.ColumnCount;
            Console.WriteLine(" table.Height : " + table.Height.ToString() + "\t table.Width: " + table.Width.ToString());
            Console.WriteLine(" Height : " + Height.ToString() + "\t Width: " + Width.ToString());
            for (int i = 0; i < table.ColumnCount; i++)
            {
                table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, (float)this.Width));
            }
            if (!solve)
            {
                boardPicture = new List <PictureBox>();
                for (int i = 0; i < table.RowCount; i++)
                {
                    for (int j = 0; j < table.ColumnCount; j++)
                    {
                        PictureBox box;
                        if (userBoard[i, j] == 0)
                        {
                            box = createPictureBox(false);
                        }
                        else
                        {
                            box = createPictureBox(true);
                        }
                        this.boardPicture.Add(box);
                        table.Controls.Add(box, j, i);
                        //box.SendToBack();
                        box.Click += new EventHandler(this.clcikeventhandle);
                    }
                }
                //table.BringToFront();
            }
            else
            {
                solveLabel = new List <Label>();
                for (int i = 0; i < table.RowCount; i++)
                {
                    for (int j = 0; j < table.ColumnCount; j++)
                    {
                        table.Controls.Add(createLabel(i, j), j, i);
                    }
                }

                //table.Click += new clcikeventhandle(this.clickCell);
            }
            table.Refresh();
        }
        private void DiagDiffPopulateTable(TableLayoutPanel table)
        {
            table.ColumnCount = diagDiff.InputLength;
            table.RowCount    = diagDiff.InputLength;

            //TableLayoutControlCollection diagDiffNumbers = new TableLayoutControlCollection(table);


            for (int i = 0; i < diagDiff.InputLength; i++)
            {
                for (int j = 0; j < diagDiff.InputLength; j++)
                {
                    var cellText = new System.Windows.Forms.Label();
                    cellText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
                                                                              | System.Windows.Forms.AnchorStyles.Bottom)
                                                                             | System.Windows.Forms.AnchorStyles.Left)
                                                                            | System.Windows.Forms.AnchorStyles.Right)));
                    cellText.AutoSize  = true;
                    cellText.Font      = new System.Drawing.Font("Fira Code Retina", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
                    cellText.Text      = diagDiff.Arr[i][j].ToString();
                    cellText.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                    table.Controls.Add(cellText, i, j);
                }
            }
            table.Refresh();
            var stop = true;
        }
        private TableLayoutPanel BuildPanel(List <Consumable> Upgrades, int Position = 0, int Max = 4)
        {
            TableLayoutPanel uPanel = new TableLayoutPanel();

            uPanel.AutoSize = true;
            uPanel.Controls.Clear();
            uPanel.RowStyles.Clear();
            uPanel.RowCount = 0;

            uPanel.ColumnCount = 1;
            uPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 500F));

            int count = 0;

            for (int c = 0; c < Upgrades.Count; c++)
            {
                if (Position != 0 && c <= Position - 1)
                {
                    continue;
                }
                else if (count >= Max)
                {
                    break;
                }
                Consumable upgrade = Upgrades[c];

                int        posY = (count * 65) + 10;
                PictureBox box  = GeneratePictureBox(upgrade, posY);
                uPanel.RowCount += 1;
                uPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F));
                uPanel.Controls.Add(box, 0, uPanel.RowCount - 1);

                Label head = GenerateHeadline(upgrade.Name);
                uPanel.RowCount += 1;
                uPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 18F));
                uPanel.Controls.Add(head, 0, uPanel.RowCount - 1);

                string labelText;
                // Hardcoded correction of incorrect text of upgrade 4286762928
                if (upgrade.ID == 4286762928)
                {
                    labelText = "Decreases reload time of torpedo tubes.\nTorpedo tubes reload time: -15%\nRisk of torpedo tubes becoming incapacitated: +50%";
                }
                else
                {
                    string perks = ExtractPerks(upgrade);
                    labelText = upgrade.Description + perks;
                }
                Label text = GenerateTextLabel(labelText, box.Height);
                uPanel.RowCount += 1;
                uPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 70F));
                uPanel.Controls.Add(text, 0, uPanel.RowCount - 1);

                count++;
            }
            uPanel.Refresh();

            return(uPanel);
        }
Esempio n. 6
0
        /// <summary>
        /// Draws the grid to the layout panel
        /// </summary>
        public virtual void Render()
        {
            // Also call playground
            PlayGround.Render();

            if (!isDirty)
            {
                return;
            }
            tableLayoutPanel.Refresh();
            isDirty = false;
        }
Esempio n. 7
0
        private void RescaleBarGraphs()
        {
            //recompute the new cell percentages
            float newPercentage = 1.0f / (float)t.ColumnCount;

            for (int i = 0; i < t.ColumnStyles.Count; i++)
            {
                t.ColumnStyles[i].Width = newPercentage;
            }
            SetCommonYAxis();
            t.Refresh();
        }
        private void setLayoutTLPCatMain()
        {
            tLPCatMain.SuspendLayout();

            createLHeaderCat();
            createLVCategories();
            createFLPCatBottom();

            tLPCatMain.Controls.Add(lHeaderCat, 0, 0);
            tLPCatMain.Controls.Add(lVCategories, 0, 1);
            tLPCatMain.Controls.Add(fLPCatBottom, 0, 2);

            tLPCatMain.ResumeLayout();
            tLPCatMain.Refresh();
        }
Esempio n. 9
0
        /// <summary>
        /// Displays the current mask.
        /// </summary>
        /// <param name="difficulty"></param>
        /// <param name="tlp"></param>
        public void ShowMask(ExerciceDifficulty difficulty, TableLayoutPanel tlp)
        {
            tlp.Visible = true;

            tlp.Refresh();

            switch (difficulty)
            {
            case ExerciceDifficulty.Easy:
                Thread.Sleep(ExercicePerception.timeEasy * 1000);     // Wait 2 seconds, but freeze the thread (and UI)
                break;

            case ExerciceDifficulty.Hard:
                Thread.Sleep(ExercicePerception.timeHard * 1000);
                //System.Threading.Tasks.Task.Delay(4000); //Needs the Microsoft .NET framework 4.5 and higher.
                break;

            default:
                throw new NotImplementedException();
            }

            tlp.Visible = false;
        }
Esempio n. 10
0
 /// <summary>
 /// Load selected layer into map grid
 /// </summary>
 /// <param name="layer"></param>
 public void fillMap(int layer)
 {
     mapSetTextBoxValues(layer);
     mapSetFullColor();
     tableFullMap.Refresh();
 }
Esempio n. 11
0
 void EndWait(TableLayoutPanel label)
 {
     label.BackColor = this.BackColor;
     label.Refresh();
 }
Esempio n. 12
0
 void BeginWait(TableLayoutPanel label)
 {
     label.BackColor = Color.Orange;
     label.Refresh();
 }
Esempio n. 13
0
        public static void updateFeePaymentTable(bool forceUpdate)
        {
            if (!forceUpdate && initialized == false)
            {
                return;
            }
            if (selectedStudent == null)
            {
                return;
            }
            tableLayoutPanel1.Hide();
            clearFeePaymentTable(false);
            checkBoxes.Clear();
            pendingPayments.Clear();
            selectedPayments.Clear();
            calculateTotalFee();
            labelResultTotalFee.Text = "0.00";
            textBoxCash.Text         = "";

            List <Payment> pments = new List <Payment>();

            selectedStudent.loadOldPendingPayment();
            List <Payment> oldPayments = selectedStudent.getOldPendingPayment();
            List <Payment> newPayments = selectedStudent.getNewPendingPayment();

            if (oldPayments != null && oldPayments.Count != 0)
            {
                pments.AddRange(oldPayments);
            }
            if (newPayments != null && newPayments.Count != 0)
            {
                pments.AddRange(newPayments);
            }
            if (pments == null || pments.Count == 0)
            {
                tableLayoutPanel1.Show();
                return;
            }
            pendingPayments = pments;
            int rows = pments.Count;

            tableLayoutPanel1.RowCount = rows + 2;
            int i = 1;

            foreach (var payment in pments)
            {
                if (payment.getPaidStatus() == true)
                {
                    continue;
                }
                tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
                tableLayoutPanel1.Controls.Add(newCheckBox(payment), 0, i);
                tableLayoutPanel1.Controls.Add(newLabel(i.ToString(), System.Drawing.FontStyle.Regular, ContentAlignment.MiddleCenter), 1, i);
                Course.loadCourses();
                Course course   = Course.getCourseById(payment.getCourseId());
                string itemName = "NaN";
                if (course != null)
                {
                    itemName = course.getCourseName();
                }
                tableLayoutPanel1.Controls.Add(newLabel(itemName, System.Drawing.FontStyle.Regular, ContentAlignment.MiddleLeft), 2, i);
                tableLayoutPanel1.Controls.Add(newLabel(payment.getIssueDate().ToString("dd/MM/yyyy"), System.Drawing.FontStyle.Regular, ContentAlignment.MiddleCenter), 3, i);
                tableLayoutPanel1.Controls.Add(newLabel(payment.getFee().ToString(), System.Drawing.FontStyle.Regular, ContentAlignment.MiddleCenter), 4, i);
                i++;
            }
            tableLayoutPanel1.Show();
            tableLayoutPanel1.Refresh();
        }
Esempio n. 14
0
        private void Searcher_Resize(object sender, EventArgs e)
        {
            panel2.Controls.Clear();
            for (int i = 0; i < list.Count; i++)
            {
                TableLayoutPanel panel = new TableLayoutPanel();
                panel.Width           = panel2.Width;
                panel.Height          = 120;
                panel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
                panel.RowCount        = 2;
                panel.ColumnCount     = 3;
                panel.RowStyles.Clear();
                for (int j = 0; j < 2; j++)
                {
                    panel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
                }
                panel.ColumnStyles.Clear();
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 120));
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
                panel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150));

                PictureBox box = new PictureBox()
                {
                    Width = 120, Height = 120
                };
                box.Margin   = new Padding(0);
                box.SizeMode = PictureBoxSizeMode.StretchImage;
                try
                {
                    box.Image = Image.FromStream(new MemoryStream(Convert.FromBase64String(list[i].preview)));
                }
                catch (Exception ex) { }
                panel.Controls.Add(box, 0, 0);
                panel.SetRowSpan(box, 2);


                Label name = new Label()
                {
                    Text = list[i].name, Dock = DockStyle.Fill, TextAlign = ContentAlignment.TopCenter
                };
                panel.Controls.Add(name, 1, 0);

                Label desc = new Label()
                {
                    Text = list[i].description, Dock = DockStyle.Fill, TextAlign = ContentAlignment.TopCenter
                };
                panel.Controls.Add(desc, 1, 1);

                Button add = new Button()
                {
                    Text = "Добавить", Width = 130, Anchor = AnchorStyles.None
                };
                int buff = i;
                add.MouseClick += (a, b) => { listAddClick(buff); };
                panel.Controls.Add(add, 2, 0);

                Button adv = new Button()
                {
                    Text = "Подробности", Width = 130, Anchor = AnchorStyles.None
                };
                adv.MouseClick += (a, b) => { listAdvClick(buff); };
                panel.Controls.Add(adv, 2, 1);

                panel2.Controls.Add(panel);
                panel.Location = new Point(0, 121 * i);
                panel.Refresh();
            }
        }
Esempio n. 15
0
        public static void StartEmulation(TableLayoutPanel table)
        {
            //pre init
            count_used = 0;
            found_flag = false;

            //init
            List <Drone> drones = new List <Drone>
            {
                new Drone(1, start_x, start_y, 0, 1),
                new Drone(2, start_x, start_y, 1, 0),
                new Drone(3, start_x, start_y, 0, -1),
                new Drone(4, start_x, start_y, -1, 0)
            };
            double gbest   = -1;
            int    gbest_x = -1;
            int    gbest_y = -1;

            //start_point processing
            used[start_y, start_x] = true;
            count_used++;
            PaintUsedCell(table, start_x, start_y, probability[start_y, start_x]);

            for (int i = 0; i < drones.Count; i++)
            {
                drones[i].UpdateBest(probability[start_y, start_x], start_x, start_y);
            }
            if (probability[start_y, start_x] > gbest)
            {
                gbest   = probability[start_y, start_x];
                gbest_x = start_x;
                gbest_y = start_y;
            }

            //Main search cycle (Particle swarm optimization)
            while (!(count_used == Settings.Area || found_flag))
            {
                for (int i = 0; i < drones.Count; i++)
                {
                    int x0 = drones[i].x;
                    int y0 = drones[i].y;

                    drones[i].UpdateV(gbest_x, gbest_y);
                    drones[i].Move(used);
                    int x = drones[i].x;
                    int y = drones[i].y;
                    PaintDroneMove(table, x0, y0, x, y, drones[i].id);

                    double w = probability[y, x];
                    if (w == Settings.ProbabilityEnd)
                    {
                        found_flag = true;
                    }

                    drones[i].UpdateBest(w, x, y);
                    if (w > gbest)
                    {
                        gbest   = w;
                        gbest_x = x;
                        gbest_y = y;
                    }

                    used[y, x] = true;
                    count_used++;
                    PaintUsedCell(table, x, y, w);

                    //break if found or full explored
                    if (count_used == Settings.Area || found_flag)
                    {
                        break;
                    }
                }

                //Thread.Sleep(Settings.StepSleep);
                table.Refresh();
            }
        }
Esempio n. 16
0
        /// <summary>
        ///     TODO
        /// </summary>
        private void PopulatePal()
        {
            var acCurDoc = Application.DocumentManager.MdiActiveDocument;

            if (acCurDoc == null)
            {
                return;
            }

            var acCurDb = acCurDoc.Database;

            const int imageColumn  = 0;
            const int buttonColumn = 1;
            const int barOffset    = 10;
            const int buttonOffset = 1;
            const int buttonHeight = 25;

            var backColor = Colors.GetCadBackColor();
            var foreColor = Colors.GetCadForeColor();
            var textColor = Colors.GetCadTextColor();

            var rowCounter = 0;

            try
            {
                using (acCurDoc.LockDocument())
                {
                    _palPanel.SuspendLayout();
                    _palPanel.BackColor = backColor;
                    _palPanel.Controls.Clear();
                    _palPanel.AutoScroll = false;

                    #region Table Layout

                    var palLayout = new TableLayoutPanel
                    {
                        AutoScroll   = true,
                        AutoSizeMode = AutoSizeMode.GrowAndShrink,
                        BackColor    = Colors.GetCadBackColor(),
                        ForeColor    = Colors.GetCadForeColor(),
                        ColumnCount  = 3,
                        Dock         = DockStyle.Fill
                    };

                    palLayout.MouseEnter += (s, e) => palLayout.Focus();

                    palLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 25F));
                    palLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                    palLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 5F));

                    #endregion

                    using (var acTrans = acCurDb.TransactionManager.StartTransaction())
                    {
                        var layerGroups = acCurDb.GetLayerTableRecord(acTrans, 0)
                                          .GroupBy(layer => layer.Name.Split(SettingsUser.LayerDelimiter)[0])
                                          .OrderBy(layer => layer.Key);

                        foreach (var group in layerGroups)
                        {
                            palLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, buttonHeight + 5));

                            if (group.Count() > 1)
                            {
                                var spButton = new SplitButton
                                {
                                    ShowSplit        = true,
                                    BackColor        = foreColor,
                                    ForeColor        = textColor,
                                    Dock             = DockStyle.Fill,
                                    Height           = buttonHeight,
                                    ContextMenuStrip = new ContextMenuStrip(),
                                    FlatStyle        = FlatStyle.Flat
                                };

                                spButton.Click += Button_Click;
                                spButton.FlatAppearance.BorderColor       = Colors.GetCadBorderColor();
                                spButton.FlatAppearance.BorderSize        = 1;
                                spButton.ContextMenuStrip.BackColor       = foreColor;
                                spButton.ContextMenuStrip.ForeColor       = textColor;
                                spButton.ContextMenuStrip.ShowImageMargin = false;
                                spButton.ContextMenuStrip.ShowCheckMargin = false;

                                Color spColor    = null;
                                var   firstParse = true;

                                foreach (var layer in group)
                                {
                                    if (firstParse)
                                    {
                                        spButton.Text = layer.Name;
                                        spColor       = layer.Color;
                                        firstParse    = false;
                                    }

                                    var tsButton = new ToolStripButton(layer.Name, GetLayerImage(layer.Color),
                                                                       ContextItem_Click)
                                    {
                                        ImageAlign = TopLeft,
                                        TextAlign  = BottomLeft,
                                        BackColor  = foreColor,
                                        ForeColor  = textColor
                                    };

                                    spButton.ContextMenuStrip.Items.Add(tsButton);
                                }

                                var picBox = new PictureBox
                                {
                                    Height = buttonHeight,
                                    Image  = GetLayerImage(spColor),
                                    Dock   = DockStyle.Fill
                                };

                                palLayout.Controls.Add(spButton, buttonColumn, rowCounter);
                                palLayout.Controls.Add(picBox, imageColumn, rowCounter);
                                rowCounter++;
                            }
                            else
                            {
                                var layer = group.First();

                                var button = new Button
                                {
                                    Text      = layer.Name,
                                    BackColor = foreColor,
                                    ForeColor = textColor,
                                    Dock      = DockStyle.Fill,
                                    Height    = buttonHeight,
                                    FlatStyle = FlatStyle.Flat
                                };

                                button.Click += Button_Click;
                                button.FlatAppearance.BorderColor = Colors.GetCadBorderColor();
                                button.FlatAppearance.BorderSize  = 1;

                                var picBox = new PictureBox
                                {
                                    Height = buttonHeight,
                                    Image  = GetLayerImage(layer.Color),
                                    Dock   = DockStyle.Fill
                                };


                                palLayout.Controls.Add(button, buttonColumn, rowCounter);
                                palLayout.Controls.Add(picBox, imageColumn, rowCounter);
                                rowCounter++;
                            }
                        }

                        //Add a blank label to the final row to keep from having a giant row at the bottom
                        var blankLabel = new Label {
                            Height = buttonHeight
                        };
                        palLayout.Controls.Add(blankLabel, buttonColumn, rowCounter + 1);
                        palLayout.RowCount++;

                        acTrans.Commit();
                    }

                    palLayout.AutoScroll = true;
                    palLayout.AutoSize   = true;
                    palLayout.Refresh();

                    if (palLayout.VerticalScroll.Visible)
                    {
                        palLayout.ColumnStyles[2].SizeType = SizeType.Absolute;
                        palLayout.ColumnStyles[2].Width    = barOffset;
                    }
                    else
                    {
                        palLayout.ColumnStyles[2].SizeType = SizeType.Absolute;
                        palLayout.ColumnStyles[2].Width    = buttonOffset;
                    }

                    palLayout.Refresh();

                    var bLayout = new TableLayoutPanel
                    {
                        BackColor   = Colors.GetCadBackColor(),
                        ForeColor   = Colors.GetCadForeColor(),
                        ColumnCount = 2,
                        Height      = 30,
                        Dock        = DockStyle.Bottom
                    };

                    bLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80F));
                    bLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
                    bLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 30f));


                    var loadButton = new Button();
                    loadButton.Click    += Load_Click;
                    loadButton.Text      = "Load From Dwg";
                    loadButton.BackColor = foreColor;
                    loadButton.ForeColor = textColor;
                    loadButton.Dock      = DockStyle.Fill;
                    loadButton.Height    = 30;
                    loadButton.FlatStyle = FlatStyle.Flat;
                    loadButton.FlatAppearance.BorderColor = Colors.GetCadBorderColor();
                    loadButton.FlatAppearance.BorderSize  = 1;

                    var updButton = new Button();
                    updButton.Click     += Update_Click;
                    updButton.Image      = Properties.Resources.RcUpdate16X16__I_;
                    updButton.ImageAlign = MiddleCenter;
                    updButton.BackColor  = foreColor;
                    updButton.ForeColor  = textColor;
                    updButton.Dock       = DockStyle.Fill;
                    loadButton.Height    = 30;
                    updButton.FlatStyle  = FlatStyle.Flat;
                    updButton.FlatAppearance.BorderColor = Colors.GetCadBorderColor();
                    updButton.FlatAppearance.BorderSize  = 1;

                    bLayout.Controls.Add(loadButton, 0, 0);
                    bLayout.Controls.Add(updButton, 1, 0);

                    _palPanel.Controls.Add(palLayout);
                    _palPanel.Controls.Add(bLayout);

                    _palPanel.ResumeLayout();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 17
0
        //======================================================================
        // Add a button for each attached monitor
        //======================================================================
        public static void UpdateMonitorPanelScreens(TableLayoutPanel monitorPanel)
        {
            // Create list of controls and then remove them all
            var controlsToRemove = new List <Control>();

            foreach (Control item in monitorPanel.Controls.OfType <PictureBox>())
            {
                controlsToRemove.Add(item);
            }

            foreach (Control item in monitorPanel.Controls.OfType <Label>())
            {
                controlsToRemove.Add(item);
            }

            foreach (Control item in controlsToRemove)
            {
                monitorPanel.Controls.Remove(item);
                item.Dispose();
            }

            // Get number of attached monitors
            var screens = Screen.AllScreens.Length;

            // Auto add a table to nest the monitor images and labels
            monitorPanel.Refresh();
            monitorPanel.ColumnStyles.Clear();
            monitorPanel.RowStyles.Clear();
            monitorPanel.ColumnCount = screens;
            monitorPanel.RowCount    = 2;
            monitorPanel.AutoSize    = true;

            var z = 0;

            foreach (var screen in Screen.AllScreens.OrderBy(i => i.Bounds.X))
            {
                monitorPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f / screens));

                var monitorImg = Resources.display_enabled;
                var x          = 100;
                var y          = 75;

                if (screens >= 4)
                {
                    monitorImg = Resources.display_enabled_small;
                    x          = 64;
                    y          = 64;
                }

                var monitor = new PictureBox
                {
                    Name = "MonitorPic" + z,
                    Size = new Size(x, y),
                    BackgroundImageLayout = ImageLayout.Stretch,
                    BackgroundImage       = monitorImg,
                    Anchor = AnchorStyles.None,
                };

                var resolution = new Label
                {
                    Name      = "MonitorLabel" + z,
                    TextAlign = ContentAlignment.MiddleCenter,
                    Font      = new Font("Segoe UI", 9),
                    ForeColor = Color.Black,
                    BackColor = Color.Transparent,
                    AutoSize  = true,
                    Text      = "DISPLAY " + z + "\r\n" + screen.Bounds.Width + "x" + screen.Bounds.Height,
                    Anchor    = AnchorStyles.None,
                };

                monitorPanel.Controls.Add(monitor, z, 0);
                monitorPanel.Controls.Add(resolution, z, 1);

                z++;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 将查询结果显示到表格
        /// </summary>
        /// <param name="results"></param>
        /// <param name="table"></param>
        private void putResultsToTable(List <Dictionary <String, String> > results, TableLayoutPanel table)
        {
            table.Controls.Clear();
            if (results == null || results.Count == 0 || table == null)
            {
                table.RowCount = 1;
                Label tip = new Label();
                tip.AutoSize  = true;
                tip.Text      = "未找到相关提示";
                tip.ForeColor = Color.Red;
                table.Controls.Add(tip, 0, 0);
                table.Refresh();
                return;
            }

            //设置表格默认样式
            // 表头 + 数据
            table.RowCount = results.Count + 1;
            table.Height   = table.RowCount * 40;

            Label questionLabel   = new Label();
            Label similarityLabel = new Label();
            Label enrollTimeLabel = new Label();

            questionLabel.Text       = "题目描述";
            similarityLabel.Text     = "题目相似度";
            enrollTimeLabel.Text     = "加入时间";
            questionLabel.Anchor     = AnchorStyles.Left;
            questionLabel.AutoSize   = true;
            similarityLabel.Anchor   = AnchorStyles.Left;
            similarityLabel.AutoSize = true;
            enrollTimeLabel.Anchor   = AnchorStyles.Left;
            enrollTimeLabel.AutoSize = true;
            table.Controls.Add(questionLabel, 0, 0);
            table.Controls.Add(similarityLabel, 1, 0);
            table.Controls.Add(enrollTimeLabel, 2, 0);

            table.RowStyles.Clear();
            for (int i = 0; i < table.RowCount; i++)
            {
                table.RowStyles.Add(new RowStyle(System.Windows.Forms.SizeType.Absolute, 80));
            }

            for (int i = 0; i < results.Count; i++)
            {
                Label question = new Label();
                question.Text     = results[i]["question"];
                question.Anchor   = AnchorStyles.Left;
                question.AutoSize = true;
                table.Controls.Add(question, 0, i + 1);
                Label similarity = new Label();
                similarity.Text     = results[i]["similarity"];
                similarity.Anchor   = AnchorStyles.Left;
                similarity.AutoSize = true;
                table.Controls.Add(similarity, 1, i + 1);
                Label enrollTime = new Label();
                enrollTime.Text     = results[i]["enrollTime"];
                enrollTime.Anchor   = AnchorStyles.Left;
                enrollTime.AutoSize = true;
                table.Controls.Add(enrollTime, 2, i + 1);
            }
            table.Refresh();
            showMessage("已完成,共找到" + results.Count + "条结果");
        }
        /// <summary>
        /// Get Default Style For Table Layout Panel Right , Bottom and Main (History)
        /// </summary>
        /// <param name="firstTLP">tlpBottom</param>
        /// <param name="mainTLP">tlpMain</param>
        /// <param name="RowStyleCal">RowStyleCal refers to new instance of TableLayoutRowStyleCollection</param>
        /// <param name="secondTLP">tlpRight</param>
        public void GetDefaultStyle(TableLayoutPanel firstTLP, TableLayoutPanel mainTLP,
                                    TableLayoutRowStyleCollection RowStyleCal, TableLayoutPanel secondTLP)//Completed Check of Syntax Code ***
        {
            firstTLP.Visible = true;
            firstTLP.Anchor  = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            firstTLP.Dock    = DockStyle.None;

            // make Refresh for Table Layout Panel Right
            secondTLP.Refresh();
            secondTLP.Dock     = DockStyle.Right;
            secondTLP.Size     = new Size(254, 486);
            secondTLP.Location = new Point(298, 0);


            // For Table Layout Panel Main
            //Declare integer Variable to loop in rows of table layout panel
            int rowCount = 0;

            // For Table Layout Panel Right
            RowStyleCal = secondTLP.RowStyles;
            foreach (RowStyle rs in RowStyleCal)
            {
                rs.SizeType = SizeType.Percent;
                if (rowCount == 0)
                {
                    rs.Height = 6;
                }
                else if (rowCount == 1)
                {
                    rs.Height = 3;
                }
                else if (rowCount == 2)
                {
                    rs.Height = 84;
                }
                else if (rowCount == 3)
                {
                    rs.Height = 7;
                }
                rowCount += 1;
            }

            // For Table Layout Panel Main
            // redefine the counter
            rowCount    = 0;
            RowStyleCal = mainTLP.RowStyles;
            foreach (RowStyle rs in RowStyleCal)
            {
                rs.SizeType = SizeType.Percent;
                if (rowCount == 0)
                {
                    rs.Height = 10;
                }
                else if (rowCount == 1)
                {
                    rs.Height = 11;
                }
                else if (rowCount == 2)
                {
                    rs.Height = 16;
                }
                else if (rowCount == 3)
                {
                    rs.Height = 63;
                }
                rowCount += 1;
            }
        }