Skip to content

Commit

Permalink
Big update!
Browse files Browse the repository at this point in the history
Fixed bug with directory, fixed updates, text is saving in Unicode, font change globally and more!
  • Loading branch information
veselcraft committed Oct 10, 2018
1 parent 98895a0 commit 425cd0d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 49 deletions.
26 changes: 13 additions & 13 deletions AboutBox.Designer.cs

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

22 changes: 11 additions & 11 deletions AboutBox.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="textBoxDescription.Text" xml:space="preserve">
<value>VeNote - Notepad written on c#
Ribbon panel created with https://github.com/RibbonWinForms/RibbonWinForms

Languages:
English - Veselcraft
Русский - Veselcraft
Україньска - Veselcraft
Беларускi - Даниил Мысливец
</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="logoPictureBox.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down Expand Up @@ -611,4 +600,15 @@ English - Veselcraft
cJWw3xX9u6JfoPW7on9X9Ku1flf074p+tdbviv5d0a/S+r//+/8BPTxUq6Ub7iwAAAAASUVORK5CYII=
</value>
</data>
<data name="textBoxDescription.Text" xml:space="preserve">
<value>VeNote - Notepad written on c#
Ribbon panel created with https://github.com/RibbonWinForms/RibbonWinForms

Languages:
English - Veselcraft
Русский - Veselcraft
Україньска - Veselcraft
Беларускi - Даниил Мысливец
Кристина, если ты это читаешь, то переведи это на Казахский~~~</value>
</data>
</root>
4 changes: 3 additions & 1 deletion Form1.Designer.cs

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

54 changes: 36 additions & 18 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
using System.Threading;
using System.Net;
using System.Diagnostics;
using Newtonsoft.Json;

namespace VeNote
{
public partial class Form1 : RibbonForm
{
INIManager inimanager = new INIManager(Directory.GetCurrentDirectory() + "\\settings.ini");
static string exeasmb = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
INIManager inimanager = new INIManager(exeasmb + "\\settings.ini");
string[] arg;
string SaveDocumentQuestionString;
string UpdateMessageString;
string originaltextstr;
public Form1(string[] args)
{
switch (inimanager.GetPrivateString("main", "language"))
{
case "en-US":
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

break;
case "ru-RU":
Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
Expand All @@ -52,18 +54,24 @@ public Form1(string[] args)
public static string GetUpdate()
{
string version = Application.ProductVersion;
string url = "http://veselcraft.ru/api/CheckUpdates.php?product=" + Application.ProductName;
string url = "http://veselcraft.ru/checkUpdates.php?product=" + Application.ProductName;
string versionActually;

using (var webCheckUpdate = new WebClient())
{
webCheckUpdate.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; VeNote " + Application.ProductVersion + ")");
Stream data = webCheckUpdate.OpenRead(url);
StreamReader reader = new StreamReader(data);
versionActually = reader.ReadToEnd();
}
return versionActually;
}

private void OriginalText() // Костыль, чтобы можно было выйти из программы, если только что открытый текст никак не изменялся
{
originaltextstr = richTextBoxClient.Text;
}

private void Form1_Load(object sender, EventArgs e)
{
switch (inimanager.GetPrivateString("main", "style"))
Expand Down Expand Up @@ -137,11 +145,14 @@ private void Form1_Load(object sender, EventArgs e)
}
if (inimanager.GetPrivateString("main", "CheckUpdates") == "1")
{
if (GetUpdate() != "3.0.3.0")

string updateStr = GetUpdate();
UpdateJson updj = JsonConvert.DeserializeObject<UpdateJson>(updateStr);
if (updj.version != Application.ProductVersion)
{
if (MessageBox.Show(UpdateMessageString + " (" + GetUpdate() + ")", "VeNote", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
if (MessageBox.Show(UpdateMessageString + " (" + updj.version + ")", "VeNote", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Process.Start("http://veselcraft.ru/post.php?id=8");
Process.Start(updj.link);
}
}
}
Expand All @@ -157,7 +168,7 @@ private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
richTextBoxClient.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.UnicodePlainText);
this.Text = openFileDialog1.FileName;
}
}
Expand Down Expand Up @@ -189,9 +200,8 @@ private void ribbonButtonSelectAll_Click(object sender, EventArgs e)

private void ribbonButtonNew_Click(object sender, EventArgs e)
{
if (richTextBoxClient.Text != "")
if (richTextBoxClient.Text != "" || richTextBoxClient.Text == originaltextstr)
{

switch (Thread.CurrentThread.CurrentUICulture.IetfLanguageTag)
{
case "en-US":
Expand All @@ -215,7 +225,7 @@ private void ribbonButtonNew_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.PlainText);
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.UnicodePlainText);
this.Text = "VeNote";
richTextBoxClient.Text = "";
}
Expand All @@ -232,7 +242,7 @@ private void ribbonButtonOpen_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
richTextBoxClient.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.UnicodePlainText);
this.Text = openFileDialog1.FileName + " - VeNote";
}
}
Expand All @@ -242,7 +252,7 @@ private void ribbonButtonSave_Click(object sender, EventArgs e)

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.PlainText);
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.UnicodePlainText);
this.Text = saveFileDialog1.FileName + " - VeNote";
}
}
Expand All @@ -251,7 +261,7 @@ private void ribbonButtonFont_Click(object sender, EventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.SelectionFont = fontDialog1.Font;
richTextBoxClient.Font = fontDialog1.Font;
var cvt = new FontConverter();
string fontSetting = cvt.ConvertToString(fontDialog1.Font);
inimanager.WritePrivateString("main", "font", fontSetting);
Expand All @@ -265,7 +275,7 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
inimanager.WritePrivateString("window", "locationy", Convert.ToString(this.Location.Y));
inimanager.WritePrivateString("window", "sizeh", Convert.ToString(this.Size.Height));
inimanager.WritePrivateString("window", "sizew", Convert.ToString(this.Size.Width));
if (richTextBoxClient.Text != "")
if (richTextBoxClient.Text != "" || richTextBoxClient.Text == originaltextstr)
{
switch (Thread.CurrentThread.CurrentUICulture.IetfLanguageTag)
{
Expand Down Expand Up @@ -293,8 +303,8 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.PlainText);

richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.UnicodePlainText);
Application.Exit();
}
}
else if (SaveDocumentQuestion == DialogResult.Cancel)
Expand Down Expand Up @@ -348,6 +358,7 @@ private void ribbonOrbMenuItemSettings_Click(object sender, EventArgs e)
ribbon1.OrbImage = null;
}
}
this.Activate();
}
}

Expand All @@ -357,7 +368,7 @@ private void ribbonOrbMenuItemExit_Click(object sender, EventArgs e)
inimanager.WritePrivateString("window", "locationy", Convert.ToString(this.Location.Y));
inimanager.WritePrivateString("window", "sizeh", Convert.ToString(this.Size.Height));
inimanager.WritePrivateString("window", "sizew", Convert.ToString(this.Size.Width));
if (richTextBoxClient.Text != "")
if (richTextBoxClient.Text != "" || richTextBoxClient.Text == originaltextstr)
{
switch (Thread.CurrentThread.CurrentUICulture.IetfLanguageTag)
{
Expand All @@ -382,7 +393,7 @@ private void ribbonOrbMenuItemExit_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.PlainText);
richTextBoxClient.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.UnicodePlainText);
Application.Exit();
}
}
Expand Down Expand Up @@ -432,4 +443,11 @@ private void ribbonButtonFind_Click(object sender, EventArgs e)
}
}
}

class UpdateJson
{
public string version { get; set; }
public string link { get; set; }
}
}

Binary file added Newtonsoft.Json.dll
Binary file not shown.
8 changes: 4 additions & 4 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VeNote")]
[assembly: AssemblyDescription("Notepad clone written on C#")]
[assembly: AssemblyDescription("Simple notepad written on C#")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("veselcraft.ru")]
[assembly: AssemblyProduct("VeNote")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.3.0")]
[assembly: AssemblyFileVersion("3.0.3.0")]
[assembly: AssemblyVersion("3.0.3.2")]
[assembly: AssemblyFileVersion("3.0.3.2")]
8 changes: 6 additions & 2 deletions VeNote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D5C1C717-0ADB-41A7-8C07-4278F53687BF}</ProjectGuid>
<OutputType>WinExe</OutputType>
Expand Down Expand Up @@ -31,14 +31,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.Windows.Forms.Ribbon, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Ribbon\src\System.Windows.Forms.Ribbon\bin\Release\System.Windows.Forms.Ribbon.dll</HintPath>
<HintPath>.\System.Windows.Forms.Ribbon.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
Expand Down

0 comments on commit 425cd0d

Please sign in to comment.