private void btn5_Click(object sender, EventArgs e) { Button button = (Button)sender; switch (button.Name) { case "sbtn": MessageBox.Show("검색"); break; case "rfbtn": //panel1.Refresh(); //MenuPan(1000, 70, 0, 0); //MainPan(1000, 530, 0, 70); MessageBox.Show("새로고침"); break; case "bmbtn": case "bmbtn2": if (((Weather)weatherlist[0]).Book) { foreach (Control c in panel1.Controls) { if (c.Name == "bmbtn2") { c.Dispose(); Btnclass bmbtn = new Btnclass(this, "bmbtn", "즐찾추가", 50, 45, 850, 0, btn5_Click); panel1.Controls.Add(dc.btn1(bmbtn)); } } MessageBox.Show("즐겨찾기삭제"); } else { foreach (Control c in panel1.Controls) { if (c.Name == "bmbtn") { c.Dispose(); Btnclass bmbtn = new Btnclass(this, "bmbtn2", "즐찾추가", 50, 45, 850, 0, btn5_Click); panel1.Controls.Add(dc.btn1(bmbtn)); } } MessageBox.Show("즐겨찾기추가"); } ((Weather)weatherlist[0]).Book = !((Weather)weatherlist[0]).Book; break; default: break; } }
public void btn(Btnclass bc) { Button btn = new Button(); btn.DialogResult = DialogResult.OK; btn.Name = bc.Name; btn.Text = bc.Text; btn.Size = new Size(bc.SX, bc.SY); btn.Location = new Point(bc.PX, bc.PY); btn.Cursor = Cursors.Hand; btn.Click += bc.eh; btn.BackColor = Color.Transparent; bc.Form.Controls.Add(btn); }
private void MenuPan(int sX, int sY, int pX, int pY) { panel3 = new Panel(); Btnclass bt1 = new Btnclass(this, "Home", "홈", 80, 70, 0, 0, btn1_Click); Btnclass bt2 = new Btnclass(this, "bookmark", "즐겨찾기", 80, 70, 80, 0, btn2_Click); Btnclass bt3 = new Btnclass(this, "feedback", "피드백", 80, 70, 800, 0, btn3_Click); Btnclass bt4 = new Btnclass(this, "option", "설정", 80, 70, 880, 0, btn4_Click); panel3.Location = new Point(pX, pY); panel3.Size = new Size(sX, sY); panel3.BackColor = Color.White; //panel3.BackgroundImageLayout = ImageLayout.Stretch; //panel3.BackgroundImage = (Bitmap)WindowsFormsHiWeather.Properties.Resources.background; //panel3.BackgroundImage = (Bitmap)WindowsFormsHiWeather.Properties.Resources.background1; Controls.Add(panel3); panel3.Controls.Add(dc.btn1(bt1)); panel3.Controls.Add(dc.btn1(bt2)); panel3.Controls.Add(dc.btn1(bt3)); panel3.Controls.Add(dc.btn1(bt4)); }
private void MainPan(int sX, int sY, int pX, int pY) { panel1 = new Panel(); panel1.Location = new Point(pX, pY); panel1.Size = new Size(sX, sY); panel1.BackgroundImageLayout = ImageLayout.Stretch; //panel1.BackgroundImage = (Bitmap)WindowsFormsHiWeather.Properties.Resources.background; panel1.BackgroundImage = (Bitmap)WindowsFormsHiWeather.Properties.Resources.background1; PictureBox weather = new PictureBox(); PictureBox picture = new PictureBox(); TextBox tb = new TextBox(); tb.Size = new Size(120, 50); tb.Location = new Point(800, 50); tb.ResumeLayout(false); tb.PerformLayout(); ResumeLayout(false); PerformLayout(); Lbclass adlb = new Lbclass(this, "adlb", ((Weather)weatherlist[0]).Place + ", " + ((Weather)weatherlist[0]).City, 300, 25, 370, 0); // 주소 라벨 Lbclass dglb = new Lbclass(this, "dglb", days[0].Toptemperature + "˚C " + days[0].Toptemperature.ToString() + "/" + days[0].Bottomtemperature.ToString() + " \n" + days[0].Condition, 110, 50, 400, 40); // 기상 라벨 Lbclass timelb = new Lbclass(this, "timelb", "마지막 업데이트: " + DateTime.Now.ToString("HH") + ":" + DateTime.Now.ToString("mm") + ":" + DateTime.Now.ToString("ss"), 200, 20, 350, 100); Btnclass sbtn = new Btnclass(this, "sbtn", "검색", 30, 40, 920, 41, btn5_Click); Btnclass rfbtn = new Btnclass(this, "rfbtn", "새로고침", 50, 45, 800, 0, btn5_Click); //Btnclass bmbtn = new Btnclass(this, "bmbtn", "즐찾추가", 50, 45, 850, 0, btn5_Click); Btnclass bmbtn; if (((Weather)weatherlist[0]).Book) { bmbtn = new Btnclass(this, "bmbtn2", "즐찾추가", 50, 45, 850, 0, btn5_Click); } else { bmbtn = new Btnclass(this, "bmbtn", "즐찾추가", 50, 45, 850, 0, btn5_Click); } weather.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject("sunny"); weather.SizeMode = PictureBoxSizeMode.StretchImage; weather.Location = new Point(330, 30); weather.Size = new Size(70, 65); weather.BackColor = Color.Transparent; picture.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject("dust2"); picture.SizeMode = PictureBoxSizeMode.StretchImage; picture.Location = new Point(510, 30); picture.Size = new Size(70, 65); picture.BackColor = Color.Transparent; Lbclass lb = new Lbclass(this, "lb", "시간별", 100, 30, 10, 120); for (int i = 0; i < ((Weather)weatherlist[0]).Conditions_hour.Length; i++) { Lbclass hour_lb = new Lbclass(this, "hour_lb", ((Weather)weatherlist[0]).Conditions_hour[i].Hour.ToString() + "시", 50, 20, 25 + (i * 120), 160); Lbclass tmp_lb = new Lbclass(this, "tmp_lb", ((Weather)weatherlist[0]).Conditions_hour[i].Temperature.ToString() + "˚C", 70, 20, 15 + (i * 120), 220); Lbclass con_lb = new Lbclass(this, "con_lb", ((Weather)weatherlist[0]).Conditions_hour[i].Condition, 100, 40, 15 + (i * 120), 240); PictureBox picture_con = new PictureBox(); PictureBox picture_dust = new PictureBox(); picture_con.Image = (Bitmap)WindowsFormsHiWeather.Properties.Resources.sunny; picture_con.SizeMode = PictureBoxSizeMode.StretchImage; picture_con.ClientSize = new Size(40, 40); picture_con.Location = new Point(10 + (i * 120), 180); picture_con.BackColor = Color.Transparent; picture_dust.Image = (Bitmap)WindowsFormsHiWeather.Properties.Resources.dust2; picture_dust.SizeMode = PictureBoxSizeMode.StretchImage; picture_dust.ClientSize = new Size(40, 40); picture_dust.Location = new Point(50 + (i * 120), 180); picture_dust.BackColor = Color.Transparent; panel1.Controls.Add(dc.lb1(tmp_lb, 15)); panel1.Controls.Add(dc.lb1(con_lb, 12)); panel1.Controls.Add(dc.lb1(hour_lb, 12)); panel1.Controls.Add(picture_con); panel1.Controls.Add(picture_dust); } panel1.Controls.Add(dc.lb2(lb, 18)); Lbclass lb_day = new Lbclass(this, "lb_day", "일별", 100, 30, 10, 280); for (int i = 0; i < days.Length; i++) { PictureBox wticon = new PictureBox(); PictureBox dusticon = new PictureBox(); Lbclass addrlb = new Lbclass(this, "addrlb", days[i].Day.ToString() + "일", 80, 20, 30 + i * 140, 320); // 주소 라벨 Lbclass dgrlb = new Lbclass(this, "dgrlb", "최고 : " + days[i].Toptemperature + "˚C " + "\n최저 : " + days[i].Bottomtemperature.ToString() + "˚C ", 100, 40, 15 + (i * 140), 390); // 기상 라벨 Lbclass cdlb = new Lbclass(this, "cdlb", days[i].Condition, 100, 40, (15 + i * 140), 430); dusticon.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject("dust1"); dusticon.SizeMode = PictureBoxSizeMode.StretchImage; dusticon.Location = new Point(55 + (i * 140), 350); dusticon.ClientSize = new Size(40, 40); dusticon.BackColor = Color.Transparent; wticon.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject("sunny"); wticon.SizeMode = PictureBoxSizeMode.StretchImage; wticon.Location = new Point(15 + (i * 140), 350); wticon.ClientSize = new Size(40, 40); wticon.BackColor = Color.Transparent; panel1.Controls.Add(dc.lb1(addrlb, 15)); panel1.Controls.Add(dc.lb1(dgrlb, 12)); panel1.Controls.Add(dc.lb1(cdlb, 12)); panel1.Controls.Add(wticon); panel1.Controls.Add(dusticon); } panel1.Controls.Add(dc.lb2(lb_day, 18)); panel1.Controls.Add(dc.lb1(adlb, 18)); panel1.Controls.Add(dc.lb1(dglb, 13)); panel1.Controls.Add(dc.btn1(sbtn)); panel1.Controls.Add(dc.btn1(rfbtn)); panel1.Controls.Add(dc.btn1(bmbtn)); panel1.Controls.Add(tb); panel1.Controls.Add(weather); panel1.Controls.Add(picture); panel1.Controls.Add(dc.lb1(timelb, 10)); Controls.Add(panel1); }
public Button btn1(Btnclass bc) { Button btn = new Button(); btn.DialogResult = DialogResult.OK; btn.Name = bc.Name; btn.Text = ""; btn.Size = new Size(bc.SX, bc.SY); btn.Location = new Point(bc.PX, bc.PY); btn.Cursor = Cursors.Hand; btn.Click += bc.eh; Image btn_myImage; if (btn.Name == "Home") { btn_myImage = (Image)Properties.Resources.Home; //MessageBox.Show(bc.Name); } else if (btn.Name == "bookmark") { btn_myImage = (Image)Properties.Resources.bookmark; //MessageBox.Show(bc.Name); } else if (btn.Name == "feedback") { btn_myImage = (Image)Properties.Resources.feedback; //MessageBox.Show(bc.Name); } else if (btn.Name == "option") { btn_myImage = (Image)Properties.Resources.setting; //MessageBox.Show(bc.Name); } else if (btn.Name == "rfbtn") { btn_myImage = (Image)Properties.Resources.refresh; //MessageBox.Show(bc.Name); } else if (btn.Name == "bmbtn") { btn_myImage = (Image)Properties.Resources.Star; //MessageBox.Show(bc.Name); } else if (btn.Name == "bmbtn2") { btn_myImage = (Image)Properties.Resources.Star1; //MessageBox.Show(bc.Name); } else { btn_myImage = (Image)Properties.Resources.search_button; } //MessageBox.Show("패스"); ImageList imageList = new ImageList(); imageList.ImageSize = new Size(255, 255); imageList.Images.Add(btn_myImage); if (btn.Name == "sbtn") { imageList.ImageSize = new Size(50, 32); } else if (btn.Name == "rfbtn" || btn.Name == "bmbtn") { imageList.ImageSize = new Size(50, 32); } else { imageList.ImageSize = new Size(70, 50); } imageList.TransparentColor = Color.Transparent; btn.ImageIndex = 0; btn.ImageList = imageList; btn.TabStop = false; btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderSize = 0; btn.BackColor = Color.Transparent; return(btn); }