/// <summary> /// Size变化的时候 /// </summary> /// <param name="o"></param> /// <param name="e"></param> private void OnSizeChanged(object o, EventArgs e) { Size size = new Size(this.Size.Width - 15, this.Size.Height - 80); _flgView.Size = size; _previousCheckBox.Location = new Point(this.Size.Width - 180, this.Size.Height - 70); //Size变化后也要设置一下行的高度 _flgView.AutoSizeRows(); }
private void setListView() { if (grfView.IsDisposed) { return; } if (grfView.Rows == null) { return; } grfView.Rows.Count = 0; Column colpic1 = grfView.Cols[colUploadImg]; colpic1.DataType = typeof(Image); foreach (String file in lFile) { try { Row row = grfView.Rows.Add(); row[colUploadPath] = file; string ext = Path.GetExtension(file); Image loadedImage, resizedImage; if (ext.ToLower().IndexOf("pdf") < 0) { loadedImage = Image.FromFile(file); int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = 280; newWidth = bc.imggridscanwidth; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); row[colUploadImg] = resizedImage; loadedImage.Dispose(); } else { row[colUploadImg] = Resources.pdf_symbol_300; } } catch (Exception ex) { new LogWriter("e", file + " " + ex.Message); MessageBox.Show("err " + file + " " + ex.Message, ""); } } grfView.AutoSizeCols(); grfView.AutoSizeRows(); }
private void BtnRefresh_Click(object sender, EventArgs e) { //throw new NotImplementedException(); grfVs.AutoSizeCols(); grfVs.AutoSizeRows(); }
private void setGrfImg(String fmcode) { showFormWaiting(); DataTable dt = new DataTable(); String limit = ""; if (chkLimit.Checked) { dt = bc.bcDB.dscDB.selectByFmCode(fmcode, "40"); } else { dt = bc.bcDB.dscDB.selectByFmCode(fmcode, ""); } grfImg.Rows.Count = 0; FtpClient ftp = new FtpClient(bc.iniC.hostFTP, bc.iniC.userFTP, bc.iniC.passFTP); Boolean findTrue = false; int colcnt = 0, rowrun = -1; int cnt = 0; cnt = dt.Rows.Count / 2; ContextMenu menuGw = new ContextMenu(); //menuGw.MenuItems.Add("ต้องการ Print ภาพนี้", new EventHandler(ContextMenu_grfscan_print)); menuGw.MenuItems.Add("ต้องการ Download ภาพนี้", new EventHandler(ContextMenu_grfImg_Download)); grfImg.ContextMenu = menuGw; grfImg.Rows.Count = cnt + 1; try { foreach (DataRow row1 in dt.Rows) { if (findTrue) { break; } colcnt++; String dgssid = "", filename = "", ftphost = "", id = "", folderftp = ""; id = row1[bc.bcDB.dscDB.dsc.doc_scan_id].ToString(); dgssid = row1[bc.bcDB.dscDB.dsc.doc_group_sub_id].ToString(); filename = row1[bc.bcDB.dscDB.dsc.image_path].ToString(); ftphost = row1[bc.bcDB.dscDB.dsc.host_ftp].ToString(); folderftp = row1[bc.bcDB.dscDB.dsc.folder_ftp].ToString(); String err = ""; try { FtpWebRequest ftpRequest = null; FtpWebResponse ftpResponse = null; Stream ftpStream = null; int bufferSize = 2048; err = "00"; Row rowd; if ((colcnt % 2) == 0) { rowd = grfImg.Rows[rowrun]; } else { rowrun++; rowd = grfImg.Rows[rowrun]; } MemoryStream stream; Image loadedImage, resizedImage; stream = new MemoryStream(); //stream = ftp.download(folderftp + "//" + filename); //loadedImage = Image.FromFile(filename); err = "01"; Application.DoEvents(); ftpRequest = (FtpWebRequest)FtpWebRequest.Create(ftphost + "/" + folderftp + "/" + filename); ftpRequest.Credentials = new NetworkCredential(bc.iniC.userFTP, bc.iniC.passFTP); ftpRequest.UseBinary = true; ftpRequest.UsePassive = bc.ftpUsePassive; ftpRequest.KeepAlive = true; ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile; ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); ftpStream = ftpResponse.GetResponseStream(); err = "02"; byte[] byteBuffer = new byte[bufferSize]; int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); try { while (bytesRead > 0) { stream.Write(byteBuffer, 0, bytesRead); bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); new LogWriter("e", "FrmScanView1 SetGrfScan try int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize); ex " + ex.Message + " " + err); } err = "03"; loadedImage = new Bitmap(stream); err = "04"; int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = bc.imgScanWidth; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); // err = "05"; if ((colcnt % 2) == 0) { rowd[colPic3] = resizedImage; // + 0001 err = "061"; // + 0001 rowd[colPic4] = id; // + 0001 err = "071"; // + 0001 } else { err = "051"; // + 0001 rowd[colPic1] = resizedImage; // + 0001 err = "06"; // + 0001 rowd[colPic2] = id; // + 0001 err = "07"; // + 0001 } strm = new listStream(); strm.id = id; err = "08"; strm.stream = stream; err = "09"; lStream.Add(strm); Application.DoEvents(); err = "12"; if (colcnt == 50) { GC.Collect(); } if (colcnt == 100) { GC.Collect(); } } catch (Exception ex) { String aaa = ex.Message + " " + err; new LogWriter("e", "FrmDocGroupFmEdit setGrfImg ex " + ex.Message + " " + err + " colcnt " + colcnt); } } } catch (Exception ex) { } frmFlash.Dispose(); grfImg.AutoSizeRows(); }
private void setGrfQueue() { //grfQue.Clear(); pageLoad = true; grfQue.DataSource = null; grfQue.Rows.Count = 1; //grfQue.Rows.Count = 200; grfQue.Cols.Count = 7; grfQue.Cols[colRowNo].Width = 250; grfQue.Cols[colQueName].Width = 250; grfQue.Cols[colQueNum].Width = 100; grfQue.Cols[colQueId].Width = 100; grfQue.ShowCursor = true; //grdFlex.Cols[colID].Caption = "no"; //grfDept.Cols[colCode].Caption = "รหัส"; grfQue.Cols[colRowNo].Caption = " "; grfQue.Cols[colQueName].Caption = "queue name"; grfQue.Cols[colQueNum].Caption = "queue"; grfQue.Cols[colQueId].Caption = "id"; grfQue.Cols[colQueCode].Caption = "ตัวย่อ"; grfQue.Cols[colQuePrefix].Caption = "Prefix"; DataTable dt = new DataTable(); DateTime dtToday = new DateTime(); DateTime.TryParse(txtDate.Text, out dtToday); String date = ""; date = DateTime.Now.Year + DateTime.Now.ToString("-MM-dd"); dt = bqc.bquDB.queDB.selectAllNotinToday(date); //dttoday = bqc.bquDB.queDateDB.selectBQueDate1(date); grfQue.Rows.Count = dt.Rows.Count + 1; if (dt.Rows.Count == 0) { grfQue.Rows.Count++; } int i = 1; foreach (DataRow drow in dt.Rows) { //Boolean chk = false; //foreach (DataRow drowtoday in dttoday.Rows) //{ // if (drowtoday["queue_id"].ToString().Equals(drow["queue_id"].ToString())) // { // chk = true; // continue; // } //} //if (chk) continue; grfQue.Rows[i][colRowNo] = i; grfQue[i, 0] = i; grfQue[i, colQueName] = drow["queue_name"].ToString(); grfQue[i, colQueNum] = drow["queue_code"].ToString(); grfQue[i, colQueId] = drow["queue_id"].ToString(); grfQue[i, colQueCode] = drow["queue_code"].ToString(); grfQue[i, colQuePrefix] = drow["queue_prefix"].ToString(); i++; } //grfQue.Rows[0].Visible = false; grfQue.Cols[colQueId].Visible = false; grfQue.Cols[colRowNo].Visible = false; //grfImg.Cols[colPathPic].Visible = false; grfQue.Cols[colRowNo].AllowEditing = false; grfQue.Cols[colQueName].AllowEditing = false; grfQue.Cols[colQueNum].AllowEditing = false; grfQue.Cols[colQueId].AllowEditing = false; //grfImg.AutoSizeCols(); grfQue.AutoSizeRows(); pageLoad = false; //theme1.SetTheme(grfQue, "Office2016Colorful"); }
private void setImage(String[] file1) { String err = ""; txtVN.Hide(); btnVn.Hide(); //label3.Hide(); //txtAN.Hide(); //txtAnCnt.Hide(); //chkIPD.Hide(); label6.Hide(); txtVisitDate.Hide(); setVisible(false); Application.DoEvents(); //txtAnDate.Hide(); //txtPreNo.Hide(); err = "01"; //MessageBox.Show("222", ""); ProgressBar pB1 = new ProgressBar(); pB1.Location = new System.Drawing.Point(15, 15); pB1.Name = "pB1"; pB1.Size = new System.Drawing.Size(862, 23); groupBox1.Controls.Add(pB1); //pB1.Left = txtVN.Left; pB1.Show(); int i = 1, j = 1, row = grf.Rows.Count; grf.Rows.Add(); row = grf.Rows.Count; String re = ""; array1.Clear(); try { err = "02"; pB1.Value = 0; pB1.Minimum = 0; pB1.Maximum = file1.Length; foreach (String file in file1) { try { Image loadedImage, resizedImage; String[] sur = file.Split('.'); String ex = ""; if (sur.Length == 2) { ex = sur[1]; } err = "021"; if (!ex.Equals("pdf")) { String ext = ""; ext = Path.GetExtension(file); if (ext.IndexOf("db") > 0) { continue; } loadedImage = Image.FromFile(file); //byte[] buff = System.IO.File.ReadAllBytes(file); //System.IO.MemoryStream ms = new System.IO.MemoryStream(buff); //MemoryStream stream = new MemoryStream(buff); //loadedImage.Save(stream, ImageFormat.Jpeg); //loadedImage.Dispose(); //loadedImage = Image.FromStream(stream); int originalWidth = 0; originalWidth = loadedImage.Width; int newWidth = 280; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); arrayImg.Add(file + ","); loadedImage.Dispose(); } else { resizedImage = Resources.pdf_symbol_80_2; } if (j > 4) { grf.Rows.Add(); row = grf.Rows.Count; j = 1; i++; } err = "022"; //grf.Cols[colPic1].ImageAndText = true; //grf.Cols[colPic2].ImageAndText = true; //grf.Cols[colPic3].ImageAndText = true; //grf.Cols[colPic4].ImageAndText = true; int hei = grf.Rows.DefaultSize; //grf[row - 1, colDay2PathPic] = file; //grfDay2Img[row - 1, colBtn] = "send"; array1.Add(i + "," + j + ",*" + file); if (j == 1) { //grf[i, colPic1] = resizedImage; grf.SetCellImage(i, colPic1, resizedImage); } else if (j == 2) { //grf[i, colPic2] = resizedImage; grf.SetCellImage(i, colPic2, resizedImage); } else if (j == 3) { //grf[i, colPic3] = resizedImage; grf.SetCellImage(i, colPic3, resizedImage); } else if (j == 4) { //grf[i, colPic4] = resizedImage; grf.SetCellImage(i, colPic4, resizedImage); } err = "023"; j++; pB1.Value++; if (pB1.Value == 47) { String aaa = ""; } //resizedImage.Dispose(); } catch (Exception ex) { re = ex.Message; MessageBox.Show("Error" + ex.Message + " Lenght " + file1.Length + " row " + pB1.Value, "err " + err); } } } catch (Exception ex) { MessageBox.Show("Error" + ex.Message, ""); } setVisible(true); //MessageBox.Show("555", ""); grf.AutoSizeCols(); grf.AutoSizeRows(); grf.Rows[0].Visible = false; grf.Cols[0].Visible = false; pB1.Dispose(); txtVN.Show(); btnVn.Show(); //label3.Show(); //txtAN.Show(); //txtAnCnt.Show(); //chkIPD.Show(); label6.Show(); //if (chkIPD.Checked) //{ // txtVisitDate.Hide(); // txtAnDate.Show(); //} //else //{ txtVisitDate.Show(); // txtAnDate.Hide(); //} //txtPreNo.Show(); }
public RunningHistoryForm() { //设置图标 this.Icon = Resources.PXILOGO; this.MinimizeBox = false; this.MaximizeBox = false; this.ShowIcon = true; this.Size = new Size(900, 450); this.StartPosition = FormStartPosition.CenterParent; this.Text = "运行历史"; this.SizeChanged += OnSizeChanged; _flgView = new C1FlexGrid(); //设置样式 //设置样式为行的高度随着内容变化而变化。 _flgView.Styles[CellStyleEnum.Normal].WordWrap = true; _flgView.AllowResizing = AllowResizingEnum.Rows; //设置空白的样 _flgView.AllowEditing = false; _flgView.BackColor = Color.White; _flgView.Styles.Normal.TextAlign = TextAlignEnum.CenterCenter; _flgView.Styles.Editor.TextAlign = TextAlignEnum.CenterCenter; _flgView.Styles.EmptyArea.BackColor = Color.White; _flgView.Styles.EmptyArea.Border.Width = 0; _flgView.ExtendLastCol = true; _flgView.SelectionMode = SelectionModeEnum.ListBox; this.Controls.Add(_flgView); Hashtable typeHashTable = new Hashtable(); typeHashTable.Add("Information", Resources.Info); typeHashTable.Add("Warning", Resources.Warning); typeHashTable.Add("Error", Resources.Error); _logDataTable.Columns.Add("时间"); _logDataTable.Columns.Add("类型"); _logDataTable.Columns.Add("级别"); _logDataTable.Columns.Add("内容"); if (File.Exists(RunningLog.LogFile.FilePath)) { string[] lines = File.ReadAllLines(RunningLog.LogFile.FilePath); foreach (var line in lines) { LogItem item = LogItem.Parse(line); if (item != null) { DataRow dataRow = _logDataTable.NewRow(); dataRow["时间"] = item.Time; dataRow["类型"] = item.Type; dataRow["级别"] = item.Level; dataRow["内容"] = item.Text; _logDataTable.Rows.Add(dataRow); } else if (line != "" && item == null) { _logDataTable.Rows[_logDataTable.Rows.Count - 1]["内容"] += "\n" + line; } } //装载完内容后设置一下行的高度 _flgView.AutoSizeRows(); } _flgView.DataSource = _logDataTable; _flgView.Cols["级别"].ImageMap = typeHashTable; _flgView.Cols[0].AllowDragging = false; _flgView.Cols[0].AllowResizing = false; _flgView.Cols[0].Width = 0; _flgView.Cols[1].Width = 200; _previousCheckBox = new CheckBox(); _previousCheckBox.AutoCheck = false; _previousCheckBox.Text = "显示过往日志"; _previousCheckBox.Size = new Size(100, 23); _previousCheckBox.TextAlign = ContentAlignment.MiddleCenter; _previousCheckBox.Click += OnPreviousBtnClick; Controls.Add(_previousCheckBox); OnSizeChanged(null, null); }
private void setGrfQueue() { //grfQue.Clear(); timer.Enabled = false; pageLoad = true; grf.DataSource = null; grf.Rows.Count = 1; //grfQue.Rows.Count = 200; grf.Cols.Count = 11; Column imageCol = grf.Cols[colSoundImg]; imageCol.Caption = "Images"; imageCol.DataType = typeof(Image); imageCol.ImageAlign = ImageAlignEnum.CenterCenter; //imageCol.Editor = new ImagePicker(); imageCol.Width = 75; grf.Cols[colCalId].Width = 250; grf.Cols[colCalQue].Width = 100; grf.Cols[colCalQueName].Width = 100; //grf.Cols[colQueId].Width = 100; grf.ShowCursor = true; //grdFlex.Cols[colID].Caption = "no"; //grfDept.Cols[colCode].Caption = "รหัส"; grf.Cols[colCalId].Caption = " "; grf.Cols[colCalQue].Caption = "queue "; grf.Cols[colCalQueName].Caption = "queue name"; DataTable dt = new DataTable(); dt = bqc.bquDB.tcallDB.selectAll(); //dttoday = bqc.bquDB.queDateDB.selectBQueDate1(date); grf.Rows.Count = dt.Rows.Count + 1; if (dt.Rows.Count == 0) { grf.Rows.Count++; } int i = 1; foreach (DataRow drow in dt.Rows) { grf.Rows[i][0] = i; grf[i, 0] = i; grf[i, colCalId] = drow["call_id"].ToString(); grf[i, colCalQue] = drow["queue"].ToString(); grf[i, colQueId] = drow["queue_id"].ToString(); grf[i, colTQueId] = drow["t_queue_id"].ToString(); grf[i, colPrefix] = drow["prefix"].ToString(); grf[i, colCode] = drow["code"].ToString(); grf[i, colCaller] = drow["caller"].ToString(); grf[i, colCallerId] = drow["call_id"].ToString(); grf[i, colCalQueName] = bqc.prefixQue1(drow["code"].ToString(), drow["prefix"].ToString(), drow["queue"].ToString()); grf[i, colSoundImg] = Resources.stop24;; i++; } grf.Rows[colCallerId].Visible = false; grf.Cols[colCalId].Visible = false; grf.Cols[colQueId].Visible = false; grf.Cols[colTQueId].Visible = false; grf.Cols[colPrefix].Visible = false; grf.Cols[colCode].Visible = false; grf.Cols[colCalQue].AllowEditing = false; grf.Cols[colCalQueName].AllowEditing = false; grf.AutoSizeRows(); pageLoad = true; //theme1.SetTheme(grfQue, "Office2016Colorful"); }
private void setGrfQueue() { //grfQue.Clear(); pageLoad = true; grfQue.DataSource = null; grfQue.Rows.Count = 1; //grfQue.Rows.Count = 200; grfQue.Cols.Count = 10; grfQue.Cols[colRowNo].Width = 250; grfQue.Cols[colQueName].Width = 250; grfQue.Cols[colQuePrefix].Width = 100; grfQue.Cols[colQueId].Width = 100; grfQue.Cols[colQueSave].Width = 80; grfQue.Cols[colQueCode].Width = 100; grfQue.Cols[colEveryDay].Width = 100; Column imageCol = grfQue.Cols[colEveryDayImage]; imageCol.Caption = "Images"; imageCol.DataType = typeof(Image); imageCol.ImageAlign = ImageAlignEnum.CenterCenter; //imageCol.Editor = new ImagePicker(); imageCol.Width = 75; grfQue.ShowCursor = true; //grdFlex.Cols[colID].Caption = "no"; //grfDept.Cols[colCode].Caption = "รหัส"; grfQue.Cols[colRowNo].Caption = " "; grfQue.Cols[colQueName].Caption = "queue name"; grfQue.Cols[colQuePrefix].Caption = "prefix"; //ตัวย่อ ชื่อย่อ grfQue.Cols[colQueId].Caption = "id"; grfQue.Cols[colQueSave].Caption = "save"; grfQue.Cols[colQueCode].Caption = "XXXX"; //XXXX grfQue.Cols[colQueStart].Caption = "คิวเริ่มต้น"; //XXXX grfQue.Cols[colEveryDayImage].Caption = "status"; //XXXX DataTable dt = new DataTable(); dt = bqc.bquDB.queDB.selectAll(); grfQue.Rows.Count = dt.Rows.Count + 1; if (dt.Rows.Count == 0) { grfQue.Rows.Count++; } int i = 1; foreach (DataRow drow in dt.Rows) { grfQue.Rows[i][colRowNo] = i; grfQue[i, 0] = i; grfQue[i, colQueName] = drow["queue_name"].ToString(); grfQue[i, colQuePrefix] = drow["queue_prefix"].ToString(); grfQue[i, colQueId] = drow["queue_id"].ToString(); grfQue[i, colQueCode] = drow["queue_code"].ToString(); grfQue[i, colQueStart] = drow["queue_start"].ToString(); grfQue[i, colEveryDay] = drow["status_everyday"] != null ? drow["status_everyday"].ToString().Equals("") ? "0": drow["status_everyday"].ToString():"0"; grfQue[i, colEveryDayImage] = drow["status_everyday"].ToString().Equals("1") ? Resources.trafficlight_green16 : Resources.trafficlight_red16; grfQue[i, colQueSave] = ""; i++; } //grfQue.Rows[0].Visible = false; grfQue.Cols[colQueId].Visible = false; grfQue.Cols[colRowNo].Visible = false; grfQue.Cols[colEveryDay].Visible = false; //grfQue.Cols[colEveryDay].Visible = false; grfQue.Cols[colEveryDayImage].AllowEditing = false; grfQue.Cols[colRowNo].AllowEditing = true; grfQue.Cols[colQueName].AllowEditing = true; grfQue.Cols[colQuePrefix].AllowEditing = true; grfQue.Cols[colQueCode].AllowEditing = true; grfQue.Cols[colQueId].AllowEditing = false; grfQue.Cols[colQueSave].AllowEditing = false; //grfImg.AutoSizeCols(); grfQue.AutoSizeRows(); pageLoad = false; //theme1.SetTheme(grfQue, "Office2016Colorful"); }