-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5769ae1
commit c932bc1
Showing
32 changed files
with
895 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+44 KB
...l/NotesManage/.vs/NotesManage/FileContentIndex/22e5b2e1-7d3d-4bfd-a3c4-f74ca8ff1cdf.vsidx
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.7.34024.191 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotesManage", "NotesManage\NotesManage.csproj", "{9238FBCE-BAA7-4F3F-B568-B13DC4B8928A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9238FBCE-BAA7-4F3F-B568-B13DC4B8928A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9238FBCE-BAA7-4F3F-B568-B13DC4B8928A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9238FBCE-BAA7-4F3F-B568-B13DC4B8928A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9238FBCE-BAA7-4F3F-B568-B13DC4B8928A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4BA57677-63B7-48FB-9C11-9135929C42A9} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> | ||
</startup> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
using ICSharpCode; | ||
using ICSharpCode.TextEditor; | ||
using ICSharpCode.TextEditor.Actions; | ||
using ICSharpCode.TextEditor.Document; | ||
|
||
namespace NotesManage | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void Form1_Load(object sender, EventArgs e) | ||
{ | ||
textEditorControl1.ShowEOLMarkers = false; | ||
textEditorControl1.ShowHRuler = false; | ||
textEditorControl1.ShowInvalidLines = false; | ||
textEditorControl1.ShowMatchingBracket = true; | ||
textEditorControl1.ShowSpaces = false; | ||
textEditorControl1.ShowTabs = false; | ||
textEditorControl1.ShowVRuler = false; | ||
textEditorControl1.AllowCaretBeyondEOL = false; | ||
textEditorControl1.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("HTML"); | ||
textEditorControl1.Encoding = Encoding.UTF8; | ||
textEditorControl1.ActiveTextAreaControl.TextArea.KeyUp += new System.Windows.Forms.KeyEventHandler(textEditorControl1_KeyUp); | ||
} | ||
private void textEditorControl1_KeyUp(object sender, KeyEventArgs e) | ||
{ | ||
if(e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.Alt) | ||
{ | ||
return; | ||
} | ||
//textEditorControl1.ActiveTextAreaControl.SelectionManager.SelectedText; | ||
int pos = textEditorControl1.Document.PositionToOffset(textEditorControl1.ActiveTextAreaControl.Caret.Position); | ||
int lineIndex = textEditorControl1.ActiveTextAreaControl.Caret.Position.Line; | ||
// 获取当前行的 LineSegment | ||
var lineSegment = textEditorControl1.Document.GetLineSegment(lineIndex); | ||
// 使用 Document.GetText 方法获取行的文本 | ||
string lineText = textEditorControl1.Document.GetText(lineSegment.Offset, lineSegment.Length); | ||
int cursorPosInLine = textEditorControl1.ActiveTextAreaControl.Caret.Offset - lineSegment.Offset; | ||
|
||
//Console.WriteLine(pos); | ||
if (cursorPosInLine > 0 && lineText.Substring(cursorPosInLine - 1, 1) == ">") | ||
{ | ||
// 获取当前行的索引 | ||
|
||
if(lineText.Substring(0, cursorPosInLine).IndexOf("<") != -1) | ||
{ | ||
if(!IsInQuote(lineText, cursorPosInLine)) | ||
{ | ||
//Console.WriteLine("!!!"); | ||
int p1 = lineText.Substring(0, cursorPosInLine).LastIndexOf("<"); | ||
string insert = lineText.Substring(p1 + 1, cursorPosInLine - p1 - 2); | ||
//Console.WriteLine(insert); | ||
if(insert.IndexOf("/") == -1) | ||
{ | ||
insert = "</" + insert.Substring(0, (insert.IndexOf(" ") != -1)? insert.IndexOf(" "):insert.Length) + ">"; | ||
textEditorControl1.Document.Insert(textEditorControl1.ActiveTextAreaControl.Caret.Offset, insert); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
private bool IsInQuote(string text, int pos) | ||
{ | ||
string before = text.Substring(0, pos); | ||
return before.Count(c => c == '\"') % 2 != 0; | ||
} | ||
|
||
private void button_add_Click(object sender, EventArgs e) | ||
{ | ||
string pos = "raw\\" + this.textBox_html.Text; | ||
if (!File.Exists(textBox_model.Text) || !File.Exists(pos)) | ||
{ | ||
MessageBox.Show("Position is not correct!"); | ||
return; | ||
} | ||
string model = File.ReadAllText(textBox_model.Text); | ||
string content = File.ReadAllText(pos); | ||
string whole = model; | ||
whole = whole.Replace("【TITLE】", this.textBox_title.Text); | ||
whole = whole.Replace("【KEYWORDS】", this.textBox_keywords.Text); | ||
whole = whole.Replace("【DESCRIPTION】", this.textBox_descrip.Text); | ||
|
||
whole = whole.Replace("【CONTENT】", content); | ||
|
||
this.textEditorControl1.Text = whole; | ||
} | ||
|
||
private void button1_Click(object sender, EventArgs e) | ||
{ | ||
string dir = this.textBox_html.Text.Substring(0, this.textBox_html.Text.IndexOf(".")) + "\\"; | ||
Directory.CreateDirectory(this.textBox_html.Text.Substring(0, this.textBox_html.Text.IndexOf("."))); | ||
File.WriteAllText(dir + "F_" + this.textBox_html.Text,this.textEditorControl1.Text); | ||
File.AppendAllText("index.txt", dir + "F_" + this.textBox_html.Text + "|" + | ||
this.textBox_title.Text + "|" + | ||
DateTime.UtcNow.ToString() + | ||
Environment.NewLine); | ||
|
||
if(Directory.Exists("raw\\" + this.textBox_html.Text.Substring(0, this.textBox_html.Text.IndexOf(".")))) | ||
{ | ||
if(MessageBox.Show("Also copy the image?", "Question: ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) | ||
{ | ||
foreach(var a in Directory.EnumerateFiles("raw\\" + this.textBox_html.Text.Substring(0, this.textBox_html.Text.IndexOf(".")))) | ||
{ | ||
File.WriteAllBytes(dir + Path.GetFileName(a), File.ReadAllBytes(a)); | ||
} | ||
} | ||
} | ||
|
||
this.textBox_html.Text = ""; | ||
this.textBox_title.Text = ""; | ||
this.textBox_descrip.Text = ""; | ||
// this.textBox_keywords.Text = ""; | ||
this.textEditorControl1.Text = ""; | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.