1 Star 0 Fork 122

熊松泉/DevelopAssistant

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
DocoFormatControl.cs 3.32 KB
Copy Edit Raw Blame History
wxd_tony1984 authored 2018-02-08 22:32 +08:00 . 给代码编辑器添加缩进功能
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Kyozy.Wke;
namespace ICSharpCode.WinFormsUI.Controls
{
public partial class DocoFormatControl : TextBoxBase
{
private IntPtr ControlHandle = IntPtr.Zero;
private Color borderColor = SystemColors.ControlDark;
Kyozy.Wke.WebView webView = new Kyozy.Wke.WebView();
public DocoFormatControl()
{
InitializeComponent();
InitializeControl();
}
public override string Text
{
get
{
GetContent();
return text;
}
set
{
text = value;
}
}
public void InitializeControl()
{
Kyozy.Wke.WebView.Init();
//this.webBrowser1.Url = new System.Uri(Application.StartupPath + "\\kindeditor\\index.html", System.UriKind.Absolute);
//this.webBrowser1.ObjectForScripting = this;
webView.Bind(this.WebBrowserView, false);
webView.OnDocumentReady += new EventHandler<DocumentReadyEventArgs>(OnDocumentReady);
webView.OnLoadingFinish += new EventHandler<LoadingFinishEventArgs>(OnLoadingFinish);
WebViewLoadFile("\\kindeditor\\index.html");
//JS.BindFunction("GetContent", new wkeJSNativeFunction(GetContent), 0);
}
public void GetContent()
{
var intptr = webView.WebViewHandle;
if (intptr == IntPtr.Zero)
return;
this.text = JS.ToStr(IntPtr.Zero, webView.RunJS("getContent();"));
}
public void OnDocumentReady(object sender, DocumentReadyEventArgs args)
{
//
}
public void OnLoadingFinish(object sender, LoadingFinishEventArgs args)
{
if (!string.IsNullOrEmpty(text))
{
var value = text.Replace('\n', ' ');
webView.RunJS("setContent('" + value + "');");
}
}
public void WebViewLoadFile(string Path)
{
string address = Application.StartupPath + Path;
webView.LoadFile(address);
}
protected override void OnCreateControl()
{
base.OnCreateControl();
if (webView.WebViewHandle == IntPtr.Zero)
{
webView.Bind(this.WebBrowserView, false);
WebViewLoadFile("\\kindeditor\\index.html");
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
borderColor, 1, ButtonBorderStyle.Solid, //左边
borderColor, 1, ButtonBorderStyle.Solid, //上边
borderColor, 1, ButtonBorderStyle.Solid, //右边
borderColor, 1, ButtonBorderStyle.Solid);//底边
}
public override void ReleaseDispose()
{
webView.UnBind();
base.ReleaseDispose();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/yisansky/DevelopAssistant.git
git@gitee.com:yisansky/DevelopAssistant.git
yisansky
DevelopAssistant
DevelopAssistant
master

Search