-
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
a8e1dbf
commit 156d3c5
Showing
29 changed files
with
3,736 additions
and
304 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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,117 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace QuickInput | ||
{ | ||
class IniManager | ||
{ | ||
/// <summary> | ||
/// 为INI文件中指定的节点取得字符串 | ||
/// </summary> | ||
/// <param name="lpAppName">欲在其中查找关键字的节点名称</param> | ||
/// <param name="lpKeyName">欲获取的项名</param> | ||
/// <param name="lpDefault">指定的项没有找到时返回的默认值</param> | ||
/// <param name="lpReturnedString">指定一个字串缓冲区,长度至少为nSize</param> | ||
/// <param name="nSize">指定装载到lpReturnedString缓冲区的最大字符数量</param> | ||
/// <param name="lpFileName">INI文件完整路径</param> | ||
/// <returns>复制到lpReturnedString缓冲区的字节数量,其中不包括那些NULL中止字符</returns> | ||
[DllImport("kernel32")] | ||
private static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName); | ||
|
||
/// <summary> | ||
/// 修改INI文件中内容 | ||
/// </summary> | ||
/// <param name="lpApplicationName">欲在其中写入的节点名称</param> | ||
/// <param name="lpKeyName">欲设置的项名</param> | ||
/// <param name="lpString">要写入的新字符串</param> | ||
/// <param name="lpFileName">INI文件完整路径</param> | ||
/// <returns>非零表示成功,零表示失败</returns> | ||
[DllImport("kernel32")] | ||
private static extern int WritePrivateProfileString(string lpApplicationName, string lpKeyName, string lpString, string lpFileName); | ||
|
||
|
||
|
||
/// <summary> | ||
/// 读取INI文件值 | ||
/// </summary> | ||
/// <param name="section">节点名</param> | ||
/// <param name="key">键</param> | ||
/// <param name="def">未取到值时返回的默认值</param> | ||
/// <param name="filePath">INI文件完整路径</param> | ||
/// <returns>读取的值</returns> | ||
public static string Read(string section, string key, string def, string filePath, bool check = false) | ||
{ | ||
if (check) | ||
{ | ||
CheckPath(filePath); | ||
} | ||
|
||
StringBuilder sb = new StringBuilder(1024); | ||
GetPrivateProfileString(section, key, def, sb, 1024, filePath); | ||
return sb.ToString(); | ||
} | ||
|
||
/// <summary> | ||
/// 写INI文件值 | ||
/// </summary> | ||
/// <param name="section">欲在其中写入的节点名称</param> | ||
/// <param name="key">欲设置的项名</param> | ||
/// <param name="value">要写入的新字符串</param> | ||
/// <param name="filePath">INI文件完整路径</param> | ||
/// <returns>非零表示成功,零表示失败</returns> | ||
public static int Write(string section, string key, string value, string filePath) | ||
{ | ||
CheckPath(filePath); | ||
return WritePrivateProfileString(section, key, value, filePath); | ||
} | ||
|
||
private static void CheckPath(string filePath) | ||
{ | ||
if (!System.IO.File.Exists(filePath)) | ||
{ | ||
System.IO.File.Create(filePath).Dispose();//创建INI文件,并释放 | ||
} | ||
WriteHelp(filePath); | ||
} | ||
|
||
public static void WriteHelp(string filePath) | ||
{ | ||
if (Read("words", "65", "", filePath).Equals("")) | ||
{ | ||
WritePrivateProfileString("words", "65", "空格 加 a以输入这行数据,需要关闭中文输入法。65-81对应a-z", filePath); | ||
} | ||
if (Read("words", "66", "", filePath).Equals("")) | ||
{ | ||
WritePrivateProfileString("words", "66", "空格 加 b以输入这行数据,需要关闭中文输入法。{ENTER}表示换行,{+}、{^}、{%}等符号有特殊含义,可以看底部链接说明。", filePath); | ||
} | ||
WritePrivateProfileString("ReadMe", "KeyCode", "You can get value-key relation in this link. https://www.bejson.com/othertools/keycodes/", filePath); | ||
WritePrivateProfileString("ReadMe", "SendKeys", "You can set special words by this way. https://www.cnblogs.com/shaozhuyong/p/5951779.html", filePath); | ||
} | ||
/// <summary> | ||
/// 删除节 | ||
/// </summary> | ||
/// <param name="section">节点名</param> | ||
/// <param name="filePath">INI文件完整路径</param> | ||
/// <returns>非零表示成功,零表示失败</returns> | ||
public static int DeleteSection(string section, string filePath) | ||
{ | ||
return Write(section, null, null, filePath); | ||
} | ||
|
||
/// <summary> | ||
/// 删除键的值 | ||
/// </summary> | ||
/// <param name="section">节点名</param> | ||
/// <param name="key">键名</param> | ||
/// <param name="filePath">INI文件完整路径</param> | ||
/// <returns>非零表示成功,零表示失败</returns> | ||
public static int DeleteKey(string section, string key, string filePath) | ||
{ | ||
return Write(section, key, null, filePath); | ||
} | ||
} | ||
} |
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,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace RevitDevelopment.CustomControls | ||
{ | ||
/// <summary> | ||
/// 带有PlaceHolder的Textbox | ||
/// </summary> | ||
/// <creator>marc</creator> | ||
public class PlaceHolderTextBox : TextBox | ||
{ | ||
private bool _isPlaceHolder = true; | ||
private string _placeHolderText; | ||
/// <summary> | ||
/// 提示文本 | ||
/// </summary> | ||
public string PlaceHolderText | ||
{ | ||
get { return _placeHolderText; } | ||
set | ||
{ | ||
_placeHolderText = value; | ||
SetPlaceholder(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 文本 | ||
/// </summary> | ||
public new string Text | ||
{ | ||
get | ||
{ | ||
return _isPlaceHolder ? string.Empty : base.Text; | ||
} | ||
set | ||
{ | ||
base.Text = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 构造函数 | ||
/// </summary> | ||
public PlaceHolderTextBox() | ||
{ | ||
GotFocus += RemovePlaceHolder; | ||
LostFocus += SetPlaceholder; | ||
} | ||
|
||
/// <summary> | ||
/// 当焦点失去的时候,将清空提示文本 | ||
/// </summary> | ||
private void SetPlaceholder() | ||
{ | ||
if (string.IsNullOrEmpty(base.Text)) | ||
{ | ||
base.Text = PlaceHolderText; | ||
this.ForeColor = Color.Gray; | ||
this.Font = new Font(this.Font, FontStyle.Italic); | ||
_isPlaceHolder = true; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 当焦点获得的时候,将显示提示文本 | ||
/// </summary> | ||
private void RemovePlaceHolder() | ||
{ | ||
if (_isPlaceHolder) | ||
{ | ||
base.Text = ""; | ||
this.ForeColor = SystemColors.WindowText; | ||
this.Font = new Font(this.Font, FontStyle.Regular); | ||
_isPlaceHolder = false; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 失去焦点 | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
private void SetPlaceholder(object sender, EventArgs e) | ||
{ | ||
SetPlaceholder(); | ||
} | ||
|
||
/// <summary> | ||
/// 获得焦点 | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
private void RemovePlaceHolder(object sender, EventArgs e) | ||
{ | ||
RemovePlaceHolder(); | ||
} | ||
} | ||
} |
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
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
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+12.3 KB
(970%)
QuickInput/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.
Binary file modified
BIN
+167 Bytes
(100%)
QuickInput/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
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 |
---|---|---|
@@ -1 +1 @@ | ||
234f27e758b4748269395cef054b9d2e69872430 | ||
d7caa3e0fb5a4a4b686d8652a9c318e287eb41b6 |
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
Binary file modified
BIN
+61 Bytes
(110%)
QuickInput/obj/Debug/QuickInput.csproj.GenerateResource.cache
Binary file not shown.
Binary file not shown.
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