/// <summary> /// 加载默认值 /// </summary> private void LoadDisplay() { Task.Run(() => { this.wifiTxt.Text = FormConfigUtil.WifiPath; this.localTxt.Text = FormConfigUtil.LocationPath; this.logTxt.Text = FormConfigUtil.LogPath; this.ipTxt.Text = FormConfigUtil.IpPath; this.countTxt.Text = FormConfigUtil.PrintCount.ToString(); var list = new List <object> { new { key = "默认居中", value = "默认居中" } }; this.localComboBox.DataSource = list; this.localComboBox.ValueMember = "value"; this.localComboBox.DisplayMember = "key"; this.localComboBox.SelectedValue = FormConfigUtil.ImgLocation; this.pageSize = ImageSizeUtil.ConverntPaperSizeName(FormConfigUtil.PageSize); this.landscape = FormConfigUtil.Landscape; this.marginLeft = FormConfigUtil.MarginLeft; this.marginRight = FormConfigUtil.MarginRight; this.marginTop = FormConfigUtil.MarginTop; this.marginBottom = FormConfigUtil.MarginBottom; this.printDocument.DefaultPageSettings.PaperSize = FormConfigUtil.GetPaperSize(printDocument, pageSize); this.printDocument.DefaultPageSettings.Margins.Top = this.marginTop; this.printDocument.DefaultPageSettings.Margins.Left = this.marginLeft; this.printDocument.DefaultPageSettings.Margins.Right = this.marginRight; this.printDocument.DefaultPageSettings.Margins.Bottom = this.marginBottom; this.portTxt.Text = FormConfigUtil.Host; }); }
private void InitData(List <ImageEditParam> imgParam, string pagerSize) { var widthD = this.detailPic.Width; var heightD = this.detailPic.Height; this.Images = imgParam.Select(x => new ImageEditParam { YuanImg = x.YuanImg, DetailImg = ImageUtil.CreateThumbnailImage(x.ScreenshotImg, widthD, heightD), ImagePath = x.ImagePath, ImageType = x.ImageType, SuoImg = ImageUtil.CreateThumbnailImage(x.ScreenshotImg, width, height), ScreenshotImg = x.ScreenshotImg, IsPrint = true }).ToList(); //将pageSize转换成A3类型的名称 this.PagerSize = ImageSizeUtil.ConverntPaperSizeName(pagerSize); this.countTxt.Text = FormConfigUtil.PrintCount.ToString(); }
private void saveBtn_Click(object sender, EventArgs e) { var wifiPath = this.wifiTxt.Text; var loaclPath = this.localTxt.Text; var logPath = this.logTxt.Text; var ipPath = this.ipTxt.Text; var countPath = this.countTxt.Text; var imgPath = this.localComboBox.SelectedValue.ToString(); var printCount = this.countTxt.Text; var port = this.portTxt.Text; string size = ImageSizeUtil.ConverntPaperSize(this.pageSize); var dic = new Dictionary <string, string> { { "wifiPath", wifiPath }, { "locationPath", loaclPath }, { "logPath", logPath }, { "ipPath", ipPath }, { "imgLocation", imgPath }, { "printCount", printCount }, { "pageSize", size }, { "landscape", this.landscape.ToString() }, { "marginLeft", this.marginLeft.ToString() }, { "marginRight", this.marginRight.ToString() }, { "marginTop", this.marginTop.ToString() }, { "marginBottom", this.marginBottom.ToString() }, { "host", port } }; FormConfigUtil.SetConfig(dic); FormFactory.MainForm.InitForm(); FormFactory.MainForm.ReloadService(x => { if (x) { MessageBox.Show("设置保存成功"); } else { MessageBox.Show("端口已被占用,请重新设置端口"); } }); }
/// <summary> /// 尺寸按钮点击事件 /// </summary> private void sizeBtn_Click(object sender, EventArgs e) { var btn = sender as Button; var text = btn.Text; var tag = btn.Tag as string; //清除其余的尺寸 this.SizeList.ForEach(x => { if (btn != x && ((tag.Equals("PrintSizeSet") && x.Tag.Equals("PrintSize")) || (tag.Equals("PrintSize") && x.Tag.Equals("PrintSizeSet")))) { x.ForeColor = Color.White; } else if (btn != x && ((tag.Equals("PaperSize") && x.Tag.Equals("PaperSizeSet")) || (tag.Equals("PaperSizeSet") && x.Tag.Equals("PaperSize")))) { x.ForeColor = Color.White; } else if (btn != x && x.Tag.Equals(tag)) { x.ForeColor = Color.White; } }); btn.ForeColor = Color.Blue; //印刷大小 if (tag == "PrintSize") { this.PrintSize = ImageSizeUtil.ConverntPaperSize(text); } //纸张大小 else if (tag == "PaperSize") { this.PaperSize = ImageSizeUtil.ConverntPaperSize(text); } //自定义尺寸 else if (tag == "PrintSizeSet") { var defaultSize = ""; if (this.PrintSize != null) { defaultSize = this.PrintSize.ToString(); } var size = this.ShowSize(defaultSize); if (!string.IsNullOrEmpty(size) && size != "empty") { this.PrintSize = size; } } //自定义大小 else if (tag == "PaperSizeSet") { var defaultSize = ""; if (this.PaperSize != null) { defaultSize = this.PaperSize.ToString(); } var size = this.ShowPaperSize(defaultSize); if (!string.IsNullOrEmpty(size) && size != "empty") { this.PaperSize = size; } } }