Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add image save function #56

Merged
merged 5 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions EarthLiveSharp/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<add key="api_key" value=""/>
<add key="api_secret" value=""/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
<add key="saveTexture" value="false"/>
<add key="saveDirectory" value="selected Directory"/>
<add key="saveMaxCount" value="10"/>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
Expand Down
9 changes: 9 additions & 0 deletions EarthLiveSharp/Cfg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public static class Cfg
public static string api_key;
public static string api_secret;
public static int source_selection;
public static bool saveTexture;
public static string saveDirectory;
public static int saveMaxCount;

public static void Load()
{
Expand All @@ -37,6 +40,9 @@ public static void Load()
api_key = app.Settings["api_key"].Value;
api_secret = app.Settings["api_secret"].Value;
source_selection = Convert.ToInt16(app.Settings["source_selection"].Value);
saveTexture = Convert.ToBoolean(app.Settings["saveTexture"].Value);
saveDirectory = Convert.ToString(app.Settings["saveDirectory"].Value);
saveMaxCount = Convert.ToInt32(app.Settings["saveMaxCount"].Value);
return;
}
catch (Exception e)
Expand All @@ -61,6 +67,9 @@ public static void Save()
app.Settings["api_secret"].Value = api_secret;
app.Settings["source_selection"].Value = source_selection.ToString();
app.Settings["zoom"].Value = zoom.ToString();
app.Settings["saveTexture"].Value = saveTexture.ToString();
app.Settings["saveDirectory"].Value = saveDirectory;
app.Settings["saveMaxCount"].Value = saveMaxCount.ToString();
config.Save();
return;
}
Expand Down
13 changes: 13 additions & 0 deletions EarthLiveSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static class Program
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();

/// <summary>
/// 应用程序的主入口点。
/// </summary>
Expand Down Expand Up @@ -58,6 +59,7 @@ static void Main(string[] args)

public static class Scrap_wrapper
{
public static int SequenceCount = 0;
private static IScraper scraper;
public static void set_scraper()
{
Expand Down Expand Up @@ -191,7 +193,18 @@ private void JoinImage()
{
Trace.WriteLine("[himawari8 zoom error]");
}

bitmap.Dispose();

if (Cfg.saveTexture && Cfg.saveDirectory != "selected Directory")
{
if (Scrap_wrapper.SequenceCount >= Cfg.saveMaxCount)
{
Scrap_wrapper.SequenceCount = 0;
}
File.Copy(string.Format("{0}\\wallpaper.bmp", Cfg.image_folder), Cfg.saveDirectory +"\\" + "wallpaper_"+ Scrap_wrapper.SequenceCount + ".bmp", true);
Scrap_wrapper.SequenceCount++;
}
}

private void InitFolder()
Expand Down
148 changes: 121 additions & 27 deletions EarthLiveSharp/settingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions EarthLiveSharp/settingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ private void button3_Click(object sender, EventArgs e)
Cfg.interval = (int)(interval.Value);
Cfg.zoom = (int)(image_zoom.Value);
Cfg.autostart = autostart.Checked;
Cfg.saveTexture = Save_Texture.Checked;
Cfg.saveMaxCount = (int)Save_Max_Count.Value;
Cfg.saveDirectory = Directory_Display.Text;

if (radioButton_CDN.Checked)
{
Cfg.source_selection = 1;
Expand Down Expand Up @@ -54,6 +58,11 @@ private void settingsForm_Load(object sender, EventArgs e)
image_zoom.Value = Cfg.zoom;
api_key.Text = Cfg.api_key;
api_secret.Text = Cfg.api_secret;
Save_Texture.Checked = Cfg.saveTexture;
Save_Max_Count.Value = Cfg.saveMaxCount;
Directory_Display.Text = Cfg.saveDirectory;


if (Cfg.source_selection == 1)
{
radioButton_CDN.Checked = true;
Expand Down Expand Up @@ -81,15 +90,19 @@ private void settingsForm_Load(object sender, EventArgs e)
case 16: image_size.SelectedIndex = 4; break;
default: image_size.SelectedIndex = 0; break;
}

}

private void button1_Click(object sender, EventArgs e)
{
Cfg.satellite = satellite.Text;
Cfg.interval = (int)(interval.Value);
Cfg.zoom = (int)(image_zoom.Value);
Cfg.autostart = autostart.Checked;
Cfg.autostart = autostart.Checked;
Cfg.saveTexture = Save_Texture.Checked;
Cfg.saveMaxCount = (int)Save_Max_Count.Value;
Cfg.saveDirectory = Directory_Display.Text;

if (radioButton_CDN.Checked)
{
Cfg.source_selection = 1;
Expand Down Expand Up @@ -117,7 +130,7 @@ private void button1_Click(object sender, EventArgs e)

private void radioButton_Orgin_CheckedChanged(object sender, EventArgs e)
{
if(radioButton_CDN.Checked)
if (radioButton_CDN.Checked)
{
panel2.Enabled = true;
}
Expand All @@ -136,5 +149,15 @@ private void satellite_SelectedIndexChanged(object sender, EventArgs e)
default: image_size.Enabled = true; break;
}
}

private void Selected_Directory_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "selected Directory";
if (dialog.ShowDialog() == DialogResult.OK)
{
Directory_Display.Text = dialog.SelectedPath;
}
}
}
}