示例#1
0
 public MLUiHost(MLPlugin plugin, OnContextMenuAdd callback, OnColumnItemAdd _columnAdd, GetImageDelegate _getImagecallback, OnLogDelegate _logCallback)
 {
     _getImage = _getImagecallback;
     _plugin = plugin;
     OnContextAdd = callback;
     OnColumnAdd = _columnAdd;
     logCallback = _logCallback;
 }
示例#2
0
 public MLUiHost(MLPlugin plugin, OnContextMenuAdd callback, OnColumnItemAdd _columnAdd, GetImageDelegate _getImagecallback, OnLogDelegate _logCallback)
 {
     _getImage    = _getImagecallback;
     _plugin      = plugin;
     OnContextAdd = callback;
     OnColumnAdd  = _columnAdd;
     logCallback  = _logCallback;
 }
示例#3
0
 void AddMenuItem(MLPlugin _plugin, ToolStripMenuItem parent, MLRatContextEntry entry)
 {
     ToolStripMenuItem _menu = new ToolStripMenuItem();
     Image toolstripIcon = getImage(entry.Icon);
     if (toolstripIcon != null)
         _menu.Image = toolstripIcon;
     _menu.Text = entry.Text;
     _menu.Tag = new MLContextData()
     {
         Plugin = _plugin,
         ContextData = entry
     };
     if (entry.OnClick != null)
         _menu.Click += ContextMenu_Click;
     if (entry.SubMenus != null)
     {
         foreach (var subentrys in entry.SubMenus)
             AddMenuItem(_plugin, _menu, subentrys);
     }
     parent.DropDownItems.Add(_menu);
 }
示例#4
0
 public pluginDisplay(MLPlugin _plugin)
 {
     InitializeComponent();
     Plugin = _plugin;
 }
示例#5
0
 public pluginDisplay(MLPlugin _plugin)
 {
     InitializeComponent();
     Plugin = _plugin;
 }
示例#6
0
 void AddSingleContext(MLPlugin _plugin, MLRatContextEntry entry)
 {
     ToolStripMenuItem _baseItem = new ToolStripMenuItem();
     Image toolstripIcon = getImage(entry.Icon);
     if (toolstripIcon != null)
         _baseItem.Image = toolstripIcon;
     _baseItem.Text = entry.Text;
     _baseItem.Tag = new MLContextData()
     {
         Plugin = _plugin,
         ContextData = entry
     };
     if (entry.OnClick != null)
         _baseItem.Click += ContextMenu_Click;
     if (entry.SubMenus != null)
     {
         foreach (var subentry in entry.SubMenus)
             AddMenuItem(_plugin, _baseItem, subentry);
     }
     ClientContextStrip.Items.Add(_baseItem);
 }
示例#7
0
 void OncontextAdd(MLPlugin _plugin, MLRatContextEntry[] entry)
 {
     foreach(MLRatContextEntry contextentry in entry)
     {
         AddSingleContext(_plugin, contextentry);
     }
 }
示例#8
0
 IClient[] SelectedClients(MLPlugin _plugin)
 {
     List<IClient> _selectedClients = new List<IClient>();
     foreach (ListViewItem i in clientList.SelectedItems)
     {
         try
         {
             this.Invoke((MethodInvoker) delegate()
             {
                 MLClientData _client = (MLClientData) i.Tag;
                 _selectedClients.Add(new MLClient(_client.ID, _plugin.ClientPluginID, _client));
             });
         }
         catch(Exception ex)
         {
             DisplayException(_plugin, ex);
         }
     }
     return _selectedClients.ToArray();
 }
示例#9
0
 void OnColumnUpdate(MLRatColumn sender, MLPlugin plugin, IClient client, string value)
 {
     try
     {
         MLClientData d = ConnectedClients[client.ID];
         ListViewItem i = (ListViewItem)d.DisplayObject;
         EditSubitem(i, sender.Index, value);
     }
     catch(Exception ex)
     {
         DisplayException(plugin, ex);
     }
 }
示例#10
0
        IMLRatColumn OnColumnAdd(MLPlugin _plugin, string name, string defaultValue)
        {
            lock(this)
            {
                MLRatColumn column = new MLRatColumn(OnColumnUpdate);
                column.Parent = _plugin;
                ColumnHeader header = clientList.Columns.Add(name);
                column.Index = header.Index;
                header.Tag = defaultValue;

                Invoke((MethodInvoker)delegate ()
                {
                    foreach (ListViewItem clientItem in clientList.Items)
                    {
                        foreach (ColumnHeader cheader in clientList.Columns)
                        {
                            if (clientItem.SubItems.Count == header.Index)
                            {
                                clientItem.SubItems.Add((string)header.Tag);
                            }
                        }
                    }
                });

                Console.WriteLine("Added column: {0}", name);
                return column;
            }
        }
示例#11
0
 void LogText(MLPlugin plugin, string text, Color c)
 {
     try
     {
         rtbPluginLog.LogText(string.Format("[{0}] ", plugin.PluginInfomation.PluginName) + text, c);
     }
     catch(Exception ex)
     {
         DisplayException(plugin, ex);
     }
 }
示例#12
0
 void LoadPlugin(string path)
 {
     MLPlugin _plugin = null;
     try
     {
         byte[] PluginBytes = File.ReadAllBytes(path);
         _plugin = new MLPlugin(PluginBytes);
         if (!_plugin.Load())
             throw new Exception("Failed to load plugin");
         if (_plugin.ClientPluginID == Guid.Empty)
             throw new Exception("Invalid plugin ID");
         if (LoadedPlugins.ContainsKey(_plugin.ClientPluginID))
             throw new Exception("Client plugin ID match");
         pluginDisplay _display = new pluginDisplay(_plugin);
         _display.Parent = pluginPanel;
         _display.Width = pluginPanel.Width;
         _display.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
         _display.Location = new Point(0, LoadedPlugins.Count*_display.Height);
         pluginPanel.Controls.Add(_display);
         LoadedPlugins.Add(_plugin.ClientPluginID, _plugin);
         Console.WriteLine("Loaded plugin: {0}", _plugin.ClientPluginID.ToString("n"));
         _plugin.ServerPlugin.OnPluginLoad(new MLUiHost(_plugin, OncontextAdd, OnColumnAdd, getImage, LogText));
     }
     catch(Exception ex)
     {
         DisplayException(_plugin, ex);
     }
 }
示例#13
0
 void DisplayException(MLPlugin plugin, Exception ex)
 {
     if (plugin != null && plugin.PluginInfomation != null)
     {
         rtbPluginLog.LogText(string.Format("[{0}] {1}", plugin.ServerPlugin, ex.Message), Color.Red);
         //Console.WriteLine("{0}: {1}", plugin.ClientPluginID, ex.ToString());
     }
     else
     {
         rtbPluginLog.LogText(ex.Message, Color.Red);
     }
 }