Skip to content

Commit

Permalink
把源码解压放在目录
Browse files Browse the repository at this point in the history
  • Loading branch information
1234567Yang committed Mar 27, 2024
1 parent 5769ae1 commit c932bc1
Show file tree
Hide file tree
Showing 32 changed files with 895 additions and 0 deletions.
Binary file removed notes/html/NotesManage.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions notes/html/NotesManage/NotesManage.sln
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
6 changes: 6 additions & 0 deletions notes/html/NotesManage/NotesManage/App.config
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>
165 changes: 165 additions & 0 deletions notes/html/NotesManage/NotesManage/Form1.Designer.cs

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

132 changes: 132 additions & 0 deletions notes/html/NotesManage/NotesManage/Form1.cs
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 = "";

}
}
}
Loading

0 comments on commit c932bc1

Please sign in to comment.