Skip to content

add next/pre button to switch picture - #4

Open
creazyboyone wants to merge 2 commits into
kfstorm:masterfrom
creazyboyone:master
Open

add next/pre button to switch picture#4
creazyboyone wants to merge 2 commits into
kfstorm:masterfrom
creazyboyone:master

Conversation

@creazyboyone

Copy link
Copy Markdown

add two buttons which can switch next picture or the previous

@kfstorm

kfstorm commented Jun 28, 2021

Copy link
Copy Markdown
Owner

@creazyboyone Thanks for creating this PR. Much appreciated.

I noticed that there is some duplicated code in it. Could you simplify it first?

@creazyboyone

Copy link
Copy Markdown
Author

ok I've solved it now

@kfstorm kfstorm left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review. Do you mind post a picture of the updated app? A video or GIF showing the interactivity would be better. I don't have a Windows dev machine right now. So it's not easy for me to build this PR and check for behavior changes.

}
else
{
_task = DoWork(_cts.Token);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When refreshTime is 0, I think we should cancel the current work before starting a new work.

}

public void Run()
public async void Run(int refrashTime)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
public async void Run(int refrashTime)
public async void Run(int refreshTime)

public async void Run(int refrashTime)
{
if (_task != null)
if (refrashTime > 0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to use refreshTime == 0 to represent a force reload. The Run method here is to start a background thread which periodically check for updates and reload the wallpaper. For one time reload, we should cancel the current task and call DoWork directly in ReflashPicture method.

prePic.Name = "PrePic";
prePic.Size = new System.Drawing.Size(75, 32);
prePic.TabIndex = 7;
prePic.Text = "上一个";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prePic.Text = "上一个";
prePic.Text = "上一张";

nextPic.Name = "NextPic";
nextPic.Size = new System.Drawing.Size(75, 32);
nextPic.TabIndex = 8;
nextPic.Text = "下一个";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nextPic.Text = "下一个";
nextPic.Text = "下一张";

Comment thread BingWallpaper/MainForm.cs

private void preButton_Click(object sender, EventArgs e)
{
if(Constants.PictureIndex > 0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should disable the button if Constants.PictureIndex is already zero.

Comment thread BingWallpaper/MainForm.cs
{
if(Constants.PictureIndex > 0)
{
Program.ReflashPicture(--Constants.PictureIndex);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PictureIndex shouldn't be in Constants anymore because it's not a constant now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants