public void SetWindowState(FormWindowState stat) { if (stat == FormWindowState.Normal) { pictureBox3.BringToFront(); } else { pictureBox2.BringToFront(); } }
public void Initialize_Form() { #region main controls transBox = new PictureBox(); transBox.Size = new Size(1000, 1000); transBox.Location = new Point(-0, -150); transBox.BackColor = Color.FromArgb(32,32,32); transBox.BringToFront(); transBox.Visible = true; this.Controls.Add(transBox); transBox.BringToFront(); this.Location = new Point(500, 200); InitializeComponent(); #endregion }
// freeze the form public void Freeze() { // Remember we have frozen the form once more // Do nothing if it was already frozen if (++FreezeCount > 1) return; Rectangle rect = form.ClientRectangle; if (rect.IsEmpty || form.WindowState == FormWindowState.Minimized) return; Point topLeft = form.PointToScreen(new Point(rect.Left, rect.Top)); // Create a PictureBox that resizes with its contents pictureBox = new PictureBox(); pictureBox.SizeMode = PictureBoxSizeMode.AutoSize; // create a bitmap as large as the form's client area and with same color depth using (Graphics frmGraphics = form.CreateGraphics()) { Bitmap bitmap = new Bitmap(rect.Width, rect.Height, frmGraphics); hBitmap = bitmap.GetHbitmap(); pictureBox.Image = Image.FromHbitmap(hBitmap); } // copy the screen contents, from the form's client area to the hidden bitmap using (Graphics picGraphics = Graphics.FromImage(pictureBox.Image)) { picGraphics.CopyFromScreen(topLeft, Point.Empty, rect.Size, CopyPixelOperation.SourceCopy); } // Display the bitmap in the picture box, and show the picture box in front of all other controls form.Controls.Add(pictureBox); pictureBox.BringToFront(); }
public PictureBox Abeja() { PictureBox bee = new PictureBox(); bee.BackgroundImage = global::SimulacionAbejasHilos.Properties.Resources.Bee; bee.BackColor = System.Drawing.Color.Transparent; bee.BackgroundImage.RotateFlip(RotateFlipType.Rotate180FlipNone); bee.Location = new System.Drawing.Point(68, 114); bee.Size = new System.Drawing.Size(25, 22); bee.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; bee.BringToFront(); if (this.InvokeRequired) { this.Invoke(new MethodInvoker( delegate() { this.Controls.Add(bee); } )); } else { this.Controls.Add(bee); } return bee; }
private int totalPoint; // le score du joueur #endregion Fields #region Constructors // constructeur, on recoit le panel, le point de départ dans le panel et si le joueur est le premier ou le deuxieme public Joueur(Panel panel, Point loc, bool j1) { pBJoueur = new PictureBox(); // on instencie le pB du joueur pBJoueur.Location = loc; // on place le joueur a la bonne position dans le panel pBJoueur.BackColor = Color.Transparent; // Astuce pour avoir un fond transparent avec un bitmap. La couleur de fond est transparente Bitmap vaisseau; if (j1) // Si c'est le joueur 1 alors il sera blanc. On choisi un pixel ( dans un des coins) dont la couleur correspondra au transparent { joueur1 = true; // variable pour les animations (pas avoir de changement de couleurs lors du changement d'image) vaisseau = new Bitmap(@".\vaisseau.bmp"); vaisseau.MakeTransparent((vaisseau.GetPixel(0, vaisseau.Size.Height - 1))); } // si c'est le joueur 2 else { joueur1 = false; vaisseau = new Bitmap(@".\vaisseau2.bmp"); vaisseau.MakeTransparent((vaisseau.GetPixel(0, vaisseau.Size.Height - 1))); } pBJoueur.Size = new Size(50, 50); // on donne la taille au pB pBJoueur.Image = vaisseau; // On donne au pB l'image pBJoueur.BringToFront(); // On met le pB au premier plan pour éviter des recouvrements this.panelFond = panel; // On met le panel recu dans une des variables pour éviter de devoir faire des envois intempestifs panelFond.Controls.Add(pBJoueur); // on ajoute le joueur au controle du panel (pour qu'on ne voie pas le gros carré noir) pBJoueur.Refresh(); // Pour etre certain que l'image est bien présente dans le pB totalPoint = 0; // on mets son score a 0 combo = 1000; // On rempli sa jauge de super tir }
private void addPB(PictureBox i_picturebox, int i_top, int i_left) { i_picturebox.Top = i_top; i_picturebox.Left = i_left; i_picturebox.BringToFront(); m_txtBox.FindForm().Controls.Add(i_picturebox); }
private void timer1_Tick(object sender, System.EventArgs e) { try { if (_iIndexImageHT == dtPathImage.Rows.Count) { _iIndexImageHT = 0; } picbx.Image = Image.FromFile(dtPathImage.Rows[_iIndexImageHT]["ten"].ToString()); _iIndexImageHT++; //lblbndangkham_hienthi.Visible=false; picbx.Visible = true; picbx.BringToFront(); _lblhoten.Visible = _lblstt.Visible = false; } catch {} }
/// <summary> 窗体加载事件 /// </summary> private void frmPicture_Load(object sender, EventArgs e) { //tsmiFileNew_Click(sender, e); //固定绘图窗口位置 this.StartPosition = FormStartPosition.Manual; this.Location = new Point(60, 230); #region 清除临时文件及加载打开的文件 _filepath = @"C:\Users\Administrator\Desktop\绘图3.cfg"; String openfile = @"C:\Users\Administrator\Desktop\绘图3.cfg"; _autosavepath = @"C:\Users\Administrator\Desktop\绘图3.cfg"; if (!_filepath.Equals(openfile)) { if (File.Exists(_autosavepath)) { if (DialogResult.Yes == MessageBox.Show("工作区域从错误中恢复,是否打开恢复文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { _filepath = openfile; openfile = _autosavepath; } } else { _filepath = openfile; } } using (FileStream fs = new FileStream(openfile, FileMode.Open)) { _wa.OpenWork(fs); fs.Close(); } #endregion String filename = Path.GetFileName(openfile); //this.Text = String.Format(_frmtitle, filename.Substring(0, filename.IndexOf("."))); this.Text = String.Format(filename.Substring(0, filename.IndexOf("."))); CreateWorkArea(); hscWScroll.Value = 0; vscWScroll.Value = 0; ScrollBar_Scroll(null, null); tmrAutoSave_Tick(sender, e); _ischange = false; _wa.RecordHistory(false); PictureBox pictureBox01; pictureBox01 = new System.Windows.Forms.PictureBox(); pictureBox01.BackColor = System.Drawing.SystemColors.Control; pictureBox01.BackgroundImage = global::IronShoes.Properties.Resources.drawtool; pictureBox01.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; pictureBox01.Location = new System.Drawing.Point(658, 452); pictureBox01.Name = "pictureBox01"; pictureBox01.Size = new System.Drawing.Size(50, 50); this.Controls.Add(pictureBox01); pictureBox01.BringToFront(); }
private void dg_import_image_FileOk(object sender, EventArgs e) { PictureBox pBox = new PictureBox(); pBox.Image = Image.FromFile(this.dg_import_image.FileName); pBox.Size = pBox.Image.Size; pBox.Location = new Point((int)(0.5f * (this.Width - pBox.Size.Width)), (int)(0.5f * (this.Height - pBox.Size.Height))); //pBox.Click += new EventHandler(pBox_Click); pBox.DragDrop += new DragEventHandler(pBox_DragDrop); this.pBoxes.Add(pBox); this.Controls.Add(pBox); pBox.BringToFront(); }
private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { PictureBox splashImage = new PictureBox(); Form aboutFrm = new Form(); aboutFrm.ClientSize = new System.Drawing.Size(600, 400); aboutFrm.Controls.Add(splashImage); splashImage.ClientSize = new System.Drawing.Size(600, 400); splashImage.BringToFront(); splashImage.BackgroundImage = new Bitmap(MedTermsFlashCardApplication.Properties.Resources.Splash); splashImage.Show(); aboutFrm.ShowDialog(); }
private void CFormListeStandardTimos_Load(object sender, System.EventArgs e) { CCustomiseurFenetresStandard.BrancheSurFenetre(this); m_btnActions.BringToFront(); #if DEBUG if (!DesignMode) { m_lnkRechercheObjetsNonUtilises.Visible = typeof(IObjetCherchable).IsAssignableFrom(ListeObjets.TypeObjets); } #else m_lnkRechercheObjetsNonUtilises.Visible = false; #endif }
public void CreateTerrainSlice(int height, int x, int y) { y = playGround.Bottom - height; PictureBox test = new PictureBox { Name = "pictureBox", Size = new Size(1, 1), Location = new Point(x, y), Visible = true, BackColor = Color.Black }; test.Height = height; test.BringToFront(); playGround.Controls.Add(test); }
/// <summary> /// Renders the blur. /// </summary> public void RenderBlur() { Bitmap bitmap = TakeSnapshot(); GaussianBlur(bitmap, BlurStrength); control.Controls.Add(pb); pb.Visible = true; pb.Image = bitmap; pb.Dock = DockStyle.Fill; pb.BringToFront(); control.Enabled = MakeTargetInactive; GC.Collect(); }
public static PictureBox CreateTerrainSlice(int height, int x, int y) { y = UI.playGround.Bottom - height; PictureBox slice = new PictureBox { Name = "pictureBox", Size = new Size(1, 1), Location = new Point(x, y), Visible = true, BackColor = Color.Black }; slice.Height = height; slice.BringToFront(); UI.playGround.Controls.Add(slice); return slice; }
void AddLocation(Location loc) { // Add npc to the list ListViewItem lvi = lvLocations.Items.Add(loc.ID.ToString()); lvi.SubItems.Add(loc.Name); lvi.Tag = loc; // Add npc to the map PictureBox pb = new PictureBox(); SetMapMarkerDark(pb, loc); _mapMarkers.Add(pb); Controls.Add(pb); pb.BringToFront(); pb.Tag = lvi; pb.MouseClick += Pb_MouseClick; pb.MouseMove += Pb_MouseMove; }
void AddNPC(NPC npc) { // Add npc to the list NPCNameID nameID = Program.s_npcNameIDs[npc.GameID]; ListViewItem lvi = lvNPCs.Items.Add(npc.ID.ToString() + ": " + nameID.ToString()); lvi.Tag = npc; // Add npc to the map PictureBox pb = new PictureBox(); SetMapMarkerRed(pb, npc); _mapMarkers.Add(pb); Controls.Add(pb); pb.BringToFront(); pb.Tag = lvi; pb.MouseClick += Pb_MouseClick; pb.MouseMove += Pb_MouseMove; }
//Permet de créer un enemi en multijoueur du coté client. Le client recoit la coordonnée de l'apparition de l'enemi public Enemi(Panel panel, Point z, Boolean multi) { this.p.X = z.X; this.p.Y = z.Y; enemi = new PictureBox(); Image vaisseau = Image.FromFile(@".\enemi1.png"); enemi.Image = vaisseau; enemi.BringToFront(); enemi.Height = 30; enemi.Width = 60; if (!multi) { enemi.BackColor = Color.Transparent; } enemi.Location = p; panel.Controls.Add(enemi); lives = 2; }
private void addRandomFlower() { try { PictureBox rnd = new System.Windows.Forms.PictureBox(); rnd.Image = this.randomImage; rnd.Name = GetPictureName(); int imY = rnd.Image.Size.Height; int imX = rnd.Image.Size.Width; rnd.Location = new System.Drawing.Point(getRandom(-imX, scrW), getRandom(-imY, scrH)); rnd.Size = new System.Drawing.Size(imX, imY); this.Controls.Add(rnd); rnd.BringToFront(); } catch { } }
private void Track(Point p) { PictureBox Item = new System.Windows.Forms.PictureBox(); Item.BackColor = Color.Black; Item.Location = p; Item.Name = "Shot"; Item.Size = new System.Drawing.Size(5, 5); Item.TabStop = false; Item.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tank_MouseDown); Item.MouseMove += new System.Windows.Forms.MouseEventHandler(this.tank_MouseMove); Item.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tank_MouseUp); this.Controls.Add(Item); Item.BringToFront(); }
public void createCanvas(int column, int row, int size) { for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { System.Windows.Forms.PictureBox newBox = new System.Windows.Forms.PictureBox(); newBox.Name = "cell"; newBox.Top = 27 + (i * size); newBox.Left = 12 + (j * size); newBox.Size = new System.Drawing.Size(size, size); newBox.BackColor = Color.White; newBox.BringToFront(); this.Controls.Add(newBox); cells.Add(newBox); newBox.Click += new System.EventHandler(this.handleCellClick); newBox.MouseEnter += new System.EventHandler(this.highlightSelection); } } }
public PlayJpegsInBatchMode(APPLICATION_DATA appData, Panel parentPanel, Form parentForm, int chan) { m_AppData = appData; m_AppData.AddOnClosing(OnStop, APPLICATION_DATA.CLOSE_ORDER.FIRST); m_Log = (ErrorLog)m_AppData.Logger; m_AppData.DVRMode = APPLICATION_DATA.DVR_MODE.STORE_ON_PLATE_FOUND; // need this set for LPR to not consolidate multiple video frames m_Channel = chan; m_ParentForm = parentForm; m_ParentPanel = parentPanel; m_DisplayImagePB = new PictureBox(); m_DisplayImagePB.SizeMode = PictureBoxSizeMode.StretchImage; m_DisplayImagePB.BackColor = Color.Black; m_DisplayImagePB.Size = m_ParentPanel.Size; m_ParentPanel.Controls.Add(m_DisplayImagePB); m_DisplayImagePB.BringToFront(); }
private void pictureBox_Click(object sender, EventArgs e) { MouseEventArgs mouseEvent = (MouseEventArgs)e; if (mouseEvent.Button.ToString() == "Right") { return; } PictureBox pic = sender as PictureBox; if (null == pic) { return; } m_curPictureBox = pic; int index = (int)pic.Tag; if (!m_isFull) { setPicTotalSize(); m_curPictureBox.BringToFront(); m_isFull = true; } else { if (m_bSizeChange) { setFourPicSize(); m_bSizeChange = false; } else { setPicSize(index); } m_isFull = false; } }
public TerrainDisplay(TerrainTile[,] tiles) { mode = Mode.Erase; this.tilesBak = (TerrainTile[,])tiles.Clone(); this.tiles = tiles; ClientSize = new Size(800, 800); BackColor = Color.Blue; WindowState = FormWindowState.Maximized; panel = new Panel() { Dock = DockStyle.Fill, AutoScroll = true, Controls = { (pic = new PictureBox() { Image = bmp = RenderColorBmp(tiles), SizeMode = PictureBoxSizeMode.AutoSize, }) } }; panel.HorizontalScroll.Enabled = true; panel.VerticalScroll.Enabled = true; panel.HorizontalScroll.Visible = true; panel.VerticalScroll.Visible = true; Controls.Add(panel); pic2 = new PictureBox() { Image = bmp, Width = 250, Height = 250, SizeMode = PictureBoxSizeMode.Zoom }; Controls.Add(pic2); pic2.BringToFront(); Text = mode.ToString(); pic.MouseMove += new MouseEventHandler(pic_MouseMove); pic.MouseDoubleClick += new MouseEventHandler(pic_MouseDoubleClick); }
private int points = 100; // On lui attribue une certaine valeur pour le score #endregion Fields #region Constructors // création, il recoit le panel sur lequel il va apparaitre et aussi si il est utilisé en multijoueur ou pas public Enemi(Panel panel, Boolean multi) { Random rnd = new Random(); // On crée un nombre aléatoire enemi = new PictureBox(); // on instancie le pB p = new Point(); // on instancie la position p.X = panel.Width; // On le met à droite du panel p.Y = rnd.Next(0, panel.Height - enemi.Height); // sa hauteur est aléatoire Image vaisseau = Image.FromFile(@".\enemi1.png"); // On lui met une image enemi.BringToFront(); // On le met au premier plan pour pas qu'il ne soit recouvert par un autre picturebox enemi.Image = vaisseau; // on attribue l'image au pB enemi.Height = 30; // on donne sa hauteur et largeur a l'enemi enemi.Width = 60; if (!multi) { enemi.BackColor = Color.Transparent; // pour éviter des pertes de performance en multijoueur, on laisse le carré noir } enemi.Location = p; // on le place en p panel.Controls.Add(enemi);// On ajoute son controle au panel (redondance) lives = 2; // On lui attribue 2 vies enemi.Refresh(); // Redondance pour etre sur que son dessin soit mis }
// Fenêtre Settings Général private void AddTriangle(Button sender) { PictureBox PB = new PictureBox(); PB.Name = "PB_triangle"; PB.BackgroundImage = new Bitmap(ChangeImageColor_GetPixel("triangle")); PB.Size = new Size(12, 31); PB.BackColor = Color.White; PB.SizeMode = PictureBoxSizeMode.Zoom; int pX; if (sender.Location.X < this.Width / 2) pX = sender.Width; else { pX = this.Width - sender.Width - PB.Width - 16; PB.BackgroundImage.RotateFlip(RotateFlipType.Rotate180FlipNone); } PB.Location = new Point(pX, 35); Controls.Add(PB); PB.BringToFront(); }
private void Cuarto_Load(object sender, EventArgs e) { if (Var.Id_room == 3) { lblHombre.Dispose(); tmrCheck.Enabled = false; } //======================================================================================= lblNombre.Text = Var.room; lblNombre.BackColor = Color.Transparent; if (Var.room == "Bedroom") this.BackgroundImage = Image.FromFile(@"fondos\habitacion.png"); else if (Var.room == "Kitchen") this.BackgroundImage = Image.FromFile(@"fondos\cocina.png"); else if (Var.room == "Bathroom") this.BackgroundImage = Image.FromFile(@"fondos\baño.png"); else if (Var.room == "Living") this.BackgroundImage = Image.FromFile(@"fondos\living.png"); else if (Var.room == "Hall") this.BackgroundImage = Image.FromFile(@"imagenes\escalera.png"); //========================================SpeechToText================================================ sRecognizer.SetInputToDefaultAudioDevice(); sSynthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult); Choices things = new Choices(new string[] { "lights", "music", "cooler","alarm" }); Choices actions = new Choices(new string[] { "on", "off" }); GrammarBuilder TurnOnOff = new GrammarBuilder("Turn"); TurnOnOff.Append(actions); TurnOnOff.Append("the"); TurnOnOff.Append(things); Grammar servicesGrammar = new Grammar(TurnOnOff); sRecognizer.LoadGrammarAsync(servicesGrammar); Choices name = new Choices(new string[] { "Lili" }); Grammar call=new Grammar(name); sRecognizer.LoadGrammar(call); Choices home = new Choices(new string[] { "go home" }); sRecognizer.LoadGrammar(new Grammar(home)); Choices secure= new Choices(new string[] { "lock", "unlock" }); GrammarBuilder Lock = new GrammarBuilder(secure); Lock.Append("the door"); servicesGrammar = new Grammar(Lock); sRecognizer.LoadGrammarAsync(servicesGrammar); sRecognizer.RecognizeAsync(RecognizeMode.Multiple); sRecognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sRecognizer_SpeechRecognized); sRecognizer.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(sRecognizer_SpeechRecognitionRejected); sRecognizer.AudioLevelUpdated += new EventHandler<AudioLevelUpdatedEventArgs>(sRecognizer_AudioLevelUpdated); sRecognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(sRecognizer_RecognizeCompleted); //+++++++++++++++++++++++++++++++++++++++++++++++++++ if (Var.aparato != null) { Aparato.Name = "chk" + Var.aparato; Aparato.Location = new Point(12, 28); Aparato.Parent = this; Aparato.Visible = true; Aparato.Enabled = true; Aparato.Text = Var.aparato; Aparato.CheckedChanged += new EventHandler(Checkbox_CheckedChanged); Aparato.BackColor = Color.Transparent; imagen = new PictureBox(); imagen.BringToFront(); imagen.AutoSize = false; imagen.SizeMode = PictureBoxSizeMode.StretchImage; imagen.Size = new Size(90, 80); imagen.Name = "lblAparato"; imagen.Visible = false; imagen.Location = new Point(29, 131); imagen.Parent = this; imagen.Enabled = true; imagen.BringToFront(); imagen.BackColor = Color.Transparent; } if (Var.Id_room == 5) { imagen.Image = Image.FromFile(@"fotos\candado.png"); } else if (Var.Id_room == 1) { imagen.Image = Image.FromFile(@"Dibujos\alarm.png"); } else if (Var.Id_room == 4) { imagen.Image = Image.FromFile(@"fotos\ventilador.png"); } }
/// /////////////////////////////////////////////////////// private void CWndPostit_Resize(object sender, System.EventArgs e) { m_panelTitre.BringToFront(); m_btnResize.BringToFront(); AssureBounds(); }
private void Update(object sender, EventArgs e) { PokeMMOCycle pokeCycle = new PokeMMOCycle(); int cycle = pokeCycle.Cycle; CurrentCycle.Text = "Cycle " + cycle; TimeSpan timeLeftTS = pokeCycle.TimeLeft; TimeLeft.Text = String.Format("Time Left : {0:00}:{1:00}:{2:00}", timeLeftTS.Hours, timeLeftTS.Minutes, timeLeftTS.Seconds); if (cycle != lastCycle) { lastCycle = cycle; updatePics = true; } if (updatePics) { updatePics = false; // updating the list of pokemons to show String[,] PokemonList = pokeCycle.PokemonListCurrentCycle; int width = this.ClientSize.Width; int elmntWidth = (width) / PokemonList.GetLength(0); int padding = 5; // remove the pictures components from the frame Control[] Carray = new Control[this.Controls.Count]; this.Controls.CopyTo(Carray, 0); foreach (Control c in Carray) { if (c.Name.Contains("pokemonBox")) { this.Controls.Remove(c); } } String extention; if (Properties.Settings.Default.AnimatedSprits) { extention = ".gif"; } else { extention = ".png"; } for (int i = 0; i < PokemonList.GetLength(0) - 1; i++) { System.Windows.Forms.PictureBox pictureBoxPKM; pictureBoxPKM = new System.Windows.Forms.PictureBox(); pictureBoxPKM.Name = "pokemonBox" + (i + 1); //((System.ComponentModel.ISupportInitialize)(pictureBoxPKM)).BeginInit(); pictureBoxPKM.ErrorImage = global::PokeMMOCycleGUI.Properties.Resources.imageNotFound; pictureBoxPKM.BackgroundImage = Image.FromFile("./ressources/pokemonFrame.png"); pictureBoxPKM.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; pictureBoxPKM.Location = new System.Drawing.Point(padding + elmntWidth * i, 40); pictureBoxPKM.Size = new System.Drawing.Size(elmntWidth - 5, elmntWidth + 8); pictureBoxPKM.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; pictureBoxPKM.BringToFront(); pictureBoxPKM.BackColor = System.Drawing.Color.Transparent; try { pictureBoxPKM.Image = Image.FromFile("./ressources/" + PokemonList[i, 0] + extention); } catch { pictureBoxPKM.Image = Properties.Resources.imageNotFound; } pictureBoxPKM.Tag = PokemonList[i, 0] + "\nEncounter Rate : " + PokemonList[i, 1] + "% \nLevel : " + PokemonList[i, 2]; pictureBoxPKM.MouseHover += pictureBox_MouseHover; this.Controls.Add(pictureBoxPKM); //((System.ComponentModel.ISupportInitialize)(pictureBoxPKM)).EndInit(); } // // Zubat // System.Windows.Forms.PictureBox pictureBoxZubat; pictureBoxZubat = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(pictureBoxZubat)).BeginInit(); pictureBoxZubat.Name = "pokemonBox0"; pictureBoxZubat.ErrorImage = global::PokeMMOCycleGUI.Properties.Resources.imageNotFound; pictureBoxZubat.Location = new System.Drawing.Point(315, 7); pictureBoxZubat.Size = new System.Drawing.Size(40, 40); pictureBoxZubat.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; pictureBoxZubat.BringToFront(); pictureBoxZubat.BackColor = System.Drawing.Color.Transparent; try { pictureBoxZubat.Image = Image.FromFile("./ressources/" + PokemonList[PokemonList.GetLength(0) - 1, 0] + extention); } catch { pictureBoxZubat.Image = Properties.Resources.imageNotFound; } pictureBoxZubat.Tag = "Zubat\nEncounter Rate : " + PokemonList[PokemonList.GetLength(0) - 1, 1] + "% \nLevel : " + PokemonList[PokemonList.GetLength(0) - 1, 2]; pictureBoxZubat.MouseHover += pictureBox_MouseHover; this.Controls.Add(pictureBoxZubat); ((System.ComponentModel.ISupportInitialize)(pictureBoxZubat)).EndInit(); } }
private void showMap() { MazeGeneratorPrim.maxl = 0; showSolNr = 0; finish = false; changeTime = TimeSpan.Zero; clearAll(); /*if (imgParent != null) imgParent.Dispose*/ imgParent = new PictureBox(); x = xVal; y = yVal; if (gameWidth / x > gameHeight / y) { tileDim = gameHeight / y; Y0Map = Y0; X0Map = X0 + (gameWidth - tileDim * x) / 2; } else { tileDim = gameWidth / x; Y0Map = Y0 + (gameHeight - tileDim * y) / 2; X0Map = X0; } speedCh = 10 * tileDim / 100; imgParent.Width = x * tileDim; imgParent.Height = y * tileDim; imgParent.SizeMode = PictureBoxSizeMode.StretchImage; imgParent.Image = Properties.Resources.Grass; imgParent.Location = new Point(X0Map, Y0Map); this.Controls.Add(imgParent); imgParent.SendToBack(); x -= 2; y -= 2; MazeGeneratorPrim.generateMap(x, y, ref xs, ref ys, ref a); int xi, yi; for (yi = 0; yi <= y + 1; yi++) { for (xi = 0; xi <= x + 1; xi++) { if (a[yi, xi] == 2 || a[yi, xi] == 1) { PictureBox img = new PictureBox(); img.Width = img.Height = tileDim; img.SizeMode = PictureBoxSizeMode.StretchImage; img.Image = Properties.Resources.Stone; img.Location = new Point(xi * tileDim, yi * tileDim); this.Controls.Add(img); img.Parent = imgParent; Rectangle frameStone = new Rectangle(img.Location, new Size(img.Width, img.Height)); listStones.Add(frameStone); } } } /*if (chImg != null) chImg.Dispose();*/ chImg = new PictureBox(); chImg.Width = 40 * tileDim / 100; chImg.Height = 65 * tileDim / 100; chImg.SizeMode = PictureBoxSizeMode.StretchImage; chImg.Image = Properties.Resources.RStay; chImg.Location = new Point(xs * tileDim, ys * tileDim); this.Controls.Add(chImg); chImg.BringToFront(); chImg.BackColor = Color.Transparent; chImg.Parent = imgParent; chImgFrame.Location = chImg.Location; chImgFrame.Size = chImg.Size; MazeGeneratorPrim.findMaxLength(xs, ys, 1, ref xf, ref yf, a); //if (imgFinal != null) // imgFinal.Dispose(); imgFinal = new PictureBox(); imgFinal.Size = new Size(tileDim, tileDim); ; imgFinal.SizeMode = PictureBoxSizeMode.StretchImage; imgFinal.Image = Properties.Resources.Finish; imgFinal.Location = new Point(xf * tileDim, yf * tileDim); imgFinalFrame = new Rectangle(imgFinal.Location, imgFinal.Size); this.Controls.Add(imgFinal); imgFinal.BackColor = Color.Transparent; imgFinal.Parent = imgParent; imgFinal.BringToFront(); startTime = DateTime.Now.TimeOfDay; timeSpanTimer.Start(); }
//nach character selektierung die oberfläche ändern private void selectCharacter() { selectedCharacterName.Text = selectedCharacter.Name; if (selectedCharacter.Equipment != null) { //leere benutzeroberfläche von früheren character die labels foreach (Label lb in this.Controls.OfType<Label>().ToArray()) { if (lb.Name.Contains("EquipmentLabel")) { lb.Dispose(); this.Controls.Remove(lb); } } //leere benutzeroberfläche von früheren character die picture boxen foreach (PictureBox pb in this.Controls.OfType<PictureBox>().ToArray()) { if (pb.Name.Contains("ItemPicture")) { pb.Dispose(); this.Controls.Remove(pb); } } int count = 0; int row = 0; foreach (Equipment equipment in selectedCharacter.Equipment) { Label label = new Label(); label.Location = new Point(350 + row, 100 + count); label.Size = new Size(100, 20); label.Text = equipment.Slot; label.Name = "EquipmentLabel" + equipment.Id; label.BackColor = Color.Transparent; label.Parent = background; this.Controls.Add(label); label.BringToFront(); PictureBox picture = new PictureBox(); picture.Location = new Point(450 + row, 100 + count); picture.Size = new Size(64, 64); picture.Text = equipment.Slot; picture.BackColor = Color.Transparent; picture.Name = "ItemPicture" + equipment.Id; picture.Parent = background; this.Controls.Add(picture); picture.BringToFront(); row += 210; if (row > 630) { count += 70; row = 0; } } } }
private void avatarBox_Click(object sender, EventArgs e) { if (pb != null) { this.WindowState = FormWindowState.Maximized; p.Show(); pb.Show(); } else { try { Cursor.Current = Cursors.WaitCursor; p = new Panel(); p.Location = new Point(0, 0); p.BackColor = Color.Black; pb = new PictureBox(); string url = _User.profile_image_url.Replace("_normal", ""); var request = WebRequestFactory.CreateHttpRequest(url); var httpResponse = (HttpWebResponse)request.GetResponse(); Stream stream = httpResponse.GetResponseStream(); Image i = new Bitmap(stream); pb.Image = i; pb.SizeMode = PictureBoxSizeMode.StretchImage; this.WindowState = FormWindowState.Maximized; pb.Size = getImageSize(i.Size, Screen.PrimaryScreen.Bounds.Size); pb.Location = new Point((Screen.PrimaryScreen.Bounds.Width / 2) - (pb.Size.Width / 2), (Screen.PrimaryScreen.Bounds.Height / 2) - (pb.Size.Height / 2)); pb.Click += new EventHandler(pb_Click); p.Click += new EventHandler(pb_Click); p.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); p.Visible = true; this.Controls.Add(p); p.BringToFront(); this.Controls.Add(pb); pb.BringToFront(); Cursor.Current = Cursors.Default; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); pb.Hide(); } } }
private void btnLogin_Click(object sender, EventArgs e) { if (btnLogin.Text == "Đăng nhập") { txtUser.Enabled = false; txtPass.Enabled = false; PictureBox loading = new PictureBox(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoadingForm)); loading.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); loading.Size = new System.Drawing.Size(172, 107); loading.Location = new Point(200, 50); loading.BackColor = Color.Transparent; loading.Name = "group_loading_gif"; dgGroups.Controls.Add(loading); loading.BringToFront(); SE.FBLogin(txtUser.Text, txtPass.Text); if (cbRemember.Checked) { Properties.Settings.Default.user = txtUser.Text; Properties.Settings.Default.Save(); Properties.Settings.Default.pass = txtPass.Text; Properties.Settings.Default.Save(); } else { Properties.Settings.Default.user = ""; Properties.Settings.Default.Save(); Properties.Settings.Default.pass = ""; Properties.Settings.Default.Save(); } } else { if (!SE.ready) { MessageBox.Show("Chương trình đang thực hiện 1 tác vụ, không thể đăng xuất!"); return; } btnLogin.Enabled = false; SE.Logout(); } }
private void PbVc_MouseClick(object sender, MouseEventArgs e) { //如果验证码没有成功加载,则视为点击刷新 if (pbVc.Image == null) { LoadVerifyCode(); return; } //添加mark var point = e.Location + new Size(0, -30); if (point.X == 0 || point.Y == 0) return; //非法坐标 (Points ?? (Points = new List<Point>())).Add(point); //添加marker var marker = new PictureBox() { Location = e.Location + new Size(-16, -16), Image = Properties.Resources.vc_marker, SizeMode = PictureBoxSizeMode.AutoSize, Tag = point }; imgContainer.Controls.Add(marker); marker.BringToFront(); //添加marker移除事件 marker.Click += (x, y) => { Points.Remove((Point)(x as PictureBox).Tag); imgContainer.Controls.Remove(x as PictureBox); btnOK.Enabled = Points.Count > 0; }; btnOK.Enabled = true; }
protected void ShowSelectedTile(Point coordinate) { Point newPoint = new Point(); newPoint.X = (coordinate.X * 50) + 5; newPoint.Y = (coordinate.Y * 50) + 5; if (pbSelectedTile == null) { pbSelectedTile = new PictureBox(); pbSelectedTile.Name = "pbSelectedTile"; pbSelectedTile.Location = newPoint; pbSelectedTile.Size = new Size(45, 45); pbSelectedTile.BackColor = Color.Honeydew; pnlBackground.Controls.Add(pbSelectedTile); pbSelectedTile.BringToFront(); } else { pbSelectedTile.Location = newPoint; } }
/*protected Point SetLocation(Point thePoint, int multiplier) { Point newLocation = new Point(); newLocation.X = (multiplier * thePoint.X) + 10; newLocation.Y = (multiplier * thePoint.Y) + 5; return newLocation; }*/ /* protected void RenderCharacters() { if (builder.GetTheseus() != null) { pbTheseus = new PictureBox(); pbTheseus.Name = "pbTheseus"; pbTheseus.Location = Painter.SetLocation(builder.GetTheseus().Coordinate, 50); pbTheseus.Image = Image.FromFile(mediaPath + @"\images\theseus.png"); pbTheseus.Size = pbTheseus.Image.Size; pnlBackground.Controls.Add(pbTheseus); pbTheseus.BringToFront(); } if (builder.GetMinotaur() != null) { pbMinotaur = new PictureBox(); pbMinotaur.Name = "pbMinotaur"; pbMinotaur.Location = Painter.SetLocation(builder.GetMinotaur().Coordinate, 50); pbMinotaur.Image = Image.FromFile(mediaPath + @"\images\minotaur.png"); pbMinotaur.Size = pbMinotaur.Image.Size; pnlBackground.Controls.Add(pbMinotaur); pbMinotaur.BringToFront(); } if (builder.GetExit() != null) { pbExit = new PictureBox(); pbExit.Name = "pbExit"; Point exitPoint = Painter.SetLocation(builder.GetExit().Coordinate, 50); exitPoint.X = exitPoint.X + 3; exitPoint.Y = exitPoint.Y + 3; pbExit.Location = exitPoint; pbExit.Image = Image.FromFile(mediaPath + @"\images\exit.gif"); pbExit.Size = new Size(30, 30); pbExit.SizeMode = PictureBoxSizeMode.Zoom; pnlBackground.Controls.Add(pbExit); pbExit.BringToFront(); } }*/ protected void RenderCharacters() { pbTheseus = new PictureBox(); pbTheseus.Name = "pbTheseus"; pbTheseus.Image = Image.FromFile(mediaPath + @"\images\theseus.png"); pbTheseus.Size = pbTheseus.Image.Size; pnlBackground.Controls.Add(pbTheseus); if (builder.GetTheseus() != null) { pbTheseus.Location = Painter.SetLocation(builder.GetTheseus().Coordinate, 50); } else { pbTheseus.Location = new Point(-50, 0); } pbMinotaur = new PictureBox(); pbMinotaur.Name = "pbMinotaur"; pbMinotaur.Image = Image.FromFile(mediaPath + @"\images\minotaur.png"); pbMinotaur.Size = pbMinotaur.Image.Size; pnlBackground.Controls.Add(pbMinotaur); if (builder.GetMinotaur() != null) { pbMinotaur.Location = Painter.SetLocation(builder.GetMinotaur().Coordinate, 50); } else { pbMinotaur.Location = new Point(-50, 25); } pbExit = new PictureBox(); pbExit.Name = "pbExit"; pbExit.Image = Image.FromFile(mediaPath + @"\images\exit.gif"); pbExit.Size = new Size(30, 30); pbExit.SizeMode = PictureBoxSizeMode.Zoom; pnlBackground.Controls.Add(pbExit); if (builder.GetExit() != null) { Point exitPoint = Painter.SetLocation(builder.GetExit().Coordinate, 50); exitPoint.X = exitPoint.X + 3; exitPoint.Y = exitPoint.Y + 3; pbExit.Location = exitPoint; } else { pbExit.Location = new Point(-50, 50); } pbSelectedTile = new PictureBox(); pbSelectedTile.Name = "pbSelectedTile"; pbSelectedTile.Location = new Point(-50, 75); pbSelectedTile.Size = new Size(45, 45); pbSelectedTile.BackColor = Color.Honeydew; pnlBackground.Controls.Add(pbSelectedTile); pbSelectedTile.BringToFront(); pbTheseus.BringToFront(); pbExit.BringToFront(); pbMinotaur.BringToFront(); }
private void picture8_MouseDown(object sender, MouseEventArgs e) { currentBox = sender as PictureBox; if (currentBox.Image == null) return; oldPosition = new Point(e.X, e.Y); originalPosition = new Point(currentBox.Location.X, currentBox.Location.Y); currentBox.BringToFront(); drag = true; moved = false; }
private void lblShowSol_Click(object sender, EventArgs e) { showSolNr++; foreach (PictureBox star in listStars) { star.Dispose(); } listStars.Clear(); MazeGeneratorPrim.findSolution(chImg.Left / tileDim, chImg.Top / tileDim, 0, xf, yf, a); for (int k = 1; k < MazeGeneratorPrim.solLength; k++) { PictureBox imgPath = new PictureBox(); imgPath.Size = new Size(tileDim, tileDim); imgPath.SizeMode = PictureBoxSizeMode.StretchImage; imgPath.Image = Properties.Resources.Grass_Solution; imgPath.Location = new Point(MazeGeneratorPrim.solPath[k].X * tileDim, MazeGeneratorPrim.solPath[k].Y * tileDim); this.Controls.Add(imgPath); imgPath.Parent = imgParent; imgPath.BackColor = Color.Transparent; imgPath.BringToFront(); listStars.Add(imgPath); } chImg.BringToFront(); }
private Control MakeControlsPanel() { _panelcontrols = new Panel { Left = 0, Height = ControlsHeight }; _pictureBoxBackground = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxBar.Image"))), Location = new Point(0, 0), Name = "_pictureBoxBackground", Size = new Size(200, 45), SizeMode = PictureBoxSizeMode.StretchImage, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxBackground); _pictureBoxPlay = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxPlay.Image"))), Location = new Point(22, 126 - 113), Name = "_pictureBoxPlay", Size = new Size(29, 29), SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _pictureBoxPlay.MouseEnter += PictureBoxPlayMouseEnter; _panelcontrols.Controls.Add(_pictureBoxPlay); _pictureBoxPlayDown = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxPlayDown.Image"))), Location = new Point(22, 127 - 113), Name = "_pictureBoxPlayDown", Size = new Size(29, 29), SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxPlayDown); _pictureBoxPlayOver = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxPlayOver.Image"))), Location = new Point(23, 126 - 113), Name = "_pictureBoxPlayOver", Size = new Size(29, 29), SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _pictureBoxPlayOver.MouseLeave += PictureBoxPlayOverMouseLeave; _pictureBoxPlayOver.MouseDown += PictureBoxPlayOverMouseDown; _pictureBoxPlayOver.MouseUp += PictureBoxPlayOverMouseUp; _panelcontrols.Controls.Add(_pictureBoxPlayOver); _pictureBoxPause.Image = ((Image)(_resources.GetObject("pictureBoxPause.Image"))); _pictureBoxPause.Location = new Point(23, 126 - 113); _pictureBoxPause.Name = "_pictureBoxPause"; _pictureBoxPause.Size = new Size(29, 29); _pictureBoxPause.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxPause.TabStop = false; _pictureBoxPause.MouseEnter += PictureBoxPauseMouseEnter; _panelcontrols.Controls.Add(_pictureBoxPause); _pictureBoxPauseDown.Image = ((Image)(_resources.GetObject("pictureBoxPauseDown.Image"))); _pictureBoxPauseDown.Location = new Point(22, 127 - 113); _pictureBoxPauseDown.Name = "_pictureBoxPauseDown"; _pictureBoxPauseDown.Size = new Size(29, 29); _pictureBoxPauseDown.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxPauseDown.TabStop = false; _panelcontrols.Controls.Add(_pictureBoxPauseDown); _pictureBoxPauseOver.Image = ((Image)(_resources.GetObject("pictureBoxPauseOver.Image"))); _pictureBoxPauseOver.Location = new Point(22, 127 - 113); _pictureBoxPauseOver.Name = "_pictureBoxPauseOver"; _pictureBoxPauseOver.Size = new Size(29, 29); _pictureBoxPauseOver.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxPauseOver.TabStop = false; _pictureBoxPauseOver.MouseLeave += PictureBoxPauseOverMouseLeave; _pictureBoxPauseOver.MouseDown += PictureBoxPauseOverMouseDown; _pictureBoxPauseOver.MouseUp += PictureBoxPauseOverMouseUp; _panelcontrols.Controls.Add(_pictureBoxPauseOver); _pictureBoxStop.Image = ((Image)(_resources.GetObject("pictureBoxStop.Image"))); _pictureBoxStop.Location = new Point(52, 130 - 113); _pictureBoxStop.Name = "_pictureBoxStop"; _pictureBoxStop.Size = new Size(20, 20); _pictureBoxStop.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxStop.TabStop = false; _pictureBoxStop.MouseEnter += PictureBoxStopMouseEnter; _panelcontrols.Controls.Add(_pictureBoxStop); _pictureBoxStopDown.Image = ((Image)(_resources.GetObject("pictureBoxStopDown.Image"))); _pictureBoxStopDown.Location = new Point(52, 130 - 113); _pictureBoxStopDown.Name = "_pictureBoxStopDown"; _pictureBoxStopDown.Size = new Size(20, 20); _pictureBoxStopDown.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxStopDown.TabStop = false; _panelcontrols.Controls.Add(_pictureBoxStopDown); _pictureBoxStopOver.Image = ((Image)(_resources.GetObject("pictureBoxStopOver.Image"))); _pictureBoxStopOver.Location = new Point(52, 130 - 113); _pictureBoxStopOver.Name = "_pictureBoxStopOver"; _pictureBoxStopOver.Size = new Size(20, 20); _pictureBoxStopOver.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxStopOver.TabStop = false; _pictureBoxStopOver.MouseLeave += PictureBoxStopOverMouseLeave; _pictureBoxStopOver.MouseDown += PictureBoxStopOverMouseDown; _pictureBoxStopOver.MouseUp += PictureBoxStopOverMouseUp; _panelcontrols.Controls.Add(_pictureBoxStopOver); _pictureBoxFullscreen.Image = ((Image)(_resources.GetObject("pictureBoxFS.Image"))); _pictureBoxFullscreen.Location = new Point(95, 130 - 113); _pictureBoxFullscreen.Name = "_pictureBoxFullscreen"; _pictureBoxFullscreen.Size = new Size(20, 20); _pictureBoxFullscreen.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxFullscreen.TabStop = false; _pictureBoxFullscreen.MouseEnter += PictureBoxFullscreenMouseEnter; _panelcontrols.Controls.Add(_pictureBoxFullscreen); _pictureBoxFullscreenDown.Image = ((Image)(_resources.GetObject("pictureBoxFSDown.Image"))); _pictureBoxFullscreenDown.Location = new Point(95, 130 - 113); _pictureBoxFullscreenDown.Name = "_pictureBoxFullscreenDown"; _pictureBoxFullscreenDown.Size = new Size(20, 20); _pictureBoxFullscreenDown.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxFullscreenDown.TabStop = false; _panelcontrols.Controls.Add(_pictureBoxFullscreenDown); _pictureBoxFullscreenOver.Image = ((Image)(_resources.GetObject("pictureBoxFSOver.Image"))); _pictureBoxFullscreenOver.Location = new Point(95, 130 - 113); _pictureBoxFullscreenOver.Name = "_pictureBoxFullscreenOver"; _pictureBoxFullscreenOver.Size = new Size(20, 20); _pictureBoxFullscreenOver.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxFullscreenOver.TabStop = false; _pictureBoxFullscreenOver.MouseLeave += PictureBoxFullscreenOverMouseLeave; _pictureBoxFullscreenOver.MouseDown += PictureBoxFullscreenOverMouseDown; _pictureBoxFullscreenOver.MouseUp += PictureBoxFullscreenOverMouseUp; _panelcontrols.Controls.Add(_pictureBoxFullscreenOver); _pictureBoxProgressbarBackground.Anchor = AnchorStyles.Top | AnchorStyles.Left; _pictureBoxProgressbarBackground.BackColor = Color.Transparent; _pictureBoxProgressbarBackground.Image = (Image)_resources.GetObject("pictureBoxProgressbarBackground.Image"); _pictureBoxProgressbarBackground.Location = new Point(43, 114 - 113); _pictureBoxProgressbarBackground.Margin = new Padding(0); _pictureBoxProgressbarBackground.Name = "_pictureBoxProgressbarBackground"; _pictureBoxProgressbarBackground.Size = new Size(531, 12); _pictureBoxProgressbarBackground.SizeMode = PictureBoxSizeMode.StretchImage; _pictureBoxProgressbarBackground.TabStop = false; _pictureBoxProgressbarBackground.MouseDown += PictureBoxProgressbarBackgroundMouseDown; _panelcontrols.Controls.Add(_pictureBoxProgressbarBackground); _pictureBoxProgressBar.Image = (Image)(_resources.GetObject("pictureBoxProgressBar.Image")); _pictureBoxProgressBar.Location = new Point(47, 118 - 113); _pictureBoxProgressBar.Name = "_pictureBoxProgressBar"; _pictureBoxProgressBar.Size = new Size(318, 4); _pictureBoxProgressBar.SizeMode = PictureBoxSizeMode.StretchImage; _pictureBoxProgressBar.TabStop = false; _pictureBoxProgressBar.MouseDown += PictureBoxProgressBarMouseDown; _panelcontrols.Controls.Add(_pictureBoxProgressBar); _pictureBoxProgressBar.BringToFront(); _pictureBoxMute.Image = ((Image)(_resources.GetObject("pictureBoxMute.Image"))); _pictureBoxMute.Location = new Point(75, 131 - 113); _pictureBoxMute.Name = "_pictureBoxMute"; _pictureBoxMute.Size = new Size(19, 19); _pictureBoxMute.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxMute.TabStop = false; _pictureBoxMute.MouseEnter += PictureBoxMuteMouseEnter; _panelcontrols.Controls.Add(_pictureBoxMute); _pictureBoxMuteDown.Image = ((Image)(_resources.GetObject("pictureBoxMuteDown.Image"))); _pictureBoxMuteDown.Location = new Point(75, 131 - 113); _pictureBoxMuteDown.Name = "_pictureBoxMuteDown"; _pictureBoxMuteDown.Size = new Size(19, 19); _pictureBoxMuteDown.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxMuteDown.TabStop = false; _pictureBoxMuteDown.Click += PictureBoxMuteDownClick; _panelcontrols.Controls.Add(_pictureBoxMuteDown); _pictureBoxMuteOver.Image = ((Image)(_resources.GetObject("pictureBoxMuteOver.Image"))); _pictureBoxMuteOver.Location = new Point(75, 131 - 113); _pictureBoxMuteOver.Name = "_pictureBoxMuteOver"; _pictureBoxMuteOver.Size = new Size(19, 19); _pictureBoxMuteOver.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxMuteOver.TabStop = false; _pictureBoxMuteOver.MouseLeave += PictureBoxMuteOverMouseLeave; _pictureBoxMuteOver.MouseDown += PictureBoxMuteOverMouseDown; _pictureBoxMuteOver.MouseUp += PictureBoxMuteOverMouseUp; _panelcontrols.Controls.Add(_pictureBoxMuteOver); _pictureBoxVolumeBarBackground.Image = ((Image)(_resources.GetObject("pictureBoxVolumeBarBackground.Image"))); _pictureBoxVolumeBarBackground.Location = new Point(111, 135 - 113); _pictureBoxVolumeBarBackground.Name = "_pictureBoxVolumeBarBackground"; _pictureBoxVolumeBarBackground.Size = new Size(82, 13); _pictureBoxVolumeBarBackground.SizeMode = PictureBoxSizeMode.AutoSize; _pictureBoxVolumeBarBackground.TabStop = false; _pictureBoxVolumeBarBackground.MouseDown += PictureBoxVolumeBarBackgroundMouseDown; _panelcontrols.Controls.Add(_pictureBoxVolumeBarBackground); _pictureBoxVolumeBar.Image = ((Image)(_resources.GetObject("pictureBoxVolumeBar.Image"))); _pictureBoxVolumeBar.Location = new Point(120, 139 - 113); _pictureBoxVolumeBar.Name = "_pictureBoxVolumeBar"; _pictureBoxVolumeBar.Size = new Size(48, 4); _pictureBoxVolumeBar.SizeMode = PictureBoxSizeMode.StretchImage; _pictureBoxVolumeBar.TabStop = false; _pictureBoxVolumeBar.MouseDown += PictureBoxVolumeBarMouseDown; _panelcontrols.Controls.Add(_pictureBoxVolumeBar); _pictureBoxVolumeBar.BringToFront(); _pictureBoxReverse = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxReverse.Image"))), Location = new Point(28, 3), Name = "_pictureBoxReverse", Size = new Size(16, 8), SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxReverse); _pictureBoxReverse.MouseEnter += PictureBoxReverseMouseEnter; _pictureBoxReverseOver = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxReverseMouseOver.Image"))), Location = _pictureBoxReverse.Location, Name = "_pictureBoxReverseOver", Size = _pictureBoxReverse.Size, SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxReverseOver); _pictureBoxReverseOver.MouseLeave += PictureBoxReverseOverMouseLeave; _pictureBoxReverseOver.MouseDown += PictureBoxReverseOverMouseDown; _pictureBoxReverseOver.MouseUp += PictureBoxReverseOverMouseUp; _pictureBoxReverseDown = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxReverseMouseDown.Image"))), Location = _pictureBoxReverse.Location, Name = "_pictureBoxReverseOver", Size = _pictureBoxReverse.Size, SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxReverseDown); _pictureBoxFastForward = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxFastForward.Image"))), Location = new Point(571, 1), Name = "_pictureBoxFastForward", Size = new Size(17, 13), SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxFastForward); _pictureBoxFastForward.MouseEnter += PictureBoxFastForwardMouseEnter; _pictureBoxFastForwardOver = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxFastForwardMouseOver.Image"))), Location = _pictureBoxFastForward.Location, Name = "_pictureBoxFastForwardOver", Size = _pictureBoxFastForward.Size, SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxFastForwardOver); _pictureBoxFastForwardOver.MouseLeave += PictureBoxFastForwardOverMouseLeave; _pictureBoxFastForwardOver.MouseDown += PictureBoxFastForwardOverMouseDown; _pictureBoxFastForwardOver.MouseUp += PictureBoxFastForwardOverMouseUp; _pictureBoxFastForwardDown = new PictureBox { Image = ((Image)(_resources.GetObject("pictureBoxFastForwardMouseDown.Image"))), Location = _pictureBoxFastForward.Location, Name = "_pictureBoxFastForwardDown", Size = _pictureBoxFastForward.Size, SizeMode = PictureBoxSizeMode.AutoSize, TabStop = false }; _panelcontrols.Controls.Add(_pictureBoxFastForwardDown); _labelTimeCode.Location = new Point(280, 28); _labelTimeCode.ForeColor = Color.Gray; _labelTimeCode.Font = new Font(_labelTimeCode.Font.FontFamily, 7); _labelTimeCode.AutoSize = true; _panelcontrols.Controls.Add(_labelTimeCode); _labelVideoPlayerName.Location = new Point(280, 17); _labelVideoPlayerName.ForeColor = Color.Gray; _labelVideoPlayerName.BackColor = Color.FromArgb(67, 75, 93); _labelVideoPlayerName.AutoSize = true; _labelVideoPlayerName.Font = new Font(_labelTimeCode.Font.FontFamily, 5); _panelcontrols.Controls.Add(_labelVideoPlayerName); _pictureBoxBackground.SendToBack(); _pictureBoxFastForward.BringToFront(); _pictureBoxFastForwardDown.BringToFront(); _pictureBoxFastForwardOver.BringToFront(); _pictureBoxPlay.BringToFront(); _panelcontrols.BackColor = _backgroundColor; _pictureBoxPlay.BringToFront(); _pictureBoxPlayDown.BringToFront(); _pictureBoxPlayOver.BringToFront(); _labelTimeCode.BringToFront(); return _panelcontrols; }
/// <summary> /// Launches the syntax editor. /// </summary> static void LaunchSyntaxEditorForm() { var initialSource = @" // Edit this code for real-time syntax checking class Greeter { static void Greet() { Console.WriteLine(""Hello, World""); } }"; Form f = new Form { Text = "C# Syntax Checker using Roslyn", Width = 500, Height = 300, }; f.MinimumSize = new Size(f.Width, f.Height); // Split editor between source view (left side) and marked up syntax view. SplitContainer splitter = new SplitContainer { Orientation = Orientation.Vertical, Top = 0, Left = 0, Height = f.ClientSize.Height, Width = f.ClientSize.Width, SplitterWidth = 5, Dock = DockStyle.Fill, SplitterDistance = f.ClientSize.Width / 2, }; f.Controls.Add(splitter); // The source code input text box TextBox sourceCode = new TextBox { Top = 0, Left = 0, Multiline = true, Width = f.ClientSize.Width, Height = f.ClientSize.Height, Text = initialSource, Dock = DockStyle.Fill, WordWrap = false, }; // The rich text syntax highlighter box RichTextBox richCode = new RichTextBox { Top = 0, Left = 0, Multiline = true, Width = f.ClientSize.Width, Height = f.ClientSize.Height, Text = initialSource, Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, WordWrap = false, ReadOnly = true, }; // When a key is pressed in the source code box build the syntax view sourceCode.KeyUp += (sender, keyArgs) => { string scriptText = sourceCode.Text; BuildSyntaxView(sourceCode, richCode); }; splitter.Panel1.Controls.Add(sourceCode); splitter.Panel2.Controls.Add(richCode); // Build the red "X" Bitmap bmpMark = new Bitmap(10, 10); using (Graphics gfx = Graphics.FromImage(bmpMark)) { Brush b = new SolidBrush(Color.Red); Pen p = new Pen(b) { Width = 2, }; gfx.DrawLine(p, 0, 0, 10, 10); gfx.DrawLine(p, 10, 0, 0, 10); gfx.Flush(); } picX = new PictureBox { Width = 10, Height = 10, Image = bmpMark, Visible = false, }; /* Add the red "X" to the rich text box control because * that is where it will be shown to highlight errors. */ richCode.Controls.Add(picX); picX.BringToFront(); f.Load += (o, a) => { sourceCode.Select(0, 1); }; // Show editor form. Application.Run(f); }
private void LoadVault(string vaultHex) { infos.Clear(); pictureBox1.Controls.Clear(); string user_items = vaultHex; //List<string> linesList = new List<string>(); int index = 0; while (index + hexLenght <= user_items.Length) { linesList.Add(user_items.Substring(index, hexLenght)); index += hexLenght; } string nullHex = ""; for (int i = 0; i < hexLenght; i++) { nullHex += "F"; } if (linesList.Count < 120) { while (linesList.Count < 120) { linesList.Add(nullHex); } } int line = 1; int xx = 0; for (int i = 0; i < linesList.Count; i++) { xx++; if (xx == 9) { xx = 1; line++; } if (linesList[i] == nullHex) { continue; } List<string> itemInfo = ItemInfo(linesList[i]); if (itemInfo.Count > 0) { infos.Add(itemInfo[3], itemInfo); Bitmap b = ItemImage(Convert.ToInt32(itemInfo[1]), Convert.ToInt32(itemInfo[2]), Convert.ToInt32(itemInfo[8]), 0); PictureBox pb = new PictureBox(); pb.Parent = pictureBox1; pb.BackColor = Color.Transparent; pb.Location = new Point(32 * (xx - 1), 32 * (line - 1)); pb.Size = new System.Drawing.Size(32 * Convert.ToInt32(itemInfo[6]), 32 * Convert.ToInt32(itemInfo[7])); pb.Image = b; pb.BackColor = Color.FromArgb(25, 255, 255, 255); PictureBox pbText = new PictureBox(); pb.Name = itemInfo[3]; pb.MouseEnter += (s, eArgs) => { if (!isMovingItem) { string picText = ""; for (int j = 0; j < itemInfo.Count; j++) { picText += itemInfo[j] + Environment.NewLine; } Size size = TextRenderer.MeasureText(picText, pbText.Font); pbText.Width = size.Width; pbText.Height = size.Height; Point mouseLocation = this.PointToClient(Cursor.Position); if (this.Width - mouseLocation.X < size.Width) { mouseLocation.X = mouseLocation.X - size.Width; } if (this.Height - mouseLocation.Y < size.Height) { mouseLocation.Y = mouseLocation.Y - size.Height; } pbText.BackColor = Color.FromArgb(200, Color.Black); pbText.Paint += (object sss, PaintEventArgs argss) => { using (Font myFont = new Font("Arial", 9)) { argss.Graphics.DrawString(picText, myFont, Brushes.White, new Point(2, 2)); } }; pbText.Parent = pictureBox1; pbText.Location = mouseLocation; this.Controls.Add(pbText); this.Controls[this.Controls.Count - 1].BringToFront(); } }; pb.MouseLeave += (s, eArgs) => { this.Controls.Remove(pbText); }; pb.MouseClick += (object send, MouseEventArgs ahah) => { if (ahah.Button == System.Windows.Forms.MouseButtons.Left && !isMovingItem) { Control control = (Control)pb; if (!isMovingItem) { oldLocation = control.Location; } if (infos.ContainsKey(control.Name)) { selectedPic = control; pb.BringToFront(); isMovingItem = true; } } }; pictureBox1.MouseClick += (object sende, MouseEventArgs ahhh) => { if (isMovingItem) { isMovingItem = false; Point loc = selectedPic.Location; int cellX = loc.X / 32; int cellY = loc.Y / 32; loc.X = cellX * 32; loc.Y = cellY * 32; int fcX = cellX; int fcy = cellY; int itemWidth = selectedPic.Width / 32; int itemHeight = selectedPic.Height / 32; Point sD = new Point(selectedPic.Location.X / 32, selectedPic.Location.Y / 32); Point sC = new Point(selectedPic.Location.X / 32 + selectedPic.Width / 32, selectedPic.Location.Y / 32); Point sA = new Point(selectedPic.Location.X / 32, selectedPic.Height / 32 + selectedPic.Location.Y / 32); Point sB = new Point(selectedPic.Width / 32 + selectedPic.Location.X / 32, selectedPic.Height / 32 + selectedPic.Location.Y / 32); Rectangle movingItem = new Rectangle(fcX, fcy, itemWidth, itemHeight); Rectangle vaultBounds = new Rectangle(-1, -1, (256 / 32) + 2, (480 / 32) + 2); bool isOnItem = false; foreach (List<string> item in infos.Values) { if (selectedPic.Name != item[3]) { Control control = pictureBox1.Controls[item[3]]; Point D = new Point(control.Location.X / 32, control.Location.Y / 32); Point C = new Point(control.Location.X / 32 + control.Width / 32, control.Location.Y / 32); Point A = new Point(control.Location.X / 32, control.Height / 32 + control.Location.Y / 32); Point B = new Point(control.Width / 32 + control.Location.X / 32, control.Height / 32 + control.Location.Y / 32); Point R = new Point(control.Width / 64 + control.Location.X / 32, control.Height / 64 + control.Location.Y / 32); bool isR = true; if (control.Width == 32) { isR = false; } if (control.Height >= (32 * 4)) { Point R1 = new Point(control.Width / 64 + control.Location.X / 32, (control.Height / 64 + control.Location.Y / 32) - 1); Point R2 = new Point(control.Width / 64 + control.Location.X / 32, (control.Height / 64 + control.Location.Y / 32) + 1); if (IsOnItem(D, movingItem, false) || IsOnItem(C, movingItem, false) || IsOnItem(A, movingItem, false) || IsOnItem(B, movingItem, false) || IsOnItem(R, movingItem, isR) || !IsOnItem(sD, vaultBounds, false) || !IsOnItem(sA, vaultBounds, false) || !IsOnItem(sB, vaultBounds, false) || !IsOnItem(sC, vaultBounds, false) || IsOnItem(R1, movingItem, isR) || IsOnItem(R2, movingItem, isR)) { selectedPic.Location = oldLocation; isOnItem = true; break; } } else if (control.Width >= (32 * 4)) { Point R1 = new Point((control.Width / 64 + control.Location.X / 32) - 1, control.Height / 64 + control.Location.Y / 32); Point R2 = new Point((control.Width / 64 + control.Location.X / 32) + 1, control.Height / 64 + control.Location.Y / 32); if (IsOnItem(D, movingItem, false) || IsOnItem(C, movingItem, false) || IsOnItem(A, movingItem, false) || IsOnItem(B, movingItem, false) || IsOnItem(R, movingItem, isR) || !IsOnItem(sD, vaultBounds, false) || !IsOnItem(sA, vaultBounds, false) || !IsOnItem(sB, vaultBounds, false) || !IsOnItem(sC, vaultBounds, false) || IsOnItem(R1, movingItem, isR) || IsOnItem(R2, movingItem, isR)) { selectedPic.Location = oldLocation; isOnItem = true; break; } } else { if (IsOnItem(D, movingItem, false) || IsOnItem(C, movingItem, false) || IsOnItem(A, movingItem, false) || IsOnItem(B, movingItem, false) || IsOnItem(R, movingItem, isR) || !IsOnItem(sD, vaultBounds, false) || !IsOnItem(sA, vaultBounds, false) || !IsOnItem(sB, vaultBounds, false) || !IsOnItem(sC, vaultBounds, false)) { selectedPic.Location = oldLocation; isOnItem = true; break; } } } } if (!isOnItem) { linesList[(loc.X / 32) + ((loc.Y / 32) * 8)] = linesList[(oldLocation.X / 32) + ((oldLocation.Y / 32) * 8)]; linesList[(oldLocation.X / 32) + ((oldLocation.Y / 32) * 8)] = nullHex; string tempVaultHex = string.Join("", linesList); if (!VaultHexCheck(tempVaultHex)) { selectedPic.Location = oldLocation; } else { selectedPic.Location = loc; oldLocation = loc; vaultHex = tempVaultHex; } } } }; pictureBox1.MouseMove += (object sndr, MouseEventArgs aaa) => { if (isMovingItem) { Point pt = Cursor.Position; pt.X = pt.X + 2; pt.Y = pt.Y + 2; selectedPic.Location = pictureBox1.PointToClient(pt); pictureBox1.Refresh(); } }; } } }
private bool AddPictureBox(DataRow dr) { string keys; try { PictureBox pb = new PictureBox(); pb.BackColor = this.BackColor; pb.AllowDrop = true; pb.Size = pPicBoxSize; pb.Location = PPicBoxLoction; pb.SizeMode = PictureBoxSizeMode.StretchImage; pb.Name = "pb" + pbCount.ToString(); string path = dr[1].ToString(); Icon icon; if (System.IO.File.Exists(path)) { icon = System.Drawing.Icon.ExtractAssociatedIcon(path); } else { return false; icon = null; } pb.Image = icon.ToBitmap(); //应用新的区域 //pb.Region = new Region(TranPicbox ((Bitmap )(pb.Image ))); //TranPicbox((Bitmap)(pb.Image)); pb.Cursor = Cursors.Hand; keys = dr[2].ToString().Trim(); if (keys == "") { if (pbCount < 10) { keys = "Alt+" + pbCount.ToString(); } else { keys ="Alt+" +(char)(55+pbCount ); } } string notice = string.Format("{0}\r\n快捷键:{1}", dr[0], keys.Replace (",","+") /*pbCount[2]*/); //路径,guid,快捷键,可选表示是否系统自定的 if (dr[2].ToString().Trim() == "") keys = keys + "|Sys"; else keys += "|User"; //名字,路径,guid,keys,sys pb.Tag = dr[0]+"|"+dr[1] + "|" + dr[3] + "|" + keys; frmDelete frm=null; Control ct = null; Point pMousDown = new Point(0,0); //用于移动frmDelete的矫正 Point pMouseLocation = new Point(0,0); //用于看pb控件移动前的位置 Point pMouseLocation1 = new Point(0, 0); pb.MouseEnter += new EventHandler(delegate(object sender, EventArgs ea) { pb.Size = new Size(pPicBoxSize.Width + 15, pPicBoxSize.Height + 15); pb.BringToFront(); if (frmDispLocation == frmDispLoc.top || frmDispLocation == frmDispLoc.buttom) MouseEnterMove(pb.Location.X ); else MouseEnterMove(pb.Location.Y ); }); pb.MouseLeave += new EventHandler(delegate(object sender, EventArgs ea) { if (pb.Size != pPicBoxSize) { pb.Size = pPicBoxSize; if (frmDispLocation == frmDispLoc.top || frmDispLocation == frmDispLoc.buttom) MouseLeaveMove(pb.Location.X); else MouseLeaveMove(pb.Location.Y ); } }); //pb左右移动的的距离 pb.MouseDown += new MouseEventHandler(delegate(object obj, MouseEventArgs mouse) { if (pb.Size != pPicBoxSize) { pb.Size = pPicBoxSize; if (frmDispLocation == frmDispLoc.top || frmDispLocation == frmDispLoc.buttom) MouseLeaveMove(pb.Location.X); else MouseLeaveMove(pb.Location.Y); } if (mouse.Button == MouseButtons.Left) { blPbDrag = true; pMousDown = mouse.Location; pMouseLocation =MousePosition ; pMouseLocation1=MousePosition ; } } ); pb.MouseMove += new MouseEventHandler(delegate(object ebj, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (blPbDrag) { if (frm == null || frm.IsDisposed) { //pb.DoDragDrop("任忌热键删除动作", DragDropEffects.All); ct = ((Control)ebj); frm = new frmDelete(ct.Tag.ToString().Split('|')[1]); frm.Show(); ct.Visible = false; } //pb.Location = new Point(); frm.Location = new Point(MousePosition.X - pMousDown.X, MousePosition.Y - pMousDown.Y); Point p = IsMovePb(MousePosition.X - pMouseLocation1.X, frm.Location.X, ct); { if (p != new Point()) { pMouseLocation1 = MousePosition; } } //frm.Show(); } } }); pb.MouseUp += new MouseEventHandler(delegate(object obj, MouseEventArgs mouse) { try { if (blPbDrag) if (!frm.IsDisposed && frm != null) { if (frm.Location.Y + frm.Height < this.Location.Y || mouse.Y > this.Location.Y + this.Height || this.Location.X + this.Width < frm.Location .X || this.Location.X > frm.Location.X + frm.Width) { frm.Show(); frm.Location = new Point(MousePosition.X - pMousDown.X, MousePosition.Y - pMousDown.Y); frm.timFrmChange.Enabled = true; DeletePb(ct); } else { frm.Close(); frm.Dispose(); ct.Visible = true; } } blPbDrag = false; } catch (Exception ex) { blPbDrag = false; ShowMessage(ex.ToString ()); } }); toolTipApp.SetToolTip(pb, notice); pb.ContextMenuStrip = this.CMenuS; this.Controls.Add(pb); pb.MouseEnter += new EventHandler(FrmMouseEnter); // pb.Click += new EventHandler(pb_Click); PPicBoxLoction = new Point(PPicBoxLoction.X + pb.Width + increment, PPicBoxLoction.Y); pbCount++; return true; } catch(Exception ex) { ShowMessage(ex.ToString ()); return false; } }