添加项目文件。
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
public class AssemblyLoaderUtil
|
||||
{
|
||||
public AssemblyLoaderUtil(string assemblyDir)
|
||||
{
|
||||
AssemblyDirectory = assemblyDir;
|
||||
}
|
||||
|
||||
public string AssemblyDirectory { get; set; }
|
||||
|
||||
public void HookAssemblyResolve()
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载目录下的所有程序集
|
||||
/// </summary>
|
||||
/// <param name="commandFolderPath"></param>
|
||||
/// <returns></returns>
|
||||
public List<Assembly> LoadAllRibbonAssemblies(string commandFolderPath)
|
||||
{
|
||||
var list = new List<Assembly>();
|
||||
foreach (var assemblyFile in Directory.GetFiles(commandFolderPath, "*.dll"))
|
||||
{
|
||||
try
|
||||
{
|
||||
list.Add(Assembly.LoadFrom(assemblyFile));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 调用此方法解决UI程序集丢失
|
||||
///// </summary>
|
||||
///// <param name="action"></param>
|
||||
//public static void ResolveAssembly(Action action)
|
||||
//{
|
||||
// string addInPath = typeof(AssemblyLoaderUtil).Assembly.Location;
|
||||
// string dirAssembly = Path.GetDirectoryName(addInPath);
|
||||
// AssemblyLoaderUtil loaderUtil = new AssemblyLoaderUtil(dirAssembly);
|
||||
// loaderUtil.HookAssemblyResolve();
|
||||
// try
|
||||
// {
|
||||
// action();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.InnerException?.ToString());
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// loaderUtil.UnhookAssemblyResolve();
|
||||
// }
|
||||
//}
|
||||
|
||||
public void UnhookAssemblyResolve()
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
|
||||
}
|
||||
|
||||
private Assembly LoadAddin(string filePath)
|
||||
{
|
||||
Assembly result;
|
||||
try
|
||||
{
|
||||
Monitor.Enter(this);
|
||||
result = Assembly.LoadFile(filePath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(this);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string SearchAssemblyFile(string assemblyName)
|
||||
{
|
||||
string[] array = { ".dll", ".exe" };
|
||||
var str = assemblyName.Substring(0, assemblyName.IndexOf(','));
|
||||
foreach (var str2 in array)
|
||||
{
|
||||
var text = AssemblyDirectory + "\\" + str + str2;
|
||||
if (File.Exists(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Assembly result;
|
||||
_ = new AssemblyName(args.Name);
|
||||
var text = SearchAssemblyFile(args.Name);
|
||||
if (File.Exists(text))
|
||||
{
|
||||
result = LoadAddin(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
var array = args.Name.Split(',');
|
||||
var text2 = array[0];
|
||||
if (array.Length > 1)
|
||||
{
|
||||
var text3 = array[2];
|
||||
if (
|
||||
text2.EndsWith(".resources", StringComparison.CurrentCultureIgnoreCase)
|
||||
&& !text3.EndsWith("neutral", StringComparison.CurrentCultureIgnoreCase)
|
||||
)
|
||||
{
|
||||
text2 = text2.Substring(0, text2.Length - ".resources".Length);
|
||||
}
|
||||
|
||||
text = SearchAssemblyFile(text2);
|
||||
if (File.Exists(text))
|
||||
{
|
||||
return LoadAddin(text);
|
||||
}
|
||||
//text = this.SearchAssemblyFile(text2);
|
||||
}
|
||||
}
|
||||
|
||||
result = LoadAddin(text);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
internal class BrowserConfiguration
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public string CachePath { get; set; }
|
||||
|
||||
public IntPtr MessageHandle { get; set; } = IntPtr.Zero;
|
||||
|
||||
public int ParentProcessId { get; set; } = -1;
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public string Net2JsObjectName { get; set; }
|
||||
|
||||
public string Net2JsUpdateStatePartialFunctionName { get; set; }
|
||||
|
||||
public string Js2NetObjectName { get; set; }
|
||||
|
||||
public string RevitVersion { get; set; }
|
||||
}
|
||||
}
|
||||
55
KGdev.BI3D.Revit.Addin.MainWindow.External.Browser/BrowserForm.Designer.cs
generated
Normal file
55
KGdev.BI3D.Revit.Addin.MainWindow.External.Browser/BrowserForm.Designer.cs
generated
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
internal partial class BrowserForm : global::System.Windows.Forms.Form
|
||||
{
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
{
|
||||
this.components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
global::System.ComponentModel.ComponentResourceManager componentResourceManager = new global::System.ComponentModel.ComponentResourceManager(typeof(global::KGdev.BI3D.Revit.Addin.MainWindow.External.Browser.BrowserForm));
|
||||
this.panelBrowser = new global::System.Windows.Forms.Panel();
|
||||
this.loader = new global::System.Windows.Forms.PictureBox();
|
||||
this.panelBrowser.SuspendLayout();
|
||||
((global::System.ComponentModel.ISupportInitialize)this.loader).BeginInit();
|
||||
base.SuspendLayout();
|
||||
this.panelBrowser.Controls.Add(this.loader);
|
||||
this.panelBrowser.Dock = global::System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelBrowser.Location = new global::System.Drawing.Point(0, 0);
|
||||
this.panelBrowser.Name = "panelBrowser";
|
||||
this.panelBrowser.Size = new global::System.Drawing.Size(800, 450);
|
||||
this.panelBrowser.TabIndex = 0;
|
||||
this.loader.BackColor = global::System.Drawing.Color.White;
|
||||
this.loader.Dock = global::System.Windows.Forms.DockStyle.Fill;
|
||||
this.loader.Image = (global::System.Drawing.Image)componentResourceManager.GetObject("loader.Image");
|
||||
this.loader.Location = new global::System.Drawing.Point(0, 0);
|
||||
this.loader.Name = "loader";
|
||||
this.loader.Size = new global::System.Drawing.Size(800, 450);
|
||||
this.loader.SizeMode = global::System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.loader.TabIndex = 0;
|
||||
this.loader.TabStop = false;
|
||||
base.AutoScaleDimensions = new global::System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = global::System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new global::System.Drawing.Size(800, 450);
|
||||
base.Controls.Add(this.panelBrowser);
|
||||
base.Icon = (global::System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
|
||||
base.Name = "BrowserForm";
|
||||
this.Text = "3DBI";
|
||||
this.panelBrowser.ResumeLayout(false);
|
||||
((global::System.ComponentModel.ISupportInitialize)this.loader).EndInit();
|
||||
base.ResumeLayout(false);
|
||||
}
|
||||
|
||||
private global::System.ComponentModel.IContainer components = null;
|
||||
|
||||
private global::System.Windows.Forms.Panel panelBrowser;
|
||||
|
||||
private global::System.Windows.Forms.PictureBox loader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using KGdev.BI3D.Revit.Addin.MainWindow.External.Browser.Properties;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
internal partial class BrowserForm : Form
|
||||
{
|
||||
public BrowserForm(
|
||||
BrowserConfiguration configuration,
|
||||
BrowserFunctions functions,
|
||||
Queue<string> browserToRevitActions,
|
||||
Queue<string> revitToBrowserActions
|
||||
)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.functions = functions;
|
||||
this.browserToRevitActions = browserToRevitActions;
|
||||
this.revitToBrowserActions = revitToBrowserActions;
|
||||
//AssemblyLoaderUtil loaderUtil = new AssemblyLoaderUtil(
|
||||
// Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||
// );
|
||||
//loaderUtil.HookAssemblyResolve();
|
||||
//try
|
||||
//{
|
||||
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// MessageBox.Show(ex.Message);
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// loaderUtil.UnhookAssemblyResolve();
|
||||
//}
|
||||
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
//Assembly.LoadFrom(dir + "//CefSharp.Core.dll");
|
||||
//Assembly.LoadFile(
|
||||
// @"D:\Users\Zhanggg\Desktop\KGdev.BI3D.Revit\KGdev.BI3D.Revit.Addin.MainWindow.External.Browser\bin\Debug\net472\CefSharp.dll"
|
||||
//);
|
||||
//Assembly.LoadFile(
|
||||
// @"D:\Users\Zhanggg\Desktop\KGdev.BI3D.Revit\KGdev.BI3D.Revit.Addin.MainWindow.External.Browser\bin\Debug\net472\CefSharp.Core.dll"
|
||||
//);
|
||||
//Assembly.LoadFile(
|
||||
// @"D:\Users\Zhanggg\Desktop\KGdev.BI3D.Revit\KGdev.BI3D.Revit.Addin.MainWindow.External.Browser\bin\Debug\net472\CefSharp.WinForms.dll"
|
||||
//);
|
||||
base.Load += (object sender, EventArgs args) =>
|
||||
{
|
||||
this.CreateBrowser();
|
||||
|
||||
Size windowSize = Settings.Default.WindowSize;
|
||||
bool flag2 = true;
|
||||
if (flag2)
|
||||
{
|
||||
base.Size = Settings.Default.WindowSize;
|
||||
}
|
||||
base.FormClosing += this.Form_Browser_FormClosing;
|
||||
base.FormClosed += this.Form_Browser_FormClosed;
|
||||
};
|
||||
this.InitializeComponent();
|
||||
this.Text = configuration.Title;
|
||||
bool flag = configuration.ParentProcessId > 0;
|
||||
if (flag)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process processById = Process.GetProcessById(configuration.ParentProcessId);
|
||||
IntPtr mainWindowHandle = processById.MainWindowHandle;
|
||||
BrowserForm.NativeMethod.SetWindowLongPtr64(base.Handle, -8, mainWindowHandle);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
this.SendMessage("handle:" + base.Handle.ToString());
|
||||
this.actionTimer.Tick += this.Action_timer_Tick;
|
||||
this.actionTimer.Start();
|
||||
}
|
||||
|
||||
private void Action_timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
bool flag = this.browserToRevitActions.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
string text = this.browserToRevitActions.Dequeue();
|
||||
this.SendMessage(text);
|
||||
}
|
||||
bool flag2 = this.revitToBrowserActions.Count > 0;
|
||||
if (flag2)
|
||||
{
|
||||
string text2 = this.revitToBrowserActions.Dequeue();
|
||||
this.browser.ExecuteScriptAsync(
|
||||
string.Concat(
|
||||
new string[]
|
||||
{
|
||||
this.configuration.Net2JsObjectName,
|
||||
".",
|
||||
this.configuration.Net2JsUpdateStatePartialFunctionName,
|
||||
"(",
|
||||
text2,
|
||||
")"
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
bool flag3 = this.configuration.ParentProcessId > 0;
|
||||
if (flag3)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process processById = Process.GetProcessById(
|
||||
this.configuration.ParentProcessId
|
||||
);
|
||||
}
|
||||
catch
|
||||
{
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMessage(string message)
|
||||
{
|
||||
BrowserForm.MyStruct myStruct;
|
||||
myStruct.Message = message;
|
||||
int num = Marshal.SizeOf<BrowserForm.MyStruct>(myStruct);
|
||||
IntPtr intPtr = Marshal.AllocHGlobal(num);
|
||||
try
|
||||
{
|
||||
Marshal.StructureToPtr<BrowserForm.MyStruct>(myStruct, intPtr, true);
|
||||
BrowserForm.COPYDATASTRUCT copydatastruct = new BrowserForm.COPYDATASTRUCT
|
||||
{
|
||||
cbData = num,
|
||||
lpData = intPtr
|
||||
};
|
||||
BrowserForm
|
||||
.NativeMethod
|
||||
.SendMessage(
|
||||
this.configuration.MessageHandle,
|
||||
74,
|
||||
base.Handle,
|
||||
ref copydatastruct
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(intPtr);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
bool flag = m.Msg == 74;
|
||||
if (flag)
|
||||
{
|
||||
BrowserForm.COPYDATASTRUCT copydatastruct = (BrowserForm.COPYDATASTRUCT)
|
||||
m.GetLParam(typeof(BrowserForm.COPYDATASTRUCT));
|
||||
bool flag2 = copydatastruct.cbData == Marshal.SizeOf(typeof(BrowserForm.MyStruct));
|
||||
if (flag2)
|
||||
{
|
||||
BrowserForm.MyStruct myStruct = (BrowserForm.MyStruct)
|
||||
Marshal.PtrToStructure(copydatastruct.lpData, typeof(BrowserForm.MyStruct));
|
||||
this.revitToBrowserActions.Enqueue(myStruct.Message);
|
||||
base.Visible = true;
|
||||
base.Activate();
|
||||
}
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
private bool CreateBrowser()
|
||||
{
|
||||
CefSettings cefSettings = new CefSettings();
|
||||
cefSettings.PackLoadingDisabled = false;
|
||||
cefSettings.LogSeverity = LogSeverity.Disable;
|
||||
cefSettings.BrowserSubprocessPath =
|
||||
this.assemblyDirectory + "\\CefSharp.BrowserSubprocess.exe";
|
||||
cefSettings.CachePath = this.configuration.CachePath;
|
||||
cefSettings.IgnoreCertificateErrors = false;
|
||||
cefSettings.PersistSessionCookies = true;
|
||||
//Cef.EnableHighDPISupport();
|
||||
//CefSharpSettings.LegacyJavascriptBindingEnabled = true;
|
||||
CefSharpSettings.WcfTimeout = TimeSpan.Zero;
|
||||
bool flag = !Cef.IsInitialized;
|
||||
if (flag)
|
||||
{
|
||||
bool flag2 = !Cef.Initialize(cefSettings);
|
||||
if (flag2)
|
||||
{
|
||||
MessageBox.Show("Failed to initialize the document browser component");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
string text = (
|
||||
this.configuration.Url.StartsWith("http")
|
||||
? this.configuration.Url
|
||||
: Path.Combine(this.assemblyDirectory, this.configuration.Url)
|
||||
);
|
||||
this.browser = new ChromiumWebBrowser(text, null);
|
||||
//this.browser.BrowserSettings.FileAccessFromFileUrls = CefState.Enabled;
|
||||
//this.browser.BrowserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
|
||||
this.browser
|
||||
.JavascriptObjectRepository
|
||||
.Register(this.configuration.Js2NetObjectName, this.functions, true, null);
|
||||
this.browser.BrowserSettings.Javascript = CefState.Enabled;
|
||||
this.browser.BrowserSettings.JavascriptCloseWindows = CefState.Enabled;
|
||||
this.browser.BrowserSettings.WebGl = CefState.Enabled;
|
||||
//this.browser.BrowserSettings.ApplicationCache = CefState.Disabled;
|
||||
this.browser.BrowserSettings.LocalStorage = CefState.Disabled;
|
||||
this.browser.BrowserSettings.Databases = CefState.Disabled;
|
||||
this.browser.LifeSpanHandler = new LifeSpanHandler();
|
||||
this.browser.MenuHandler = new ContextMenuHandler();
|
||||
this.browser.LoadingStateChanged += delegate(
|
||||
object sender,
|
||||
LoadingStateChangedEventArgs args
|
||||
)
|
||||
{
|
||||
bool flag3 = !args.IsLoading;
|
||||
if (flag3)
|
||||
{
|
||||
base.Invoke(
|
||||
new MethodInvoker(
|
||||
delegate
|
||||
{
|
||||
this.loader.Visible = false;
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
this.panelBrowser.Controls.Add(this.browser);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Form_Browser_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
bool flag = base.WindowState == FormWindowState.Normal;
|
||||
if (flag)
|
||||
{
|
||||
Settings.Default.WindowSize = base.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Default.WindowSize = base.RestoreBounds.Size;
|
||||
}
|
||||
Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void Form_Browser_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
bool isInitialized = Cef.IsInitialized;
|
||||
if (isInitialized)
|
||||
{
|
||||
Cef.Shutdown();
|
||||
}
|
||||
this.SendMessage("close:");
|
||||
}
|
||||
|
||||
private const int WM_COPYDATA = 74;
|
||||
|
||||
private const int WM_CLOSE = 16;
|
||||
|
||||
private const int MESSAGE_MAX_SIZE = 16777216;
|
||||
|
||||
private string assemblyDirectory = Path.GetDirectoryName(
|
||||
new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath
|
||||
);
|
||||
|
||||
private Queue<string> browserToRevitActions;
|
||||
|
||||
private Queue<string> revitToBrowserActions;
|
||||
|
||||
private ChromiumWebBrowser browser = null;
|
||||
|
||||
private Timer actionTimer = new Timer { Interval = 300 };
|
||||
|
||||
private readonly BrowserConfiguration configuration;
|
||||
|
||||
private readonly BrowserFunctions functions;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct MyStruct
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16777216)]
|
||||
public string Message;
|
||||
}
|
||||
|
||||
internal struct COPYDATASTRUCT
|
||||
{
|
||||
public IntPtr dwData;
|
||||
|
||||
public int cbData;
|
||||
|
||||
public IntPtr lpData;
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal class NativeMethod
|
||||
{
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr SendMessage(
|
||||
IntPtr hWnd,
|
||||
int Msg,
|
||||
IntPtr wParam,
|
||||
ref BrowserForm.COPYDATASTRUCT lParam
|
||||
);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
|
||||
public static extern IntPtr SetWindowLongPtr64(
|
||||
IntPtr hWnd,
|
||||
int nIndex,
|
||||
IntPtr dwNewLong
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
internal class BrowserFunctions
|
||||
{
|
||||
public BrowserFunctions(Queue<string> callQueue)
|
||||
{
|
||||
this.callQueue = callQueue;
|
||||
}
|
||||
|
||||
public void Execute(ExpandoObject obj)
|
||||
{
|
||||
string text = JsonConvert.SerializeObject(obj);
|
||||
this.callQueue.Enqueue("execute:" + text);
|
||||
}
|
||||
|
||||
private Queue<string> callQueue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using CefSharp;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
public class ContextMenuHandler : IContextMenuHandler
|
||||
{
|
||||
public void OnBeforeContextMenu(
|
||||
IWebBrowser browserControl,
|
||||
IBrowser browser,
|
||||
IFrame frame,
|
||||
IContextMenuParams parameters,
|
||||
IMenuModel model
|
||||
)
|
||||
{
|
||||
model.Clear();
|
||||
}
|
||||
|
||||
public bool OnContextMenuCommand(
|
||||
IWebBrowser browserControl,
|
||||
IBrowser browser,
|
||||
IFrame frame,
|
||||
IContextMenuParams parameters,
|
||||
CefMenuCommand commandId,
|
||||
CefEventFlags eventFlags
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnContextMenuDismissed(
|
||||
IWebBrowser browserControl,
|
||||
IBrowser browser,
|
||||
IFrame frame
|
||||
) { }
|
||||
|
||||
public bool RunContextMenu(
|
||||
IWebBrowser browserControl,
|
||||
IBrowser browser,
|
||||
IFrame frame,
|
||||
IContextMenuParams parameters,
|
||||
IMenuModel model,
|
||||
IRunContextMenuCallback callback
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{6EF0F4D1-EDD2-498A-A9C7-13DAAF6C5361}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>KGdev.BI3D.Revit.Addin.MainWindow.External.Browser</RootNamespace>
|
||||
<AssemblyName>KGdev.BI3D.Revit.Addin.MainWindow.External.Browser</AssemblyName>
|
||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<EnableDefaultItems>False</EnableDefaultItems>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<StartupObject>KGdev.BI3D.Revit.Addin.MainWindow.External.Browser.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyLoaderUtil.cs" />
|
||||
<Compile Include="BrowserConfiguration.cs" />
|
||||
<Compile Include="BrowserForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BrowserForm.Designer.cs">
|
||||
<DependentUpon>BrowserForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BrowserFunctions.cs" />
|
||||
<Compile Include="ContextMenuHandler.cs" />
|
||||
<Compile Include="LifeSpanHandler.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:\ProgramData\Autodesk\Revit\Addins\2020\3DBI for Revit\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CefSharp.WinForms" Version="120.1.110" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="resources\logo.png" />
|
||||
<Resource Include="resources\logo512.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using CefSharp;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
public class LifeSpanHandler : ILifeSpanHandler
|
||||
{
|
||||
public bool OnBeforePopup(
|
||||
IWebBrowser browserControl,
|
||||
IBrowser browser,
|
||||
IFrame frame,
|
||||
string targetUrl,
|
||||
string targetFrameName,
|
||||
WindowOpenDisposition targetDisposition,
|
||||
bool userGesture,
|
||||
IPopupFeatures popupFeatures,
|
||||
IWindowInfo windowInfo,
|
||||
IBrowserSettings browserSettings,
|
||||
ref bool noJavascriptAccess,
|
||||
out IWebBrowser newBrowser
|
||||
)
|
||||
{
|
||||
Process.Start(targetUrl);
|
||||
newBrowser = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser) { }
|
||||
|
||||
public bool DoClose(IWebBrowser browserControl, IBrowser browser)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
IntPtr zero = IntPtr.Zero;
|
||||
bool flag = args.Length >= 1;
|
||||
if (flag)
|
||||
{
|
||||
zero = new IntPtr(int.Parse(args[0]));
|
||||
}
|
||||
int num = -1;
|
||||
bool flag2 = args.Length >= 2;
|
||||
if (flag2)
|
||||
{
|
||||
num = int.Parse(args[1]);
|
||||
}
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Queue<string> queue = new Queue<string>();
|
||||
Queue<string> queue2 = new Queue<string>();
|
||||
string text = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
".3dbi-for-revit",
|
||||
"cache"
|
||||
);
|
||||
Directory.CreateDirectory(text);
|
||||
BrowserConfiguration browserConfiguration = new BrowserConfiguration
|
||||
{
|
||||
Title = "3DBI",
|
||||
CachePath = text,
|
||||
MessageHandle = zero,
|
||||
Url = Path.Combine(
|
||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
"root",
|
||||
"index.html"
|
||||
),
|
||||
Js2NetObjectName = "revit",
|
||||
Net2JsObjectName = "fromRevit",
|
||||
ParentProcessId = num,
|
||||
Net2JsUpdateStatePartialFunctionName = "updatePartialState"
|
||||
};
|
||||
Application.Run(
|
||||
new BrowserForm(browserConfiguration, new BrowserFunctions(queue), queue, queue2)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
[assembly: AssemblyVersion("1.3.0.0")]
|
||||
[assembly: AssemblyCompany("KGdev.BI3D.Revit.Addin.MainWindow.External.Browser")]
|
||||
[assembly: AssemblyConfiguration("Release 2020")]
|
||||
[assembly: AssemblyFileVersion("1.3.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.3.0")]
|
||||
[assembly: AssemblyProduct("KGdev.BI3D.Revit.Addin.MainWindow.External.Browser")]
|
||||
[assembly: AssemblyTitle("KGdev.BI3D.Revit.Addin.MainWindow.External.Browser")]
|
||||
54
KGdev.BI3D.Revit.Addin.MainWindow.External.Browser/Properties/Settings.Designer.cs
generated
Normal file
54
KGdev.BI3D.Revit.Addin.MainWindow.External.Browser/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Addin.MainWindow.External.Browser.Properties
|
||||
{
|
||||
[CompilerGenerated]
|
||||
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
|
||||
internal sealed partial class Settings : ApplicationSettingsBase
|
||||
{
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[UserScopedSetting]
|
||||
[DebuggerNonUserCode]
|
||||
[DefaultSettingValue("0, 0")]
|
||||
public Point WindowLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Point)this["WindowLocation"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["WindowLocation"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[UserScopedSetting]
|
||||
[DebuggerNonUserCode]
|
||||
[DefaultSettingValue("1500, 800")]
|
||||
public Size WindowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Size)this["WindowSize"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["WindowSize"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static Settings defaultInstance = (Settings)SettingsBase.Synchronized(new Settings());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile CurrentProfile="(Default)" GeneratedClassNamespace="KGdev.BI3D.Revit.Addin.MainWindow.External.Browser.Properties" GeneratedClassName="Settings" xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="WindowLocation" Type="System.Drawing.Point" Scope="User">
|
||||
<Value Profile="(Default)">0, 0</Value>
|
||||
</Setting>
|
||||
<Setting Name="WindowSize" Type="System.Drawing.Size" Scope="User">
|
||||
<Value Profile="(Default)">1500, 800</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Reference in New Issue
Block a user