2010-05-06

還沒修正的數位相框



1.相片讀入會變色、扭曲,我使用ImageList,最大只能256 x 256
2.加入相片,不能按CTRL多選,只能一張一張加





檔案在此:http://rapidshare.com/files/373468807/photo.beta.exe
程式碼如下:
一、FORM 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        string s;
        int c1, c2, c3, i, x = 0;
        double b;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (i < imageList1.Images.Count)
            {
                pictureBox1.Image = imageList1.Images[i];
                i++;
            }
            else i = 0;
        }
        private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer2.Enabled = false;
            imageList1.Images.Clear();
            pictureBox1.Image = null;
            timer1.Enabled = false;
        }
        private void 加入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "JPG(.JPG)|*.JPG|BMP(.BMP)|*.BMP";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                s = openFileDialog1.FileName;
                imageList1.Images.Add(Image.FromFile(s));
                timer1.Enabled = true;
            }

        }
        private void 離開ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        private void 背景ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            colorDialog1.FullOpen = true;
            colorDialog1.Color = this.BackColor;
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                timer2.Enabled = false;
                this.BackColor = colorDialog1.Color;
            }
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            Random abc = new Random();
            c1 = abc.Next(0, 255);
            c2 = abc.Next(0, 255);
            c3 = abc.Next(0, 255);
            this.BackColor = Color.FromArgb(c1, c2, c3);
        }
        private void 速度ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 obj = new Form2();
            obj.Show(this);
            b = Convert.ToDouble(timer1.Interval);
            obj.updates (b);
        }
        public void updateb(double value)
        {
            this.b = value;
            x = Convert.ToInt32(b * 1000);
            timer1.Interval = x;
        }
              
    }
}

二、FORM 2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
    public partial class Form2 : Form
    {
        double a;
       
        public Form2()
        {
            InitializeComponent();
        }
        private void Form2_Load(object sender, EventArgs e)
        {
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Form1 owner = (Form1)this.Owner;
            try
            {
                a = double.Parse(textBox1.Text);
                owner.updateb(a);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("請輸入數字");
            }
        }
            public void updates(double value)
            {
                this.a=value;
                a=a/1000;
                textBox1.Text=a.ToString();
            }
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();       
        }
    }
}




沒有留言:

張貼留言