public clsCard(System.Xml.XmlNode n, string picpath) : this() { System.Xml.XmlNode cb = n.SelectSingleNode("//card[@name='CardBack']"); Name = getAttributeValue(n, "name"); img = getAttributeValue(n, "img"); CardFront.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; CardFront.Load(picpath + img); CardFront.Visible = true; CardFront.Tag = this; if (cb != null) { CardBack.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; CardBack.Load(picpath + cb.Attributes.GetNamedItem("img").Value); CardBack.Visible = true; } value = getAttributeIntValue(n, "value"); type = getAttributeValue(n, "type"); subtype = getAttributeValue(n, "subtype"); group = getAttributeValue(n, "group"); skill = getAttributeValue(n, "skill"); cost = getAttributeIntValue(n, "cost"); power = getAttributeIntValue(n, "power"); recruit = getAttributeIntValue(n, "recruit"); text = getAttributeValue(n, "text"); }
public static void InitializeImages() { foreach (Char charOption in Board.k_CharOptionsForCell) { System.Windows.Forms.PictureBox picBox = new System.Windows.Forms.PictureBox(); picBox.Load(string.Format("http://lorempixel.com/80/80/")); m_ImagesForCards.Add(charOption, picBox); } }
// режет большие картинки на мелкие, сохраняет, возвращает массив локальных путей // вход - список урлов, массив количество строк, массив количеств колонок // выход - массив локальных путей public static string[] GetSmallImagePathes(OneTab T, List <string> urls, int[] Rows, int[] Cols) { int SmallImageCount = GetSmallImageCount(urls, Rows, Cols); string[] SmallImagePath = new string[SmallImageCount]; List <string> tmplist = new List <string>(); string basename = Environment.CurrentDirectory + @"\Pics\g" + T.level.G.gameid + "_l" + T.level.number.ToString() + "_p{1}_n{2}.jpg"; for (int part = 0; part < urls.Count; part++) { System.Windows.Forms.PictureBox PictBox = new System.Windows.Forms.PictureBox(); PictBox.Load(urls[part]); Bitmap Bmp = new Bitmap(PictBox.Image); int total_parts = Rows[part] * Cols[part]; int w = Bmp.Width; int h = Bmp.Height; int dw = w / Cols[part] - 2 * image_border_width; // ширина одного блока int dh = h / Rows[part] - 2 * image_border_width; int cnt = 0; for (int r = 0; r < Rows[part]; r++) { for (int c = 0; c < Cols[part]; c++) { cnt++; int sw = image_border_width + (w * c / Cols[part]); int sh = image_border_width + (h * r / Rows[part]); System.Drawing.Bitmap nb = new System.Drawing.Bitmap(dw, dh); System.Drawing.Rectangle re = new System.Drawing.Rectangle(sw, sh, dw, dh); nb = Bmp.Clone(re, System.Drawing.Imaging.PixelFormat.Undefined); string fn = basename; fn = fn.Replace("{1}", part.ToString()); fn = fn.Replace("{2}", cnt.ToString()); nb.Save(fn, System.Drawing.Imaging.ImageFormat.Jpeg); tmplist.Add(fn); } } } SmallImagePath = new string[tmplist.Count]; for (int i = 0; i < tmplist.Count; i++) { SmallImagePath[i] = tmplist[i]; } return(SmallImagePath); }
//识别车牌 public void pateShow(WTY.plate_result recResult, String fullImgFile, String plateImgFile, System.Windows.Forms.PictureBox FullImg, System.Windows.Forms.PictureBox PlateImg, Label lbl) { string fileNameTime = DateTime.Now.ToString("hh-mm-ss"); recResult.shootTime.Year = Convert.ToInt32(DateTime.Now.Year.ToString()); recResult.shootTime.Month = Convert.ToInt32(DateTime.Now.Month.ToString()); recResult.shootTime.Day = Convert.ToInt32(DateTime.Now.Day.ToString()); recResult.shootTime.Hour = Convert.ToInt32(DateTime.Now.Hour.ToString()); recResult.shootTime.Minute = Convert.ToInt32(DateTime.Now.Minute.ToString()); recResult.shootTime.Second = Convert.ToInt32(DateTime.Now.Second.ToString()); recResult.shootTime.Millisecond = 2; //string fileNameTime = System.DateTime.Now.ToString(); string directoryPath = recResult.chWTYIP.ToString(); // 显示车牌 string strLicesen = new string(recResult.chLicense);//车牌显示字符串 string strColor = new string(recResult.chColor); object[] Dl = { strLicesen, strColor, lbl }; // int handle = new WindowInteropHelper(this).Handle.ToInt32(); Dispatcher.BeginInvoke(new delShowPlate(ShowPlate), Dl); Directory.CreateDirectory(recResult.chWTYIP.ToString()); // 显示识别时间 object[] D2 = { recResult.shootTime.Year, recResult.shootTime.Month, recResult.shootTime.Day, recResult.shootTime.Hour, recResult.shootTime.Minute, recResult.shootTime.Second, recResult.shootTime.Millisecond }; Dispatcher.BeginInvoke(new delShowRecogniseTime(ShowRecogniseTime), D2); // 显示识别坐标 //object[] D3 = { // recResult.pcLocation.Left, // recResult.pcLocation.Top, // recResult.pcLocation.Right, // recResult.pcLocation.Bottom // }; //Dispatcher.BeginInvoke(new delShowPlateC(ShowPlateC), D3); // 显示识别图像 if (recResult.nFullLen > 0) { // 保存全景图 FullImg.Load("111.jpg"); System.IO.FileStream fs = new System.IO.FileStream(fullImgFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite); //System.IO.FileStream fs = new System.IO.FileStream(directoryPath + fileNameTime + ".jpg", System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, FileShare.ReadWrite); try { fs.Write(recResult.chFullImage, 0, recResult.nFullLen); fs.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } // 将全景图显示在界面上 FullImg.Image = null; FileInfo fi = new FileInfo(fullImgFile); if (fi.Exists) { FullImg.Load(fullImgFile); } } if (recResult.nPlateLen > 0) { // 保存车牌小图 PlateImg.Load("112.jpg"); System.IO.FileStream fs = new System.IO.FileStream(plateImgFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite); try { fs.Write(recResult.chPlateImage, 0, recResult.nPlateLen); fs.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } // 将车牌小图显示在界面上 PlateImg.Image = null; FileInfo fi = new FileInfo(plateImgFile); if (fi.Exists) { PlateImg.Load(plateImgFile); } } }
public clsZone(System.Xml.XmlNode n, string picpath) : this() { int v = 0; Name = n.Name; max = 500; foreach (System.Xml.XmlNode a in n.Attributes) { bool bol; Int32.TryParse(a.Value, out v); switch (a.Name) { case "x": x = v; if (Pic != null && Pic.Left != x) { Pic.Location = new System.Drawing.Point(x, y); } break; case "y": y = v; if (Pic != null && Pic.Top != y) { Pic.Location = new System.Drawing.Point(x, y); } break; case "power": power = v; break; case "width": width = v; if (Pic != null && Pic.Width != width) { Pic.Width = width; } break; case "height": height = v; if (Pic != null && Pic.Height != height) { Pic.Height = height; } break; case "img": Pic = new System.Windows.Forms.PictureBox(); Pic.Location = new System.Drawing.Point(x, y); Pic.Height = height; Pic.Width = width; Pic.Visible = true; Pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; Pic.Load(picpath + a.Value); break; case "background": Pic = new System.Windows.Forms.PictureBox(); Pic.BackColor = getColor(a.Value); Pic.Location = new System.Drawing.Point(x, y); Pic.Height = height; Pic.Width = width; Pic.Visible = true; Pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; break; case "cardvisible": Visibility vis; Enum.TryParse(a.Value, out vis); visibility = vis; break; case "style": Style styl; Enum.TryParse(a.Value, out styl); style = styl; break; case "max": max = v; break; case "text": text = a.Value; break; case "tiledir": TileDir p; Enum.TryParse(a.Value, out p); tiledir = p; break; case "rotate": rotate = v; break; case "playable": bol = false; bool.TryParse(a.Value, out bol); isplayable = bol; break; case "buyable": bol = false; bool.TryParse(a.Value, out bol); isbuyable = bol; break; case "killable": bol = false; bool.TryParse(a.Value, out bol); iskillable = bol; break; case "discardable": bol = false; bool.TryParse(a.Value, out bol); isdiscardable = bol; break; } } if (Pic != null && text != null) { Pic.Tag = text; } }
private PopupPanel ParsePanel() { StringBuilder sb = new StringBuilder("<P>"); PopupPanel popupPanel = new PopupPanel(new BorderLayout()); #region Layout int i = 0; int j = 0; int end; do { end = 0; switch (this._Reader.Read()) { #region BackgroundImage case 0x55: string backgroundImageURL = this._Reader.ReadString(); if (backgroundImageURL.StartsWith("pics/")) { System.Windows.Forms.PictureBox pb = new System.Windows.Forms.PictureBox(); pb.Load("http://knuddels.net/" + backgroundImageURL); popupPanel.BackgroundImage = pb.Image; //pControl.BackgroundImage = ImageHelper.LoadImage(bgImg); if (popupPanel.BackgroundImage != null) { popupPanel.Size = popupPanel.BackgroundImage.Size; popupPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Tile; } } break; #endregion #region ScrollPane case 0x50: popupPanel.Size = new System.Drawing.Size(this._Reader.ReadShort(), this._Reader.ReadShort()); popupPanel.AutoScroll = true; break; #endregion #region GridLayout case 0x47: popupPanel = new PopupPanel(new GridLayout(this._Reader.ReadSize(), this._Reader.ReadSize(), this._Reader.ReadSize(), this._Reader.ReadSize())); break; #endregion #region CardLayout case 0x43: //popupPanel = new PopupPanel(new CardLayout()); j = 1; break; #endregion #region FlowLayout case 0x46: popupPanel = new PopupPanel(new FlowLayout()); break; #endregion #region BorderLayout case 0x42: default: i = 1; break; #endregion } } while (end != 0); #endregion int x = 0; int y = 0; while (!this._Reader.End()) { string popupAlign = string.Empty; #region Align if (i != 0) { switch (this._Reader.Read()) { case 0x4E: popupAlign = "NORTH"; break; case 0x53: popupAlign = "SOUTH"; break; case 0x45: popupAlign = "EAST"; break; case 0x57: popupAlign = "WEST"; break; case 0x43: popupAlign = "CENTER"; break; default: this._Reader.Back(1); popupAlign = "CENTER"; break; } } #endregion #region Controls System.Windows.Forms.Control pControl = null; string controlId; int fontSize = 8; System.Drawing.FontStyle fontStyle = System.Drawing.FontStyle.Regular; string controlcallBack; int opcode = this._Reader.Read(); switch (opcode) { #region Panel case 0x70: controlId = this._Reader.ReadString(opcode); pControl = ParsePanel(); //((PopupPanel)pControl).AutoSize = true; break; #endregion #region Label case 0x6C: bool setBackgroundColor = true; System.Windows.Forms.Label label = new System.Windows.Forms.Label(); label.Text = this._Reader.ReadString(); label.AutoSize = false; controlId = this._Reader.ReadString(opcode); controlcallBack = "ã"; while (!this._Reader.End()) { switch (this._Reader.Read()) { #region Font case 0x70: fontStyle = System.Drawing.FontStyle.Regular; break; case 0x69: fontStyle = System.Drawing.FontStyle.Italic; break; case 0x62: fontStyle = System.Drawing.FontStyle.Bold; break; case 0x67: fontSize = this._Reader.ReadSize() - 8; break; #endregion #region Colors case 0x74: setBackgroundColor = false; break; case 0x68: if (setBackgroundColor) { label.BackColor = this._Reader.ReadColor(); } break; case 0x66: label.ForeColor = this._Reader.ReadColor(); break; #endregion #region CallBack case 0x6E: controlcallBack += "ãsendbackã"; break; case 0x73: controlcallBack += "ãlightsubmit" + this._Reader.ReadString() + "ã"; break; #endregion #region Unknown case 0x6C: case 0x63: case 0x72: case 0x75: break; #endregion } } if (fontSize > 0) { label.Font = new System.Drawing.Font("Arial", fontSize, fontStyle); } label.Height = System.Windows.Forms.TextRenderer.MeasureText(label.Text, label.Font).Height + 4; label.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); pControl = label; break; #endregion #region Button case 0x62: System.Windows.Forms.Button button = new System.Windows.Forms.Button(); button.Text = this._Reader.ReadString(); this._Reader.ReadString(opcode); bool addForegroundColor = false; controlcallBack = "ã"; while (!this._Reader.End()) { switch (this._Reader.Read()) { #region Style case 0x63: //Neuer Button addForegroundColor = true; break; case 0x65: //Styled (New Button) break; #endregion #region Font case 0x70: fontStyle = System.Drawing.FontStyle.Regular; break; case 0x69: fontStyle = System.Drawing.FontStyle.Italic; break; case 0x62: fontStyle = System.Drawing.FontStyle.Bold; break; case 0x67: fontSize = this._Reader.ReadSize() - 4; break; #endregion #region Colors case 0x66: if (!addForegroundColor) { button.ForeColor = this._Reader.ReadColor(); } break; case 0x68: button.BackColor = this._Reader.ReadColor(); break; #endregion #region CallBack case 0x6E: //Sendback controlcallBack += "sendbackã"; break; case 0x53: //Submit controlcallBack += "submitã"; break; case 0x73: //Dispose (Close) controlcallBack += "disposeã"; break; case 0x75: //OpenURL controlcallBack += "openurl" + this._Reader.ReadString() + "ã"; break; case 0x6F: //LightSubmit controlcallBack += "lightsubmitã"; break; case 0x6B: //Id controlcallBack += "idõ" + this._Reader.ReadString() + "ã"; break; #endregion #region Unknown case 0x49: this._Reader.ReadString(); break; case 0x61: this._Reader.ReadString(); break; #endregion } } if (fontSize > 0) { button.Font = new System.Drawing.Font("Arial", fontSize, fontStyle); } pControl = button; break; #endregion #region KCodePanel case 0x63: System.Windows.Forms.Control kCodeControl = new System.Windows.Forms.Control(); string kCode = this._Reader.ReadString(); Debug.WriteLine(kCode); controlId = this._Reader.ReadString(opcode); bool bool3; System.Drawing.Size prefferedDimension = new System.Drawing.Size(0, 0); while (!this._Reader.End()) { switch (this._Reader.Read()) { #region CallBack case 0x74: controlcallBack = this._Reader.ReadString(); break; #endregion #region Colors case 0x66: kCodeControl.ForeColor = this._Reader.ReadColor(); break; case 0x68: kCodeControl.BackColor = this._Reader.ReadColor(); break; #endregion #region Dimension case 0x73: //PrefferedDimension prefferedDimension = new System.Drawing.Size(this._Reader.ReadSize(), this._Reader.ReadSize()); break; #endregion #region BackgroundImage case 0x69: //BackgroundImage string bgImg = this._Reader.ReadString(); int bgWdith = this._Reader.ReadShort(); //Nicht sicher, kp ? :D //Console.WriteLine("\tKCodePanel (BackImg) " + bgImg + " | " + bgWdith); System.Windows.Forms.PictureBox pb = new System.Windows.Forms.PictureBox(); if (bgImg.StartsWith("pics/")) { pb.Load("http://knuddels.net/" + bgImg); } kCodeControl.BackgroundImage = pb.Image; break; #endregion #region Unknown case 0x6E: //? bool3 = false; break; #endregion } } kCodeControl.Size = new System.Drawing.Size(200, 500); kCodeControl.BackColor = System.Drawing.Color.Red; pControl = kCodeControl; break; #endregion #region TextArea case 0x74: System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox(); rtb.Text = this._Reader.ReadString(); controlId = this._Reader.ReadString(opcode); int rows = this._Reader.ReadSize(); int cols = this._Reader.ReadSize(); while (!this._Reader.End()) { switch (this._Reader.Read()) { #region Font case 0x67: //FontSize fontSize = this._Reader.ReadSize() - 8; break; #endregion #region ScrollBars case 0x6E: //Horizontal rtb.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Horizontal; break; case 0x73: //Vertical rtb.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; break; case 0x62: rtb.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Both; break; #endregion #region Editable case 0x65: controlcallBack = "sendbackã"; rtb.ReadOnly = false; break; #endregion #region Colors case 0x66: rtb.ForeColor = this._Reader.ReadColor(); break; case 0x68: rtb.BackColor = this._Reader.ReadColor(); break; #endregion } } if (fontSize > 0) { rtb.Font = new System.Drawing.Font("Arial", fontSize, fontStyle); } pControl = rtb; break; #endregion #region TextField case 0x66: System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox(); textBox.Text = this._Reader.ReadString(); int row = this._Reader.ReadSize(); controlId = this._Reader.ReadString(opcode); while (!this._Reader.End()) { switch (this._Reader.Read()) { case 0x65: //Editable textBox.ReadOnly = this._Reader.ReadBoolean(); break; case 0x67: //FontSize fontSize = this._Reader.ReadSize() - 4; break; case 0x63: //EchoChar textBox.PasswordChar = (char)this._Reader.Read(); break; #region Colors case 0x66: textBox.ForeColor = this._Reader.ReadColor(); break; case 0x68: textBox.BackColor = this._Reader.ReadColor(); break; #endregion } } if (fontSize > 0) { textBox.Font = new System.Drawing.Font("Arial", fontSize, fontStyle); } pControl = textBox; break; #endregion #region CheckBox case 0x78: System.Windows.Forms.CheckBox checkBox = new System.Windows.Forms.CheckBox(); controlId = this._Reader.ReadString(opcode); while (!this._Reader.End()) { switch (this._Reader.Read()) { case 0x6C: //Text checkBox.Text = this._Reader.ReadString(); break; case 0x73: //CheckedState checkBox.Checked = this._Reader.ReadBoolean(); break; case 0x64: //Disable checkBox.Enabled = false; break; #region Font case 0x70: //Regular fontStyle = System.Drawing.FontStyle.Regular; break; case 0x69: //Itlalic fontStyle = System.Drawing.FontStyle.Italic; break; case 0x62: //Bold fontStyle = System.Drawing.FontStyle.Bold; break; case 0x67: //FontSize fontSize = this._Reader.ReadSize() - 4; break; #endregion #region Colors case 0x66: checkBox.ForeColor = this._Reader.ReadColor(); break; case 0x68: checkBox.BackColor = this._Reader.ReadColor(); break; #endregion #region Unknown case 0x53: //Console.WriteLine("CheckBox (AddItemListener) " + this._Reader.ReadString()); break; case 0x72: this._Reader.ReadSize(); break; #endregion } } if (fontSize > 0) { checkBox.Font = new System.Drawing.Font("Arial", fontSize, fontStyle); } pControl = checkBox; break; #endregion #region ComboBox case 0x6F: System.Windows.Forms.ComboBox comboBox = new System.Windows.Forms.ComboBox(); controlcallBack = "ã"; int selectedItemIndex = -1; string selectedItemText = null; while (!this._Reader.End()) { switch (this._Reader.Read()) { case 0x63: //SetSelectedIndex selectedItemIndex = this._Reader.ReadSize(); break; case 0x43: //SetSelecedItem selectedItemText = this._Reader.ReadString(); break; case 0x64: //Disable comboBox.Enabled = false; break; case 0x67: //FontSize fontSize = this._Reader.ReadSize() - 4; break; case 0x41: controlcallBack += "sendbackã"; break; #region Colors case 0x66: comboBox.ForeColor = this._Reader.ReadColor(); break; case 0x68: comboBox.BackColor = this._Reader.ReadColor(); break; #endregion #region Unknown case 0x61: Console.WriteLine("ComboBox (AddItemListener) " + this._Reader.ReadString()); break; #endregion } } if (fontSize > 0) { comboBox.Font = new System.Drawing.Font("Arial", fontSize, fontStyle); } while (!this._Reader.End()) { comboBox.Items.Add(this._Reader.ReadString()); } if (selectedItemText != null) { comboBox.SelectedText = selectedItemText; } if (selectedItemIndex >= 0) { comboBox.SelectedIndex = selectedItemIndex; } pControl = comboBox; break; #endregion #region Unknown default: controlId = this._Reader.ReadString(opcode); break; #endregion } #endregion if (pControl != null) { //pControl.Parent = popupPanel; popupPanel.addControl(popupAlign, pControl); //Console.WriteLine("Add Control " + pControl.GetType().Name); } } HTML = sb.ToString(); return(popupPanel); }