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 autosave and "display window" checkbox #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions PasteIntoFile/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="PasteIntoFile.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<userSettings>
<PasteIntoFile.Properties.Settings>
<setting name="displayWindow" serializeAs="String">
<value>True</value>
</setting>
</PasteIntoFile.Properties.Settings>
</userSettings>
</configuration>
22 changes: 17 additions & 5 deletions PasteIntoFile/Properties/Settings.Designer.cs

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

14 changes: 8 additions & 6 deletions PasteIntoFile/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PasteIntoFile.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="displayWindow" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
91 changes: 46 additions & 45 deletions PasteIntoFile/frmMain.Designer.cs

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

26 changes: 26 additions & 0 deletions PasteIntoFile/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ private void frmMain_Load(object sender, EventArgs e)
txtFilename.Text = DateTime.Now.ToString(filename);
txtCurrentLocation.Text = CurrentLocation ?? @"C:\";

var displayWindow = (bool)PasteIntoFile.Properties.Settings.Default["displayWindow"];
cbxDisplayWindow.Checked = displayWindow;

if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Paste Into File\command", "", null) == null)
{
if (MessageBox.Show("Seems that you are running this application for the first time,\nDo you want to Register it with your system Context Menu ?", "Paste Into File", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
Expand All @@ -43,12 +46,15 @@ private void frmMain_Load(object sender, EventArgs e)
}
}



if (Clipboard.ContainsText())
{
lblType.Text = "Text File";
comExt.SelectedItem = "txt";
IsText = true;
txtContent.Text = Clipboard.GetText();
autosave();
return;
}

Expand All @@ -57,6 +63,7 @@ private void frmMain_Load(object sender, EventArgs e)
lblType.Text = "Image";
comExt.SelectedItem = "png";
imgContent.Image = Clipboard.GetImage();
autosave();
return;
}

Expand All @@ -65,8 +72,21 @@ private void frmMain_Load(object sender, EventArgs e)


}
private void autosave()
{
if (!cbxDisplayWindow.Checked)
{
save();
}
}


private void btnSave_Click(object sender, EventArgs e)
{
save();
}

private void save()
{
string location = txtCurrentLocation.Text;
location = location.EndsWith("\\") ? location : location + "\\";
Expand Down Expand Up @@ -151,5 +171,11 @@ private void txtFilename_KeyPress(object sender, KeyPressEventArgs e)
btnSave_Click(sender, null);
}
}

private void cbxDisplayWindow_CheckedChanged(object sender, EventArgs e)
{
PasteIntoFile.Properties.Settings.Default["displayWindow"] = cbxDisplayWindow.Checked;
PasteIntoFile.Properties.Settings.Default.Save();
}
}
}