• 大小: 19.52MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-05
  • 语言: 其他
  • 标签: winfromC#  

资源简介

这个小程序是winfrom窗体应用程序, 1:将图片进行分割, 2:并且创建多个picturebox去装, 3:通过鼠标的点击, 4:交换自定义的picturebox中的分割小图片

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace JD_Game_TZ
{
    public partial class FrmMain : Form
    {
        //图片原图块
        private int FirstBlock;
        //布局大小
        private int GameSize;
        //图片宽度
        private int MAP_WIDTH = 300;
        //图片列表
        public PictureBox[] PicBlock;
        //存放图片序号的数组
        private int[] Position;
        //图片新图块
        private int SecondBlock;
        //原图像
        private Bitmap Source;
        //所选择的文件名
        private string filename;
        //是否交换
        private bool flag;

        public FrmMain()
        {
            InitializeComponent();
        }

        #region 窗体事件
        //窗体加载时
        private void FrmMain_Load(object sender EventArgs e)
        {
            //设置默认图像路径
            filename = Application.StartupPath + “\\image.bmp“;
            //将图片放置到pictureBox1里
            pictureBox1.Image = Image.FromFile(filename);
            //不交换
            flag = false;
            //设置图片大小
            MAP_WIDTH = 300;
            //设置位图区域
            Source = new Bitmap(MAP_WIDTH MAP_WIDTH);
            SavBmp();
        }

        //打开文件对话框选择图片
        private void btnImage_Click(object sender EventArgs e)
        {
            ////打开对话框
            //openFileDialog1.ShowDialog();
            ////判断字符串是否为空字符串
            //if (!string.IsNullOrEmpty(openFileDialog1.FileName))
            //{
            //    //获取图片全路径
            //    filename = openFileDialog1.FileName;
            //    //将图片赋给pictureBox1
            //    pictureBox1.Image = Image.FromFile(filename);
            //    //指定大小保存位图
            //    SavBmp();
            //}
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //获取图片全路径
                filename = openFileDialog1.FileName;
                //将图片赋给pictureBox1
                pictureBox1.Image = Image.FromFile(filename);
                //指定大小保存位图
                SavBmp();
            }
            
        }

        //开始按钮
        private void btnBegin_Click(object sender EventArgs e)
        {
            //卸载上次的图片块
            init(GameSize);
            //重新加载图片块
            int i = 0;
            //获取小图片的边距
            int BWidth = 0;
            BWidth = MAP_WIDTH / GameSize;
            //遍历布局
            for (i = 0; i <= GameSize * GameSize - 1; i++)
            {
                //创建PictureBox
                PicBlock[i] = new PictureBox();
                //PictureBox添加到控件
                Controls.Add(PicBlock[i]);
                //左边距
                PicBlock[i].Left = 250 + BWidth * (i % GameSize);
                //上边距
                PicBlock[i].Top = BWidth * (i / GameSize) + 70;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     295926  2016-01-28 17:01  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\14.ico

     文件        187  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\App.config

     文件     509996  1997-07-15 01:00  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\Good.WAV

     文件     617494  2016-01-28 15:20  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\image.bmp

     文件     310272  2016-03-15 16:25  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\JD_Game_TZ.exe

     文件        187  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\JD_Game_TZ.exe.config

     文件      38400  2016-03-15 16:25  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\JD_Game_TZ.pdb

     文件      22984  2016-03-15 16:25  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\JD_Game_TZ.vshost.exe

     文件        187  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\JD_Game_TZ.vshost.exe.config

     文件        490  2014-01-13 21:31  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\JD_Game_TZ.vshost.exe.manifest

     文件       5566  1998-03-30 22:37  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\bin\Debug\RIGHT.WAV

     文件       9361  2016-01-28 18:26  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\Form1.cs

     文件       7670  2016-01-28 16:30  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\Form1.Designer.cs

     文件       6221  2016-01-28 16:30  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\Form1.resx

     文件       3950  2016-01-28 17:01  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\JD_Game_TZ.csproj

     文件       1308  2016-01-28 17:00  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7322  2016-03-15 16:22  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       3435  2016-03-15 16:25  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.csproj.FileListAbsolute.txt

     文件        975  2016-01-28 17:01  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.csproj.GenerateResource.Cache

     文件       2209  2016-01-28 17:01  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.csprojResolveAssemblyReference.cache

     文件     310272  2016-03-15 16:25  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.exe

     文件        180  2016-01-28 17:01  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.FrmMain.resources

     文件      38400  2016-03-15 16:25  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.pdb

     文件        180  2016-01-28 17:01  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\JD_Game_TZ.Properties.Resources.resources

     文件          0  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        524  2016-01-28 14:54  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\Program.cs

     文件       1358  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\Properties\AssemblyInfo.cs

     文件       2872  2016-01-28 14:50  图片拼图游戏\JD_Game_TZ\JD_Game_TZ\Properties\Resources.Designer.cs

............此处省略106个文件信息

评论

共有 条评论

相关资源