-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
9 changed files
with
604 additions
and
0 deletions.
There are no files selected for viewing
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,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using WzComparerR2.WzLib; | ||
|
||
namespace WzComparerR2 | ||
{ | ||
public class FindWzEventArgs:EventArgs | ||
{ | ||
public FindWzEventArgs() | ||
{ | ||
} | ||
|
||
public FindWzEventArgs(Wz_Type type) | ||
{ | ||
this.wzType = type; | ||
} | ||
|
||
private string fullPath; | ||
private Wz_Type wzType; | ||
private Wz_File wzFile; | ||
private Wz_Node wzNode; | ||
|
||
/// <summary> | ||
/// 获取或设置要查找wz节点的完全名称,用于输入参数。 | ||
/// </summary> | ||
public string FullPath | ||
{ | ||
get { return fullPath; } | ||
set { fullPath = value; } | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置要查找wz节点的Wz_Type,用于输入参数。 | ||
/// </summary> | ||
public Wz_Type WzType | ||
{ | ||
get { return wzType; } | ||
set { wzType = value; } | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置要查找wz节点的所属Wz_File,用于输入和输出参数。 | ||
/// </summary> | ||
public Wz_File WzFile | ||
{ | ||
get { return wzFile; } | ||
set { wzFile = value; } | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置要查找wz节点的Wz_Node,用于输出参数。 | ||
/// </summary> | ||
public Wz_Node WzNode | ||
{ | ||
get { return wzNode; } | ||
set { wzNode = value; } | ||
} | ||
} | ||
} |
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,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace WzComparerR2 | ||
{ | ||
public delegate void FindWzEventHandler(object sender, FindWzEventArgs e); | ||
} |
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,175 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using WzComparerR2.WzLib; | ||
using WzComparerR2.Common; | ||
using DevComponents.DotNetBar; | ||
using WzComparerR2.Controls; | ||
|
||
namespace WzComparerR2.PluginBase | ||
{ | ||
public class PluginContext | ||
{ | ||
internal PluginContext(PluginContextProvider contextProvider) | ||
{ | ||
this.contextProvider = contextProvider; | ||
} | ||
|
||
private PluginContextProvider contextProvider; | ||
|
||
public Form MainForm | ||
{ | ||
get { return this.contextProvider.MainForm; } | ||
} | ||
|
||
public DotNetBarManager DotNetBarManager | ||
{ | ||
get { return this.contextProvider.DotNetBarManager; } | ||
} | ||
|
||
public Wz_Node SelectedNode1 | ||
{ | ||
get { return this.contextProvider.SelectedNode1; } | ||
} | ||
|
||
public Wz_Node SelectedNode2 | ||
{ | ||
get { return this.contextProvider.SelectedNode2; } | ||
} | ||
|
||
public Wz_Node SelectedNode3 | ||
{ | ||
get { return this.contextProvider.SelectedNode3; } | ||
} | ||
|
||
public SuperTabItem SelectedTab | ||
{ | ||
get { return this.SuperTabControl1.SelectedTab; } | ||
} | ||
|
||
public event EventHandler<WzNodeEventArgs> SelectedNode1Changed | ||
{ | ||
add { contextProvider.SelectedNode1Changed += value; } | ||
remove { contextProvider.SelectedNode1Changed -= value; } | ||
} | ||
|
||
public event EventHandler<WzNodeEventArgs> SelectedNode2Changed | ||
{ | ||
add { contextProvider.SelectedNode2Changed += value; } | ||
remove { contextProvider.SelectedNode2Changed -= value; } | ||
} | ||
|
||
public event EventHandler<WzNodeEventArgs> SelectedNode3Changed | ||
{ | ||
add { contextProvider.SelectedNode3Changed += value; } | ||
remove { contextProvider.SelectedNode3Changed -= value; } | ||
} | ||
|
||
public event EventHandler<WzStructureEventArgs> WzOpened | ||
{ | ||
add { contextProvider.WzOpened += value; } | ||
remove { contextProvider.WzOpened-= value; } | ||
} | ||
|
||
public event EventHandler<WzStructureEventArgs> WzClosing | ||
{ | ||
add { contextProvider.WzClosing += value; } | ||
remove { contextProvider.WzClosing -= value; } | ||
} | ||
|
||
public StringLinker DefaultStringLinker | ||
{ | ||
get { return this.contextProvider.DefaultStringLinker; } | ||
} | ||
|
||
public AlphaForm DefaultTooltipWindow | ||
{ | ||
get { return this.contextProvider.DefaultTooltipWindow; } | ||
} | ||
|
||
private SuperTabControl SuperTabControl1 | ||
{ | ||
get | ||
{ | ||
var controls = this.contextProvider.MainForm.Controls.Find("superTabControl1", true); | ||
SuperTabControl tabControl = controls.Length > 0 ? (controls[0] as SuperTabControl) : null; | ||
return tabControl; | ||
} | ||
} | ||
|
||
public void AddRibbonBar(string tabName, RibbonBar ribbonBar) | ||
{ | ||
RibbonControl ribbonCtrl = this.MainForm.Controls["ribbonControl1"] as RibbonControl; | ||
|
||
if (ribbonCtrl == null) | ||
{ | ||
throw new Exception("无法找到RibbonContainer。"); | ||
} | ||
|
||
RibbonPanel ribbonPanel = null; | ||
RibbonTabItem tabItem; | ||
foreach (BaseItem item in ribbonCtrl.Items) | ||
{ | ||
if ((tabItem = item as RibbonTabItem) != null | ||
&& string.Equals(Convert.ToString(tabItem.Tag), tabName, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
ribbonPanel = tabItem.Panel; | ||
break; | ||
} | ||
} | ||
|
||
if (ribbonPanel == null) | ||
{ | ||
throw new Exception("无法找到RibbonPanel。"); | ||
} | ||
|
||
Control lastBar = ribbonPanel.Controls[0]; | ||
ribbonBar.Location = new System.Drawing.Point(lastBar.Location.X + lastBar.Width, lastBar.Location.Y); | ||
ribbonBar.Size = new System.Drawing.Size(Math.Max(1, ribbonBar.Width), lastBar.Height); | ||
ribbonPanel.SuspendLayout(); | ||
ribbonPanel.Controls.Add(ribbonBar); | ||
ribbonPanel.Controls.SetChildIndex(ribbonBar, 0); | ||
ribbonPanel.ResumeLayout(false); | ||
} | ||
|
||
public RibbonBar AddRibbonBar(string tabName, string barText) | ||
{ | ||
RibbonBar bar = new RibbonBar(); | ||
bar.Text = barText; | ||
AddRibbonBar(tabName, bar); | ||
return bar; | ||
} | ||
|
||
public void AddTab(string tabName, SuperTabControlPanel tabPanel) | ||
{ | ||
SuperTabControl tabControl = this.SuperTabControl1; | ||
|
||
if (tabControl == null) | ||
{ | ||
throw new Exception("无法找到SuperTabControl。"); | ||
} | ||
|
||
tabControl.SuspendLayout(); | ||
|
||
SuperTabItem tabItem = new SuperTabItem(); | ||
tabControl.Controls.Add(tabPanel); | ||
|
||
tabControl.Tabs.Add(tabItem); | ||
tabPanel.TabItem = tabItem; | ||
|
||
tabItem.Text = tabName; | ||
tabItem.AttachedControl = tabPanel; | ||
tabControl.ResumeLayout(false); | ||
} | ||
|
||
public SuperTabControlPanel AddTab(string tabName) | ||
{ | ||
SuperTabControlPanel panel = new SuperTabControlPanel(); | ||
|
||
AddTab(tabName, panel); | ||
panel.Controls.Add(new Button()); | ||
return panel; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
MapleStoryDB2/WzComparerR2.PluginBase/PluginContextProvider.cs
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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using DevComponents.DotNetBar; | ||
using WzComparerR2.WzLib; | ||
using WzComparerR2; | ||
using WzComparerR2.Common; | ||
using WzComparerR2.Controls; | ||
|
||
namespace WzComparerR2.PluginBase | ||
{ | ||
internal interface PluginContextProvider | ||
{ | ||
Office2007RibbonForm MainForm { get; } | ||
DotNetBarManager DotNetBarManager { get; } | ||
IList<Wz_Structure> LoadedWz { get; } | ||
Wz_Node SelectedNode1 { get; } | ||
Wz_Node SelectedNode2 { get; } | ||
Wz_Node SelectedNode3 { get; } | ||
StringLinker DefaultStringLinker { get; } | ||
AlphaForm DefaultTooltipWindow { get; } | ||
|
||
event EventHandler<WzNodeEventArgs> SelectedNode1Changed; | ||
event EventHandler<WzNodeEventArgs> SelectedNode2Changed; | ||
event EventHandler<WzNodeEventArgs> SelectedNode3Changed; | ||
event EventHandler<WzStructureEventArgs> WzOpened; | ||
event EventHandler<WzStructureEventArgs> WzClosing; | ||
} | ||
} |
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,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Reflection; | ||
|
||
namespace WzComparerR2.PluginBase | ||
{ | ||
public abstract class PluginEntry | ||
{ | ||
public PluginEntry(PluginContext context) | ||
{ | ||
this.Context = context; | ||
} | ||
|
||
public PluginContext Context | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public virtual string Name | ||
{ | ||
get | ||
{ | ||
var attr = GetAsmAttr<AssemblyTitleAttribute>(); | ||
return attr != null ? attr.Title : null; | ||
} | ||
} | ||
|
||
public virtual string Author | ||
{ | ||
get | ||
{ | ||
var attr = GetAsmAttr<AssemblyCompanyAttribute>(); | ||
return attr != null ? attr.Company : null; | ||
} | ||
} | ||
|
||
public virtual string Version | ||
{ | ||
get | ||
{ | ||
return this.GetType().Assembly.GetName().Version.ToString(); | ||
} | ||
} | ||
|
||
public virtual string FileVersion | ||
{ | ||
get | ||
{ | ||
var attrInfoVersion = GetAsmAttr<AssemblyInformationalVersionAttribute>(); | ||
if (!string.IsNullOrEmpty(attrInfoVersion?.InformationalVersion)) | ||
{ | ||
return attrInfoVersion.InformationalVersion; | ||
} | ||
|
||
var attrFileVersion = GetAsmAttr<AssemblyFileVersionAttribute>(); | ||
return attrFileVersion?.Version; | ||
} | ||
} | ||
|
||
private T GetAsmAttr<T>() | ||
{ | ||
object[] attr = this.GetType().Assembly.GetCustomAttributes(typeof(T), true); | ||
if (attr != null && attr.Length > 0) | ||
{ | ||
return (T)attr[0]; | ||
} | ||
return default(T); | ||
} | ||
|
||
protected internal virtual void OnLoad() | ||
{ | ||
|
||
} | ||
|
||
protected internal virtual void OnUnload() | ||
{ | ||
|
||
} | ||
} | ||
} |
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Reflection; | ||
|
||
namespace WzComparerR2.PluginBase | ||
{ | ||
internal class PluginInfo | ||
{ | ||
public string FileName { get; set; } | ||
public Assembly Assembly { get; set; } | ||
public PluginEntry Instance { get; set; } | ||
} | ||
} |
Oops, something went wrong.