From 1ddfc9fbdf82e74b106f7ead6d7d8d1c11b922e3 Mon Sep 17 00:00:00 2001 From: erik Date: Thu, 29 May 2025 17:56:44 +0200 Subject: [PATCH] 3.0.0.6 --- MosswartMassacre/MainView.cs | 96 -- MosswartMassacre/Properties/AssemblyInfo.cs | 4 +- MosswartMassacre/VirindiViews/Wrapper.cs | 427 ------ .../VirindiViews/Wrapper_Decal.cs | 1120 --------------- .../VirindiViews/Wrapper_MyHuds.cs | 1225 ----------------- .../VirindiViews/Wrapper_WireupHelper.cs | 329 ----- 6 files changed, 2 insertions(+), 3199 deletions(-) delete mode 100644 MosswartMassacre/MainView.cs delete mode 100644 MosswartMassacre/VirindiViews/Wrapper.cs delete mode 100644 MosswartMassacre/VirindiViews/Wrapper_Decal.cs delete mode 100644 MosswartMassacre/VirindiViews/Wrapper_MyHuds.cs delete mode 100644 MosswartMassacre/VirindiViews/Wrapper_WireupHelper.cs diff --git a/MosswartMassacre/MainView.cs b/MosswartMassacre/MainView.cs deleted file mode 100644 index 063e7f7..0000000 --- a/MosswartMassacre/MainView.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using MyClasses.MetaViewWrappers; - -namespace MosswartMassacre -{ - internal static class MainView - { - private static IView View; - private static IStaticText lblTotalKills; - private static IStaticText lblKillsPer5Min; - private static IStaticText lblKillsPerHour; - private static IStaticText lblElapsedTime; - private static IStaticText lblRareCount; - private static IButton btnRestart; - private static IButton btnToggleRareMeta; - - public static void ViewInit() - { - try - { - // Load the view from the embedded XML resource - View = MyClasses.MetaViewWrappers.ViewSystemSelector.CreateViewResource( - PluginCore.MyHost, "MosswartMassacre.ViewXML.mainView.xml"); - - // Get references to controls - lblTotalKills = (IStaticText)View["lblTotalKills"]; - lblKillsPer5Min = (IStaticText)View["lblKillsPer5Min"]; - lblKillsPerHour = (IStaticText)View["lblKillsPerHour"]; - lblElapsedTime = (IStaticText)View["lblElapsedTime"]; - lblRareCount = (IStaticText)View["lblRareCount"]; - btnRestart = (IButton)View["btnRestart"]; - btnRestart.Hit += OnRestartClick; - btnToggleRareMeta = (IButton)View["btnToggleRareMeta"]; - btnToggleRareMeta.Hit += OnToggleRareMetaClick; - btnToggleRareMeta.Text = "Meta: ON"; - - PluginCore.WriteToChat("View initialized."); - } - catch (Exception ex) - { - PluginCore.WriteToChat("Error initializing view: " + ex.Message); - } - } - - public static void ViewDestroy() - { - try - { - View.Dispose(); - PluginCore.WriteToChat("View destroyed."); - btnRestart.Hit -= OnRestartClick; - btnToggleRareMeta.Hit -= OnToggleRareMetaClick; - } - catch (Exception ex) - { - PluginCore.WriteToChat("Error destroying view: " + ex.Message); - } - } - - public static void UpdateKillStats(int totalKills, double killsPer5Min, double killsPerHour) - { - lblTotalKills.Text = $"Total Kills: {totalKills}"; - lblKillsPer5Min.Text = $"Kills per 5 Min: {killsPer5Min:F2}"; - lblKillsPerHour.Text = $"Kills per Hour: {killsPerHour:F2}"; - } - - public static void UpdateElapsedTime(TimeSpan elapsed) - { - int days = elapsed.Days; - int hours = elapsed.Hours; - int minutes = elapsed.Minutes; - int seconds = elapsed.Seconds; - - if (days > 0) - lblElapsedTime.Text = $"Time: {days}d {hours:D2}:{minutes:D2}:{seconds:D2}"; - else - lblElapsedTime.Text = $"Time: {hours:D2}:{minutes:D2}:{seconds:D2}"; - } - public static void UpdateRareCount(int rareCount) - { - lblRareCount.Text = $"Rare Count: {rareCount}"; - } - private static void OnRestartClick(object sender, EventArgs e) - { - PluginCore.RestartStats(); - } - private static void OnToggleRareMetaClick(object sender, EventArgs e) - { - PluginCore.ToggleRareMeta(); - } - public static void SetRareMetaToggleState(bool enabled) - { - btnToggleRareMeta.Text = enabled ? "Meta: ON" : "Meta: OFF"; - } - } -} diff --git a/MosswartMassacre/Properties/AssemblyInfo.cs b/MosswartMassacre/Properties/AssemblyInfo.cs index c9219eb..e084d4c 100644 --- a/MosswartMassacre/Properties/AssemblyInfo.cs +++ b/MosswartMassacre/Properties/AssemblyInfo.cs @@ -26,5 +26,5 @@ using System.Runtime.InteropServices; // Minor Version // Build Number // Revision -[assembly: AssemblyVersion("3.0.0.5")] -[assembly: AssemblyFileVersion("3.0.0.5")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.0.6")] +[assembly: AssemblyFileVersion("3.0.0.6")] \ No newline at end of file diff --git a/MosswartMassacre/VirindiViews/Wrapper.cs b/MosswartMassacre/VirindiViews/Wrapper.cs deleted file mode 100644 index 7cca722..0000000 --- a/MosswartMassacre/VirindiViews/Wrapper.cs +++ /dev/null @@ -1,427 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -//File: Wrapper.cs -// -//Description: Contains the interface definitions for the MetaViewWrappers classes. -// -//References required: -// System.Drawing -// -//This file is Copyright (c) 2010 VirindiPlugins -// -//Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -//The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -/////////////////////////////////////////////////////////////////////////////// - -using System; -using System.Collections.Generic; -using System.Text; - -#if METAVIEW_PUBLIC_NS -namespace MetaViewWrappers -#else -namespace MyClasses.MetaViewWrappers -#endif -{ -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - delegate void dClickedList(object sender, int row, int col); - - - #region EventArgs Classes - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class MVControlEventArgs : EventArgs - { - private int id; - - internal MVControlEventArgs(int ID) - { - this.id = ID; - } - - public int Id - { - get { return this.id; } - } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class MVIndexChangeEventArgs : MVControlEventArgs - { - private int index; - - internal MVIndexChangeEventArgs(int ID, int Index) - : base(ID) - { - this.index = Index; - } - - public int Index - { - get { return this.index; } - } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class MVListSelectEventArgs : MVControlEventArgs - { - private int row; - private int col; - - internal MVListSelectEventArgs(int ID, int Row, int Column) - : base(ID) - { - this.row = Row; - this.col = Column; - } - - public int Row - { - get { return this.row; } - } - - public int Column - { - get { return this.col; } - } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class MVCheckBoxChangeEventArgs : MVControlEventArgs - { - private bool check; - - internal MVCheckBoxChangeEventArgs(int ID, bool Check) - : base(ID) - { - this.check = Check; - } - - public bool Checked - { - get { return this.check; } - } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class MVTextBoxChangeEventArgs : MVControlEventArgs - { - private string text; - - internal MVTextBoxChangeEventArgs(int ID, string text) - : base(ID) - { - this.text = text; - } - - public string Text - { - get { return this.text; } - } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class MVTextBoxEndEventArgs : MVControlEventArgs - { - private bool success; - - internal MVTextBoxEndEventArgs(int ID, bool success) - : base(ID) - { - this.success = success; - } - - public bool Success - { - get { return this.success; } - } - } - - #endregion EventArgs Classes - - - #region View - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IView: IDisposable - { - void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML); - void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML); - void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey); - void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey); - - void SetIcon(int icon, int iconlibrary); - void SetIcon(int portalicon); - - string Title { get; set; } - bool Visible { get; set; } -#if !VVS_WRAPPERS_PUBLIC - ViewSystemSelector.eViewSystem ViewType { get; } -#endif - - System.Drawing.Point Location { get; set; } - System.Drawing.Rectangle Position { get; set; } - System.Drawing.Size Size { get; } - - IControl this[string id] { get; } - - void Activate(); - void Deactivate(); - bool Activated { get; set; } - } - - #endregion View - - #region Controls - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IControl : IDisposable - { - string Name { get; } - bool Visible { get; set; } - string TooltipText { get; set;} - int Id { get; } - System.Drawing.Rectangle LayoutPosition { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IButton : IControl - { - string Text { get; set; } - event EventHandler Hit; - event EventHandler Click; - System.Drawing.Color TextColor { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface ICheckBox : IControl - { - string Text { get; set; } - bool Checked { get; set; } - event EventHandler Change; - event EventHandler Change_Old; - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface ITextBox : IControl - { - string Text { get; set; } - event EventHandler Change; - event EventHandler Change_Old; - event EventHandler End; - int Caret { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface ICombo : IControl - { - IComboIndexer Text { get; } - IComboDataIndexer Data { get; } - int Count { get; } - int Selected { get; set; } - event EventHandler Change; - event EventHandler Change_Old; - void Add(string text); - void Add(string text, object obj); - void Insert(int index, string text); - void RemoveAt(int index); - void Remove(int index); - void Clear(); - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IComboIndexer - { - string this[int index] { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IComboDataIndexer - { - object this[int index] { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface ISlider : IControl - { - int Position { get; set; } - event EventHandler Change; - event EventHandler Change_Old; - int Maximum { get; set; } - int Minimum { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IList : IControl - { - event EventHandler Selected; - event dClickedList Click; - void Clear(); - IListRow this[int row] { get; } - IListRow AddRow(); - IListRow Add(); - IListRow InsertRow(int pos); - IListRow Insert(int pos); - int RowCount { get; } - void RemoveRow(int index); - void Delete(int index); - int ColCount { get; } - int ScrollPosition { get; set;} - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IListRow - { - IListCell this[int col] { get; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IListCell - { - System.Drawing.Color Color { get; set; } - int Width { get; set; } - object this[int subval] { get; set; } - void ResetColor(); - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IStaticText : IControl - { - string Text { get; set; } - event EventHandler Click; - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface INotebook : IControl - { - event EventHandler Change; - int ActiveTab { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IProgressBar : IControl - { - int Position { get; set; } - int Value { get; set; } - string PreText { get; set; } - int MaxValue { get; set; } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - interface IImageButton : IControl - { - event EventHandler Click; - void SetImages(int unpressed, int pressed); - void SetImages(int hmodule, int unpressed, int pressed); - int Background { set; } - System.Drawing.Color Matte { set; } - } - - #endregion Controls -} diff --git a/MosswartMassacre/VirindiViews/Wrapper_Decal.cs b/MosswartMassacre/VirindiViews/Wrapper_Decal.cs deleted file mode 100644 index a917ca8..0000000 --- a/MosswartMassacre/VirindiViews/Wrapper_Decal.cs +++ /dev/null @@ -1,1120 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -//File: Wrapper_Decal.cs -// -//Description: Contains MetaViewWrapper classes implementing Decal views. -// -//References required: -// System.Drawing -// Decal.Adapter -// -//This file is Copyright (c) 2010 VirindiPlugins -// -//Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -//The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -/////////////////////////////////////////////////////////////////////////////// - -using System; -using System.Collections.Generic; -using System.Text; - -#if METAVIEW_PUBLIC_NS -namespace MetaViewWrappers.DecalControls -#else -namespace MyClasses.MetaViewWrappers.DecalControls -#endif - -{ -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class View : IView - { - Decal.Adapter.Wrappers.ViewWrapper myView; - public Decal.Adapter.Wrappers.ViewWrapper Underlying { get { return myView; } } - - #region IView Members - - public void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML) - { - myView = p.LoadViewResource(pXML); - } - - public void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML) - { - myView = p.LoadView(pXML); - } - - public void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey) - { - myView = p.LoadViewResource(pXML); - } - - public void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey) - { - myView = p.LoadView(pXML); - } - - public void SetIcon(int icon, int iconlibrary) - { - myView.SetIcon(icon, iconlibrary); - } - - public void SetIcon(int portalicon) - { - //throw new Exception("The method or operation is not implemented."); - } - - public string Title - { - get - { - return myView.Title; - } - set - { - myView.Title = value; - } - } - - public bool Visible - { - get - { - return myView.Activated; - } - set - { - myView.Activated = value; - } - } - - public bool Activated - { - get - { - return Visible; - } - set - { - Visible = value; - } - } - - public void Activate() - { - Visible = true; - } - - public void Deactivate() - { - Visible = false; - } - - public System.Drawing.Point Location - { - get - { - return new System.Drawing.Point(myView.Position.X, myView.Position.Y); - } - set - { - int w = myView.Position.Width; - int h = myView.Position.Height; - myView.Position = new System.Drawing.Rectangle(value.X, value.Y, w, h); - } - } - - public System.Drawing.Rectangle Position - { - get - { - return myView.Position; - } - set - { - myView.Position = value; - } - } - - public System.Drawing.Size Size - { - get - { - return new System.Drawing.Size(myView.Position.Width, myView.Position.Height); - } - } - -#if VVS_WRAPPERS_PUBLIC - internal -#else - public -#endif - ViewSystemSelector.eViewSystem ViewType { get { return ViewSystemSelector.eViewSystem.DecalInject; } } - Dictionary CreatedControlsByName = new Dictionary(); - - public IControl this[string id] - { - get - { - if (CreatedControlsByName.ContainsKey(id)) return CreatedControlsByName[id]; - - Control ret = null; - Decal.Adapter.Wrappers.IControlWrapper iret = myView.Controls[id]; - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.PushButtonWrapper)) - ret = new Button(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.CheckBoxWrapper)) - ret = new CheckBox(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.TextBoxWrapper)) - ret = new TextBox(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ChoiceWrapper)) - ret = new Combo(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.SliderWrapper)) - ret = new Slider(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ListWrapper)) - ret = new List(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.StaticWrapper)) - ret = new StaticText(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.NotebookWrapper)) - ret = new Notebook(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ProgressWrapper)) - ret = new ProgressBar(); - if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ButtonWrapper)) - ret = new ImageButton(); - - if (ret == null) return null; - - ret.myControl = iret; - ret.myName = id; - ret.Initialize(); - allocatedcontrols.Add(ret); - CreatedControlsByName[id] = ret; - return ret; - } - } - - List allocatedcontrols = new List(); - - #endregion - - #region IDisposable Members - - bool disposed = false; - public void Dispose() - { - if (disposed) return; - disposed = true; - GC.SuppressFinalize(this); - - foreach (Control c in allocatedcontrols) - c.Dispose(); - - myView.Dispose(); - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Control : IControl - { - internal Decal.Adapter.Wrappers.IControlWrapper myControl; - public Decal.Adapter.Wrappers.IControlWrapper Underlying { get { return myControl; } } - internal string myName; - - public virtual void Initialize() - { - - } - - #region IControl Members - - public string Name - { - get { return myName; } - } - - public bool Visible - { - get { return true; } - set { } - } - - public string TooltipText - { - get - { - return ""; - } - set - { - - } - } - - public int Id - { - get - { - return myControl.Id; - } - } - - public System.Drawing.Rectangle LayoutPosition - { - get - { -#if DECAL_INTEROP - //This is kinda bad, but whatever - Decal.Interop.Inject.ILayer Ly = (Decal.Interop.Inject.ILayer)(Underlying.Underlying); - Decal.Interop.Core.tagRECT rct = Ly.get_Position(); - return new System.Drawing.Rectangle(rct.left, rct.top, rct.right - rct.left, rct.bottom - rct.top); -#else -#warning DECAL_INTEROP not defined, MetaViewWrappers.DecalControls.Control.LayoutPosition will not be available. - return new System.Drawing.Rectangle(); -#endif - } - set - { -#if DECAL_INTEROP - Decal.Interop.Inject.ILayer Ly = (Decal.Interop.Inject.ILayer)(Underlying.Underlying); - Decal.Interop.Core.tagRECT rct = new Decal.Interop.Core.tagRECT(); - rct.left = value.Left; - rct.top = value.Top; - rct.right = value.Right; - rct.bottom = value.Bottom; - Ly.set_Position(ref rct); -#endif - } - } - - #endregion - - #region IDisposable Members - - bool disposed = false; - public virtual void Dispose() - { - if (disposed) return; - disposed = true; - - //myControl.Dispose(); - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Button : Control, IButton - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).Hit += new EventHandler(Button_Hit); - ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).Click += new EventHandler(Button_Click); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).Hit -= new EventHandler(Button_Hit); - ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).Click -= new EventHandler(Button_Click); - } - - void Button_Hit(object sender, Decal.Adapter.ControlEventArgs e) - { - if (Hit != null) - Hit(this, null); - } - - void Button_Click(object sender, Decal.Adapter.ControlEventArgs e) - { - if (Click != null) - Click(this, new MVControlEventArgs(this.Id)); - } - - #region IButton Members - - public string Text - { - get - { - return ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).Text; - //throw new Exception("The method or operation is not implemented."); - } - set - { - ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).Text = value; - //throw new Exception("The method or operation is not implemented."); - } - } - - public System.Drawing.Color TextColor - { - get - { - return ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).TextColor; - } - set - { - ((Decal.Adapter.Wrappers.PushButtonWrapper)myControl).TextColor = value; - } - } - - public event EventHandler Hit; - public event EventHandler Click; - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class CheckBox : Control, ICheckBox - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.CheckBoxWrapper)myControl).Change += new EventHandler(CheckBox_Change); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.CheckBoxWrapper)myControl).Change -= new EventHandler(CheckBox_Change); - } - - void CheckBox_Change(object sender, Decal.Adapter.CheckBoxChangeEventArgs e) - { - if (Change != null) - Change(this, new MVCheckBoxChangeEventArgs(this.Id, Checked)); - if (Change_Old != null) - Change_Old(this, null); - } - - #region ICheckBox Members - - public string Text - { - get - { - return ((Decal.Adapter.Wrappers.CheckBoxWrapper)myControl).Text; - } - set - { - ((Decal.Adapter.Wrappers.CheckBoxWrapper)myControl).Text = value; - } - } - - public bool Checked - { - get - { - return ((Decal.Adapter.Wrappers.CheckBoxWrapper)myControl).Checked; - } - set - { - ((Decal.Adapter.Wrappers.CheckBoxWrapper)myControl).Checked = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class TextBox : Control, ITextBox - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).Change += new EventHandler(TextBox_Change); - ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).End += new EventHandler(TextBox_End); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).Change -= new EventHandler(TextBox_Change); - ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).End -= new EventHandler(TextBox_End); - } - - void TextBox_Change(object sender, Decal.Adapter.TextBoxChangeEventArgs e) - { - if (Change != null) - Change(this, new MVTextBoxChangeEventArgs(this.Id, e.Text)); - if (Change_Old != null) - Change_Old(this, null); - } - - void TextBox_End(object sender, Decal.Adapter.TextBoxEndEventArgs e) - { - if (End != null) - End(this, new MVTextBoxEndEventArgs(this.Id, e.Success)); - } - - #region ITextBox Members - - public string Text - { - get - { - return ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).Text; - } - set - { - ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).Text = value; - } - } - - public int Caret - { - get - { - return ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).Caret; - } - set - { - ((Decal.Adapter.Wrappers.TextBoxWrapper)myControl).Caret = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - public event EventHandler End; - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Combo : Control, ICombo - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Change += new EventHandler(Combo_Change); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Change -= new EventHandler(Combo_Change); - } - - void Combo_Change(object sender, Decal.Adapter.IndexChangeEventArgs e) - { - if (Change != null) - Change(this, new MVIndexChangeEventArgs(this.Id, e.Index)); - if (Change_Old != null) - Change_Old(this, null); - } - - #region ICombo Members - - public IComboIndexer Text - { - get - { - return new ComboIndexer(this); - } - } - - public IComboDataIndexer Data - { - get - { - return new ComboDataIndexer(this); - } - } - - public int Count - { - get - { - return ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Count; - } - } - - public int Selected - { - get - { - return ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Selected; - } - set - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Selected = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - - public void Add(string text) - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Add(text, null); - } - - public void Add(string text, object obj) - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Add(text, obj); - } - - public void Insert(int index, string text) - { - throw new Exception("The method or operation is not implemented."); - } - - public void RemoveAt(int index) - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Remove(index); - } - - public void Remove(int index) - { - RemoveAt(index); - } - - public void Clear() - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myControl).Clear(); - } - - #endregion - - internal class ComboIndexer: IComboIndexer - { - Combo myCombo; - internal ComboIndexer(Combo c) - { - myCombo = c; - } - - #region IComboIndexer Members - - public string this[int index] - { - get - { - return ((Decal.Adapter.Wrappers.ChoiceWrapper)myCombo.myControl).Text[index]; - } - set - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myCombo.myControl).Text[index] = value; - } - } - - #endregion - } - - internal class ComboDataIndexer : IComboDataIndexer - { - Combo myCombo; - internal ComboDataIndexer(Combo c) - { - myCombo = c; - } - - #region IComboIndexer Members - - public object this[int index] - { - get - { - return ((Decal.Adapter.Wrappers.ChoiceWrapper)myCombo.myControl).Data[index]; - } - set - { - ((Decal.Adapter.Wrappers.ChoiceWrapper)myCombo.myControl).Data[index] = value; - } - } - - #endregion - } - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Slider : Control, ISlider - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.SliderWrapper)myControl).Change += new EventHandler(Slider_Change); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.SliderWrapper)myControl).Change -= new EventHandler(Slider_Change); - } - - void Slider_Change(object sender, Decal.Adapter.IndexChangeEventArgs e) - { - if (Change != null) - Change(this, new MVIndexChangeEventArgs(this.Id, e.Index)); - if (Change_Old != null) - Change_Old(this, null); - } - - #region ISlider Members - - public int Position - { - get - { - return ((Decal.Adapter.Wrappers.SliderWrapper)myControl).SliderPostition; - } - set - { - ((Decal.Adapter.Wrappers.SliderWrapper)myControl).SliderPostition = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - - public int Maximum - { - get - { - return ((Decal.Adapter.Wrappers.SliderWrapper)myControl).Maximum; - } - set - { - ((Decal.Adapter.Wrappers.SliderWrapper)myControl).Maximum = value; - } - } - public int Minimum - { - get - { - return ((Decal.Adapter.Wrappers.SliderWrapper)myControl).Minimum; - } - set - { - ((Decal.Adapter.Wrappers.SliderWrapper)myControl).Minimum = value; - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class List : Control, IList - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.ListWrapper)myControl).Selected += new EventHandler(List_Selected); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.ListWrapper)myControl).Selected -= new EventHandler(List_Selected); - } - - void List_Selected(object sender, Decal.Adapter.ListSelectEventArgs e) - { - if (Click != null) - Click(this, e.Row, e.Column); - if (Selected != null) - Selected(this, new MVListSelectEventArgs(this.Id, e.Row, e.Column)); - } - - #region IList Members - - public event dClickedList Click; - public event EventHandler Selected; - - public void Clear() - { - ((Decal.Adapter.Wrappers.ListWrapper)myControl).Clear(); - } - - public IListRow this[int row] - { - get - { - return new ListRow(this, row); - } - } - - public IListRow AddRow() - { - ((Decal.Adapter.Wrappers.ListWrapper)myControl).Add(); - return new ListRow(this, ((Decal.Adapter.Wrappers.ListWrapper)myControl).RowCount - 1); - } - - public IListRow Add() - { - return AddRow(); - } - - public IListRow InsertRow(int pos) - { - ((Decal.Adapter.Wrappers.ListWrapper)myControl).Insert(pos); - return new ListRow(this, pos); - } - - public IListRow Insert(int pos) - { - return InsertRow(pos); - } - - public int RowCount - { - get { return ((Decal.Adapter.Wrappers.ListWrapper)myControl).RowCount; } - } - - public void RemoveRow(int index) - { - ((Decal.Adapter.Wrappers.ListWrapper)myControl).Delete(index); - } - - public void Delete(int index) - { - RemoveRow(index); - } - - public int ColCount - { - get - { - return ((Decal.Adapter.Wrappers.ListWrapper)myControl).ColCount; - } - } - - public int ScrollPosition - { - get - { - return ((Decal.Adapter.Wrappers.ListWrapper)myControl).ScrollPosition; - } - set - { - ((Decal.Adapter.Wrappers.ListWrapper)myControl).ScrollPosition = value; - } - } - - #endregion - - public class ListRow : IListRow - { - internal List myList; - internal int myRow; - internal ListRow(List l, int r) - { - myList = l; - myRow = r; - } - - - #region IListRow Members - - public IListCell this[int col] - { - get { return new ListCell(myList, myRow, col); } - } - - #endregion - } - - public class ListCell : IListCell - { - internal List myList; - internal int myRow; - internal int myCol; - public ListCell(List l, int r, int c) - { - myList = l; - myRow = r; - myCol = c; - } - - #region IListCell Members - - public void ResetColor() - { - Color = System.Drawing.Color.White; - } - - public System.Drawing.Color Color - { - get - { - return ((Decal.Adapter.Wrappers.ListWrapper)myList.myControl)[myRow][myCol].Color; - } - set - { - ((Decal.Adapter.Wrappers.ListWrapper)myList.myControl)[myRow][myCol].Color = value; - } - } - - public int Width - { - get - { - return ((Decal.Adapter.Wrappers.ListWrapper)myList.myControl)[myRow][myCol].Width; - } - set - { - ((Decal.Adapter.Wrappers.ListWrapper)myList.myControl)[myRow][myCol].Width = value; - } - } - - public object this[int subval] - { - get - { - return ((Decal.Adapter.Wrappers.ListWrapper)myList.myControl)[myRow][myCol][subval]; - } - set - { - ((Decal.Adapter.Wrappers.ListWrapper)myList.myControl)[myRow][myCol][subval] = value; - } - } - - #endregion - } - - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class StaticText : Control, IStaticText - { - - #region IStaticText Members - - public string Text - { - get - { - return ((Decal.Adapter.Wrappers.StaticWrapper)myControl).Text; - } - set - { - ((Decal.Adapter.Wrappers.StaticWrapper)myControl).Text = value; - } - } - -#pragma warning disable 0067 - public event EventHandler Click; -#pragma warning restore 0067 - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Notebook : Control, INotebook - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.NotebookWrapper)myControl).Change += new EventHandler(Notebook_Change); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.NotebookWrapper)myControl).Change -= new EventHandler(Notebook_Change); - } - - void Notebook_Change(object sender, Decal.Adapter.IndexChangeEventArgs e) - { - if (Change != null) - Change(this, new MVIndexChangeEventArgs(this.Id, e.Index)); - } - - #region INotebook Members - - public event EventHandler Change; - - public int ActiveTab - { - get - { - return ((Decal.Adapter.Wrappers.NotebookWrapper)myControl).ActiveTab; - } - set - { - ((Decal.Adapter.Wrappers.NotebookWrapper)myControl).ActiveTab = value; - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class ProgressBar : Control, IProgressBar - { - - #region IProgressBar Members - - public int Position - { - get - { - return ((Decal.Adapter.Wrappers.ProgressWrapper)myControl).Value; - } - set - { - ((Decal.Adapter.Wrappers.ProgressWrapper)myControl).Value = value; - } - } - - public int Value - { - get - { - return Position; - } - set - { - Position = value; - } - } - - public string PreText - { - get - { - return ((Decal.Adapter.Wrappers.ProgressWrapper)myControl).PreText; - } - set - { - ((Decal.Adapter.Wrappers.ProgressWrapper)myControl).PreText = value; - } - } - - public int MaxValue - { - get - { - return ((Decal.Adapter.Wrappers.ProgressWrapper)myControl).MaxValue; - } - set - { - ((Decal.Adapter.Wrappers.ProgressWrapper)myControl).MaxValue = value; - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class ImageButton : Control, IImageButton - { - public override void Initialize() - { - base.Initialize(); - ((Decal.Adapter.Wrappers.ButtonWrapper)myControl).Click += new EventHandler(ImageButton_Click); - } - - public override void Dispose() - { - base.Dispose(); - ((Decal.Adapter.Wrappers.ButtonWrapper)myControl).Click -= new EventHandler(ImageButton_Click); - } - - void ImageButton_Click(object sender, Decal.Adapter.ControlEventArgs e) - { - if (Click != null) - Click(this, new MVControlEventArgs(this.Id)); - } - - - #region IImageButton Members - - public event EventHandler Click; - - public void SetImages(int unpressed, int pressed) - { - ((Decal.Adapter.Wrappers.ButtonWrapper)myControl).SetImages(unpressed, pressed); - } - - public void SetImages(int hmodule, int unpressed, int pressed) - { - ((Decal.Adapter.Wrappers.ButtonWrapper)myControl).SetImages(hmodule, unpressed, pressed); - } - - public int Background - { - set - { - ((Decal.Adapter.Wrappers.ButtonWrapper)myControl).Background = value; - } - } - - public System.Drawing.Color Matte - { - set - { - ((Decal.Adapter.Wrappers.ButtonWrapper)myControl).Matte = value; - } - } - - #endregion - } -} - diff --git a/MosswartMassacre/VirindiViews/Wrapper_MyHuds.cs b/MosswartMassacre/VirindiViews/Wrapper_MyHuds.cs deleted file mode 100644 index e2e097f..0000000 --- a/MosswartMassacre/VirindiViews/Wrapper_MyHuds.cs +++ /dev/null @@ -1,1225 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -//File: Wrapper_MyHuds.cs -// -//Description: Contains MetaViewWrapper classes implementing Virindi View Service -// views. These classes are only compiled if the VVS_REFERENCED symbol is defined. -// -//References required: -// System.Drawing -// VirindiViewService (if VVS_REFERENCED is defined) -// -//This file is Copyright (c) 2010 VirindiPlugins -// -//Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -//The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -/////////////////////////////////////////////////////////////////////////////// - -#if VVS_REFERENCED - -using System; -using System.Collections.Generic; -using System.Text; -using VirindiViewService; - -#if METAVIEW_PUBLIC_NS -namespace MetaViewWrappers.VirindiViewServiceHudControls -#else -namespace MyClasses.MetaViewWrappers.VirindiViewServiceHudControls -#endif -{ -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class View : IView - { - HudView myView; - public HudView Underlying { get { return myView; } } - - #region IView Members - - public void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML) - { - VirindiViewService.XMLParsers.Decal3XMLParser ps = new VirindiViewService.XMLParsers.Decal3XMLParser(); - ViewProperties iprop; - ControlGroup igroup; - ps.ParseFromResource(pXML, out iprop, out igroup); - myView = new VirindiViewService.HudView(iprop, igroup); - } - - public void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML) - { - VirindiViewService.XMLParsers.Decal3XMLParser ps = new VirindiViewService.XMLParsers.Decal3XMLParser(); - ViewProperties iprop; - ControlGroup igroup; - ps.Parse(pXML, out iprop, out igroup); - myView = new VirindiViewService.HudView(iprop, igroup); - } - - public void Initialize(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey) - { - VirindiViewService.XMLParsers.Decal3XMLParser ps = new VirindiViewService.XMLParsers.Decal3XMLParser(); - ViewProperties iprop; - ControlGroup igroup; - ps.ParseFromResource(pXML, out iprop, out igroup); - myView = new VirindiViewService.HudView(iprop, igroup, pWindowKey); - } - - public void InitializeRawXML(Decal.Adapter.Wrappers.PluginHost p, string pXML, string pWindowKey) - { - VirindiViewService.XMLParsers.Decal3XMLParser ps = new VirindiViewService.XMLParsers.Decal3XMLParser(); - ViewProperties iprop; - ControlGroup igroup; - ps.Parse(pXML, out iprop, out igroup); - myView = new VirindiViewService.HudView(iprop, igroup, pWindowKey); - } - - public void SetIcon(int icon, int iconlibrary) - { - myView.Icon = ACImage.FromIconLibrary(icon, iconlibrary); - } - - public void SetIcon(int portalicon) - { - myView.Icon = portalicon; - } - - public string Title - { - get - { - return myView.Title; - } - set - { - myView.Title = value; - } - } - - public bool Visible - { - get - { - return myView.Visible; - } - set - { - myView.Visible = value; - } - } - - public bool Activated - { - get - { - return Visible; - } - set - { - Visible = value; - } - } - - public void Activate() - { - Visible = true; - } - - public void Deactivate() - { - Visible = false; - } - - public System.Drawing.Point Location - { - get - { - return myView.Location; - } - set - { - myView.Location = value; - } - } - - public System.Drawing.Size Size - { - get - { - return new System.Drawing.Size(myView.Width, myView.Height); - } - } - - public System.Drawing.Rectangle Position - { - get - { - return new System.Drawing.Rectangle(Location, Size); - } - set - { - Location = value.Location; - myView.ClientArea = value.Size; - } - } - -#if VVS_WRAPPERS_PUBLIC - internal -#else - public -#endif - ViewSystemSelector.eViewSystem ViewType { get { return ViewSystemSelector.eViewSystem.VirindiViewService; } } - Dictionary CreatedControlsByName = new Dictionary(); - - public IControl this[string id] - { - get - { - if (CreatedControlsByName.ContainsKey(id)) return CreatedControlsByName[id]; - - Control ret = null; - VirindiViewService.Controls.HudControl iret = myView[id]; - if (iret.GetType() == typeof(VirindiViewService.Controls.HudButton)) - ret = new Button(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudCheckBox)) - ret = new CheckBox(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudTextBox)) - ret = new TextBox(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudCombo)) - ret = new Combo(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudHSlider)) - ret = new Slider(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudList)) - ret = new List(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudStaticText)) - ret = new StaticText(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudTabView)) - ret = new Notebook(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudProgressBar)) - ret = new ProgressBar(); - if (iret.GetType() == typeof(VirindiViewService.Controls.HudImageButton)) - ret = new ImageButton(); - - if (ret == null) return null; - - ret.myControl = iret; - ret.myName = id; - ret.Initialize(); - allocatedcontrols.Add(ret); - CreatedControlsByName[id] = ret; - return ret; - } - } - - #endregion - - #region IDisposable Members - - bool disposed = false; - public void Dispose() - { - if (disposed) return; - disposed = true; - GC.SuppressFinalize(this); - - foreach (Control c in allocatedcontrols) - c.Dispose(); - - myView.Dispose(); - } - - #endregion - - List allocatedcontrols = new List(); - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Control : IControl - { - internal VirindiViewService.Controls.HudControl myControl; - internal string myName; - public VirindiViewService.Controls.HudControl Underlying { get { return myControl; } } - - public virtual void Initialize() - { - - } - - #region IControl Members - - public string Name - { - get { return myName; } - } - - public bool Visible - { - get { return myControl.Visible; } - set { myControl.Visible = value; } - } - - VirindiViewService.TooltipSystem.cTooltipInfo itooltipinfo = null; - public string TooltipText - { - get - { - if (itooltipinfo != null) - return itooltipinfo.Text; - else - return ""; - } - set - { - if (itooltipinfo != null) - { - VirindiViewService.TooltipSystem.RemoveTooltip(itooltipinfo); - itooltipinfo = null; - } - if (!String.IsNullOrEmpty(value)) - { - itooltipinfo = VirindiViewService.TooltipSystem.AssociateTooltip(myControl, value); - } - } - } - - public int Id - { - get - { - return myControl.XMLID; - } - } - - public System.Drawing.Rectangle LayoutPosition - { - get - { - //Relative to what?!??! - if (Underlying.Group.HeadControl == null) - return new System.Drawing.Rectangle(); - - if (Underlying.Group.HeadControl.Name == Underlying.Name) - return new System.Drawing.Rectangle(); - - VirindiViewService.Controls.HudControl myparent = Underlying.Group.ParentOf(Underlying.Name); - - if (myparent == null) - return new System.Drawing.Rectangle(); - - //Position only valid inside fixedlayouts - VirindiViewService.Controls.HudFixedLayout layoutparent = myparent as VirindiViewService.Controls.HudFixedLayout; - - if (layoutparent == null) - return new System.Drawing.Rectangle(); - - return layoutparent.GetControlRect(Underlying); - } - set - { - if (Underlying.Group.HeadControl == null) - return; - - if (Underlying.Group.HeadControl.Name == Underlying.Name) - return; - - VirindiViewService.Controls.HudControl myparent = Underlying.Group.ParentOf(Underlying.Name); - - if (myparent == null) - return; - - //Position only valid inside fixedlayouts - VirindiViewService.Controls.HudFixedLayout layoutparent = myparent as VirindiViewService.Controls.HudFixedLayout; - - if (layoutparent == null) - return; - - layoutparent.SetControlRect(Underlying, value); - } - } - - #endregion - - #region IDisposable Members - - bool disposed = false; - public virtual void Dispose() - { - if (disposed) return; - disposed = true; - - myControl.Dispose(); - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Button : Control, IButton - { - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudButton)myControl).MouseEvent += new EventHandler(Button_MouseEvent); - } - - public override void Dispose() - { - base.Dispose(); - ((VirindiViewService.Controls.HudButton)myControl).MouseEvent -= new EventHandler(Button_MouseEvent); - } - - void Button_MouseEvent(object sender, VirindiViewService.Controls.ControlMouseEventArgs e) - { - switch (e.EventType) - { - case VirindiViewService.Controls.ControlMouseEventArgs.MouseEventType.MouseHit: - if (Click != null) - Click(this, new MVControlEventArgs(this.Id)); - return; - case VirindiViewService.Controls.ControlMouseEventArgs.MouseEventType.MouseDown: - if (Hit != null) - Hit(this, null); - return; - } - } - - #region IButton Members - - public string Text - { - get - { - return ((VirindiViewService.Controls.HudButton)myControl).Text; - } - set - { - ((VirindiViewService.Controls.HudButton)myControl).Text = value; - } - } - - public System.Drawing.Color TextColor - { - get - { - return System.Drawing.Color.Black; - } - set - { - - } - } - - public event EventHandler Hit; - public event EventHandler Click; - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class CheckBox : Control, ICheckBox - { - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudCheckBox)myControl).Change += new EventHandler(CheckBox_Change); - } - - public override void Dispose() - { - base.Dispose(); - ((VirindiViewService.Controls.HudCheckBox)myControl).Change -= new EventHandler(CheckBox_Change); - } - - void CheckBox_Change(object sender, EventArgs e) - { - if (Change != null) - Change(this, new MVCheckBoxChangeEventArgs(this.Id, Checked)); - if (Change_Old != null) - Change_Old(this, null); - } - - #region ICheckBox Members - - public string Text - { - get - { - return ((VirindiViewService.Controls.HudCheckBox)myControl).Text; - } - set - { - ((VirindiViewService.Controls.HudCheckBox)myControl).Text = value; - } - } - - public bool Checked - { - get - { - return ((VirindiViewService.Controls.HudCheckBox)myControl).Checked; - } - set - { - ((VirindiViewService.Controls.HudCheckBox)myControl).Checked = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class TextBox : Control, ITextBox - { - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudTextBox)myControl).Change += new EventHandler(TextBox_Change); - myControl.LostFocus += new EventHandler(myControl_LostFocus); - } - - public override void Dispose() - { - base.Dispose(); - ((VirindiViewService.Controls.HudTextBox)myControl).Change -= new EventHandler(TextBox_Change); - myControl.LostFocus -= new EventHandler(myControl_LostFocus); - } - - void TextBox_Change(object sender, EventArgs e) - { - if (Change != null) - Change(this, new MVTextBoxChangeEventArgs(this.Id, Text)); - if (Change_Old != null) - Change_Old(this, null); - } - - void myControl_LostFocus(object sender, EventArgs e) - { - if (!myControl.HasFocus) return; - - if (End != null) - End(this, new MVTextBoxEndEventArgs(this.Id, true)); - } - - #region ITextBox Members - - public string Text - { - get - { - return ((VirindiViewService.Controls.HudTextBox)myControl).Text; - } - set - { - ((VirindiViewService.Controls.HudTextBox)myControl).Text = value; - } - } - - public int Caret - { - get - { - return 0; - } - set - { - - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - public event EventHandler End; - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Combo : Control, ICombo - { - List iData = new List(); - - public Combo() - { - //TODO: add data values from the xml - } - - public class ComboIndexer : IComboIndexer - { - Combo underlying; - internal ComboIndexer(Combo c) - { - underlying = c; - } - - #region IComboIndexer Members - - public string this[int index] - { - get - { - return ((VirindiViewService.Controls.HudStaticText)(((VirindiViewService.Controls.HudCombo)underlying.myControl)[index])).Text; - } - set - { - ((VirindiViewService.Controls.HudStaticText)(((VirindiViewService.Controls.HudCombo)underlying.myControl)[index])).Text = value; - } - } - - #endregion - } - - public class ComboDataIndexer : IComboDataIndexer - { - Combo underlying; - internal ComboDataIndexer(Combo c) - { - underlying = c; - } - - #region IComboIndexer Members - - public object this[int index] - { - get - { - return underlying.iData[index]; - } - set - { - underlying.iData[index] = value; - } - } - - #endregion - } - - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudCombo)myControl).Change += new EventHandler(Combo_Change); - } - - public override void Dispose() - { - base.Dispose(); - ((VirindiViewService.Controls.HudCombo)myControl).Change -= new EventHandler(Combo_Change); - } - - void Combo_Change(object sender, EventArgs e) - { - if (Change != null) - Change(this, new MVIndexChangeEventArgs(this.Id, Selected)); - if (Change_Old != null) - Change_Old(this, null); - } - - #region ICombo Members - - public IComboIndexer Text - { - get { return new ComboIndexer(this); } - } - - public IComboDataIndexer Data - { - get { return new ComboDataIndexer(this); } - } - - public int Count - { - get { return ((VirindiViewService.Controls.HudCombo)myControl).Count; } - } - - public int Selected - { - get - { - return ((VirindiViewService.Controls.HudCombo)myControl).Current; - } - set - { - ((VirindiViewService.Controls.HudCombo)myControl).Current = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - - public void Add(string text) - { - ((VirindiViewService.Controls.HudCombo)myControl).AddItem(text, null); - iData.Add(null); - } - - public void Add(string text, object obj) - { - ((VirindiViewService.Controls.HudCombo)myControl).AddItem(text, null); - iData.Add(obj); - } - - public void Insert(int index, string text) - { - ((VirindiViewService.Controls.HudCombo)myControl).InsertItem(index, text, null); - iData.Insert(index, null); - } - - public void RemoveAt(int index) - { - ((VirindiViewService.Controls.HudCombo)myControl).DeleteItem(index); - iData.RemoveAt(index); - } - - public void Remove(int index) - { - RemoveAt(index); - } - - public void Clear() - { - ((VirindiViewService.Controls.HudCombo)myControl).Clear(); - iData.Clear(); - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Slider : Control, ISlider - { - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudHSlider)myControl).Changed += new VirindiViewService.Controls.LinearPositionControl.delScrollChanged(Slider_Changed); - } - - public override void Dispose() - { - base.Dispose(); - ((VirindiViewService.Controls.HudHSlider)myControl).Changed -= new VirindiViewService.Controls.LinearPositionControl.delScrollChanged(Slider_Changed); - } - - void Slider_Changed(int min, int max, int pos) - { - if (Change != null) - Change(this, new MVIndexChangeEventArgs(this.Id, pos)); - if (Change_Old != null) - Change_Old(this, null); - } - - #region ISlider Members - - public int Position - { - get - { - return ((VirindiViewService.Controls.HudHSlider)myControl).Position; - } - set - { - ((VirindiViewService.Controls.HudHSlider)myControl).Position = value; - } - } - - public event EventHandler Change; - public event EventHandler Change_Old; - - public int Maximum - { - get - { - return ((VirindiViewService.Controls.HudHSlider)myControl).Max; - } - set - { - ((VirindiViewService.Controls.HudHSlider)myControl).Max = value; - } - } - public int Minimum - { - get - { - return ((VirindiViewService.Controls.HudHSlider)myControl).Min; - } - set - { - ((VirindiViewService.Controls.HudHSlider)myControl).Min = value; - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class List : Control, IList - { - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudList)myControl).Click += new VirindiViewService.Controls.HudList.delClickedControl(List_Click); - } - - public override void Dispose() - { - base.Dispose(); - ((VirindiViewService.Controls.HudList)myControl).Click -= new VirindiViewService.Controls.HudList.delClickedControl(List_Click); - } - - void List_Click(object sender, int row, int col) - { - if (Click != null) - Click(this, row, col); - if (Selected != null) - Selected(this, new MVListSelectEventArgs(this.Id, row, col)); - } - - public class ListRow : IListRow - { - List myList; - int myRow; - internal ListRow(int row, List l) - { - myList = l; - myRow = row; - } - - #region IListRow Members - - public IListCell this[int col] - { - get { return new ListCell(myRow, col, myList); } - } - - #endregion - } - public class ListCell : IListCell - { - List myList; - int myRow; - int myCol; - internal ListCell(int row, int col, List l) - { - myRow = row; - myCol = col; - myList = l; - } - - #region IListCell Members - - public void ResetColor() - { - ((VirindiViewService.Controls.HudStaticText)(((VirindiViewService.Controls.HudList)myList.myControl)[myRow][myCol])).ResetTextColor(); - } - - public System.Drawing.Color Color - { - get - { - return ((VirindiViewService.Controls.HudStaticText)(((VirindiViewService.Controls.HudList)myList.myControl)[myRow][myCol])).TextColor; - } - set - { - ((VirindiViewService.Controls.HudStaticText)(((VirindiViewService.Controls.HudList)myList.myControl)[myRow][myCol])).TextColor = value; - } - } - - public int Width - { - get - { - return ((VirindiViewService.Controls.HudStaticText)(((VirindiViewService.Controls.HudList)myList.myControl)[myRow][myCol])).ClipRegion.Width; - } - set - { - throw new Exception("The method or operation is not implemented."); - } - } - - public object this[int subval] - { - get - { - VirindiViewService.Controls.HudControl c = ((VirindiViewService.Controls.HudList)myList.myControl)[myRow][myCol]; - if (subval == 0) - { - if (c.GetType() == typeof(VirindiViewService.Controls.HudStaticText)) - return ((VirindiViewService.Controls.HudStaticText)c).Text; - if (c.GetType() == typeof(VirindiViewService.Controls.HudCheckBox)) - return ((VirindiViewService.Controls.HudCheckBox)c).Checked; - } - else if (subval == 1) - { - if (c.GetType() == typeof(VirindiViewService.Controls.HudPictureBox)) - return ((VirindiViewService.Controls.HudPictureBox)c).Image.PortalImageID; - } - return null; - } - set - { - VirindiViewService.Controls.HudControl c = ((VirindiViewService.Controls.HudList)myList.myControl)[myRow][myCol]; - if (subval == 0) - { - if (c.GetType() == typeof(VirindiViewService.Controls.HudStaticText)) - ((VirindiViewService.Controls.HudStaticText)c).Text = (string)value; - if (c.GetType() == typeof(VirindiViewService.Controls.HudCheckBox)) - ((VirindiViewService.Controls.HudCheckBox)c).Checked = (bool)value; - } - else if (subval == 1) - { - if (c.GetType() == typeof(VirindiViewService.Controls.HudPictureBox)) - ((VirindiViewService.Controls.HudPictureBox)c).Image = (int)value; - } - } - } - - #endregion - } - - #region IList Members - - public event dClickedList Click; - public event EventHandler Selected; - - public void Clear() - { - ((VirindiViewService.Controls.HudList)myControl).ClearRows(); - } - - public IListRow this[int row] - { - get { return new ListRow(row, this); } - } - - public IListRow AddRow() - { - ((VirindiViewService.Controls.HudList)myControl).AddRow(); - return new ListRow(((VirindiViewService.Controls.HudList)myControl).RowCount - 1, this); - } - - public IListRow Add() - { - return AddRow(); - } - - public IListRow InsertRow(int pos) - { - ((VirindiViewService.Controls.HudList)myControl).InsertRow(pos); - return new ListRow(pos, this); - } - - public IListRow Insert(int pos) - { - return InsertRow(pos); - } - - public int RowCount - { - get { return ((VirindiViewService.Controls.HudList)myControl).RowCount; } - } - - public void RemoveRow(int index) - { - ((VirindiViewService.Controls.HudList)myControl).RemoveRow(index); - } - - public void Delete(int index) - { - RemoveRow(index); - } - - public int ColCount - { - get - { - return ((VirindiViewService.Controls.HudList)myControl).ColumnCount; - } - } - - public int ScrollPosition - { - get - { - return ((VirindiViewService.Controls.HudList)myControl).ScrollPosition; - } - set - { - ((VirindiViewService.Controls.HudList)myControl).ScrollPosition = value; - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class StaticText : Control, IStaticText - { - public override void Initialize() - { - base.Initialize(); - //((VirindiViewService.Controls.HudStaticText)myControl) - } - - public override void Dispose() - { - base.Dispose(); - } - - #region IStaticText Members - - public string Text - { - get - { - return ((VirindiViewService.Controls.HudStaticText)myControl).Text; - } - set - { - ((VirindiViewService.Controls.HudStaticText)myControl).Text = value; - } - } - -#pragma warning disable 0067 - public event EventHandler Click; -#pragma warning restore 0067 - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class Notebook : Control, INotebook - { - public override void Initialize() - { - base.Initialize(); - ((VirindiViewService.Controls.HudTabView)myControl).OpenTabChange += new EventHandler(Notebook_OpenTabChange); - } - - public override void Dispose() - { - ((VirindiViewService.Controls.HudTabView)myControl).OpenTabChange -= new EventHandler(Notebook_OpenTabChange); - base.Dispose(); - } - - void Notebook_OpenTabChange(object sender, EventArgs e) - { - if (Change != null) - Change(this, new MVIndexChangeEventArgs(this.Id, ActiveTab)); - } - - #region INotebook Members - - public event EventHandler Change; - - public int ActiveTab - { - get - { - return ((VirindiViewService.Controls.HudTabView)myControl).CurrentTab; - } - set - { - ((VirindiViewService.Controls.HudTabView)myControl).CurrentTab = value; - ((VirindiViewService.Controls.HudTabView)myControl).Invalidate(); - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class ProgressBar : Control, IProgressBar - { - - #region IProgressBar Members - - public int Position - { - get - { - return ((VirindiViewService.Controls.HudProgressBar)myControl).Position; - } - set - { - ((VirindiViewService.Controls.HudProgressBar)myControl).Position = value; - } - } - - public int Value - { - get - { - return Position; - } - set - { - Position = value; - } - } - - public string PreText - { - get - { - return ((VirindiViewService.Controls.HudProgressBar)myControl).PreText; - } - set - { - ((VirindiViewService.Controls.HudProgressBar)myControl).PreText = value; - } - } - - - public int MaxValue - { - get - { - return ((VirindiViewService.Controls.HudProgressBar)myControl).Max; - } - set - { - ((VirindiViewService.Controls.HudProgressBar)myControl).Max = value; - } - } - - #endregion - } - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - class ImageButton : Control, IImageButton - { - public override void Initialize() - { - base.Initialize(); - myControl.MouseEvent += new EventHandler(Button_MouseEvent); - } - - public override void Dispose() - { - base.Dispose(); - myControl.MouseEvent -= new EventHandler(Button_MouseEvent); - } - - void Button_MouseEvent(object sender, VirindiViewService.Controls.ControlMouseEventArgs e) - { - switch (e.EventType) - { - case VirindiViewService.Controls.ControlMouseEventArgs.MouseEventType.MouseHit: - if (Click != null) - Click(this, new MVControlEventArgs(this.Id)); - return; - } - } - - #region IImageButton Members - - public event EventHandler Click; - - public void SetImages(int unpressed, int pressed) - { - ACImage upimg; - if (!VirindiViewService.Service.PortalBitmapExists(unpressed | 0x06000000)) - upimg = new ACImage(); - else - upimg = new ACImage(unpressed, ACImage.eACImageDrawOptions.DrawStretch); - - ACImage pimg; - if (!VirindiViewService.Service.PortalBitmapExists(pressed | 0x06000000)) - pimg = new ACImage(); - else - pimg = new ACImage(pressed, ACImage.eACImageDrawOptions.DrawStretch); - - ((VirindiViewService.Controls.HudImageButton)myControl).Image_Up = upimg; - ((VirindiViewService.Controls.HudImageButton)myControl).Image_Up_Pressing = pimg; - } - - public void SetImages(int hmodule, int unpressed, int pressed) - { - ((VirindiViewService.Controls.HudImageButton)myControl).Image_Up = ACImage.FromIconLibrary(unpressed, hmodule); - ((VirindiViewService.Controls.HudImageButton)myControl).Image_Up_Pressing = ACImage.FromIconLibrary(pressed, hmodule); - } - - public int Background - { - set - { - ((VirindiViewService.Controls.HudImageButton)myControl).Image_Background2 = new ACImage(value, ACImage.eACImageDrawOptions.DrawStretch); - } - } - - public System.Drawing.Color Matte - { - set - { - ((VirindiViewService.Controls.HudImageButton)myControl).Image_Background = new ACImage(value); - } - } - - #endregion - } -} - -#else -#warning VVS_REFERENCED not defined, MetaViewWrappers for VVS will not be available. -#endif \ No newline at end of file diff --git a/MosswartMassacre/VirindiViews/Wrapper_WireupHelper.cs b/MosswartMassacre/VirindiViews/Wrapper_WireupHelper.cs deleted file mode 100644 index 63deeaf..0000000 --- a/MosswartMassacre/VirindiViews/Wrapper_WireupHelper.cs +++ /dev/null @@ -1,329 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -//File: Wrapper_WireupHelper.cs -// -//Description: A helper utility that emulates Decal.Adapter's automagic view -// creation and control/event wireup with the MetaViewWrappers. A separate set -// of attributes is used. -// -//References required: -// Wrapper.cs -// -//This file is Copyright (c) 2010 VirindiPlugins -// -//Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -//The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -/////////////////////////////////////////////////////////////////////////////// - -using System; -using System.Collections.Generic; -using System.Text; -using System.Reflection; - -#if METAVIEW_PUBLIC_NS -namespace MetaViewWrappers -#else -namespace MyClasses.MetaViewWrappers -#endif -{ - #region Attribute Definitions - - [AttributeUsage(AttributeTargets.Class)] -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - sealed class MVWireUpControlEventsAttribute : Attribute - { - public MVWireUpControlEventsAttribute() { } - } - - [AttributeUsage(AttributeTargets.Field)] -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - sealed class MVControlReferenceAttribute : Attribute - { - string ctrl; - - // Summary: - // Construct a new ControlReference - // - // Parameters: - // control: - // Control to reference - public MVControlReferenceAttribute(string control) - { - ctrl = control; - } - - // Summary: - // The Control Name - public string Control - { - get - { - return ctrl; - } - } - } - - [AttributeUsage(AttributeTargets.Field)] -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - sealed class MVControlReferenceArrayAttribute : Attribute - { - private System.Collections.ObjectModel.Collection myControls; - - /// - /// Constructs a new ControlReference array - /// - /// Names of the controls to put in the array - public MVControlReferenceArrayAttribute(params string[] controls) - : base() - { - this.myControls = new System.Collections.ObjectModel.Collection(controls); - } - - /// - /// Control collection - /// - public System.Collections.ObjectModel.Collection Controls - { - get - { - return this.myControls; - } - } - } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - sealed class MVViewAttribute : Attribute - { - string res; - - // Summary: - // Constructs a new view from the specified resource - // - // Parameters: - // Resource: - // Embedded resource path - public MVViewAttribute(string resource) - { - res = resource; - } - - // Summary: - // The resource to load - public string Resource - { - get - { - return res; - } - } - } - - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - sealed class MVControlEventAttribute : Attribute - { - string c; - string e; - // Summary: - // Constructs the ControlEvent - // - // Parameters: - // control: - // Control Name - // - // controlEvent: - // Event to Wire - public MVControlEventAttribute(string control, string eventName) - { - c = control; - e = eventName; - } - - // Summary: - // Control Name - public string Control - { - get - { - return c; - } - } - - // - // Summary: - // Event to Wire - public string EventName - { - get - { - return e; - } - } - } - - #endregion Attribute Definitions - -#if VVS_WRAPPERS_PUBLIC - public -#else - internal -#endif - static class MVWireupHelper - { - private class ViewObjectInfo - { - public List Views = new List(); - } - static Dictionary VInfo = new Dictionary(); - - public static MyClasses.MetaViewWrappers.IView GetDefaultView(object ViewObj) - { - if (!VInfo.ContainsKey(ViewObj)) - return null; - if (VInfo[ViewObj].Views.Count == 0) - return null; - return VInfo[ViewObj].Views[0]; - } - - public static void WireupStart(object ViewObj, Decal.Adapter.Wrappers.PluginHost Host) - { - if (VInfo.ContainsKey(ViewObj)) - WireupEnd(ViewObj); - ViewObjectInfo info = new ViewObjectInfo(); - VInfo[ViewObj] = info; - - Type ObjType = ViewObj.GetType(); - - //Start views - object[] viewattrs = ObjType.GetCustomAttributes(typeof(MVViewAttribute), true); - foreach (MVViewAttribute a in viewattrs) - { - info.Views.Add(MyClasses.MetaViewWrappers.ViewSystemSelector.CreateViewResource(Host, a.Resource)); - } - - //Wire up control references - foreach (FieldInfo fi in ObjType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)) - { - if (Attribute.IsDefined(fi, typeof(MVControlReferenceAttribute))) - { - MVControlReferenceAttribute attr = (MVControlReferenceAttribute)Attribute.GetCustomAttribute(fi, typeof(MVControlReferenceAttribute)); - MetaViewWrappers.IControl mycontrol = null; - - //Try each view - foreach (MyClasses.MetaViewWrappers.IView v in info.Views) - { - try - { - mycontrol = v[attr.Control]; - } - catch { } - if (mycontrol != null) - break; - } - - if (mycontrol == null) - throw new Exception("Invalid control reference \"" + attr.Control + "\""); - - if (!fi.FieldType.IsAssignableFrom(mycontrol.GetType())) - throw new Exception("Control reference \"" + attr.Control + "\" is of wrong type"); - - fi.SetValue(ViewObj, mycontrol); - } - else if (Attribute.IsDefined(fi, typeof(MVControlReferenceArrayAttribute))) - { - MVControlReferenceArrayAttribute attr = (MVControlReferenceArrayAttribute)Attribute.GetCustomAttribute(fi, typeof(MVControlReferenceArrayAttribute)); - - //Only do the first view - if (info.Views.Count == 0) - throw new Exception("No views to which a control reference can attach"); - - Array controls = Array.CreateInstance(fi.FieldType.GetElementType(), attr.Controls.Count); - - IView view = info.Views[0]; - for (int i = 0; i < attr.Controls.Count; ++i) - { - controls.SetValue(view[attr.Controls[i]], i); - } - - fi.SetValue(ViewObj, controls); - } - } - - //Wire up events - foreach (MethodInfo mi in ObjType.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)) - { - if (!Attribute.IsDefined(mi, typeof(MVControlEventAttribute))) - continue; - Attribute[] attrs = Attribute.GetCustomAttributes(mi, typeof(MVControlEventAttribute)); - - foreach (MVControlEventAttribute attr in attrs) - { - MetaViewWrappers.IControl mycontrol = null; - //Try each view - foreach (MyClasses.MetaViewWrappers.IView v in info.Views) - { - try - { - mycontrol = v[attr.Control]; - } - catch { } - if (mycontrol != null) - break; - } - - if (mycontrol == null) - throw new Exception("Invalid control reference \"" + attr.Control + "\""); - - EventInfo ei = mycontrol.GetType().GetEvent(attr.EventName); - ei.AddEventHandler(mycontrol, Delegate.CreateDelegate(ei.EventHandlerType, ViewObj, mi.Name)); - } - } - } - - public static void WireupEnd(object ViewObj) - { - if (!VInfo.ContainsKey(ViewObj)) - return; - - foreach (MyClasses.MetaViewWrappers.IView v in VInfo[ViewObj].Views) - v.Dispose(); - - VInfo.Remove(ViewObj); - } - } -} \ No newline at end of file