Ejemplo n.º 1
0
 /// <summary>
 /// 显示消息
 /// </summary>
 /// <param name="form">窗体</param>
 /// <param name="text">消息文本</param>
 /// <param name="style">消息样式。不指定则使用默认样式</param>
 /// <param name="delay">消息停留时长(ms)。为负时使用全局时长</param>
 /// <param name="floating">是否漂浮,不指定则使用全局设置</param>
 /// <param name="point">消息窗显示位置。不指定则智能判定,当由工具栏项(ToolStripItem)弹出时,请指定该参数或使用接收控件的重载</param>
 /// <param name="centerByPoint">是否以point参数为中心进行呈现。为false则是在其附近呈现</param>
 public static void ShowInfoTip(this Form form, string text, TipStyle style = null, int delay = -1, bool?floating = null,
                                Point?point = null, bool centerByPoint = false)
 => UIMessageTip.Show(text, style, delay, floating, point, centerByPoint);
Ejemplo n.º 2
0
 /// <summary>
 /// 在指定控件附近显示消息
 /// </summary>
 /// <param name="form">窗体</param>
 /// <param name="controlOrItem">控件或工具栏项</param>
 /// <param name="text">消息文本</param>
 /// <param name="style">消息样式。不指定则使用默认样式</param>
 /// <param name="delay">消息停留时长(ms)。为负时使用全局时长</param>
 /// <param name="floating">是否漂浮,不指定则使用全局设置</param>
 /// <param name="centerInControl">是否在控件中央显示,不指定则自动判断</param>
 public static void ShowInfoTip(this Form form, Component controlOrItem, string text, TipStyle style = null, int delay = -1,
                                bool?floating = null, bool?centerInControl = null)
 => UIMessageTip.Show(controlOrItem, text, style, delay, floating, centerInControl);
Ejemplo n.º 3
0
        /// <summary>
        /// 載入匯入的相關檔案與執行相關初始化動作。
        /// </summary>
        public void RefreshImportSource()
        {
            FileInfo file       = new FileInfo(SourceFileName);
            string   backupName = Path.Combine(file.DirectoryName, "原始資備份_" + file.Name);

            if (!File.Exists(backupName))
            {
                File.Copy(SourceFileName, backupName);
            }

            Workbook book = new Workbook();

            book.Open(SourceFileName);

            _workbook = book;
            Worksheet sheet;

            try
            {
                // sheet = _workbook.Worksheets["學生資料"];

                // 先改成預設讀取第1個工作表,保持與其他匯入一致。
                sheet = _workbook.Worksheets[0];
            }
            catch (Exception)
            {
                sheet = _workbook.Worksheets[0];
            }
            // 2017/8/22 穎驊依據高雄小組專案 [03-05][04+] EXCEL匯入格式可否修正為xlsx也可匯入? 更改為新版 Aspose.Cells_201402 寫法 ,GetStyle()
            //_styles = new TipStyle(_workbook, sheet.Cells[0, 0].Style); //用第一格來當作樣版。


            _styles = new TipStyle(_workbook, sheet.Cells[0, 0].GetStyle()); //用第一格來當作樣版。


            _source_sheet = sheet;

            _source_reader = new SheetReader();
            _source_reader.BindSheet(sheet, 0, 0);

            //設定資料讀取器的「識別欄」。
            if (!string.IsNullOrEmpty(IdentifyField))
            {
                _source_reader.SetKeyColumn(IdentifyField);
            }

            //取得可匯入欄位與使用者提供的欄位交集。
            _accept_columns = BulkDescription.Columns.GetInstersection(_source_reader.Columns.GetNames());

            //檢查是否有之前驗證過的欄位。
            //將 Accept SheetColumn 與 BulkColumn 建立關係。
            foreach (SheetColumn each in SourceColumns.Values)
            {
                // 2017/8/22 穎驊依據高雄小組專案 [03-05][04+] EXCEL匯入格式可否修正為xlsx也可匯入? 更改為新版 Aspose.Cells_201402 寫法 ,GetStyle()
                //Style s = each.BindingCell.Style, t = TipStyle.Header;

                Style s = each.BindingCell.GetStyle(), t = TipStyle.Header;

                if (s.ForegroundColor == t.ForegroundColor && s.Font.Color == t.Font.Color)
                {
                    each.UsedValid = true;
                }
                else
                {
                    each.UsedValid = false;
                }

                if (_accept_columns.ContainsKey(each.Name))
                {
                    each.SetBulkColumn(_accept_columns[each.Name]);
                }
            }

            //復原欄位到預設樣式。
            foreach (SheetColumn each in SourceColumns.Values)
            {
                each.SetStyle(TipStyle.Normal);
            }

            //設定「識別欄」樣式。
            if (!string.IsNullOrEmpty(IdentifyField))
            {
                SourceColumns[IdentifyField].SetStyle(TipStyle.Header);
            }

            //設定「檢查欄」樣式。
            if (!string.IsNullOrEmpty(ShiftCheckField))
            {
                SourceColumns[ShiftCheckField].SetStyle(TipStyle.Header);
            }

            //將使用者選擇的欄位設成「欄」樣式。
            foreach (SheetColumn each in SourceColumns.Values)
            {
                if (SelectedFields != null)
                {
                    if (SelectedFields.ContainsKey(each.Name))
                    {
                        each.SetStyle(TipStyle.Header);
                    }
                }
            }
        }