Exemple #1
0
        /// <summary>
        /// 调节窗体的位置
        /// </summary>
        private void middleForm()
        {
            Form rootDisplayForm = textBox.FindForm();

            // 根据父窗体居中
            Location = FormUtisl.MiddleForm(this, rootDisplayForm);
            // 获取当前屏幕分辨率
            int[] wh = MessyUtils.GetResolvingpower();

            int w = rootDisplayForm.Location.X + rootDisplayForm.Width;

            if (w + Width <= wh[0])
            {
                // 设置相对于启动窗体贴右
                Location = new Point(w, Location.Y);
                return;
            }
            if (Width <= rootDisplayForm.Location.X)
            {
                w        = rootDisplayForm.Location.X - Width;
                Location = new Point(w, Location.Y);
                return;
            }
        }
Exemple #2
0
        /// <summary>
        /// 确定窗体的大小
        /// </summary>
        /// <param name="rowColuArr">生成表格说使用的数据</param>
        private void defineFormSize(string[][] rowColuArr)
        {
            int cellWidth = redrawDataTable.Rows[0].Cells[0].Size.Width;
            // 数据表格在窗体中所占的宽
            int dataViewW = redrawDataTable.Location.X + redrawDataTable.RowHeadersWidth + (cellWidth * rowColuArr.Max(x => x.Length));
            // 数据表格在窗体中所占的高
            int dataViewH = redrawDataTable.Location.Y + colHeadersHeight + (cellDefHeight * rowColuArr.Length);

            // 判断工作区的宽
            if (dataViewW > 1000)
            {
                Width = MessyUtils.GetResolvingpower()[0] - 100;
            }
            else if (dataViewW < 600)
            {
                Width = 600;
            }
            else
            {
                Width = (Width - ClientSize.Width) + dataViewW + 15;
            }
            // 判断工作区的高
            if (dataViewH > Screen.PrimaryScreen.Bounds.Height)
            {
                Height = MessyUtils.GetResolvingpower()[1] - 100;
            }
            else if (dataViewH < 500)
            {
                Height = 500;
            }
            else
            {
                Height = (Height - ClientSize.Height) + dataViewH + 15;
            }
            // MinimumSize = new Size(Width, Height);
        }