/// <summary>
        /// Called when flag is toggled
        /// </summary>
        /// <param name="info"></param>
        protected override void OnToggleFlag(IRaiseEventCallInfo info)
        {
            PluginHost.LogError("SetFlag");

            Dictionary <byte, object> data = info.Request.Data as Dictionary <byte, object>;

            int y = (int)data[0];
            int x = (int)data[1];

            if (board.IsFlag(y, x) || board.IsReveald(y, x))
            {
                return;                                              //Can not remove flag
            }
            if (board.IsMine(y, x))
            {
                board.ToggleFlag(y, x);
            }

            if (board.IsMine(y, x))
            {
                BroadcastEvent((byte)Event.ReceiveToggleFlag, new Dictionary <byte, object>()
                {
                    { (byte)0, y }, { (byte)1, x }, { (byte)2, board.IsFlag(y, x) }
                });
            }
            else
            {
                OpenTile(y, x, board.GetTile(y, x));
            }

            scoreManager.AddPoints(turnManager.Actors.Find(a => a.ActorNr == info.ActorNr), board.IsMine(y, x) ? 5 : -5);
        }
        /// <summary>
        /// Called when tile is opened
        /// </summary>
        /// <param name="info"></param>
        protected override void OnOpen(IRaiseEventCallInfo info)
        {
            Dictionary <byte, object> data = info.Request.Data as Dictionary <byte, object>;

            int y   = (int)data[0];
            int x   = (int)data[1];
            int val = board.GetTile(y, x);

            PluginHost.LogError(string.Format("y: {0} , x: {1} , val: {2} , IsIsReveald: {3} ", y, x, val, board.IsReveald(y, x)));

            if (!board.IsReveald(y, x))
            {
                OpenTile(y, x, val);
                if (!board.IsFlag(y, x))
                {
                    scoreManager.AddPoints(turnManager.Actors.Find(a => a.ActorNr == info.ActorNr), val == 10 ? -5 : 3);
                }
            }
            else
            if (TryOpenRest(y, x))
            {
                scoreManager.AddPoints(turnManager.Actors.Find(a => a.ActorNr == info.ActorNr), 2);
            }

            if (board.CheckIfComplete())
            {
                EndGame();
            }
        }
Ejemplo n.º 3
0
 protected override void Startup()
 {
     MyHost = Host;
     ViewInit();
     initChatEvents();
     initLoginEvents();
 }
Ejemplo n.º 4
0
        public static async Task Main(string[] args)
        {
            var pluginHost = new PluginHost();

            // KV sample client doesn't support MTLS
            // pluginHost.PKI = PKI.SimplePKIDetails.GenerateRSA();

            pluginHost.PrepareHost(args);
            pluginHost.BuildHostApp();
            pluginHost.MapGrpcService <Services.KVService>();
            var log = pluginHost.Services.GetRequiredService <ILogger <PluginMain> >();

            log.LogInformation("Starting up Plugin Host...");
            var hostingTask = pluginHost.StartHosting();

            log.LogInformation("Capturing console cancel request");
            Console.CancelKeyPress += (o, e) => {
                log.LogInformation("Got CANCEL request");
                pluginHost.StopHosting();
                log.LogInformation("Initiated Plugin Stop");
            };

            Console.WriteLine("Running...");
            Console.WriteLine("Hit CTRL+C to exit.");

            _ = Task.Run(async() => {
                await Task.Delay(20 * 1000);
                log.LogInformation("Timedout hosting");
                pluginHost.StopHosting();
                log.LogInformation("Initiated Plugin Stop");
            });

            await hostingTask;
        }
Ejemplo n.º 5
0
        public static void Dispose()
        {
            Core.ChatNameClicked -= HandleChatCommand;

            mHost             = null;
            mCore             = null;
            mFileService      = null;
            mMainPluginThread = null;

            mQueuedActions.Clear();
            mQueuedActions = null;
            mChatActions.Clear();
            mChatActions = null;

            if (mActionQueueTimer != null)
            {
                mActionQueueTimer.Dispose();
                mActionQueueTimer = null;
            }

            if (mDebugWriter != null)
            {
                mDebugWriter.Dispose();
                mDebugWriter = null;
            }
        }
Ejemplo n.º 6
0
 public ec(PluginHost A_0, string[] A_1, string A_2, string A_3, int A_4, ec.a A_5, string A_6, string A_7, IView A_8) : base(A_7, A_8)
 {
     this.a = A_1;
     this.b = A_2;
     this.c = A_3;
     this.d = A_4;
     this.e = A_5;
     this.f = A_6;
     if (base.a(A_0))
     {
         this.g = new IButton[this.a.Length];
         for (int i = 0; i < this.a.Length; i++)
         {
             this.g[i]      = (IButton)base.a["btn" + i.ToString()];
             this.g[i].Hit += new EventHandler(this.a);
         }
         this.h      = (ITextBox)base.a["Textbox1"];
         this.h.Text = this.f;
         this.i      = (IStaticText)base.a["Label1"];
         this.i.Text = this.c;
         if (base.a is View)
         {
             this.b();
         }
     }
 }
Ejemplo n.º 7
0
    private static IView a(PluginHost A_0, string A_1)
    {
        IView view = new View();

        view.InitializeRawXML(A_0, A_1);
        return(view);
    }
Ejemplo n.º 8
0
        protected internal virtual bool CheckCounters(IClient user, IPacket packet)
        {
            DateTime now = DateTime.Now;

            foreach (var rule in flood_rules.Where((s) => s.Id == packet.Id))
            {
                if (!user.Counters.TryGetValue(packet.Id, out IFloodCounter counter))
                {
                    counter = new FloodCounter(0, now);
                    user.Counters.Add(packet.Id, counter);
                }

                if (now.Subtract(counter.Last).TotalMilliseconds > rule.Timeout)
                {
                    counter.Count = 0;
                }

                if (++counter.Count >= rule.Count)
                {
                    Stats.FloodsTriggered++;

                    if (!PluginHost.OnFlood(user, rule, packet))
                    {
                        return(false);
                    }
                }
                else
                {
                    counter.Last = now;
                }
            }

            return(true);
        }
Ejemplo n.º 9
0
        private void PluginFrm_Load(object sender, EventArgs e)
        {
            try
            {
                int i = 0;
                foreach (PluginTag p in PluginHost.GetPluginTags())
                {
                    Node nd = new Node();
                    nd.Name = "p" + i.ToString();
                    nd.Text = p.Name;
                    Node d = new Node();
                    d.Name = "d" + i.ToString();
                    d.Text = "Description : " + p.Description;
                    Node v = new Node();
                    v.Name = "v" + i.ToString();
                    v.Text = "Version : " + p.Version;
                    Node f = new Node();
                    f.Name = "f" + i.ToString();
                    f.Text = "Location : " + p.Fullpath;
                    Node s = new Node();
                    s.Name = "s" + i.ToString();
                    s.Text = "Status : " + p.Disabled.ToString();
                    nd.Nodes.Add(d);
                    nd.Nodes.Add(v);
                    nd.Nodes.Add(f);
                    nd.Nodes.Add(s);

                    advTree1.Nodes.Add(nd);
                    i++;
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 10
0
        public void LoadPluginTest()
        {
            string pathToPlugin = typeof(IISPlugin).Assembly.Location;
            string className    = typeof(IISPlugin).FullName;

            PluginHost.RemoveInstance(PluginHost.CreateInstance(PluginHost.LoadPlugin(pathToPlugin, className)));
        }
Ejemplo n.º 11
0
        public void ArmedLoad_IFakePartWithComposedDependencies_ReturnsPart()
        {
            var dependency = new ComposedDependency();
            var part       = PluginHost.ArmedLoad <IFakePartWithComposedDependencies, IFakeDependency>(dependency);

            Assert.NotNull(part);
        }
Ejemplo n.º 12
0
    public ek(CoreManager A_0, PluginHost A_1, int A_2)
    {
        this.a = A_0;
        this.b = A_1;
        this.c = A_2;
        foreach (cv cv in PluginCore.cq.p.d())
        {
            int num = cv.a(dt.d, 0);
            if (((num == 0x1000000) || (num == 0x100000)) || ((num == 0x400000) || (num == 0x2000000)))
            {
                this.d = cv.k;
            }
            switch (num)
            {
            case 0x800000:
                this.e = cv.k;
                break;

            case 0x200000:
                this.f = cv.k;
                break;
            }
            if (num > 0)
            {
                this.g.Add(cv.k);
            }
        }
        PluginCore.PC.a(new uTank2.PluginCore.a(this.a));
    }
Ejemplo n.º 13
0
        protected bool HasLink(IIOContainer pinContainer)
        {
            try
            {
                var connected = pinContainer.GetPluginIO().IsConnected;

                foreach (var associated in pinContainer.AssociatedContainers)
                {
                    connected |= associated.GetPluginIO().IsConnected;
                }
                return(connected);
            }
            catch (InvalidComObjectException)
            {
                // [Import]s not yet ready. try another time.
                // its safe to assume that no pins have been created yet.
                FLogger.Log(LogType.Warning, "Not fully initialized [" + this.GetType().Name + "].");
                return(false);
            }
            catch (Exception)
            {
                string nodePath = PluginHost.GetNodePath(false);
                FLogger.Log(LogType.Error, "Failed to protect a " + this.GetType().Name + " node: " + nodePath);
                return(false);
            }
        }
Ejemplo n.º 14
0
 protected override void Shutdown()
 {
     destroyLoginEvents();
     destroyChatEvents();
     ViewDestroy();
     MyHost = null;
 }
Ejemplo n.º 15
0
        public cClassGroup(PluginHost h, CoreManager c)
        {
            Host = h;
            Core = c;

            XPCounting = new cXPCounting(this);
        }
Ejemplo n.º 16
0
        public AresServer(IServerConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config", "Server configuration cannot be null.");
            }

            this.config = config;

            ticklength = TimeSpan.FromSeconds(1);

            stats    = new AresServerStats();
            users    = new AresClientList();
            channels = new AresChannels(this);
            plugins  = new PluginHost(this);

            idpool = new SortedStack <UInt16>();
            idpool.SetSort((a, b) => (a - b));

            pending     = new List <PendingConnection>();
            flood_rules = new List <IFloodRule>();

            history = new History(this);
            history.Load();
        }
Ejemplo n.º 17
0
        public static bool IsVCSPresent(PluginHost pHost)
        {
            try
            {
                //See if VCS assembly is loaded
                if (!seenvcsassembly)
                {
                    System.Reflection.Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (System.Reflection.Assembly a in asms)
                    {
                        AssemblyName nmm = a.GetName();
                        if ((nmm.Name == "VCS5") && (nmm.Version >= new System.Version("5.0.0.5")))
                        {
                            seenvcsassembly = true;
                            break;
                        }
                    }
                }

                if (seenvcsassembly)
                {
                    if (Curtain_VCSInstanceEnabled())
                    {
                        return(true);
                    }
                }
            }
            catch
            {
            }

            return(false);
        }
Ejemplo n.º 18
0
        private static void Main(string[] args)
        {
            string  tempLogFile = SetupLogging();
            string  cwd         = Environment.CurrentDirectory;
            Project?project     = PluginHost <IBuildPlugin> .LoadPlugins()
                                  .Select(plugin => plugin.DetectProject(cwd, "src", "build"))
                                  .FirstOrDefault(proj => proj != null);

            if (project == null)
            {
                Log.Error($"Couldn't detect a project in the directory {cwd}.");
                Log.Error("Make sure you are in the right directory to call this command.");
                FinalizeLog();
                Console.WriteLine($"Log file written to {tempLogFile}");
            }
            else
            {
                project.WriteNinja();
                string destLogFile = Path.Combine(project.BuildDir, "Xay.log");
                FinalizeLog();
                if (File.Exists(destLogFile))
                {
                    File.Delete(destLogFile);
                }
                File.Copy(tempLogFile, destLogFile);
            }
        }
Ejemplo n.º 19
0
        public static void Initialize(string pluginName, PluginHost host, CoreManager core, string basePath)
        {
            mPluginName              = pluginName;
            mChatLinkId              = pluginName.GetHashCode() & int.MaxValue;
            mChatActionCommand       = null;
            mOpenErrorsTxtCommand    = null;
            mOpenPluginFolderCommand = null;
            mHost             = host;
            mCore             = core;
            mFileService      = (FileService)core.FileService;
            Util.BasePath     = basePath;
            mMainPluginThread = Thread.CurrentThread;

            mDefaultWindow         = ChatWindow.MainChat;
            mWriteErrorsToMainChat = true;
            mNumExceptionsWritten  = 0;

            mQueuedActions = new Queue <QueuedAction>();

            mActionQueueTimer          = new WindowsTimer();
            mActionQueueTimer.Tick    += new EventHandler(ActionQueueTimer_Tick);
            mActionQueueTimer.Interval = 100;
            mActionQueueTimer.Start();

            mChatActions      = new SortedList <int, QueuedAction>();
            mNextChatActionId = 0;
        }
Ejemplo n.º 20
0
        public static void GetPluginAssemblies([NotNull] this PluginHost pluginHost, [NotNull] IList <string> fileNames, bool includePackages, bool includeAssemblies, bool includeServerComponents)
        {
            Assert.ArgumentNotNull(pluginHost, nameof(pluginHost));
            Assert.ArgumentNotNull(fileNames, nameof(fileNames));

            AppHost.Files.CreateDirectory(AppHost.Plugins.PluginFolder);
            AppHost.Files.CreateDirectory(AppHost.Plugins.PackageFolder);

            pluginHost.CleanPluginFolder();
            pluginHost.CleanPackageFolder();

            if (includeAssemblies)
            {
                pluginHost.GetPluginAssembliesFromPluginFolder(fileNames);
                pluginHost.GetPluginAssembliesFromPluginFolders(fileNames);
                pluginHost.GetPluginAssembliesFromCommandLine(fileNames, includeServerComponents);

                RemoveUninstalledAssemblies(fileNames);
            }

            if (includePackages)
            {
                pluginHost.GetPluginAssembliesFromPackages(fileNames);
            }
        }
        /// <summary>
        /// Cleans up the HudManager and Disposes all windows that are
        /// being managed by this HudManager. Use this function when the
        /// plugin is shutting down. Also be sure to unregister
        /// <see cref="GraphicsReset()"/> from the GraphicsReset event.
        /// </summary>
        public void Dispose()
        {
            if (Disposed)
            {
                return;
            }

            if (mRepaintHeartbeat.Running)
            {
                mRepaintHeartbeat.Stop();
            }
            mRepaintHeartbeat.Timeout -= RepaintHeartbeatDispatch;
            mRepaintHeartbeat          = null;

            //Core.WindowMessage -= WindowMessageDispatch;

            // Need to use a copy of the list because the Dispose() method of
            // windows modifies mWindowList.
            UpdateHudsListCopy();
            foreach (IManagedHud hud in mHudsListCopy)
            {
                hud.Dispose();
            }
            mHudsOnTopList.Clear();
            mHudsList.Clear();
            mHudsListCopy.Clear();

            mHost              = null;
            mCore              = null;
            mDefaultView       = null;
            mDefaultViewActive = null;

            mDisposed = true;
        }
Ejemplo n.º 22
0
 public static bool b(PluginHost A_0)
 {
     try
     {
         Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
         bool       flag       = false;
         foreach (Assembly assembly in assemblies)
         {
             AssemblyName name = assembly.GetName();
             if ((name.Name == "VCS5") && (name.Version >= new Version("5.0.0.5")))
             {
                 flag = true;
                 break;
             }
         }
         if (flag && b())
         {
             return(true);
         }
     }
     catch
     {
     }
     return(false);
 }
Ejemplo n.º 23
0
        public override bool Loaded()
        {
            Host2 = Host;

            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GridUIv2));
            var temp = (string)(resources.GetObject("$this.Text"));

            but        = new ToolStripMenuItem(temp);
            but.Click += but_Click;

            bool hit = false;
            ToolStripItemCollection col = Host.FPMenuMap.Items;
            int index = col.Count;

            foreach (ToolStripItem item in col)
            {
                if (item.Text.Equals(Strings.AutoWP))
                {
                    index = col.IndexOf(item);
                    ((ToolStripMenuItem)item).DropDownItems.Add(but);
                    hit = true;
                    break;
                }
            }

            if (hit == false)
            {
                col.Add(but);
            }

            return(true);
        }
Ejemplo n.º 24
0
        public async Task TestPluginExports()
        {
            const string pluginPath = "/path/to/plugin.sln";
            var          api        = new NvimAPI();
            await PluginHost.RegisterPlugin <TestPlugin>(api, pluginPath);

            await api.Command(
                $"let g:result = {nameof(TestPlugin.AddNumbers)}(1, 2)");

            var result = await api.GetVar("result");

            Assert.AreEqual(3L, result);

            await api.Command($"{nameof(TestPlugin.TestCommand1)} a b c");

            CollectionAssert.AreEqual(new[] { "a", "b", "c" }, TestPlugin.Command1Args);

            await api.Command($"{nameof(TestPlugin.TestCommand2)} 1 2 3");

            Assert.AreEqual("1 2 3", TestPlugin.Command2Args);

            await api.Command("edit test.cs");

            Assert.IsTrue(TestPlugin.AutocmdCalled);

            await api.Command($"call {nameof(TestPlugin.CountLines)}()");

            Assert.IsTrue(TestPlugin.CountLinesReturn == 1);
        }
Ejemplo n.º 25
0
        public static void GetPluginAssembliesFromPluginFolder([NotNull] this PluginHost pluginHost, [NotNull] IList <string> fileNames)
        {
            Assert.ArgumentNotNull(pluginHost, nameof(pluginHost));
            Assert.ArgumentNotNull(fileNames, nameof(fileNames));

            GetAssembliesFromFolder(fileNames, AppHost.Plugins.PluginFolder);
        }
Ejemplo n.º 26
0
        public static void UninstallPlugins([NotNull] this PluginHost pluginHost)
        {
            Assert.ArgumentNotNull(pluginHost, nameof(pluginHost));

            var folder = AppHost.Plugins.PluginFolder;

            if (!AppHost.Files.FolderExists(folder))
            {
                return;
            }

            foreach (var source in Directory.GetFiles(folder, @"*.uninstall"))
            {
                try
                {
                    var target = AppHost.Files.ReadAllText(source);
                    File.Delete(source);

                    target = Path.Combine(AppHost.Plugins.PluginFolder, target);

                    if (AppHost.Files.FileExists(target))
                    {
                        AppHost.Files.Delete(target);
                    }
                    else if (AppHost.Files.FolderExists(target))
                    {
                        AppHost.Files.DeleteFolder(target);
                    }
                }
                catch (Exception ex)
                {
                    AppHost.MessageBox(string.Format(Resources.PluginManager_UninstallDeferred_, Path.GetFileNameWithoutExtension(source), ex.Message), Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 27
0
        protected void LoadPlugins()
        {
            (RunnerDomain, Runner) = PluginHost.Create(SMA.Instance.Collection);
            Runner.Setup();

            Runner.Export <ISuperMemoAssistant>(SMA.Instance);
            Runner.Export <ISuperMemoUI>(SMA.Instance.UI);
            Runner.Export <ISuperMemoRegistry>(SMA.Instance.Registry);

            //Runner.Export<IKeyboardHotKeyMgr>(KeyboardHotKey.Instance);

            Runner.Export <IElementRegistry>(ElementRegistry.Instance);
            Runner.Export <IComponentRegistry>(ComponentRegistry.Instance);
            Runner.Export <ITextRegistry>(TextRegistry.Instance);
            Runner.Export <IBinaryRegistry>(BinaryRegistry.Instance);
            Runner.Export <IConceptRegistry>(ConceptRegistry.Instance);
            Runner.Export <IImageRegistry>(ImageRegistry.Instance);
            Runner.Export <ITemplateRegistry>(TemplateRegistry.Instance);
            Runner.Export <ISoundRegistry>(SoundRegistry.Instance);
            Runner.Export <IVideoRegistry>(VideoRegistry.Instance);

            Runner.Export <IElementWdw>(ElementWdw.Instance);

            Runner.PostSetup();

            foreach (var plugin in Runner.Plugins)
            {
                System.Diagnostics.Debug.WriteLine($"[PluginMgr] Loaded plugin {plugin.Name} ({plugin.Version})");
            }
        }
Ejemplo n.º 28
0
        //On leave is also called when player is inside a room or got disconnected
        public override void OnLeave(ILeaveGameCallInfo info)
        {
            base.OnLeave(info);
            m_InfoRoom.I_NumberOfPlayers--;
            if (m_InfoRoom.I_NoOfClientReady >= 0)
            {
                m_InfoRoom.I_NoOfClientReady--;
            }

            int numberPlayerCounter = m_InfoRoom.I_NumberOfPlayers - 1;


            if ((m_InfoRoom.I_NoOfClientReady < numberPlayerCounter) || (m_InfoRoom.I_NoOfClientReady == 0 && numberPlayerCounter == 0))
            {
                PluginHost.BroadcastEvent(target: ReciverGroup.Others,
                                          senderActor: 0,
                                          targetGroup: 0,
                                          data: new Dictionary <byte, object>()
                {
                    {
                        (byte)245, null
                    }, { 254, 0 }
                },
                                          evCode: (byte)MyOwnEventCode.S2C_Not_ReadyToStart,
                                          cacheOp: 0);
            }
        }
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            var request = new HttpRequest
            {
                Url       = "https://httpbin.org/response-headers",
                UserState = info,
                Method    = info.Request.EvCode == 1 ? "GET" : "POST",
                Callback  = this.Callback
            };

            if (this.PluginHost.GameId.Contains("OldHttp"))
            {
#pragma warning disable CS0612 // Type or member is obsolete
                PluginHost.HttpRequest(request);
#pragma warning restore CS0612 // Type or member is obsolete

                base.OnRaiseEvent(info);
            }
            else
            {
                PluginHost.HttpRequest(request, info);

                if (this.PluginHost.GameId.Contains("Async"))
                {
                    base.OnRaiseEvent(info);
                }
            }
        }
Ejemplo n.º 30
0
        public static void GetPluginAssembliesFromCommandLine([NotNull] this PluginHost pluginHost, [NotNull] IList <string> fileNames, bool includeServerComponents)
        {
            Assert.ArgumentNotNull(pluginHost, nameof(pluginHost));
            Assert.ArgumentNotNull(fileNames, nameof(fileNames));

            var args = AppHost.Shell.CommandLineArgs;

            for (var index = 0; index < args.Length - 1; index++)
            {
                var part = args[index];

                if (string.Compare(part, @"/rocks.plugin", StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    continue;
                }

                var folder = args[index + 1];
                if (!AppHost.Files.FolderExists(folder))
                {
                    continue;
                }

                var assemblyFileNames = Directory.GetFiles(folder, "*.dll", SearchOption.AllDirectories);
                foreach (var assemblyFileName in assemblyFileNames)
                {
                    var f = Path.GetFileName(assemblyFileName);

                    if (!AppHost.Plugins.IsServerComponent(f) || includeServerComponents)
                    {
                        fileNames.Add(assemblyFileName);
                    }
                }
            }
        }
Ejemplo n.º 31
0
        public static void Init(string pluginName, PluginHost host, CoreManager core)
        {
            PluginName = pluginName;

            Host = host;

            Core = core;
        }
Ejemplo n.º 32
0
		public ChatFilter(PluginHost host)
		{
			try
			{
				this.host = host;

				CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(Current_ChatBoxMessage);

				host.Underlying.Hooks.StatusTextIntercept += new Decal.Interop.Core.IACHooksEvents_StatusTextInterceptEventHandler(Hooks_StatusTextIntercept);
			}
			catch (Exception ex) { Debug.LogException(ex); }
		}
Ejemplo n.º 33
0
        public MainForm()
        {
            host = new PluginHost(this);

            InitializeComponent();

            if (databaseViewer.Menu != null)
                ToolStripManager.Merge(databaseViewer.Menu, menuStrip);
            if (databaseViewer.MainToolStrip != null)
                ToolStripManager.Merge(databaseViewer.MainToolStrip, mainToolStrip);
            if (databaseViewer.StatusStrip != null)
                ToolStripManager.Merge(databaseViewer.StatusStrip, statusStrip);
        }
        private static void LoadConfiguration()
        {
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            IPluginHost pluginHost = new PluginHost(path);

            var fileInfo = new FileInfo(ConfigFileName);
            _configFileSize = fileInfo.Length;
            _configFileHash = ComputeConfigHash();
            var settings = new XmlReaderSettings {ConformanceLevel = ConformanceLevel.Auto,};
            var serializer = new DataContractSerializer(typeof (TransportAgentConfig), pluginHost.KnownTypes);
            using (XmlReader reader = XmlReader.Create(ConfigFileName, settings))
            {
                _config = (TransportAgentConfig) serializer.ReadObject(reader, true);
            }
        }
Ejemplo n.º 35
0
        Program()
        {
            Instance = this;

            Config = new ConfigGroup();
            Paths = new WindarPaths(Application.StartupPath);
            Daemon = new DaemonController(Paths);
            ScanQueue = new Queue<string>();
            MainForm = new MainForm();
            Tray = new Tray();
            PluginHost = new PluginHost(Paths);
            WaitingDialog = new WaitingDialog();

            // Register command event handlers.
            Daemon.ScanCompleted += ScanCompleted;
            Daemon.PlaydarStopped += PlaydarStopped;
            Daemon.PlaydarStarted += PlaydarStarted;
            Daemon.PlaydarStartFailed += PlaydarStartFailed;
        }
Ejemplo n.º 36
0
 public MainForm()
 {
     pluginsHost = new PluginHost(this);
     InitializeComponent();
     Text = Resources.AppTitle;
     languagePackDialog = new LanguagePackDialog();
     extractionSettingsDialog = new ExtractionSettingsDialog();
     extractionSettingsDialog.DestinationDirectory = Settings.Default.ExtractionDirectory;
     extractionSettingsDialog.Recurse = Settings.Default.ExtractionRecurse;
     extractionSettingsDialog.OverwriteFiles = Settings.Default.ExtractionOverwriteFiles;
     extractionProgressionDialog = new ExtractionProgressionDialog();
     nodePropertiesForm = new NodePropertiesForm(this);
     nodeDictionnary = new Dictionary<string, TreeNode>();
     temporaryNodeList = new List<TreeNode>();
     fileViewers = new Dictionary<string, FileViewer>();
     fileViewerAssociations = new Dictionary<string, FileViewer>();
     LoadEmbeddedViewers();
     LoadPlugins();
     ResolveAssociations();
     LoadIcons();
     AdjustStyles();
     ApplySettings();
 }
Ejemplo n.º 37
0
		/// <summary>
		/// Constructs a new instance of a HudManager. You <b>must</b> also register
		///  the GraphicsReset() function for the PluginBase.GraphicsReset event.
		/// </summary>
		/// <param name="host">PluginBase.Host</param>
		/// <param name="core">PluginBase.Core</param>
		/// <param name="startHeartbeatNow">If this is true, the heartbeat 
		///		timer will start ticking right away. This is generally 
		///		undesirable if this HudManager is created in the Startup() 
		///		method of the plugin. If this is false, you must call 
		///		<see cref="StartHeartbeat()"/> at a later time, such as during 
		///		the PlayerLogin event.</param>
		public HudManager(PluginHost host, CoreManager core, ViewWrapper defaultView, DefaultViewActiveDelegate defaultViewActive, bool startHeartbeatNow)
		{
			mHost = host;
			mCore = core;
			mDefaultView = defaultView;
			mDefaultViewActive = defaultViewActive;

			mToolTip = new ToolTipHud(this);

			mRepaintHeartbeat = new DecalTimer();
			mRepaintHeartbeat.Timeout += new Decal.Interop.Input.ITimerEvents_TimeoutEventHandler(RepaintHeartbeatDispatch);
			if (startHeartbeatNow)
				StartHeartbeat();

			//Core.WindowMessage += new EventHandler<WindowMessageEventArgs>(WindowMessageDispatch);
		}
Ejemplo n.º 38
0
		/// <summary>
		/// Cleans up the HudManager and Disposes all windows that are 
		/// being managed by this HudManager. Use this function when the 
		/// plugin is shutting down. Also be sure to unregister 
		/// <see cref="GraphicsReset()"/> from the GraphicsReset event.
		/// </summary>
		public void Dispose()
		{
			if (Disposed)
				return;

			if (mRepaintHeartbeat.Running)
				mRepaintHeartbeat.Stop();
			mRepaintHeartbeat.Timeout -= RepaintHeartbeatDispatch;
			mRepaintHeartbeat = null;

			//Core.WindowMessage -= WindowMessageDispatch;

			// Need to use a copy of the list because the Dispose() method of 
			// windows modifies mWindowList.
			UpdateHudsListCopy();
			foreach (IManagedHud hud in mHudsListCopy)
			{
				hud.Dispose();
			}
			mHudsOnTopList.Clear();
			mHudsList.Clear();
			mHudsListCopy.Clear();

			mHost = null;
			mCore = null;
			mDefaultView = null;
			mDefaultViewActive = null;

			mDisposed = true;
		}