Skip to content

Instantly share code, notes, and snippets.

View lindexi's full-sized avatar

lindexi lindexi

View GitHub Profile
@lindexi
lindexi / Bbcode2md.cs
Last active May 25, 2024 10:22
从 BBCode 转换为 Markdown
class Bbcode2md
{
/// <summary>
/// To convert bbcode to markdown
/// </summary>
/// <remarks>[JonDum/BBCode-To-Markdown-Converter](https://github.com/JonDum/BBCode-To-Markdown-Converter )</remarks>
/// <param name="str"></param>
/// <returns></returns>
public static string BbcodetoMd(string str)
@lindexi
lindexi / Parse dte get all projects
Created February 9, 2017 04:18
获取 dte 所有项目
private static int TryParseProject(DTE dte, List<string> project)
{
int noLoadProjectCount = 0;
foreach (var temp in dte.Solution.Projects)
{
try
{
if (temp is Project)
{
@lindexi
lindexi / ExtendedWindowStyles.cs
Created March 1, 2018 07:11
ExtendedWindowStyles code from msdn
/// <summary>
/// 扩展的窗口风格
/// </summary>
/// 代码:[Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
/// code from [Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
[Flags]
public enum ExtendedWindowStyles : long
{
/// <summary>
/// The window accepts drag-drop files
@lindexi
lindexi / CharUnicodeRange.cs
Last active May 14, 2020 08:47
获取字符所在哪个 Unicode 平面
// NuGet install System.Text.Encodings.Web
// <PackageReference Include="System.Text.Encodings.Web" Version="4.7.1" />
// using System.Text.Unicode;
// UnicodeRange: https://github.com/dotnet/runtime/blob/5372ee9dbe48058ca8d3591763e989d3b2e65581/src/libraries/System.Text.Encodings.Web/src/System/Text/Unicode/UnicodeRange.cs
// UnicodeRanges https://github.com/dotnet/runtime/blob/5372ee9dbe48058ca8d3591763e989d3b2e65581/src/libraries/System.Text.Encodings.Web/src/System/Text/Unicode/UnicodeRanges.generated.cs
/// <summary>
/// 获取字符所在哪个 Unicode 平面
/// </summary>
@lindexi
lindexi / Parse solution
Last active January 21, 2019 15:19
获得 .sln 所有项目。 Parse .sln to projects with FullName
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
namespace lindexi.wpf.Solution
{
public class Solution
private static (string output, int exitCode) Control(string str)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = true; //接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true; //由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true; //重定向标准错误输出
p.StartInfo.CreateNoWindow = true; //不显示程序窗口
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;//Encoding.GetEncoding("GBK");//乱码
@lindexi
lindexi / ReferenceVersion.cs
Created June 23, 2018 03:23
转换引用的版本
/// <summary>
/// 引用的版本
/// 用来转换 [2.1.0.293,3.0)、 (1.1.0.3,2.0]、 5.2 的版本
/// </summary>
public class ReferenceVersion
{
/// <summary>
/// 创建引用版本
/// </summary>
/// <param name="version">版本</param>
@lindexi
lindexi / UWPStringToColor.cs
Created May 22, 2018 06:22
uwp string to color
public SolidColorBrush GetSolidColorBrush(string hex)
{
hex = hex.Replace("#", string.Empty);
//#FFDFD991
//#DFD991
//#FD92
//#DAC
bool existAlpha = hex.Length == 8 || hex.Length == 4;
@lindexi
lindexi / MakeValidFileName.cs
Created February 23, 2018 01:10
替换不能做文件名的字符
public static string MakeValidFileName(string text, string replacement = "_")
{
StringBuilder str=new StringBuilder();
var invalidFileNameChars = System.IO.Path.GetInvalidFileNameChars();
foreach (var c in text)
{
if (invalidFileNameChars.Contains(c))
{
str.Append(replacement??"");
}
@lindexi
lindexi / GifImageControl.cs
Last active February 11, 2018 03:00
WPF 使用 WinForm 播放 gif
/// <summary>
/// 使用 WinForm 播放 Gif
/// </summary>
/// <example>
/// xaml:
/// <local:GifImageControl x:Name="Image" Path="lindexi.gif"></local:GifImageControl>
/// cs:
/// var image = new GifImageControl("E:\\lindexi.gif");
/// Grid.Children.Add(image);
/// </example>