Added able to make editor readonly

This commit is contained in:
Alexander 2020-01-13 12:40:14 +02:00
parent 392f5d8a3b
commit e7583a09a5
No known key found for this signature in database
GPG key ID: 1F83313BFEB322E9
9 changed files with 64 additions and 3 deletions

View file

@ -171,6 +171,9 @@
<setting name="passwordGeneratorAdditional" serializeAs="String">
<value>False</value>
</setting>
<setting name="statusPanelReadonly" serializeAs="String">
<value>True</value>
</setting>
</Crypto_Notepad.Properties.Settings>
</userSettings>
</configuration>

View file

@ -199,6 +199,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\document--pencil.png" />
<None Include="Resources\Updater.exe" />
<Content Include="Notepad_Lock.ico" />
</ItemGroup>

View file

@ -56,6 +56,7 @@ public void InitializeComponent()
this.mainMenuSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.selectAllMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.wordWrapMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.readOnlyMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenuSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.clearMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
@ -280,6 +281,7 @@ public void InitializeComponent()
this.mainMenuSeparator6,
this.selectAllMainMenu,
this.wordWrapMainMenu,
this.readOnlyMainMenu,
this.mainMenuSeparator7,
this.clearMainMenu});
this.editMainMenu.ForeColor = System.Drawing.SystemColors.ControlText;
@ -381,6 +383,15 @@ public void InitializeComponent()
this.wordWrapMainMenu.Text = "Word Wrap";
this.wordWrapMainMenu.Click += new System.EventHandler(this.WordWrapMainMenu_Click);
//
// readOnlyMainMenu
//
this.readOnlyMainMenu.CheckOnClick = true;
this.readOnlyMainMenu.Name = "readOnlyMainMenu";
this.readOnlyMainMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.R)));
this.readOnlyMainMenu.Size = new System.Drawing.Size(180, 22);
this.readOnlyMainMenu.Text = "Readonly";
this.readOnlyMainMenu.Click += new System.EventHandler(this.ReadOnlyMainMenu_Click);
//
// mainMenuSeparator7
//
this.mainMenuSeparator7.Name = "mainMenuSeparator7";
@ -1357,5 +1368,6 @@ public void InitializeComponent()
protected internal System.Windows.Forms.PictureBox newToolbarButton;
protected internal System.Windows.Forms.ToolStripMenuItem newMainMenu;
protected internal System.Windows.Forms.ToolStripMenuItem fileMainMenu;
private System.Windows.Forms.ToolStripMenuItem readOnlyMainMenu;
}
}

View file

@ -416,6 +416,7 @@ protected internal void StatusPanelFileInfo()
StatusPanelTextInfo();
}
}
statusPanelReadonlyLabel.Text = "Readonly: " + readOnlyMainMenu.Checked.ToString();
}
}
@ -560,6 +561,7 @@ private void LoadSettings()
statusPanelLinesLabel.Visible = settings.statusPanelLines;
statusPanelModifiedLabel.Visible = settings.statusPanelModified;
statusPanelSizeLabel.Visible = settings.statusPanelSize;
statusPanelReadonlyLabel.Visible = settings.statusPanelReadonly;
richTextBox.WordWrap = settings.editorWrap;
richTextBox.ForeColor = settings.editroForeColor;
richTextBox.BackColor = settings.editorBackColor;
@ -596,6 +598,7 @@ public void MenuIcons(bool menuIcons)
findMainMenu.Image = Resources.magnifier;
selectAllMainMenu.Image = Resources.selection_input;
wordWrapMainMenu.Image = Resources.wrap_option;
readOnlyMainMenu.Image = Resources.document__pencil;
clearMainMenu.Image = Resources.document;
changePasswordMainMenu.Image = Resources.key;
lockMainMenu.Image = Resources.lock_warning;
@ -836,6 +839,7 @@ private async void MainWindow_Load(object sender, EventArgs e)
Methods.DeleteUpdateFiles();
MenuIcons(settings.menuIcons);
ToolbarIcons(settings.oldToolbarIcons);
statusPanelReadonlyLabel.Text = "Readonly: " + readOnlyMainMenu.Checked.ToString();
if (args.Length == 2) /*drag & drop to executable*/
{
OpenAsotiations();
@ -1350,6 +1354,12 @@ private void SelectAllMainMenu_Click(object sender, EventArgs e)
}
}
private void ReadOnlyMainMenu_Click(object sender, EventArgs e)
{
richTextBox.ReadOnly = readOnlyMainMenu.Checked;
statusPanelReadonlyLabel.Text = "Readonly: " + readOnlyMainMenu.Checked.ToString();
}
private void WordWrapMainMenu_Click(object sender, EventArgs e)
{
if (wordWrapMainMenu.Checked)
@ -1363,12 +1373,16 @@ private void WordWrapMainMenu_Click(object sender, EventArgs e)
settings.menuWrap = wordWrapMainMenu.Checked;
settings.editorWrap = richTextBox.WordWrap;
settings.Save();
statusPanelWordwrapLabel.Text = "Word Wrap: " + wordWrapMainMenu.Checked.ToString();
}
private void ClearMainMenu_Click(object sender, EventArgs e)
{
richTextBox.SelectAll();
richTextBox.SelectedText = " ";
if (!readOnlyMainMenu.Checked)
{
richTextBox.SelectAll();
richTextBox.SelectedText = " ";
}
}
/*Edit*/
@ -1549,7 +1563,10 @@ private void RightToLeftContextMenu_Click(object sender, EventArgs e)
private void ClearContextMenu_Click(object sender, EventArgs e)
{
ClearMainMenu_Click(this, new EventArgs());
if (!readOnlyMainMenu.Checked)
{
ClearMainMenu_Click(this, new EventArgs());
}
}
#endregion
@ -1924,6 +1941,8 @@ private void VariablesMainMenu_Click(object sender, EventArgs e)
Debug.WriteLine("metadataCorrupt: " + PublicVar.metadataCorrupt);
#endif
}
#endregion

View file

@ -57,6 +57,7 @@ private void LoadSettings()
statusPanelModifiedCheckBox.Checked = settings.statusPanelModified;
statusPanelSizeCheckBox.Checked = settings.statusPanelSize;
statusPanelLabelsGroupBox.Visible = settings.statusPanelVisible;
statusPanelReadonlyCheckBox.Checked = settings.statusPanelReadonly;
encryptionHintLabel.Visible = settings.encryptionHint;
}
#endregion
@ -556,6 +557,13 @@ private void StatusPanelSizeCheckBox_Click(object sender, EventArgs e)
}
#endregion
private void StatusPanelReadonlyCheckBox_Click(object sender, EventArgs e)
{
MainForm main = Owner as MainForm;
main.statusPanelReadonlyLabel.Visible = statusPanelReadonlyCheckBox.Checked;
settings.statusPanelReadonly = statusPanelReadonlyCheckBox.Checked;
main.StatusPanelFileInfo();
}
}
}

View file

@ -1053,4 +1053,7 @@
xJcYtFboYiS58tuSgL/TRqSIfPg4hwAAAABJRU5ErkJggg==
</value>
</data>
<data name="document__pencil" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\document--pencil.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -712,5 +712,17 @@ public bool passwordGeneratorAdditional {
this["passwordGeneratorAdditional"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool statusPanelReadonly {
get {
return ((bool)(this["statusPanelReadonly"]));
}
set {
this["statusPanelReadonly"] = value;
}
}
}
}

View file

@ -161,5 +161,8 @@
<Setting Name="passwordGeneratorAdditional" Provider="PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="statusPanelReadonly" Provider="PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B