public void shipSelect(PictureBox sender) { foreach (PictureBox shipPictureBox in shipPictureBoxes) { shipPictureBox.BackColor = Color.Transparent; } sender.BackColor = Color.White; activeShipPictureBox = sender; if (sender.Equals(ship2PictureBox)) { selectedShip = controller.getPlayer().getShip(ShipName.patrol); } else if (sender.Equals(ship3aPictureBox)) { selectedShip = controller.getPlayer().getShip(ShipName.submarine); } else if (sender.Equals(ship3bPictureBox)) { selectedShip = controller.getPlayer().getShip(ShipName.battleship); } else if (sender.Equals(ship4PictureBox)) { selectedShip = controller.getPlayer().getShip(ShipName.destroyer); } else if (sender.Equals(ship5PictureBox)) { selectedShip = controller.getPlayer().getShip(ShipName.carrier); } }
private void RandomLen(PictureBox PicBox) { //清空原本图形 Graphics GPic = PicBox.CreateGraphics(); GPic.Clear(Color.White); //随机宽度 Random Ran = new Random(GetRandomSeed()); int Len = Ran.Next(10, 80); if (PicBox.Equals(pictureBox1)) { Pic1Len = Len; } if (PicBox.Equals(pictureBox2)) { Pic2Len = Len; } SolidBrush Bru = new SolidBrush(Color.Black); GPic.FillRectangle(Bru, 0, 0, Len, 200); GPic.Dispose(); Bru.Dispose(); }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="pictureBox">The picture box.</param> /// <param name="useFallbackUri">if set to <c>true</c> [use fallback URI].</param> /// <returns></returns> private Uri GetImageUrl(PictureBox pictureBox, bool useFallbackUri) { string path = String.Empty; if (pictureBox.Equals(CharacterPictureBox)) { path = String.Format(CultureConstants.InvariantCulture, NetworkConstants.CCPPortraits, m_killLog.Victim.ID, (int)EveImageSize.x128); } if (pictureBox.Equals(ShipPictureBox)) { path = String.Format(CultureConstants.InvariantCulture, NetworkConstants.CCPIconsFromImageServer, "render", m_killLog.Victim.ShipTypeID, (int)EveImageSize.x128); } if (pictureBox.Equals(CorpPictureBox)) { path = String.Format(CultureConstants.InvariantCulture, NetworkConstants.CCPIconsFromImageServer, "corporation", m_killLog.Victim.CorporationID, (int)EveImageSize.x32); } if (pictureBox.Equals(AlliancePictureBox)) { path = String.Format(CultureConstants.InvariantCulture, NetworkConstants.CCPIconsFromImageServer, "alliance", m_killLog.Victim.AllianceID, (int)EveImageSize.x32); } return(useFallbackUri ? ImageService.GetImageServerBaseUri(path) : ImageService.GetImageServerCdnUri(path)); }
private void ChooseScenario(object sender, EventArgs e) { this.button1.Enabled = true; PictureBox pb = sender as PictureBox; if (pb.Equals(pictureBox1)) { scenario = "S"; pictureBox1.BackgroundImage = Properties.Resources.indeks; pictureBox2.BackgroundImage = Properties.Resources.N2; pictureBox3.BackgroundImage = Properties.Resources.PRL2; } else if (pb.Equals(pictureBox2)) { scenario = "N"; pictureBox1.BackgroundImage = Properties.Resources.S2; pictureBox2.BackgroundImage = Properties.Resources.bbc9154ba1758b447e8c7547fe0f; pictureBox3.BackgroundImage = Properties.Resources.PRL2; } else { scenario = "PRL"; pictureBox1.BackgroundImage = Properties.Resources.S2; pictureBox2.BackgroundImage = Properties.Resources.N2; pictureBox3.BackgroundImage = Properties.Resources.absurdy_prl_23814353; } }
private void togglePictureBoxSelection(PictureBox pBox) { PictureBox tempPicBox = selectedPicBox; if (selectedPicBox != null) { unselectCurrentCrossing(); } if (tempPicBox != null && tempPicBox.Equals(pBox)) { return; } selectedPicBox = pBox; if (isLocked) { EnableEditing(); } else { btnRemove.Enabled = true; } //enableNum(); pBox.Refresh(); }
private new void MouseLeft(PictureBox picture) { if (!picture.Equals(playerPicture)) { picture.Image = minions[picture.Name].normal; } }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="pictureBox">The picture box.</param> /// <param name="useFallbackUri">if set to <c>true</c> [use fallback URI].</param> /// <returns></returns> private Uri GetImageUrl(PictureBox pictureBox, bool useFallbackUri) { string path; if (pictureBox == CharacterPictureBox) { path = string.Format(CultureConstants.InvariantCulture, NetworkConstants.CCPPortraits, m_attacker.ID, (int)EveImageSize.x64); return(useFallbackUri ? ImageService.GetImageServerBaseUri(path) : ImageService.GetImageServerCdnUri(path)); } int typeId = pictureBox.Equals(ShipPictureBox) ? m_attacker.ShipTypeID : m_attacker.WeaponTypeID; path = string.Format(CultureConstants.InvariantCulture, NetworkConstants.CCPIconsFromImageServer, "type", typeId, (int)EveImageSize.x32); return(useFallbackUri ? ImageService.GetImageServerBaseUri(path) : ImageService.GetImageServerCdnUri(path)); }
private int valid(int linie, int coloana, PictureBox personaj) { if (linie < 0 || coloana < 0 || linie >= nrLinii | coloana >= nrcoloane) { return(0); } if (personaj.Equals(pictureBox1) == true && labirint[linie, coloana].BackColor != Color.CadetBlue) { return(0); } if (personaj.Equals(pictureBox1) == false && labirint[linie, coloana].BackColor == Color.Black) { return(0); } return(1); }
private new void MouseEntered(PictureBox picture) { if (!picture.Equals(playerPicture)) { picture.Image = minions[picture.Name].glow; } }
private void PlaseazaPersonaj(int linie, int coloana, PictureBox personaj) { if (personaj.Equals(pictureBox1) == false) { labirint[linie, coloana].BackColor = Color.Red; } personaj.Top = (linie + 1) * dwh; personaj.Left = (coloana + 1) * dwh; }
/// <summary> /// Gets the image for the specified picture box. /// </summary> /// <param name="pictureBox">The picture box.</param> private async Task GetImageForAsync(PictureBox pictureBox) { Image img = await ImageService.GetImageAsync(GetImageUrl(pictureBox)); if (img != null || pictureBox.Equals(WeaponPictureBox)) { pictureBox.Image = img; } }
public bool EnemyCollision(PictureBox Object) { if (Object != null) { if ((Object.Bounds.IntersectsWith(enemy.Bounds)) && (!(Object.Equals(enemy)))) { return(true); } } return(false); }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="pictureBox">The picture box.</param> /// <returns></returns> private Uri GetImageUrl(PictureBox pictureBox) { if (pictureBox == CharacterPictureBox) { return(ImageHelper.GetPortraitUrl(m_attacker.ID, (int)EveImageSize.x64)); } else { return(ImageHelper.GetTypeImageURL(pictureBox.Equals(ShipPictureBox) ? m_attacker.ShipTypeID : m_attacker.WeaponTypeID)); } }
private void PictureBox_Click(object sender, EventArgs e) { PictureBox item = (PictureBox)sender; if (item.Equals(buttonGithub)) { System.Diagnostics.Process.Start(Resources.ResourceManager.GetString("URL_Github")); } else if (item.Equals(buttonPayPal)) { System.Diagnostics.Process.Start(Resources.ResourceManager.GetString("URL_PayPal")); } else if (item.Equals(buttonTwitter)) { System.Diagnostics.Process.Start(Resources.ResourceManager.GetString("URL_Twitter")); } else { throw new ArgumentOutOfRangeException("Unknown URL requested,"); } }
// Get La Carte associated with the PictureBox / Joueur private Carte GetCarteWithPicBox(PictureBox pictureBox) { Carte carte = null; foreach (KeyValuePair <PictureBox, Carte> entry in mesCartes) { if (pictureBox.Equals(entry.Key)) { carte = entry.Value; } } return(carte); }
public static void SetImageOnTop(PictureBox p) { if (OnTopBox != null) { if (OnTopBox.Equals(p)) { return; } BackImage(); } p.Top = p.Top - p.Height; OnTopBox = p; }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="pictureBox">The picture box.</param> /// <param name="useFallbackUri">if set to <c>true</c> [use fallback URI].</param> /// <returns></returns> private Uri GetImageUrl(PictureBox pictureBox, bool useFallbackUri) { if (pictureBox.Equals(CharacterPictureBox)) { return(ImageHelper.GetPortraitUrl(useFallbackUri, m_killLog.Victim.ID, (int)EveImageSize.x128)); } if (pictureBox.Equals(ShipPictureBox)) { return(ImageHelper.GetImageUrl(useFallbackUri, "render", m_killLog.Victim.ShipTypeID, (int)EveImageSize.x128)); } if (pictureBox.Equals(CorpPictureBox)) { return(ImageHelper.GetImageUrl(useFallbackUri, "corporation", m_killLog.Victim.CorporationID)); } // Picture box is for alliance return(ImageHelper.GetImageUrl(useFallbackUri, "alliance", m_killLog.Victim.AllianceID)); }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="pictureBox">The picture box.</param> /// <param name="useFallbackUri">if set to <c>true</c> [use fallback URI].</param> /// <returns></returns> private Uri GetImageUrl(PictureBox pictureBox, bool useFallbackUri) { if (pictureBox == CharacterPictureBox) { return(ImageHelper.GetPortraitUrl(useFallbackUri, m_attacker.ID, (int)EveImageSize.x64)); } int typeId = pictureBox.Equals(ShipPictureBox) ? m_attacker.ShipTypeID : m_attacker.WeaponTypeID; return(ImageHelper.GetImageUrl(useFallbackUri, "type", typeId)); }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="pictureBox">The picture box.</param> /// <returns></returns> private Uri GetImageUrl(PictureBox pictureBox) { if (pictureBox.Equals(CharacterPictureBox)) { return(ImageHelper.GetPortraitUrl(m_killLog.Victim.ID, (int)EveImageSize.x128)); } if (pictureBox.Equals(ShipPictureBox)) { return(ImageHelper.GetTypeRenderURL(m_killLog.Victim.ShipTypeID, (int)EveImageSize.x128)); } if (pictureBox.Equals(CorpPictureBox)) { return(ImageHelper.GetCorporationImageURL(m_killLog.Victim.CorporationID)); } // Picture box is for alliance return(ImageHelper.GetAllianceImageURL(m_killLog.Victim.AllianceID)); }
public bool PlayerCollision(PictureBox Object) { if (Object != null) { if (Object != null) { if ((Object.Bounds.IntersectsWith(player.Bounds)) && (!(Object.Equals(player)))) { return(true); } } } return(false); }
/// <summary> /// 控制下方障礙物重新生成的方法 /// </summary> /// <param name="pictureBox"></param> private void PictureBoxRecreate_Down(PictureBox pictureBox) { if (pictureBox.Equals(pictureBox2)) // pictureBox1 和 pictureBox2 為上下成對障礙物, { // pictureBox2 和 pictureBox1 中間要間隔 150 的通道 pictureBox.Top = pictureBox1.Height + 150; } else { pictureBox.Top = pictureBox3.Height + 150; // pictureBox3 和 pictureBox4 為上下成對障礙物, } // pictureBox4 和 pictureBox3 中間要間隔 150 的通道 pictureBox.Left = ClientSize.Width; // 從視窗最右邊重新生成 pictureBox.Height = ClientSize.Height - pictureBox.Top; // 新生成的下方障礙物長度(Height)為 ClientSize - 自己的 Top 座標 }
private Card GetWhatCardChoise(PictureBox cl_pb) { int i = 0; MakeFeatureUnvisible(false); foreach (PictureBox pb in playerboxes) { if (cl_pb.Equals(pb)) { break; } else { i++; } } i = i + ImageWorker.Firscardindex; return(CurrentPlayer.Cards[i]); }
private int[] GetPositionOfPic(PictureBox elem) { // iterate through fields for (int column = 0; column < this.PicField.GetLength(0); column++) { for (int line = 0; line < this.PicField.GetLength(0); line++) { // and compare PictureBox to see whether it's the one, which we need if (elem.Equals(this.PicField[column, line])) { Debug.WriteLine("getPositionOfPic: line {0}, column {1} = {2}", line, column, this.PicField[column, line]); return(new int[2] { line, column }); } } } throw new ArgumentOutOfRangeException("could not find picture"); }
public void cardClick(object sender, EventArgs e) { bool isfirstT = true; if (isfirstT) { isfirstT = false; playTime.Start(); } PictureBox selectedC = (PictureBox)sender; Console.WriteLine($"You clicked {(Card)selectedC.Tag}"); bool isCardFromDealer = false; bool Replaceable = false; bool moveToSlotAble = false; for (int i = 0; i < 7; i++) { if (lines[i].Contains(selectedC)) { for (int j = 0; j < lines[i].Count; j++) { if (lines[i][j] == selectedC && j + 1 <= lines[i].Count - 1) { Replaceable = true; break; } } } } for (int i = 0; i < 7; i++) { if (lines[i].Contains(glowingC)) { for (int j = 0; j < lines[i].Count; j++) { if (lines[i][j] == glowingC && j + 1 == lines[i].Count) { moveToSlotAble = true; break; } } } } if (glowingC == null || glowingC.Tag == null) { glowImg = Resize(glowImg, 95, 145); glowPB.Location = new Point(selectedC.Location.X - 5, selectedC.Location.Y - 5); glowPB.Image = glowImg; glowPB.Size = glowImg.Size; Controls.Add(glowPB); glowingC = selectedC; }//Apply glow else { if (selectedC == glowingC) { Controls.Remove(glowPB); glowingC = null; Console.WriteLine($"You removed the glow from {(Card)selectedC.Tag}"); }//Remove glow on same card else if (deck.areDifferentcolors((Card)selectedC.Tag, (Card)glowingC.Tag) && (deck.areFollowingNum((Card)glowingC.Tag, (Card)selectedC.Tag)) && !Replaceable && !(selectedC.Location.X == 600 && selectedC.Location.Y == 50) && (!(selectedC.Equals(slotSpb) || selectedC.Equals(slotHpb) || selectedC.Equals(slotDpb) || selectedC.Equals(slotCpb)))) { Controls.Remove(glowPB); for (int i = 0; i < dealer.Count; i++) { if (((PictureBox)dealer[i].Tag).Equals(glowingC)) { glowingC.Location = new Point(selectedC.Location.X, selectedC.Location.Y + 20); glowingC.BringToFront(); Console.WriteLine($"You moved {(Card)glowingC.Tag} from the dealer to under {(Card)selectedC.Tag}"); openCard = null; isCardFromDealer = true; for (int j = 0; j < 7; j++) { if (lines[j].Contains(selectedC)) { lines[j].Add((PictureBox)dealer[i].Tag); } } Controls.Remove(dealer[i]); dealer.Remove(dealer[i]); break; } }//Move Card from dealer if ((glowingC.Equals(slotSpb) || glowingC.Equals(slotHpb) || glowingC.Equals(slotDpb) || glowingC.Equals(slotCpb)) && !isCardFromDealer) { removeFromSlots(selectedC); } else if (!isCardFromDealer) { int j, k = 0; PictureBox[] tempCs = new PictureBox[0]; for (int i = 0; i < 7; i++) { if (lines[i].Contains(glowingC)) { for (j = 0; j < lines[i].Count; j++) { if (lines[i][j] == glowingC) { tempCs = new PictureBox[lines[i].Count - j]; for (k = 0; k < tempCs.Length; k++) { tempCs[k] = lines[i][j + k]; } } } for (int u = 0; u < tempCs.Length; u++) { tempCs[u].Location = new Point(selectedC.Location.X, selectedC.Location.Y + (u + 1) * 20); tempCs[u].BringToFront(); lines[i].Remove(tempCs[u]); } if (lines[i].Count != 0) { try { lines[i][lines[i].Count - 1].Image = ((PictureBox)lines[i][lines[i].Count - 1].Tag).Image; lines[i][lines[i].Count - 1].Click += cardClick; lines[i][lines[i].Count - 1].Tag = ((PictureBox)lines[i][lines[i].Count - 1].Tag).Tag; bruhCount++; } catch { } } } } for (int i = 0; i < 7; i++) { if (lines[i].Contains(selectedC)) { for (int r = 0; r < tempCs.Length; r++) { lines[i].Add(tempCs[r]); } } } k = 0; Console.WriteLine($"You moved {(Card)glowingC.Tag} and {tempCs.Length - 1} other Cards to under {(Card)selectedC.Tag}"); } //Move Cards from line to line movesCounter++; glowingC = null; } else if (((Card)selectedC.Tag).getNum() == ((Card)glowingC.Tag).getNum() - 1 && (((Card)selectedC.Tag).getType() == ((Card)glowingC.Tag).getType()) && (selectedC.Equals(slotSpb) || selectedC.Equals(slotHpb) || selectedC.Equals(slotDpb) || selectedC.Equals(slotCpb))) { Controls.Remove(glowPB); for (int i = 0; i < dealer.Count; i++) { if (((PictureBox)dealer[i].Tag).Equals(glowingC)) { glowingC.Location = new Point(selectedC.Location.X, selectedC.Location.Y); glowingC.BringToFront(); Controls.Remove(dealer[i]); dealer.Remove(dealer[i]); openCard = null; Console.WriteLine($"You moved {(Card)glowingC.Tag} to slot {((Card)selectedC.Tag).getType()}"); isCardFromDealer = true; break; } }//Move from dealer to slot if (!isCardFromDealer && moveToSlotAble) { glowingC.Location = new Point(selectedC.Location.X, selectedC.Location.Y); glowingC.BringToFront(); for (int i = 0; i < 7; i++) { if (lines[i].Contains(glowingC)) { lines[i].Remove(glowingC); if (lines[i].Count != 0) { try { lines[i][lines[i].Count - 1].Image = ((PictureBox)lines[i][lines[i].Count - 1].Tag).Image; lines[i][lines[i].Count - 1].Click += cardClick; lines[i][lines[i].Count - 1].Tag = ((PictureBox)lines[i][lines[i].Count - 1].Tag).Tag; bruhCount++; } catch { } } } } Console.WriteLine($"You moved {(Card)glowingC.Tag} to slot {((Card)selectedC.Tag).getType()}"); }//Move from lines to slot { if (((Card)selectedC.Tag).getType() == "Spade") { slotSCount++; slotSpb = glowingC; } else if (((Card)selectedC.Tag).getType() == "Heart") { slotHCount++; slotHpb = glowingC; } else if (((Card)selectedC.Tag).getType() == "Diamond") { slotDCount++; slotDpb = glowingC; } else if (((Card)selectedC.Tag).getType() == "Club") { slotCCount++; slotCpb = glowingC; } } glowingC = null; movesCounter++; } else if (!(selectedC.Equals(slotSpb) || selectedC.Equals(slotHpb) || selectedC.Equals(slotDpb) || selectedC.Equals(slotCpb))) { glowImg = Resize(glowImg, 95, 145); glowPB.Location = new Point(selectedC.Location.X - 5, selectedC.Location.Y - 5); glowPB.Image = glowImg; glowPB.Size = glowImg.Size; Controls.Add(glowPB); glowingC = selectedC; } } if (glowingC != null) { Console.WriteLine($"GlowingC is {(Card)glowingC.Tag}"); } checkWin(); }
public void start(PictureBox picture, string jkip, string jkport) { bool running = false; bool m_stop = false; int switchImage = 0; int portmy = Convert.ToInt32(jkport); //端口号为int32 m_stop = false; NetworkStream sin = null; if (picture == pictureBox1) { switchImage = 1; } using (Socket connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { try { connection.Connect(jkip, portmy); sin = new NetworkStream(connection, true); } catch (Exception ex) { m_stop = true; MessageBox.Show("连接失败"); } //byte[] buffer0 = new byte[1024 * 1024]; byte[] buffer = new byte[512 * 1024]; while (!m_stop) { byte[] b = Encoding.ASCII.GetBytes("O" + "K" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0); int n = 0; int siz = 0; try { connection.Send(b); //n = connection.Receive(buffer); n = sin.Read(buffer, 0, HDRLEN);//HDRLEN=50; } catch (Exception ex) { m_stop = true; } if (n < HDRLEN) { if (n <= 0) { m_stop = true; } continue; } else { int ssz = SZOFS;//SZOFS=29 siz += unsignedByteToInt(buffer[ssz + 3]) << 24; siz += unsignedByteToInt(buffer[ssz + 2]) << 16; siz += unsignedByteToInt(buffer[ssz + 1]) << 8; siz += unsignedByteToInt(buffer[ssz]); n = HDRLEN; if (buffer[0] != 'S' || buffer[1] != 'P' || buffer[2] != 'C' || buffer[3] != 'A') { continue; } else if (siz <= 0 || siz > (512 * 1024)) { siz = 0; try { sin.Read(buffer, n, buffer.Length); //connection.Receive(buffer); } catch (Exception ex) { } continue; } else { do { int r = 0; try { // r = in.read(buffer, n, HDLREN + siz - n); r = sin.Read(buffer, n, buffer.Length - n); } catch (Exception ex) { //e.printStackTrace(); } n += r; }while (n < (siz + HDRLEN)); } } byte[] buffer2 = new byte[n]; // int height; for (int i = 0; i < n; i++) { buffer2[i] = buffer[i + HDRLEN];//****************************************************图像数据存储在了buffer2[]中 } try { using (MemoryStream ms = new MemoryStream(buffer2)) { try { Bitmap img = new Bitmap(ms); imageJt = img; switch (switchImage) { case 1: if (capture1 == 1) { picname1 = @"D:\截图保存\监控点1\"; picname1 = picname1 + "-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + "-" + "报警" + ".jpg"; imageJt.Save(picname1); capture1 = 0; } break; break; default: break; } if (picture.Equals(pictureBox1) == true) { picture.Image = img; } } catch (Exception ex) { ex.Message.ToString(); } } } catch (IOException e) { } }// while try { connection.Close(); } catch (IOException e) { } } m_stop = true; running = true; }
// Első elem választása private void Player_element_Click(object sender, EventArgs e) { PictureBox picturebox = (PictureBox)sender; Start_Ingame.Enabled = false; // Első elemek kiválasztása if (picturebox.Equals(Player_first_element)) { // Első kisikon /1 Element_First = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 10, picturebox.Location.Y + 20), BackColor = Color.Red, }; // Második kisikon /1 Element_Second = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 70, picturebox.Location.Y + 20), BackColor = Color.Aqua, }; // Harmadik kisikon /1 Element_Third = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 40, picturebox.Location.Y + 70), BackColor = Color.LawnGreen, }; } // Második elemek kiválasztása else if (picturebox.Equals(Player_second_element)) { // Első kisikon /2 Element_Fourth = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 10, picturebox.Location.Y + 20), BackColor = Color.Red, }; // Második kisikon /2 Element_Fiveth = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 70, picturebox.Location.Y + 20), BackColor = Color.Aqua, }; // Harmadik kisikon /2 Element_Sixth = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 40, picturebox.Location.Y + 70), BackColor = Color.LawnGreen, }; } // Harmadik elemek kiválasztása else if (picturebox.Equals(Player_third_element)) { // Első kisikon /3 Element_Seventh = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 10, picturebox.Location.Y + 20), BackColor = Color.Red, }; // Második kisikon /3 Element_Eighth = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 70, picturebox.Location.Y + 20), BackColor = Color.Aqua, }; // Harmadik kisikon /3 Element_Nineth = new PictureBox { Name = "Element_Choose", Size = new Size(15, 15), Location = new Point(picturebox.Location.X + 40, picturebox.Location.Y + 70), BackColor = Color.LawnGreen, }; } //Első element if (picturebox.Equals(Player_first_element)) { // Eventek hozzáadása Element_First.Click += Element_First_Change_Click; Element_Second.Click += Element_First_Change_Click; Element_Third.Click += Element_First_Change_Click; this.Controls.Remove(picturebox); this.Controls.Add(Element_First); this.Controls.Add(Element_Second); this.Controls.Add(Element_Third); } // Második element else if (picturebox.Equals(Player_second_element)) { // Eventek hozzáadása Element_Fourth.Click += Element_Second_Change_Click; Element_Fiveth.Click += Element_Second_Change_Click; Element_Sixth.Click += Element_Second_Change_Click; this.Controls.Remove(picturebox); this.Controls.Add(Element_Fourth); this.Controls.Add(Element_Fiveth); this.Controls.Add(Element_Sixth); } // Harmadik element else if (picturebox.Equals(Player_third_element)) { // Eventek hozzáadása Element_Seventh.Click += Element_Third_Change_Click; Element_Eighth.Click += Element_Third_Change_Click; Element_Nineth.Click += Element_Third_Change_Click; this.Controls.Remove(picturebox); this.Controls.Add(Element_Seventh); this.Controls.Add(Element_Eighth); this.Controls.Add(Element_Nineth); } }
private void useXLogScaleToolStripMenuItem_Click(object sender, EventArgs e) { if (LastPictureBoxClicked.Equals(TreblePictureBox)) { if (CsCoreMod._DigitaltreblePrint3DSpectrum.IsXLogScale == true) { CsCoreMod._DigitaltreblePrint3DSpectrum.IsXLogScale = false; } else { CsCoreMod._DigitaltreblePrint3DSpectrum.IsXLogScale = true; } } else if (LastPictureBoxClicked.Equals(MedioPictureBox)) { if (CsCoreMod._DigitalMedioPrint3DSpectrum.IsXLogScale == true) { CsCoreMod._DigitalMedioPrint3DSpectrum.IsXLogScale = false; } else { CsCoreMod._DigitalMedioPrint3DSpectrum.IsXLogScale = true; } } else if (LastPictureBoxClicked.Equals(BassPictureBox)) { if (CsCoreMod._DigitalBassPrint3DSpectrum.IsXLogScale == true) { CsCoreMod._DigitalBassPrint3DSpectrum.IsXLogScale = false; } else { CsCoreMod._DigitalBassPrint3DSpectrum.IsXLogScale = true; } } else if (LastPictureBoxClicked.Equals(DigitalSoundBars)) { if (CsCoreMod._DigitallineSpectrum.IsXLogScale == true) { CsCoreMod._DigitallineSpectrum.IsXLogScale = false; } else { CsCoreMod._DigitallineSpectrum.IsXLogScale = true; } } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { if (splitContainer2.Panel2Collapsed) { hidePropertiesToolStripMenuItem.CheckState = CheckState.Checked; } else { hidePropertiesToolStripMenuItem.CheckState = CheckState.Unchecked; } ContextMenuStrip cms = sender as ContextMenuStrip; PictureBox clickedImage = cms.SourceControl as PictureBox; LastPictureBoxClicked = clickedImage; NameToolStripTextBox.Text = clickedImage.Tag.ToString(); if (clickedImage.Equals(TreblePictureBox)) { if (CsCoreMod._DigitaltreblePrint3DSpectrum.IsXLogScale == true) { useXLogScaleToolStripMenuItem.Checked = true; } else { useXLogScaleToolStripMenuItem.Checked = false; } if (CsCoreMod._DigitaltreblePrint3DSpectrum.UseAverage == true) { useAverageToolStripMenuItem.Checked = true; } else { useAverageToolStripMenuItem.Checked = false; } switch (CsCoreMod._DigitaltreblePrint3DSpectrum.ScalingStrategy) { case ScalingStrategy.Sqrt: squareRootToolStripMenuItem.Checked = true; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Decibel: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = true; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Linear: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = true; break; } } else if (clickedImage.Equals(MedioPictureBox)) { if (CsCoreMod._DigitalMedioPrint3DSpectrum.IsXLogScale == true) { useXLogScaleToolStripMenuItem.Checked = true; } else { useXLogScaleToolStripMenuItem.Checked = false; } if (CsCoreMod._DigitalMedioPrint3DSpectrum.UseAverage == true) { useAverageToolStripMenuItem.Checked = true; } else { useAverageToolStripMenuItem.Checked = false; } switch (CsCoreMod._DigitalMedioPrint3DSpectrum.ScalingStrategy) { case ScalingStrategy.Sqrt: squareRootToolStripMenuItem.Checked = true; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Decibel: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = true; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Linear: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = true; break; } } else if (clickedImage.Equals(BassPictureBox)) { if (CsCoreMod._DigitalBassPrint3DSpectrum.IsXLogScale == true) { useXLogScaleToolStripMenuItem.Checked = true; } else { useXLogScaleToolStripMenuItem.Checked = false; } if (CsCoreMod._DigitalBassPrint3DSpectrum.UseAverage == true) { useAverageToolStripMenuItem.Checked = true; } else { useAverageToolStripMenuItem.Checked = false; } switch (CsCoreMod._DigitalBassPrint3DSpectrum.ScalingStrategy) { case ScalingStrategy.Sqrt: squareRootToolStripMenuItem.Checked = true; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Decibel: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = true; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Linear: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = true; break; } } else if (clickedImage.Equals(DigitalSoundBars)) { if (CsCoreMod._DigitallineSpectrum.IsXLogScale == true) { useXLogScaleToolStripMenuItem.Checked = true; } else { useXLogScaleToolStripMenuItem.Checked = false; } if (CsCoreMod._DigitallineSpectrum.UseAverage == true) { useAverageToolStripMenuItem.Checked = true; } else { useAverageToolStripMenuItem.Checked = false; } switch (CsCoreMod._DigitallineSpectrum.ScalingStrategy) { case ScalingStrategy.Sqrt: squareRootToolStripMenuItem.Checked = true; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Decibel: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = true; linearToolStripMenuItem.Checked = false; break; case ScalingStrategy.Linear: squareRootToolStripMenuItem.Checked = false; decibelToolStripMenuItem.Checked = false; linearToolStripMenuItem.Checked = true; break; } } if (this.TopMost == true) { alwaysOnTopToolStripMenuItem.Checked = true; } else { alwaysOnTopToolStripMenuItem.Checked = false; } }
//picBox点击事件 //参数sender表示触发事件的控件,e表示触发的事件是什么,具体可以百度下事件触发机制 private void pictureBox1_Click(object sender, EventArgs e) { //C#中对象参数赋值都是采用引用的方式,相当于是C++中的"指针"赋值 //声明一个picturebox的"指针",指向这个触发事件的控件 //C#中没有指针,为了便于理解可以这样想。 //因为sender和picturebox类型不同,赋值需要强制转换 PictureBox picturebox = (PictureBox)sender; //如果点击的是灰色块 if (CompareByBase64String((Bitmap)picturebox.Image, SUDOKU.Properties.Resources.blank)) { int loc = 0; for (int k = 1; k <= 81; k++) { if (picturebox.Equals(picBox[k])) { loc = k; break; } } //将其他蓝色变成灰色的 for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 9; j++) { if (numColor[i, j] == 4) { picBox[(i - 1) * 9 + j].Image = SUDOKU.Properties.Resources.blank; numColor[i, j] = 3; } else if (numColor[i, j] == 5) { picBox[(i - 1) * 9 + j].Image = numC[numberPanel[i, j]].Image; numColor[i, j] = 2; } } } int x = (loc - 1) / 9 + 1; int y = loc % 9; if (y == 0) { y = 9; } numColor[x, y] = 4; //将这个变成蓝色的 picturebox.Image = SUDOKU.Properties.Resources.blank_s; } //如果选中的是蓝色填充数字,就将数字变为蓝色选中数字 else { //将其他的蓝色去除 int loc = 0; for (int k = 1; k <= 81; k++) { if (picturebox.Equals(picBox[k])) { loc = k; break; } } for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 9; j++) { if (numColor[i, j] == 4) { picBox[(i - 1) * 9 + j].Image = SUDOKU.Properties.Resources.blank; numColor[i, j] = 3; } else if (numColor[i, j] == 5) { picBox[(i - 1) * 9 + j].Image = numC[numberPanel[i, j]].Image; numColor[i, j] = 2; } } } //将这个变为蓝色的 int x = (loc - 1) / 9 + 1; int y = loc % 9; if (y == 0) { y = 9; } if (numColor[x, y] == 1) { } else if (numberPanel[x, y] > 0) { numColor[x, y] = 5; picturebox.Image = buttonNumO[numberPanel[x, y]].Image; } else if (numColor[x, y] < 9) { numColor[x, y] = 4; picBox[(x - 1) * 9 + y].Image = SUDOKU.Properties.Resources.blank_s; } } }
void ShipMouseUp(object sender, MouseEventArgs e) { if (shipInitialLocation != Point.Empty) { bool returnToInitialPosition = true; PictureBox ship = sender as PictureBox; Point loc = ship.Location; if (loc.X > myBoard.Location.X && loc.X <= myBoard.Location.X + myBoard.Width && loc.Y > myBoard.Location.Y && loc.Y <= myBoard.Location.Y + myBoard.Height) { int gridx = myBoard.convertWindowToGridXCoordinate(loc.X - myBoard.Location.X); int gridy = myBoard.convertWindowToGridYCoordinate(loc.Y - myBoard.Location.Y); // MessageBox.Show(gridx + "\n" + gridy); Direction direction = Direction.HORIZONTAL; if (ship.Height > ship.Width) { direction = Direction.VERTICAL; } int size = 0; if (ship.Equals(ship1)) { size = 2; } else if (ship.Equals(ship2)) { size = 3; } else if (ship.Equals(ship3)) { size = 4; } else if (ship.Equals(ship4)) { size = 5; } else if (ship.Equals(ship5)) { size = 6; } Coords startloc = new Coords(gridx, gridy); if (islocationvalid(startloc, direction, size)) { Coords blockCoords = myBoard.getGridCoords(gridx, gridy); Point newLocation = new Point(blockCoords.X + myBoard.Location.X, blockCoords.Y + myBoard.Location.Y); ship.Location = newLocation; data.initShip(size, direction, startloc); returnToInitialPosition = false; } } if (returnToInitialPosition) { Point returnLocation = ship.Location; returnLocation.X = shipInitialLocation.X - shipOffset.X; returnLocation.Y = shipInitialLocation.Y - shipOffset.Y; ship.Location = returnLocation; } shipInitialLocation = Point.Empty; } }