Diashow



  • Hi wollte mal wissen was ihr zu meinem Diashowprogramm sagt

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.IO;
    
    public class main : Form {
    	public int Zahl;
    	public int Zahl2;
    	public int Zahl3;
    	Font f = new Font("New Times Roman",12);
    	Button b3 = new Button();
    	Button b2 = new Button(); 
    	OpenFileDialog ofp = new OpenFileDialog();
    	Button b1 = new Button();
    	TextBox tb = new TextBox();
    	public 	ListBox lb = new ListBox();
    	public	RadioButton rb = new RadioButton();
    	public		RadioButton rb2= new RadioButton();
    
    public	main():base(){
    	this.TopMost = true;
    		b3.Location = new Point(120,320);
    		b3.Parent = this;
    		b3.Text = "Start";
    		b3.Font = f;
    		b3.Click += new EventHandler(BClick3);
    		b2.Location = new Point(50,280);
    		b2.Parent = this;
    		b2.Text = "OK";
    		b2.Click += new EventHandler(BClick2);
    		ofp.Filter ="Bilddatein (*.bmp;*.jpg)|*.bmp;*.jpg";
    		b1.Location = new Point (170,240);
    		b1.Size = new Size(30,30);
    		b1.Parent = this;
    		b1.Text = "...";
    		b1.Click +=new EventHandler(BClick);
    		tb.Location = new Point(10,250);
    		tb.Parent = this;
    		tb.Size = new Size(150,50);
    		this.StartPosition = FormStartPosition.CenterScreen;
    		this.Size = new Size (400,400);
    		this.MaximumSize = this.Size;
    		lb.Parent = this;
    		lb.Dock = DockStyle.Right;
    		lb.Size = new Size(180,100);
    		rb.Location = new Point(10,100);
    		rb.Parent = this;
    		rb.Text = "Strechimage";
    		rb2.Location = new Point(10,150);
    		rb2.Parent = this;
    		rb2.Text = "Centerimage";
    
    		}
    	protected override void OnPaint(PaintEventArgs p){
    		Graphics g = p.Graphics;
    
    		g.DrawString("Bilder auswählen",f,Brushes.Black,80,20);
    		g.DrawString("Pfad:",f,Brushes.Black,10,230);
    
    	}
    	void BClick(object sender,EventArgs ea){
    
    		ofp.ShowDialog();
    		tb.Text = ofp.FileName;
    
    	}
    	void BClick2(object sender,EventArgs ea){
    		if(tb.Text != "" ){
    			if(tb.Text !=" "){
    		lb.Items.Add(tb.Text);
    			}
    		}
    
    	}
    	void BClick3(object sender, EventArgs ea){
    		Zahl = 1;
    		Zahl2= 1;
    		this.Close();
    	}
    
    }
    
    public class Monitor : Form{
    	int Zahl;
    	OverButton ob = new OverButton();
    	Timer t3 = new Timer();
    	ProgressBar PB2 = new ProgressBar();
    	main m = new main();
    	PictureBox pb = new PictureBox();
    	Timer t1 = new Timer();
    	Timer t2 =new Timer();
    	static void Main(){
    		Application.Run (new Monitor());
    	}
    
    	public Monitor():base(){
    		m.Show();
    		this.WindowState = FormWindowState.Maximized;
    		this.FormBorderStyle = FormBorderStyle.None;
    		t1.Enabled = true;
    		t1.Interval = 1;
    		t1.Tick += new EventHandler(TTick);
    		t2.Interval = 5000;
    		t2.Tick += new EventHandler(TTick2);
    		pb.Dock = DockStyle.Fill;
    		pb.SizeMode = PictureBoxSizeMode.CenterImage;
    		PB2.Location = new Point (300,400);
    		PB2.BackColor = Color.Black;
    		PB2.Parent = this;
    		PB2.Size = new Size(400,50);
    		PB2.Maximum  =5;
    		PB2.Minimum  =0;
    		t3.Interval = 1000;
    		t3.Enabled = false;
    		t3.Tick += new EventHandler(TTick3);
    		ob.Parent = this;
    		ob.Location = new Point(980,20);
    
    	}
    	protected virtual void TTick(object sender,EventArgs ea){
    
    		if(m.rb.Checked ==true){
    			pb.SizeMode = PictureBoxSizeMode.StretchImage;
    		}
    		if(m.rb2.Checked == true){
    			pb.SizeMode = PictureBoxSizeMode.CenterImage;
    		}
    		t3.Enabled = false;
    		if(m.Zahl2 == 1){
    			t2.Enabled = true;
    			t3.Enabled = true;
    			t1.Enabled = false;
    		}
    
    }
    	protected virtual void TTick2(object sender,EventArgs ea){
    		 	Zahl++;
    			pb.Parent = this;
    			if(Zahl == m.lb.Items.Count){
    			Zahl=0;
    			}
    			pb.Image = Image.FromFile(m.lb.Items[Zahl].ToString());
    			PB2.Visible = false;
    	}
    
    			protected virtual void TTick3(object sender,EventArgs ea){
    				PB2.Step =1 ;
    				PB2.PerformStep();
    			}
    
    		}
    
    public class OverButton : PictureBox {
    
    	public OverButton():base() {
    		this.Image = Image.FromFile("Kreuz.bmp");
    		this.Size = new Size(15,15);
    		}
    
    protected override void OnMouseUp(MouseEventArgs m){
    		this.BorderStyle = BorderStyle.FixedSingle;
    		Form.ActiveForm.Close();
    	}
    }
    


  • Da du wohl bereits sehnsüchtig auf eine Antwort wartest,
    erbarm ich mich halt mal ein wenig ..

    Der Code ist grässlich, absolut scheußlich. Hoffe nur du schreibst
    nie größere Projekte in so einem Stil (ist ernst gemeint).

    Ist ja zwar löblich, dass du die GUI etc. selbst schreiben willst, aber wenn du das schon machst, dann auch wenigstens
    halbwegs lesbar. In deinem Fall empfehle ich dir wirklich, verwende lieber den Forms Designer (ist wirklich selten,
    dass ich das empfehle). Der hat wenigstens eine klare Struktur und gibt den Feldern keine nichtssagenden Namen wie 'm'.

    Guck dir nur mal einen Ausschnitt aus deinem Code an ..

    if(Zahl == m.lb.Items.Count){
    Zahl=0;
    }
    

    Dein Code schreit gerade zu nach Kommentaren ..

    Wenn ich allein schonmal gucke, wieviel public Felder du in deinem Projekt bereits hast und ich nehm mal an
    die Formatierung des Codes ist jetzt nur in dem Forum hier so verunglückt ..

    Ich empfehl dir also, entweder du lässt absofort mal mindestens ein halbes Jahr lang (und das is wirklich Minimum)
    die Finger von GUIs, oder du verwendest absofort den Forms Designer und zeigst deinen Freunden wie 1337 du doch
    bist, aber dafür lässt du den Code dann nicht mehr bewerten ..

    Nimms mir nicht übel, hab nur das gesagt, was sich wohl der Großteil hier bereits dachte ..



  • Ganz ehrlich ich finde den Code jetzt auch nicht gerade schön aber wie immer zählt das Resultat.


Anmelden zum Antworten