private bool isDelPageAskMethod()
        {
            bool retBool = false;

            // 删除是否提示
            if (IsDelPageAsk)
            {
                retBool = DialogResult.OK.Equals(ControlsUtils.ShowAskMessBox("是否删除该标签", "删除标签", null, null));
            }
            else
            {
                retBool = true;
            }
            return(retBool);
        }
Beispiel #2
0
 /// <summary>
 /// 实例化字体对话框
 /// </summary>
 /// <returns></returns>
 public static object fontDialogMethod(Dictionary <Type, object> data)
 {
     // 判断是否存在文本框
     if (data.ContainsKey(typeof(TextBox)) && data[typeof(TextBox)] is TextBox)
     {
         TextBox t   = (TextBox)data[typeof(TextBox)];
         object  obj = PublicEventMet.fontDialogMethod(t);
         if (obj != null && obj is Dictionary <string, object> )
         {
             Dictionary <string, object> dic = (Dictionary <string, object>)obj;
             // 获取字体设置对话框
             FontDialog fontD = dic.ContainsKey("1") && dic["1"] is FontDialog? (FontDialog)dic["1"] : null;
             // 是否点击了确定
             DialogResult ok = dic.ContainsKey("2") && dic["2"] is DialogResult? (DialogResult)dic["2"] : DialogResult.None;
             if (DialogResult.OK.Equals(ok) && fontD != null)
             {
                 // 询问是否将该字体应用到全部的文本框
                 ControlsUtils.ShowAskMessBox("是否将该字体应用到全部的文本框中", "设置字体",
                                              delegate {
                     MainTextBConfig.TEXTBOX_FONT = fontD.Font;
                     // 获取tab容器中的全部的主文本框
                     TextBox[] textAll = ControlCacheFactory.getSingletonChildCon <TextBox>(DefaultNameEnum.TAB_CONTENT);
                     if (textAll != null)
                     {
                         foreach (TextBox textB in textAll)
                         {
                             if (textB.Name.IndexOf(EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF)) >= 0)
                             {
                                 // 设置字体
                                 textB.Font = fontD.Font;
                             }
                         }
                     }
                 }, null);
             }
         }
     }
     else
     {
         MessageBox.Show("无法获取文本框");
     }
     return(null);
 }
Beispiel #3
0
 /// <summary>
 /// 恢复文本框默认字体
 /// </summary>
 /// <returns></returns>
 public static object textBoxFontReset(Dictionary <Type, object> data)
 {
     ControlsUtils.ShowAskMessBox("是否恢复全部文本框的默认字体", "恢复默认字体",
                                  delegate {
         MainTextBConfig.TEXTBOX_FONT = TextBoxDataLibcs.TEXTBOX_FONT_DEF;
         // 获取tab容器中的全部的主文本框
         TextBox[] textAll = ControlCacheFactory.getSingletonChildCon <TextBox>(DefaultNameEnum.TAB_CONTENT);
         if (textAll != null)
         {
             foreach (TextBox textB in textAll)
             {
                 if (textB.Name.IndexOf(EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF)) >= 0)
                 {
                     // 设置字体
                     textB.Font = TextBoxDataLibcs.TEXTBOX_FONT_DEF;
                 }
             }
         }
     }, null);
     return(null);
 }
        /// <summary>
        /// 粘贴内容到选定单元格
        /// </summary>
        /// <param name="view">表格</param>
        public static void pasteTextToSelCell(DataGridView view)
        {
            string text = Clipboard.GetText();
            DataGridViewSelectedCellCollection selCell = view.SelectedCells;

            // 选中单元格的行与列索引
            int[][] rowsColns = getSelCellRowsColns(view);
            if (rowsColns.Length == 0 || selCell.Count == 0)
            {
                return;
            }
            int minRow  = rowsColns[0].Min <int>();
            int minColn = rowsColns[1].Min <int>();

            // 判断剪贴板内容不为空并且选中单元格不为0
            if (text != null && text.Length > 0 && selCell.Count > 0)
            {
                string[][] rowColArr = StringUtils.SplitStrToArray(text,
                                                                   new string[] { Environment.NewLine }, new string[] { "\t" }, true, true, true, true);
                string[] endstrArr = rowColArr[rowColArr.Length - 1];
                // 去除末尾的空行
                if (1.Equals(endstrArr.Length) && 0.Equals(endstrArr[0].Length))
                {
                    Array.Resize(ref rowColArr, rowColArr.Length - 1);
                }

                // 获取要填充数据的列的最大值
                int maxColu = rowColArr.Max(x => x.Length);
                // 判断要粘贴的内容的行与列大于选中的单元格的行与列
                if (rowColArr.Length > rowsColns[0].Length ||
                    maxColu > rowsColns[1].Length)
                {
                    // 弹出对话框
                    ControlsUtils.ShowAskMessBox("当前选定单元格与粘贴板的内容不一致,是否继续",
                                                 "提示"
                                                 , delegate {
                        // 判断列是否需要添加
                        if (view.Rows[0].Cells.Count - minColn < maxColu)
                        {
                            int cellWidth = view.Rows[0].Cells[0].Size.Width;
                            // 添加列头并且返回添加的索引
                            for (int i = 0, len = (maxColu - (view.Rows[0].Cells.Count - minColn)); i < len; i++)
                            {
                                int index = view.Columns.Add("列" + (view.Columns.Count + 1), "列" + (view.Columns.Count + 1));
                                // 不包含排序
                                view.Columns[index].SortMode = DataGridViewColumnSortMode.NotSortable;
                                // 设置列的宽度
                                view.Columns[index].Width = cellWidth;
                            }
                        }
                        // 判断行是否需要添加
                        if ((view.Rows.Count - minRow) < rowColArr.Length)
                        {
                            int rowCount = view.Rows.Count;
                            int addI     = rowColArr.Length - (view.Rows.Count - minRow);
                            // 添加行
                            view.Rows.Add(addI);
                            //将序列赋值给行头
                            for (; rowCount < view.Rows.Count; rowCount++)
                            {
                                view.Rows[rowCount].HeaderCell.Value = (rowCount + 1).ToString();
                            }
                        }
                        // 清除选定
                        view.ClearSelection();
                        // 填充数据
                        for (int i = 0, len = rowColArr.Length; i < len; i++)
                        {
                            for (int j = 0, len2 = rowColArr[i].Length; j < len2; j++)
                            {
                                view.Rows[minRow + i].Cells[minColn + j].Value    = rowColArr[i][j];
                                view.Rows[minRow + i].Cells[minColn + j].Selected = true;
                            }
                        }
                    }, null);
                }
                else
                {
                    // 判断要粘贴的内容为一列和一行
                    if (rowColArr.Length == 1 && maxColu == 1)
                    {
                        // 改变所有选中单元格内容为该内容
                        foreach (DataGridViewCell cell in view.SelectedCells)
                        {
                            cell.Value = rowColArr[0][0];
                        }
                    }
                    else
                    {
                        // 将粘贴内容按照行列依次放入表格中
                        for (int i = 0, len = rowColArr.Length; i < len; i++)
                        {
                            for (int j = 0, len2 = rowColArr[i].Length; j < len2; j++)
                            {
                                view.Rows[minRow + i].Cells[minColn + j].Value    = rowColArr[i][j];
                                view.Rows[minRow + i].Cells[minColn + j].Selected = true;
                            }
                        }
                    }
                }
            }
        }