相册 C#Word下载.docx

上传人:b****1 文档编号:4696135 上传时间:2023-05-03 格式:DOCX 页数:53 大小:2.54MB
下载 相关 举报
相册 C#Word下载.docx_第1页
第1页 / 共53页
相册 C#Word下载.docx_第2页
第2页 / 共53页
相册 C#Word下载.docx_第3页
第3页 / 共53页
相册 C#Word下载.docx_第4页
第4页 / 共53页
相册 C#Word下载.docx_第5页
第5页 / 共53页
相册 C#Word下载.docx_第6页
第6页 / 共53页
相册 C#Word下载.docx_第7页
第7页 / 共53页
相册 C#Word下载.docx_第8页
第8页 / 共53页
相册 C#Word下载.docx_第9页
第9页 / 共53页
相册 C#Word下载.docx_第10页
第10页 / 共53页
相册 C#Word下载.docx_第11页
第11页 / 共53页
相册 C#Word下载.docx_第12页
第12页 / 共53页
相册 C#Word下载.docx_第13页
第13页 / 共53页
相册 C#Word下载.docx_第14页
第14页 / 共53页
相册 C#Word下载.docx_第15页
第15页 / 共53页
相册 C#Word下载.docx_第16页
第16页 / 共53页
相册 C#Word下载.docx_第17页
第17页 / 共53页
相册 C#Word下载.docx_第18页
第18页 / 共53页
相册 C#Word下载.docx_第19页
第19页 / 共53页
相册 C#Word下载.docx_第20页
第20页 / 共53页
亲,该文档总共53页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

相册 C#Word下载.docx

《相册 C#Word下载.docx》由会员分享,可在线阅读,更多相关《相册 C#Word下载.docx(53页珍藏版)》请在冰点文库上搜索。

相册 C#Word下载.docx

【C:

\Photo】这是程序里面写死的路径(各位如果拿到源代码的话,可以自己修改;

甚至可以将这个路径作为画面的输入项,自由指定)。

我在工程包里面已经放了一些好看的照片了,可以直接把工程里面的Photo文件夹拷贝到C盘根目录下。

2.图片数量限制:

【100】同上所述,也是程序里面写死的(同样可以自己扩展修改)。

意思是本相册最多只接受100张相片。

3.图片格式限制:

【*.jpg*.png】同上所述,也是程序里面写死的。

图片的格式有很多,为演示,本相册只接受以上2种格式的图片文件。

点击按钮【加载图片】,效果如下:

可以看到,将【C:

\Photo】下的照片显示到画面中了。

排序照片:

选中照片(勾选CheckBox),点击上移、下移即可排序照片。

排序规则如下:

ABCD…代表未勾选的照片,a1a2a3…代表已勾选的照片,他们的原顺序A、a1、a2、B、C、a3。

单击上移时,效果:

a1、a2、A、B、a3、C

单击下移时,效果:

A、B、a1、a2、C、a3

(说的有点麻烦,其实想一想,意思很简单……)

旋转照片:

双击任意一张照片,可以打开照片的单独页面,如下所示:

此时可以点击按钮【左旋转】、【右旋转】查看效果,效果图如下:

此时还可以点击按钮【上一张】、【下一张】浏览照片。

(可以扩展功能,实现自动播放功能。

按下Esc,回到主页面。

右键任意一个照片,存在右键菜单。

点击【设为头像】,则左上角的头像即被设定(可以随时设定任意的图片为头像):

点击【路径】,则弹出提示框,提示此图片的路径:

点击【放大】,其效果跟双击一样,前文已提到,不再赘述。

可扩展功能:

主要是右键菜单。

前文提到的右键菜单的3个功能只是很简单的例子,其实想到什么都可以在此实现。

只要知道了我们点击的是哪张照片,接下来什么事都好办!

一开始也提到,本程序没有用到数据库,其实可以使用数据库保存图片等操作信息。

程序代码:

如果需要源码,请发邮件至:

tang.peng.ju@

【CtlPicShow.cs】

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Drawing;

usingSystem.Data;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.IO;

namespacePhotoManager

{

publicpartialclassCtlPicShow:

UserControl

{

///<

summary>

图片单击事件<

/summary>

publicMouseEventHandlerPicMouseRightClick;

图片双击事件<

publicMouseEventHandlerPicMouseDoubleClick;

图片信息<

privatePhotoFilephotoInfo;

文件路径<

publicstringFileName

get{returnthis.photoInfo.FileName;

}

///构造方法

paramname="

photoFile"

>

<

/param>

publicCtlPicShow(PhotoFilephotoFile)

InitializeComponent();

//数据信息

this.photoInfo=photoFile;

//控件内容显示

this.RefreshPhoto();

///显示数据

publicvoidRefreshPhoto()

//显示到控件

this.pbPhoto.Image=PhotoManager.GetImageThumbnail(photoInfo.FileName,this.pbPhoto.Size);

this.chkSel.Text=photoInfo.Name;

this.chkSel.Checked=photoInfo.IsChecked;

///鼠标点击

sender"

e"

privatevoidpbPhoto_MouseClick(objectsender,MouseEventArgse)

if(e.Button==MouseButtons.Right&

&

this.PicMouseRightClick!

=null)

this.PicMouseRightClick(this,e);

///鼠标双击

privatevoidpbPhoto_MouseDoubleClick(objectsender,MouseEventArgse)

if(e.Button==MouseButtons.Left&

this.PicMouseDoubleClick!

this.PicMouseDoubleClick(this,e);

///选中状态记录

privatevoidchkSel_CheckedChanged(objectsender,EventArgse)

this.photoInfo.IsChecked=this.chkSel.Checked;

}

 

【CtlPicShow.Designer.cs】

partialclassCtlPicShow

///必要なデザイナ変数です。

privateSystem.ComponentModel.IContainercomponents=null;

///使用中のリソースをすべてクリーンアップします。

disposing"

マネージリソースが破棄される場合true、破棄されない場合はfalseです。

protectedoverridevoidDispose(booldisposing)

if(disposing&

(components!

=null))

components.Dispose();

base.Dispose(disposing);

#regionコンポーネントデザイナで生成されたコード

///デザイナサポートに必要なメソッドです。

このメソッドの内容を

///コードエディタで変更しないでください。

privatevoidInitializeComponent()

this.pbPhoto=newSystem.Windows.Forms.PictureBox();

this.chkSel=newSystem.Windows.Forms.CheckBox();

((System.ComponentModel.ISupportInitialize)(this.pbPhoto)).BeginInit();

this.SuspendLayout();

//

//pbPhoto

this.pbPhoto.Anchor=((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top|System.Windows.Forms.AnchorStyles.Bottom)

|System.Windows.Forms.AnchorStyles.Left)

|System.Windows.Forms.AnchorStyles.Right)));

this.pbPhoto.Location=newSystem.Drawing.Point(0,0);

this.pbPhoto.Name="

pbPhoto"

;

this.pbPhoto.Size=newSystem.Drawing.Size(200,160);

this.pbPhoto.TabIndex=0;

this.pbPhoto.TabStop=false;

this.pbPhoto.MouseDoubleClick+=newSystem.Windows.Forms.MouseEventHandler(this.pbPhoto_MouseDoubleClick);

this.pbPhoto.MouseClick+=newSystem.Windows.Forms.MouseEventHandler(this.pbPhoto_MouseClick);

//chkSel

this.chkSel.AutoSize=true;

this.chkSel.Location=newSystem.Drawing.Point(3,165);

this.chkSel.Name="

chkSel"

this.chkSel.Size=newSystem.Drawing.Size(72,16);

this.chkSel.TabIndex=1;

this.chkSel.Text="

FileName"

this.chkSel.UseVisualStyleBackColor=true;

this.chkSel.CheckedChanged+=newSystem.EventHandler(this.chkSel_CheckedChanged);

//CtlPicShow

this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);

this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;

this.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;

this.Controls.Add(this.chkSel);

this.Controls.Add(this.pbPhoto);

this.Font=newSystem.Drawing.Font("

SimSun"

9F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(0)));

this.Name="

CtlPicShow"

this.Size=newSystem.Drawing.Size(200,184);

((System.ComponentModel.ISupportInitialize)(this.pbPhoto)).EndInit();

this.ResumeLayout(false);

this.PerformLayout();

#endregion

privateSystem.Windows.Forms.PictureBoxpbPhoto;

privateSystem.Windows.Forms.CheckBoxchkSel;

【FrmBigPhoto】

publicpartialclassFrmBigPhoto:

Form

主画面同步<

publicDelegateShowTargetPhotoShowTargetPhoto;

privatePhotoManagerdataManager;

privateintphotoIndex;

publicFrmBigPhoto(PhotoManagerdataManager,intphotoIndex)

this.dataManager=dataManager;

this.photoIndex=photoIndex;

ShowImage(false);

///图片显示

synFlg"

主画面图片同步标志<

privatevoidShowImage(boolsynFlg)

bool[]status=this.dataManager.CheckStatus(photoIndex);

this.btnPre.Enabled=status[0];

this.btnNext.Enabled=status[1];

this.lblPage.Text=string.Format("

{0}/{1}"

(photoIndex+1),this.dataManager.PhotoCount);

stringfileName=dataManager.GetFileName(photoIndex);

this.Text=Path.GetFileName(fileName);

if(File.Exists(fileName))

this.pbPhoto.Image=Bitmap.FromFile(fileName);

else

this.lblNoneTip.Visible=true;

this.btnLeft.Enabled=false;

this.btnRight.Enabled=false;

if(synFlg&

this.ShowTargetPhoto!

this.ShowTargetPhoto(photoIndex);

///Esc退出功能

privatevoidFrmBigPhoto_KeyPress(objectsender,KeyPressEventArgse)

if((int)e.KeyChar==(int)Keys.Escape)

this.Close();

///左旋转

privatevoidbtnLeft_Click(objectsender,EventArgse)

if(this.pbPhoto.Image==null)return;

this.pbPhoto.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);

this.pbPhoto.Refresh();

///右旋转

privatevoidbtnRight_Click(objectsender,EventArgse)

this.pbPhoto.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);

///上一张

privatevoidbtnPre_Click(objectsender,EventArgse)

photoIndex--;

ShowImage(true);

///下一张

privatevoidbtnNext_Click(objectsender,EventArgse)

photoIndex++;

【FrmBigPhoto.Designer.cs】

partialclassFrmBigPhoto

///Requireddesignervariable.

///Cleanupanyresourcesbeingused.

trueifmanagedresourcesshouldbedisposed;

otherwise,false.<

if(this.pbPhoto.Image!

this.pbPhoto.Image.Dispose();

this.pbPhoto.Image=null;

#regionWindowsFormDesignergeneratedcode

///RequiredmethodforDesignersupport-donotmodify

///thecontentsofthismethodwiththecodeeditor.

this.btnLeft=newSystem.Windows.Forms.Button();

this.btnRight=newSystem.Windows.Forms.Button();

this.lblNoneTip=newSystem.Windows.Forms.Label();

this.btnPre=newSystem.Windows.Forms.Button();

this.btnNext=newSystem.Windows.Forms.Button();

this.lblPage=newSystem.Windows.Forms.Label();

this.SuspendLayo

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2