예제 #1
0
 private void Init()
 {
     layoutPanel = new TableLayoutPanel();
     layoutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.InsetDouble;
     layoutPanel.Dock = DockStyle.Fill;
     this.machinePanel.Controls.Add(layoutPanel);
     int row = 4, col = 4;
     DynamicLayout(layoutPanel, row, col);
     int index = 1;
     for (int i = 0; i < row; i++)
     {
         for (int j = 0; j < col; j++)
         {
             MachineControl machine = new MachineControl();
             uiMachines[index-1] = machine;
             machine.Dock = DockStyle.Fill;
             //machine.IPAddress = string.Format("192.168.0.{0:G}", 4 + index);
             machine.IPAddress = MainForm.Sixteen_IP[index - 1];
             machine.anotherName = MainForm.Sixteen_Name[index - 1];
             layoutPanel.Controls.Add(machine);
             layoutPanel.SetRow(machine, i);
             layoutPanel.SetColumn(machine, j);
             index++;
         }
     }
 }
예제 #2
0
		public void TestExtenderMethods ()
		{
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c = new Button ();

			Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetCellPosition (c), "A1");
			Assert.AreEqual (-1, p.GetColumn (c), "A2");
			Assert.AreEqual (1, p.GetColumnSpan (c), "A3");
			Assert.AreEqual (-1, p.GetRow (c), "A4");
			Assert.AreEqual (1, p.GetRowSpan (c), "A5");

			p.SetCellPosition (c, new TableLayoutPanelCellPosition (1, 1));
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetCellPosition (c), "A6");

			p.SetColumn (c, 2);
			Assert.AreEqual (2, p.GetColumn (c), "A7");
			p.SetRow (c, 2);
			Assert.AreEqual (2, p.GetRow (c), "A9");

			p.SetColumnSpan (c, 2);
			Assert.AreEqual (2, p.GetColumnSpan (c), "A8");


			p.SetRowSpan (c, 2);
			Assert.AreEqual (2, p.GetRowSpan (c), "A10");

			Assert.AreEqual (new TableLayoutPanelCellPosition (2, 2), p.GetCellPosition (c), "A11");

			// ???????
			//Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetPositionFromControl (c), "A12");
			//Assert.AreEqual (c, p.GetControlFromPosition(0, 0), "A13");
		}
예제 #3
0
		public void TestCellPositioning12 ()
		{
			// Requesting a column greater than ColumnCount, request is ignored
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetColumn (c1, 4);

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
		}
예제 #4
0
		public void TestCellPositioning7 ()
		{
			// One control has fixed column and row
			TableLayoutPanel p = new TableLayoutPanel ();
			Control c1 = new Button ();
			Control c2 = new Button ();
			Control c3 = new Button ();
			Control c4 = new Button ();

			p.ColumnCount = 2;
			p.RowCount = 2;

			p.SetColumn (c3, 1);
			p.SetRow (c3, 1);

			p.Controls.Add (c1);
			p.Controls.Add (c2);
			p.Controls.Add (c3);
			p.Controls.Add (c4);

			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
			Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C3");
			Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c4), "C4");
		}
예제 #5
0
        private void GenerateGui()
        {
            var s = config.GetSections().ToList();
            s.Sort();

            foreach (var section in s)
            {
                var page = new TabPage(Utilities.GetPrettyName(section));
                var panel = new TableLayoutPanel { Dock = DockStyle.Fill, ColumnCount = 2 };
                var lastComment = "";
                var i = 0;

                foreach (var option in config.EnumSection(section))
                {

                    if (!new[] { "#", ";", "//" }.Any(c => option.StartsWith(c)))
                    {
                        var l = new Label
                        {
                            Text = Utilities.GetPrettyName(option) + ":",
                            TextAlign = ContentAlignment.MiddleLeft,
                            //Width = tabControlMain.Width/4,
                            AutoEllipsis = true
                        };
                        panel.SetColumn(l, 0);
                        panel.SetRow(l, i);
                        panel.Controls.Add(l);

                        Control t = null;
                        var defaultValue = config.GetSetting(section, option);
                        var tooltip = "";

                        // Check previous comment
                        if (!String.IsNullOrEmpty(lastComment))
                        {
                            var tmp = lastComment.Trim().Split(new[] { ']' }, 2);

                            if (tmp.Length > 1)
                                tooltip = tmp[1].Trim();

                            var m = Regex.Match(lastComment, @"\[(?<min>[-]?[\d.]{1,8}):(?<max>[-]?[\d.]{1,8})\]");
                            if (m.Success)
                            {
                                t = new NumericUpDown
                                {
                                    Minimum = decimal.Parse(m.Groups["min"].Value),
                                    Maximum = decimal.Parse(m.Groups["max"].Value),
                                    Value = decimal.Parse(defaultValue)
                                };

                                ((NumericUpDown)t).ValueChanged += (o, args) => { config.AddSetting(section, option, ((NumericUpDown)o).Value.ToString()); };
                            }
                            else
                            {
                                m = Regex.Match(lastComment, @"\[(?<value>.+,.+)\]");
                                if (m.Success)
                                {
                                    t = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right };

                                    var items = new List<String>();
                                    var description = new List<string>();
                                    foreach (var v in m.Groups["value"].Value.Split(new[] { ',' }))
                                    {
                                        String name, value;
                                        if (v.Contains(':'))
                                        {
                                            var parts = v.Split(new[] { ':' }, 2);
                                            name = parts[1];
                                            value = parts[0];
                                            description.Add(String.Format(" {0} ({1})", name, value));
                                        }
                                        else
                                        {
                                            name = v;
                                            value = v;
                                        }

                                        items.Add(value);
                                        ((ComboBox)t).Items.Add(name);

                                        if (defaultValue.Equals(value))
                                        {
                                            ((ComboBox)t).SelectedIndex = ((ComboBox)t).Items.Count - 1;
                                        }
                                    }

                                    if (description.Count > 0)
                                    {
                                        if (!String.IsNullOrEmpty(tooltip))
                                            tooltip += Environment.NewLine + Environment.NewLine;
                                        tooltip += "Available options:" + Environment.NewLine +
                                                   String.Join(Environment.NewLine, description);
                                    }
                                    t.Tag = items;

                                    // No default value match
                                    if (((ComboBox)t).SelectedIndex < 0)
                                    {
                                        ((ComboBox)t).DropDownStyle = ComboBoxStyle.DropDown;
                                        t.Text = defaultValue;
                                    }

                                    ((ComboBox)t).SelectedValueChanged += (o, args) =>
                                    {
                                        var c = o as ComboBox;
                                        if (c != null)
                                        {
                                            string v = null;
                                            if (c.Tag != null)
                                            {
                                                var list = c.Tag as List<string>;
                                                if (list != null)
                                                    v = list[c.SelectedIndex];
                                            }

                                            if(v == null)
                                                v = c.SelectedValue.ToString();

                                            config.AddSetting(section, option, v);
                                        }
                                    };
                                }
                            }
                        }

                        if (t == null)
                        {
                            t = new TextBox
                            {
                                Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                                Text = defaultValue /*, Width = (int) (tabControlMain.Width / 1.5)*/
                            };

                            t.TextChanged += (o, args) => { config.AddSetting(section, option, ((TextBox) o).Text); };
                        }

                        panel.SetColumn(t, 1);
                        panel.SetRow(l, i++);
                        panel.Controls.Add(t);

                        if (!String.IsNullOrEmpty(tooltip) && toolTipInfo != null)
                            toolTipInfo.SetToolTip(t, tooltip);

                        lastComment = "";
                    }
                    else
                        lastComment = option;
                }

                if (panel.Controls.Count > 0)
                {
                    panel.AutoScroll = true;
                    page.Controls.Add(panel);
                    tabControlMain.Controls.Add(page);
                }
                else
                {
                    page.Dispose();
                    panel.Dispose();
                }
            }
        }
예제 #6
0
        private void AddTable(string name, List<BasicTable.TableItem> items)
        {
            int row = 0;

            var panel = new TableLayoutPanel
            {
                ColumnCount = 2,
                RowCount = items.Count
            };

            panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 35));
            panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 65));
            // ReSharper disable ForCanBeConvertedToForeach
            for (int i = 0; i < items.Count; i++) // ReSharper restore ForCanBeConvertedToForeach
            {
                panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            }

            foreach (var item in items)
            {
                panel.Controls.Add(item.Control);
                panel.SetRow(item.Control, row);
                panel.SetColumn(item.Control, 1);

                if (string.IsNullOrEmpty(item.Name) == false)
                {
                    var label = new Label()
                    {
                        Text = string.Format(Properties.Localization.Editor_BasicTable_ItemLabelFormat, item.Name),
                        Dock = DockStyle.Fill,
                        AutoSize = true,
                        TextAlign = ContentAlignment.MiddleRight,
                    };
                    panel.Controls.Add(label);
                    panel.SetRow(label, row);
                    panel.SetColumn(label, 0);
                }
                else
                {
                    panel.SetColumnSpan(item.Control, 2);
                }

                if (item.Binding != null)
                {
                    item.Control.DataBindings.Add(item.Binding);
                }

                row++;
            }

            panel.AutoSize = true;
            panel.Dock = DockStyle.Fill;

            var group = new GroupBox();
            group.Text = name;
            group.MinimumSize = new Size(320, 0);
            group.AutoSize = true;
            group.Controls.Add(panel);

            this._PlayerBasicPanel.Controls.Add(group);
        }
예제 #7
0
파일: Business.cs 프로젝트: fatbudy/CSSM
        private void set_TopDataColumn(Dictionary<string, ColumnSetting> dcs, DataTable dt)
        {
            TopflowLayoutPanel.SuspendLayout();
            ColumnSetting cs = null;

            foreach (DataColumn dc in dt.Columns)
            {
                if (dcs.ContainsKey(dc.ColumnName) && dcs[dc.ColumnName].Visiable)
                {
                    cs = dcs[dc.ColumnName];
                    TableLayoutPanel tlp = new TableLayoutPanel();

                    tlp.RowCount = 1;
                    tlp.Parent = TopflowLayoutPanel;
                    tlp.Height = 32;
                    tlp.Show();

                    Label lleft = new Label();
                    lleft.Text = dcs[dc.ColumnName].HeadText;
                    lleft.Anchor = AnchorStyles.None;
                    lleft.AutoSize = true;
                    lleft.Show();

                    Control rtb = null;
                    if (cs.ReadOnly)
                    {
                        rtb = new Label() {  BorderStyle= System.Windows.Forms.BorderStyle.FixedSingle };
                    }
                    else
                    {
                        rtb = new TextBox();
                    }

                    rtb.DataBindings.Add(new Binding("Text", topbs, dc.ColumnName, true));
                    rtb.Width = dcs[dc.ColumnName].Width;
                    rtb.Anchor = AnchorStyles.Left;
                    tlp.ColumnCount = 2;

                    rtb.Show();

                    tlp.Controls.AddRange(new Control[] { lleft, rtb });
                    tlp.SetColumn(lleft, 0);
                    tlp.SetColumn(rtb, 1);

                    //start list data link
                    if (cs.LinkData && !cs.ReadOnly)    //列表数据类型
                    {
                        rtb.Tag = cs;
                        //这种委托不知道是否是共用,还是每个实例一个,待确定
                        MouseEventHandler rtb_right = delegate(object sender, MouseEventArgs e)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                //弹出窗体对话框,用于选择数据
                                SelectItemValue siv = SelectItemValue.Default;
                                TextBox rtb_tmp = (TextBox)sender;
                                ColumnSetting cs_rtb = (ColumnSetting)rtb_tmp.Tag;

                                siv.Text = string.Format("选择 {0} ...", cs_rtb.HeadText);
                                siv.SetColumnSetting(_dblClass, cs_rtb, ModelName, cs_rtb.HeadText);
                                if (siv.ShowDialog() == DialogResult.OK)
                                {
                                    rtb_tmp.Text = siv.SelectValue;
                                }
                            }
                        };
                        rtb.MouseDoubleClick += rtb_right;

                        //tlp.ColumnCount = 3;
                        //ComboBox cb = new ComboBox();
                        //cb.Width = 20;
                        //cb.DropDownWidth = 200;
                        //cb.DropDownStyle = ComboBoxStyle.DropDownList;
                        //cb.TabIndex = 0;
                        //_dblClass.RefreshColumnSettingLinkData(ref _sqlcommand, dc.ColumnName); //更新数据
                        //cb.DataSource = cs.LinkDataTable;
                        //cb.DisplayMember = cs.LinkColumnName ;
                        ////cb.DataBindings.Add("Text", cs.LinkDataTable, "Value");
                        //EventHandler _Commit = delegate(object sender, EventArgs e)
                        // {
                        //     rtb.Text = cb.Text;
                        // };
                        //cb.SelectionChangeCommitted += _Commit;
                        //cb.Show();

                        //tlp.Controls.Add(cb);
                        //tlp.SetColumn(cb, 2);
                    }
                    //end list data link
                    tlp.AutoSize = true;
                    tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                }

                //有些列后添加的,但是需要显示,只是没有配置信息的情况
                //此情况未处理
            }
            TopflowLayoutPanel.ResumeLayout();
        }
예제 #8
0
        private AppErrorDialog()
        {
            if (!appErrorInitialized)
            {
                Application.EnableVisualStyles();
                appErrorInitialized = true;
            }

            string title = FL.AppErrorDialogTitle;
            string appName = FL.AppName;
            if (!string.IsNullOrEmpty(appName))
            {
                title = appName + " – " + title;
            }

            this.BackColor = SystemColors.Window;
            this.ControlBox = false;
            this.MinimizeBox = false;
            this.MaximizeBox = false;
            this.Font = SystemFonts.MessageBoxFont;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.ShowInTaskbar = false;
            this.Size = new Size(550, 300);
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = title;
            this.TopMost = true;

            tablePanel = new TableLayoutPanel();
            tablePanel.Dock = DockStyle.Fill;
            tablePanel.RowCount = 6;
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 0));
            tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            tablePanel.ColumnCount = 1;
            tablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
            this.Controls.Add(tablePanel);

            introLabel = new Label();
            introLabel.BackColor = Color.FromArgb(221, 74, 59);
            introLabel.ForeColor = Color.White;
            introLabel.Dock = DockStyle.Fill;
            introLabel.AutoSize = true;
            introLabel.Font = new Font(
                SystemFonts.MessageBoxFont.FontFamily,
                SystemFonts.MessageBoxFont.SizeInPoints * 1.3f,
                SystemFonts.MessageBoxFont.Style);
            introLabel.MaximumSize = new Size(this.ClientSize.Width, 0);
            introLabel.Padding = new Padding(6, 4, 7, 6);
            introLabel.Margin = new Padding();
            introLabel.UseCompatibleTextRendering = false;
            introLabel.UseMnemonic = false;
            tablePanel.Controls.Add(introLabel);
            tablePanel.SetRow(introLabel, 0);
            tablePanel.SetColumn(introLabel, 0);

            errorPanel = new Panel();
            errorPanel.AutoScroll = true;
            errorPanel.Dock = DockStyle.Fill;
            errorPanel.Margin = new Padding(7, 8, 10, 6);
            errorPanel.Padding = new Padding();
            tablePanel.Controls.Add(errorPanel);
            tablePanel.SetRow(errorPanel, 1);
            tablePanel.SetColumn(errorPanel, 0);

            errorLabel = new Label();
            errorLabel.AutoSize = true;
            errorLabel.MaximumSize = new Size(this.ClientSize.Width - 20, 0);
            errorLabel.Padding = new Padding();
            errorLabel.Margin = new Padding();
            errorLabel.UseCompatibleTextRendering = false;
            errorLabel.UseMnemonic = false;
            errorPanel.Controls.Add(errorLabel);

            logLabel = new LinkLabel();
            logLabel.AutoSize = true;
            logLabel.MaximumSize = new Size(this.ClientSize.Width - 20, 0);
            logLabel.Margin = new Padding(8, 6, 10, 0);
            logLabel.Padding = new Padding();
            if (FL.LogFileBasePath != null)
            {
                logLabel.Text = string.Format(FL.AppErrorDialogLogPath, FL.LogFileBasePath.Replace("\\", "\\\u200B") + "*.fl");
                string dir = Path.GetDirectoryName(FL.LogFileBasePath).Replace("\\", "\\\u200B");
                logLabel.LinkArea = new LinkArea(FL.AppErrorDialogLogPath.IndexOf("{0}", StringComparison.Ordinal), dir.Length);
                logLabel.LinkClicked += (s, e) =>
                {
                    Process.Start(Path.GetDirectoryName(FL.LogFileBasePath));
                };
            }
            else
            {
                logLabel.Text = FL.AppErrorDialogNoLog;
                logLabel.LinkArea = new LinkArea(0, 0);
            }
            logLabel.UseCompatibleTextRendering = false;
            logLabel.UseMnemonic = false;
            tablePanel.Controls.Add(logLabel);
            tablePanel.SetRow(logLabel, 2);
            tablePanel.SetColumn(logLabel, 0);

            detailsLabel = new LinkLabel();
            detailsLabel.AutoSize = true;
            detailsLabel.Margin = new Padding(7, 6, 10, 10);
            detailsLabel.Padding = new Padding();
            detailsLabel.TabIndex = 11;
            detailsLabel.Text = FL.AppErrorDialogDetails;
            detailsLabel.UseCompatibleTextRendering = false;
            detailsLabel.Visible = CanShowDetails;
            tablePanel.Controls.Add(detailsLabel);
            tablePanel.SetRow(detailsLabel, 3);
            tablePanel.SetColumn(detailsLabel, 0);

            var attr = new TypeConverterAttribute(typeof(ExpandableObjectConverter));
            TypeDescriptor.AddAttributes(typeof(Exception), attr);
            grid = new PropertyGrid();
            grid.Dock = DockStyle.Fill;
            grid.Margin = new Padding(10, 10, 10, 10);
            grid.ToolbarVisible = false;
            grid.HelpVisible = false;
            grid.PropertySort = PropertySort.Alphabetical;
            grid.UseCompatibleTextRendering = false;
            grid.Visible = false;
            tablePanel.Controls.Add(grid);
            tablePanel.SetRow(grid, 4);
            tablePanel.SetColumn(grid, 0);

            bool isGridColumnResized = false;
            grid.Resize += (s, e) =>
            {
                if (!isGridColumnResized)
                {
                    isGridColumnResized = true;
                    // Source: http://stackoverflow.com/a/14475276/143684
                    FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic);
                    if (fi != null)
                    {
                        Control view = fi.GetValue(grid) as Control;
                        if (view != null)
                        {
                            MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic);
                            if (mi != null)
                            {
                                mi.Invoke(view, new object[] { 170 });
                            }
                            mi = view.GetType().GetMethod("set_GrayTextColor", BindingFlags.Instance | BindingFlags.NonPublic);
                            if (mi != null)
                            {
                                mi.Invoke(view, new object[] { Color.Black });
                            }
                        }
                    }
                }
            };

            detailsLabel.LinkClicked += (s, e) =>
            {
                detailsLabel.Hide();
                this.Height += 300;
                this.Top -= Math.Min(this.Top - 4, 150);
                tablePanel.RowStyles[4].Height = 350;
                grid.Visible = true;
            };

            buttonsPanel = new TableLayoutPanel();
            buttonsPanel.AutoSize = true;
            buttonsPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            buttonsPanel.BackColor = SystemColors.Control;
            buttonsPanel.Dock = DockStyle.Fill;
            buttonsPanel.Margin = new Padding();
            buttonsPanel.Padding = new Padding(10, 10, 10, 10);
            buttonsPanel.ColumnCount = 4;
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            tablePanel.Controls.Add(buttonsPanel);
            tablePanel.SetRow(buttonsPanel, 5);
            tablePanel.SetColumn(buttonsPanel, 0);

            sendCheckBox = new CheckBox();
            sendCheckBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
            sendCheckBox.AutoSize = true;
            sendCheckBox.Enabled = FL.CanSubmitLog;
            if (sendCheckBox.Enabled)
            {
                sendCheckBox.Checked = true;
            }
            sendCheckBox.FlatStyle = FlatStyle.System;
            sendCheckBox.Margin = new Padding();
            sendCheckBox.Padding = new Padding();
            sendCheckBox.Text = FL.AppErrorDialogSendLogs;
            sendCheckBox.UseCompatibleTextRendering = false;
            buttonsPanel.Controls.Add(sendCheckBox);
            buttonsPanel.SetRow(sendCheckBox, 0);
            buttonsPanel.SetColumn(sendCheckBox, 0);

            nextButton = new Button();
            nextButton.AutoSize = true;
            nextButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            nextButton.FlatStyle = FlatStyle.System;
            nextButton.Margin = new Padding(6, 0, 0, 0);
            nextButton.Padding = new Padding(2, 1, 2, 1);
            nextButton.Text = FL.AppErrorDialogNext;
            nextButton.UseCompatibleTextRendering = false;
            nextButton.UseVisualStyleBackColor = true;
            nextButton.Visible = false;
            nextButton.Click += (s, e) =>
            {
                ShowNextError();
            };
            buttonsPanel.Controls.Add(nextButton);
            buttonsPanel.SetRow(nextButton, 0);
            buttonsPanel.SetColumn(nextButton, 1);

            terminateButton = new Button();
            terminateButton.AutoSize = true;
            terminateButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            terminateButton.FlatStyle = FlatStyle.System;
            terminateButton.Margin = new Padding(6, 0, 0, 0);
            terminateButton.Padding = new Padding(2, 1, 2, 1);
            terminateButton.Text = FL.AppErrorDialogTerminate;
            terminateButton.UseCompatibleTextRendering = false;
            terminateButton.UseVisualStyleBackColor = true;
            terminateButton.Click += (s, e) =>
            {
                StartSubmitTool();
                Close();
                FL.Shutdown();
                Environment.Exit(1);
            };
            buttonsPanel.Controls.Add(terminateButton);
            buttonsPanel.SetRow(terminateButton, 0);
            buttonsPanel.SetColumn(terminateButton, 2);

            continueButton = new Button();
            continueButton.AutoSize = true;
            continueButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            continueButton.FlatStyle = FlatStyle.System;
            continueButton.Margin = new Padding(6, 0, 0, 0);
            continueButton.Padding = new Padding(2, 1, 2, 1);
            continueButton.Text = FL.AppErrorDialogContinue;
            continueButton.UseCompatibleTextRendering = false;
            continueButton.UseVisualStyleBackColor = true;
            continueButton.Click += (s, e) =>
            {
                StartSubmitTool();
                Close();
            };
            buttonsPanel.Controls.Add(continueButton);
            buttonsPanel.SetRow(continueButton, 0);
            buttonsPanel.SetColumn(continueButton, 3);
        }
예제 #9
0
        private void LoadRooms(TabPage roomTypeTab)
        {
            try
            {

                long TypeID = ((RoomType)roomTypeTab.Tag).Typeid;
                KryptonPanel roomOutlinePane = new KryptonPanel();
                TableLayoutPanel roomLayoutPane = new TableLayoutPanel();

                RoomCollection mRoomColl = new RoomCollection();
                if (TypeID > -1)
                    mRoomColl.Where(Room.TypeidColumn.ColumnName, TypeID).Load();
                else
                    mRoomColl.Load();

                roomLayoutPane.RowCount = mRoomColl.Count >= 26 ? mRoomColl.Count - 1 : 25;
                roomLayoutPane.ColumnCount = 12;
                roomLayoutPane.Size = new Size(ROOM_BUTTON_WIDTH * roomLayoutPane.RowCount + 3, ROOM_BUTTON_HEIGHT * roomLayoutPane.ColumnCount + 3);

                int currRowIndex = 0; int currColIndex = 0;
                roomLayoutPane.SuspendLayout();
                foreach (Room room in mRoomColl)
                {
                    var roomButton = new KryptonButton
                    {
                        Name = ("RM" + room.Roomid),
                        Size = new Size(ROOM_BUTTON_WIDTH, ROOM_BUTTON_HEIGHT),
                        Text =
                            (room.Name.Trim().ToLowerInvariant().StartsWith("room")
                                 ? room.Name
                                 : "Room " + room.Name),
                        Tag = room
                    };

                    CreateRoomMenu(roomButton);
                    roomLayoutPane.Controls.Add(roomButton);
                    roomLayoutPane.SetRow(roomButton, currRowIndex);
                    roomLayoutPane.SetColumn(roomButton, currColIndex);

                    if (currColIndex == roomLayoutPane.ColumnCount)
                    {
                        currRowIndex++;
                        currColIndex = 0;
                    }
                    else
                    {
                        currColIndex++;
                    }
                }
                roomLayoutPane.ResumeLayout();
                roomLayoutPane.BackColor = Color.Transparent;
                roomOutlinePane.Dock = DockStyle.Fill;
                roomOutlinePane.Controls.Add(roomLayoutPane);
                roomTypeTab.Controls.Add(roomOutlinePane); //Add to Current Tab
            }
            catch (Exception ex) { }
        }
예제 #10
0
파일: Learn.cs 프로젝트: dbremner/szotar
		public RoundOverview(int round, int count, int correct) {
			// TODO: Make theme-aware.
			correctCount.ForeColor = correctLabel.ForeColor = correctRatio.ForeColor = AnswerColors.Correct;
			incorrectCount.ForeColor = incorrectLabel.ForeColor = incorrectRatio.ForeColor = AnswerColors.Incorrect;

			base.Font = new Font(base.Font.FontFamily, base.Font.Size * 1.4f);
			FontFamily titleFontFamily = Array.Exists(FontFamily.Families, x => x.Name == "Cambria") 
				? new FontFamily("Cambria")
				: roundNo.Font.FontFamily;

			roundNo.Font = new Font(titleFontFamily, base.Font.Size * 2.0f, FontStyle.Bold);
			Disposed += delegate {
				Font.Dispose();
				roundNo.Font.Dispose();
			};
			
			prompt.ForeColor = SystemColors.GrayText;

			table = new TableLayoutPanel { RowCount = 4, ColumnCount = 3 }; 
			
			foreach (var label in new[] { roundNo, correctLabel, incorrectLabel, correctCount, incorrectCount, correctRatio, incorrectRatio, prompt }) {
				label.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top;
				label.TextAlign = ContentAlignment.MiddleLeft;
				label.AutoSize = true;
				table.Controls.Add(label);
			}

			prompt.TextAlign = ContentAlignment.MiddleCenter;

			table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
			table.RowStyles.Add(new RowStyle(SizeType.Percent, 0.5f));
			table.RowStyles.Add(new RowStyle(SizeType.Percent, 0.5f));
			table.RowStyles.Add(new RowStyle(SizeType.AutoSize));

			table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 1.0f));
			table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
			table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));

			// Row 0: Header
			table.SetRow(roundNo, 0); 
			table.SetColumn(roundNo, 0);
			table.SetColumnSpan(roundNo, 3);

			// Row 1: Correct guesses
			table.SetRow(correctLabel, 1);
			table.SetRow(correctCount, 1);
			table.SetRow(correctRatio, 1);
			table.SetColumn(correctLabel, 0);
			table.SetColumn(correctCount, 1);
			table.SetColumn(correctRatio, 2);

			// Row 2: Incorrect guesses
			table.SetRow(incorrectLabel, 2);
			table.SetRow(incorrectCount, 2);
			table.SetRow(incorrectRatio, 2);
			table.SetColumn(incorrectLabel, 0);
			table.SetColumn(incorrectCount, 1);
			table.SetColumn(incorrectRatio, 2);

			// Row 3: Prompt
			table.SetRow(prompt, 3);
			table.SetColumn(prompt, 0);
			table.SetColumnSpan(prompt, 3);

			Controls.Add(table);

			Resize += delegate { Layout(); };

			UpdateScore(round, count, correct);
		}
 //Add control to cell (x, y) on the table. The control becomes absolutely positioned if neither x nor y is equal to -1
 /// <include file='doc\TableLayoutPanel.uex' path='docs/doc[@for="TableLayoutControlCollection.Add"]/*' />
 public virtual void Add(Control control, int column, int row)
 {
     base.Add(control);
     _container.SetColumn(control, column);
     _container.SetRow(control, row);
 }
예제 #12
0
        public MainForm()
        {
            InitializeComponent();

              dictCharts = new Dictionary<int, Chart[]>();
              signals = new Tuple<double[], double[]>[9];
              spectors = new List<Complex[]>();

              TableLayoutPanel tableLayoutPanel;
              // Создаем для трех отведений.
              for (int t = 0; t < 3; t++)
              {
            tableLayoutPanel = new TableLayoutPanel();
            tabControl.TabPages[t].Controls.Add(tableLayoutPanel);
            tableLayoutPanel.Dock = DockStyle.Fill;
            tableLayoutPanel.ColumnCount = 2;
            tableLayoutPanel.RowCount = 4;
            tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
            tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
            tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 25F));
            tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 25F));
            tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 25F));
            tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 25F));

            Chart[] charts = new Chart[6];
            for (int i = 0; i < 6; i++)
            {
              int row = i < 3 ? i / 2 : (i + 1) / 2;
              int col = i < 3 ? i % 2 : (i + 1) % 2;

              Chart chart = charts[i] = CreateChart();
              tableLayoutPanel.Controls.Add(chart);
              tableLayoutPanel.SetRow(chart, row);
              tableLayoutPanel.SetColumn(chart, col);
              if ((i + 1) % 3 == 0)
              {
            tableLayoutPanel.SetColumnSpan(chart, 2);
              }
            }
            dictCharts[t] = charts;
              }

              // Создаем для остальных отведений.
              tableLayoutPanel = new TableLayoutPanel();
              tabControl.TabPages[3].Controls.Add(tableLayoutPanel);
              tableLayoutPanel.Dock = DockStyle.Fill;
              tableLayoutPanel.ColumnCount = 1;
              tableLayoutPanel.RowCount = 9;
              tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
              for (int i = 0; i < 9; i++)
              {
            tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / 9));
              }
              for (int i = 0; i < 9; i++)
              {
            Chart chart = CreateChart();
            tableLayoutPanel.Controls.Add(chart);
            tableLayoutPanel.SetRow(chart, i);
            tableLayoutPanel.SetColumn(chart, 0);
            dictCharts[3 + i] = new Chart[] { chart };

            chart.Titles.Add(new string[] { "AVR", "AVL", "AVF", "C1", "C2", "C3", "C4", "C5", "C6" }[i]);
            chart.Titles[0].Docking = Docking.Left;
              }

              EnableButtons(false);
        }
예제 #13
0
파일: testcmd.cs 프로젝트: lexzh/Myproject
 private void SetControl(TableLayoutPanel tb, Control con, int row, int col)
 {
     tb.Controls.Add(con);
     tb.SetRow(con, row);
     tb.SetColumn(con, col);
 }
예제 #14
0
		public void InitializeComponent() 
		{
			table = new TableLayoutPanel();
			view = new ViewportPanel();
			scroll = new VScrollBar();

			scroll.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
			view.Dock = DockStyle.Fill;

			table.Dock = DockStyle.Fill;
			table.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
			table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
			table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 0));
			table.RowCount = 1;
			table.ColumnCount = 2;
			table.Controls.Add(view);
			table.Controls.Add(scroll);
			table.SetColumn(view, 0);
			table.SetColumn(scroll, 1);

			scroll.Scroll += (sender, e) => OnScroll(e);
			view.Paint += (sender, e) => OnPaint(e);

			Controls.Add(table);
		}
예제 #15
0
 private void AddControls()
 {
     List<Requirement> reqs = GetAllRequirements();
     panel.Controls.Clear();
     TableLayoutPanel pn = new TableLayoutPanel
     {
         Dock = DockStyle.Fill,
         RowCount = reqs.Count,
         ColumnCount = 2,
         AutoSize = true,
         AutoScroll = true,                ColumnStyles =
         {
             new ColumnStyle{Width=30,SizeType=SizeType.Percent},
             new ColumnStyle{Width=70,SizeType=SizeType.Percent},
             
         }
     };
     List<Control> labels = reqs.GenerateLabels();
     List<Control> ctrls = reqs.GenerateControls(Settings.Instance.GlobalMetadataDictionary);
     for (int x = 0; x < reqs.Count; x++)
     {
         pn.RowStyles.Add(new RowStyle { Height = 30, SizeType = SizeType.Absolute });
         pn.Controls.Add(labels[x]);
         pn.Controls.Add(ctrls[x]);
         pn.SetColumn(labels[x], 0);
         pn.SetRow(labels[x], x);
         pn.SetColumn(ctrls[x], 1);
         pn.SetRow(ctrls[x], x);
     }
     pn.RowStyles.Add(new RowStyle { Height = 1, SizeType = SizeType.Percent });
     Panel pp = new Panel
     {
         Dock = DockStyle.Fill,
     };
     pn.Controls.Add(pp);
     pn.SetColumn(pp,0);
     pn.SetRow(pp,reqs.Count);
     pn.SetColumn(pp,2);
     panel.Controls.Add(pn);
 }
예제 #16
0
        private void CreateAdvancedSettings(TabPage tabPage)
        {
            var advancedSettings = new List<String>(new[] { "VariableRefactoringStartingSeed", "ProgramTemplate" });
            foreach (SettingsProperty r in Settings.Default.Properties)
                if (r.Name.StartsWith("Regex"))
                    advancedSettings.Add(r.Name);

            advancedSettings.Sort();

            var table = new TableLayoutPanel {ColumnCount = 2, RowCount = advancedSettings.Count() + 1, Dock = DockStyle.Fill};
            
            var row = 0;
            foreach (var s in advancedSettings)
            {
                var l = new Label { Text = s, Anchor = AnchorStyles.Left, AutoSize = true };
                table.Controls.Add(l);
                table.SetRow(l, row);
                table.SetColumn(l, 0);

                var t = new TextBox { Dock = DockStyle.Fill, Multiline = true, ScrollBars = ScrollBars.Vertical, Height=38 };
                t.DataBindings.Add(new Binding("Text", Settings.Default, s, true,DataSourceUpdateMode.OnPropertyChanged));
                table.Controls.Add(t);
                table.SetRow(t, row++);
                table.SetColumn(t, 1);
            }


            for (var i = 0; i < table.ColumnCount; i++)
                table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));

            for (var i = 0; i < table.RowCount; i++)
                table.RowStyles.Add(new RowStyle(SizeType.AutoSize));

            tabPage.Controls.Add(table);
        }
예제 #17
0
        private void AddControls()
        {
            DownloadPluginInfo pinfo = (DownloadPluginInfo) cmbPlugin.SelectedItem;

            panel.Controls.Clear();
            TableLayoutPanel pn = new TableLayoutPanel
            {
                Dock = DockStyle.Fill,
                RowCount = pinfo.AuthenticationRequirements.Count,
                ColumnCount = 2,
                AutoSize = true,
                AutoScroll = true,
                ColumnStyles =
                {
                    new ColumnStyle{Width=30,SizeType=SizeType.Percent},
                    new ColumnStyle{Width=70,SizeType=SizeType.Percent},
                    
                }
            };

            List<Control> labels = pinfo.AuthenticationRequirements.GenerateLabels();
            List<Control> ctrls=pinfo.AuthenticationRequirements.GenerateControls(Settings.Instance.AuthorizationsMetadataDictionary[pinfo.Name]);
            for (int x = 0; x < pinfo.AuthenticationRequirements.Count; x++)
            {
                pn.RowStyles.Add(new RowStyle {Height = 30, SizeType = SizeType.Absolute});
                pn.Controls.Add(labels[x]);
                pn.Controls.Add(ctrls[x]);
                pn.SetColumn(labels[x],0);
                pn.SetRow(labels[x], x);
                pn.SetColumn(ctrls[x],1);
                pn.SetRow(ctrls[x],x);
            }
            pn.RowStyles.Add(new RowStyle { Height = 1, SizeType = SizeType.Percent });
            Panel pp = new Panel
            {
                Dock = DockStyle.Fill,
            };
            pn.Controls.Add(pp);
            pn.SetColumn(pp, 0);
            pn.SetRow(pp, pinfo.AuthenticationRequirements.Count);
            pn.SetColumn(pp, 2);
            panel.Controls.Add(pn);
            panel.Controls.Add(pn);
        }