// -------------- ADD CONTROL NO PICTURE -------------- private void addGameControl(string name) { string value = "0 0 0 0"; if (Editor.iniArray.ContainsKey(name)) { value = Editor.iniArray[name]; } int[] coords = Editor.stringToRectArray(value); Size cSize = new Size(0, 0); if (isValidRect(coords)) { cSize = new Size(coords[2] - coords[0], coords[3] - coords[1]); } Bitmap img = new Bitmap(FOIE.Properties.Resources.hatch); var picture = new PictureBox { Name = name, Location = new Point(coords[0], coords[1]), Size = cSize, BackgroundImage = img, BackgroundImageLayout = ImageLayout.Tile, BackColor = Color.Transparent, }; string imgMain = Editor.currentBackground; PictureBox bgImg = panel1.Controls.Find(imgMain, true).FirstOrDefault() as PictureBox; string hint = Editor.getHintforKey(name); new ToolTip().SetToolTip(picture, hint); bgImg.Controls.Add(picture); PictureBox picBox = this.Controls.Find(name, true).FirstOrDefault() as PictureBox; picBox.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); picBox.LocationChanged += new System.EventHandler(this.pictureBox1_LocationChanged); picBox.SizeChanged += new System.EventHandler(this.pictureBox1_LocationChanged); // picBox.MouseDown += (sender, e) => picBox.BringToFront(); picBox.MouseDown += (sender, e) => picBoxClickHighlight(picBox, e); picBox.MouseUp += (sender, e) => picBoxClickHighlightOff(picBox, e); ControlMoverOrResizer.Init(picBox); string areaSize = Editor.getSizeFromStringCoords(value); addTxtControlsLine(null, name, true, true, value, areaSize, false, "Area", true); }
private void addMainPic(string name, string bgImage) { string areaValue = "0 0 0 0"; string picName = ""; Bitmap img; Size pSize = new Size(0, 0); Size cSize = new Size(0, 0); //----------------------------------------------------------------------------------- if (Editor.iniArray.ContainsKey(bgImage)) { picName = Editor.iniArray[bgImage]; } string path = (Editor.fullPath + picName); bool imgExist = true; try { img = LoadBitmapUnlocked(@path); pSize = new Size(img.Width, img.Height); } catch { img = new Bitmap(FOIE.Properties.Resources.nofile1); imgExist = false; } //----------------------------------------------------------------------------------- if (Editor.iniArray.ContainsKey(name)) { areaValue = Editor.iniArray[name]; int[] coords = Editor.stringToRectArray(areaValue); if (isValidRect(coords)) { cSize = new Size(coords[2] - coords[0], coords[3] - coords[1]); } } if (name == "0") //if (name == "" || name == null) { if (imgExist) { cSize = pSize; } else { cSize = new Size(0, 0); } } var picture = new PictureBox { Name = name, //"imgMain", Size = cSize, Location = new Point(0, 0), Image = img, BackgroundImageLayout = ImageLayout.None, }; picture.LocationChanged += new System.EventHandler(this.pictureBox1_LocationChanged); picture.SizeChanged += new System.EventHandler(this.pictureBox1_LocationChanged); picture.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); string areaSize = Editor.getSizeFromStringCoords(areaValue); string imgSize = pSize.Width + "x" + pSize.Height; addTxtControlsLine(name, name, false, false, areaValue, areaSize, false, "Area", true); addTxtControlsLine(name, bgImage, false, false, picName, imgSize, true, "Picture", imgExist); ControlMoverOrResizer.Init(picture); //allow move and resize main BG string hint = Editor.getHintforKey(name); new ToolTip().SetToolTip(picture, hint); panel1.Controls.Add(picture); }
// -------------- ADD addBttnControl -------------- private void addBttnControl(string[] line) { string areaValue = "0 0 0 0"; if (Editor.iniArray.ContainsKey(line[0])) { areaValue = Editor.iniArray[line[0]]; } Bitmap img; int[] coords = Editor.stringToRectArray(areaValue); Size cSize = new Size(0, 0); if (isValidRect(coords)) { cSize = new Size(coords[2] - coords[0], coords[3] - coords[1]); } string name = line[0]; var picture = new PictureBox { Name = name, Location = new Point(coords[0], coords[1]), Size = cSize, BackColor = Color.Transparent, }; string imgMain = Editor.currentBackground; PictureBox bgImg = panel1.Controls.Find(imgMain, true).FirstOrDefault() as PictureBox; string hint = Editor.getHintforKey(name); new ToolTip().SetToolTip(picture, hint); bgImg.Controls.Add(picture); PictureBox picBox = this.Controls.Find(name, true).FirstOrDefault() as PictureBox; picBox.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); picBox.MouseDown += (sender, e) => picBoxClickHighlight(picBox, e); picBox.MouseUp += (sender, e) => picBoxClickHighlightOff(picBox, e); picBox.LocationChanged += new System.EventHandler(this.pictureBox1_LocationChanged); picBox.SizeChanged += new System.EventHandler(this.pictureBox1_LocationChanged); ControlMoverOrResizer.Init(picBox); string imgSize = cSize.Width + "x" + cSize.Height; addTxtControlsLine(name, name, true, true, areaValue, imgSize, false, "Area", true); //--------------------------------------------------------------------- for (int i = 1; i < line.Length; i++) { string picSize = ""; bool picExist = true; string value = (Editor.iniArray.ContainsKey(line[i])) ? Editor.iniArray[line[i]] : ""; string path = Editor.fullPath + value; try { //img = new Bitmap(@path); img = LoadBitmapUnlocked(@path); cSize = new Size(img.Width, img.Height); picSize = cSize.Width + "x" + cSize.Height; } catch { img = new Bitmap(FOIE.Properties.Resources.nofile1); picSize = "error"; picExist = false; } addTxtControlsLine(line[0], line[i], false, false, value, picSize, true, "Picture", picExist); } }