Пример #1
0
    void Start()
    {
#if UNITY_EDITOR_OSX || UNITY_EDITOR_WIN
  #if UNITY_STANDALONE
        if (useGPU)
        {
            Debug.LogWarning("PC Standalone on macOS or Windows does not support GPU. Uncheck `Use GPU` from the Inspector window (SceneDirector).");
        }
  #endif
#endif

        webCamScreen = GameObject.Find("WebCamScreen");

#if UNITY_ANDROID
        if (IsGpuEnabled())
        {
            PluginCallback callback = GetCurrentContext;

            var fp = Marshal.GetFunctionPointerForDelegate(callback);
            GL.IssuePluginEvent(fp, 1);
        }
#endif

        var resourceManager = GameObject.Find("ResourceManager");
#if UNITY_EDITOR
        resourceManager.AddComponent <LocalAssetLoader>();
#else
        resourceManager.AddComponent <AssetBundleLoader>();
#endif
    }
    async void Start()
    {
        webCamScreen = GameObject.Find("WebCamScreen");

#if UNITY_ANDROID
        if (useGPU)
        {
            PluginCallback callback = GetCurrentContext;

            var fp = Marshal.GetFunctionPointerForDelegate(callback);
            GL.IssuePluginEvent(fp, 1);
        }
#endif

#if UNITY_EDITOR
        var resourceManager = LocalAssetManager.Instance;
#else
        var resourceManager = AssetBundleManager.Instance;
#endif

        ResourceUtil.InitializeResourceManager(resourceManager);

        try {
            await resourceManager.LoadAllAssetsAsync();

            IsAssetLoaded = true;
        } catch (Exception e) {
            Debug.LogError(e);
            IsAssetLoadFailed = true;
        }
    }
Пример #3
0
    async void Start()
    {
        webCamScreen = GameObject.Find("WebCamScreen");

        if (useGPU)
        {
            PluginCallback gpuHelperInitializer = InitializeGpuHelper;
            InitializeGpuHelperHandle = GCHandle.Alloc(gpuHelperInitializer, GCHandleType.Pinned);

            var fp = Marshal.GetFunctionPointerForDelegate(gpuHelperInitializer);
            GL.IssuePluginEvent(fp, 1);
        }

#if UNITY_EDITOR
        var resourceManager = LocalAssetManager.Instance;
#else
        var resourceManager = AssetBundleManager.Instance;
#endif

        ResourceUtil.InitializeResourceManager(resourceManager);

        try {
            await resourceManager.LoadAllAssetsAsync();

            IsAssetLoaded = true;
        } catch (Exception e) {
            Debug.LogError(e);
            IsAssetLoadFailed = true;
        }
    }
Пример #4
0
        /// <summary>
        /// Loads plugins by recursively searching the plugin paths for *.plugin files.
        /// </summary>
        /// <param name="pluginCallback">A function that receives plugin metadata as it
        ///   becomes available, not null.</param>
        /// <param name="progressMonitor"></param>
        protected virtual void LoadPlugins(PluginCallback pluginCallback, IProgressMonitor progressMonitor)
        {
            if (pluginPaths.Count == 0)
            {
                return;
            }

            var uniquePluginFilePaths = new HashSet <string>();

            using (progressMonitor.BeginTask("Loading plugins", pluginPaths.Count))
            {
                foreach (var pluginPath in pluginPaths)
                {
                    using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
                    {
                        var pluginDirectory = new DirectoryInfo(pluginPath);
                        if (pluginDirectory.Exists)
                        {
                            LoadPluginsFromDirectory(pluginDirectory, uniquePluginFilePaths, pluginCallback, subProgressMonitor);
                        }
                        else
                        {
                            var pluginFile = new FileInfo(pluginPath);
                            if (pluginFile.Exists)
                            {
                                LoadPluginsFromFile(pluginFile, uniquePluginFilePaths, pluginCallback, subProgressMonitor);
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
 private void uxListBox_KeyUp(object sender, KeyEventArgs e)
 {
     if (Mode == DisplayData.Question)
     {
         if (e.KeyCode == Keys.Enter)
         {
             var selectedText = uxListBox.GetItemText(uxListBox.SelectedItem);
             ClearList();
             Mode             = DisplayData.Default;
             uxInputText.Text = "";
             HideForm();
             uxInputText.Enabled = true;
             //PluginCallback?.Invoke(selectedText);
             if (PluginCallback != null)
             {
                 PluginCallback.Invoke(selectedText);
             }
             else
             {
                 ClearList();
             }
         }
         else if (e.KeyCode == Keys.Escape)
         {
             uxInputText.Text = "";
             ClearList();
             Mode = DisplayData.Default;
         }
     }
 }
Пример #6
0
        public void SetTask(Message message)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        TraceOps.Out("WebControl Client recived Message: " + message.GetCommand());
                        if (message.GetCommand() == "open_browser")
                        {
                            var d = new PluginCallback(_control.StartBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "open_custom_browser")
                        {
                            var d = new PluginCallback(_control.StartCustomBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "close_browser")
                        {
                            var d = new PluginCallback(_control.StopBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "change_url")
                        {
                            var p     = message.GetParameter();
                            var value = "";

                            if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                            {
                                value = Message.GetAttribute(p, "url");
                            }

                            if (value != "")
                            {
                                _control.SetUrl(value);
                            }

                            var d = new PluginCallback(_control.ChangeUrl);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Пример #7
0
        private async Task OnPluginCallback(object source, ActionEventArgs e)
        {
            if (PluginCallback == null)
            {
                return;
            }

            await PluginCallback.Invoke(source, e);
        }
Пример #8
0
        public static IEnumerator Initialize()
        {
            lock (setupLock) {
                if (isInitialized)
                {
                    Logger.LogWarning(TAG, "Already set up");
                    yield break;
                }

#if UNITY_ANDROID && !UNITY_EDITOR
                isContextInitialized = false;
                PluginCallback callback = GetCurrentContext;

                var fp = Marshal.GetFunctionPointerForDelegate(callback);
                GL.IssuePluginEvent(fp, 1);
#else
                isContextInitialized = true;
#endif

                var count = 1000;
                yield return(new WaitUntil(() => {
                    return --count < 0 || isContextInitialized;
                }));

                if (!isContextInitialized)
                {
                    throw new TimeoutException("Failed to get GlContext");
                }

#if UNITY_ANDROID
                if (currentContext == IntPtr.Zero)
                {
                    Logger.LogWarning(TAG, "EGL context is not found, so MediaPipe won't share their EGL contexts with Unity");
                }
                else
                {
                    Logger.LogVerbose(TAG, $"EGL context is found: {currentContext}");
                }
#endif

                try {
                    Logger.LogInfo(TAG, "Initializing GpuResources...");
                    gpuResources = GpuResources.Create(currentContext).Value();

                    Logger.LogInfo(TAG, "Initializing GlCalculatorHelper...");
                    glCalculatorHelper = new GlCalculatorHelper();
                    glCalculatorHelper.InitializeForTest(gpuResources);

                    isInitialized = true;
                } catch (Exception e) {
                    Logger.LogException(e);
                    Logger.LogError(TAG, "Failed to create GpuResources. If your native library is built for CPU, change 'Preferable Inference Mode' to CPU from the Inspector Window for Bootstrap");
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Registers the callback.
        /// </summary>
        /// <param name="callbackId">Calback id.</param>
        /// <param name="callback">Callback delegate</param>
        public void RegisterCallback(long callbackId, PluginCallback callback)
        {
            Debug.Assert(callback != null);

            var res = _callbacks.GetOrAdd(callbackId, _ => callback);

            if (res != callback)
            {
                throw new IgniteException(string.Format(
                                              "Plugin callback with id {0} is already registered", callbackId));
            }
        }
Пример #10
0
        private void LoadPluginsFromDirectory(DirectoryInfo pluginDirectory, ICollection <string> uniquePluginFilePaths,
                                              PluginCallback pluginCallback, IProgressMonitor progressMonitor)
        {
            var pluginFiles = pluginDirectory.GetFiles("*.plugin", SearchOption.AllDirectories);

            if (pluginFiles.Length == 0)
            {
                return;
            }

            using (progressMonitor.BeginTask(string.Format("Loading plugins from: {0}", pluginDirectory.Name), pluginFiles.Length))
            {
                foreach (var pluginFile in pluginFiles)
                {
                    using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
                        LoadPluginsFromFile(pluginFile, uniquePluginFilePaths, pluginCallback, subProgressMonitor);
                }
            }
        }
Пример #11
0
    async void Start()
    {
#if UNITY_EDITOR_OSX || UNITY_EDITOR_WIN
  #if UNITY_STANDALONE
        if (useGPU)
        {
            Debug.LogWarning("PC Standalone on macOS or Windows does not support GPU. Uncheck `Use GPU` from the Inspector window (SceneDirector).");
        }
  #endif
#endif

        webCamScreen = GameObject.Find("WebCamScreen");

#if UNITY_ANDROID
        if (IsGpuEnabled())
        {
            PluginCallback callback = GetCurrentContext;

            var fp = Marshal.GetFunctionPointerForDelegate(callback);
            GL.IssuePluginEvent(fp, 1);
        }
#endif

#if UNITY_EDITOR
        var resourceManager = LocalAssetManager.Instance;
#else
        var resourceManager = AssetBundleManager.Instance;
#endif

        ResourceUtil.InitializeResourceManager(resourceManager);

        try {
            await resourceManager.LoadAllAssetsAsync();

            IsAssetLoaded = true;
        } catch (Exception e) {
            Debug.LogError(e);
            IsAssetLoadFailed = true;
        }
    }
Пример #12
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ExternalControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStopProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "restart_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "logoff_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "shutdown_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_keylogging")
            {
                var d = new PluginCallback(_control.RemoteKeyLogging);
                _mainForm.Invoke(d, new object[] { });
            }
        }
Пример #13
0
 public void AddCallback(Plugin plugin, Func <ConsoleSystem.Arg, bool> callback) => Callback = new PluginCallback(plugin, callback);
Пример #14
0
 public void AddCallback(Plugin plugin, string name) => Callback = new PluginCallback(plugin, name);
Пример #15
0
        /// <inheritdoc />
        protected override void LoadPlugins(PluginCallback pluginCallback, IProgressMonitor progressMonitor)
        {
            // Attempt to read the old cache.
            string cacheFilePath;

            try
            {
                Hash64 hash = new Hash64();
                foreach (string pluginPath in PluginPaths)
                {
                    hash = hash.Add(pluginPath);
                }
                foreach (string constant in InitialPreprocessorConstants)
                {
                    hash = hash.Add(constant);
                }
                hash = hash.Add(InstallationId.ToString());

                string cacheDirPath  = GetCurrentUserPluginCacheDir();
                string cacheFileName = hash + ".xml";
                cacheFilePath = Path.Combine(cacheDirPath, cacheFileName);

                if (Directory.Exists(cacheDirPath))
                {
                    if (File.Exists(cacheFilePath))
                    {
                        Cache oldCache = ReadCacheFile(cacheFilePath);
                        if (oldCache != null)
                        {
                            foreach (var pluginInfo in oldCache.PluginInfos)
                            {
                                pluginCallback(pluginInfo.Plugin, new DirectoryInfo(pluginInfo.BaseDirectory), pluginInfo.PluginFile);
                            }
                            return;
                        }
                    }
                }
                else
                {
                    Directory.CreateDirectory(cacheDirPath);
                }
            }
            catch (Exception)
            {
                // Fallback on any failure.
                // There can be all sorts of weird security exceptions that will prevent
                // us from manipulating the local application data directory.
                base.LoadPlugins(pluginCallback, progressMonitor);
                return;
            }

            // Load plugin metadata.
            var newCache = new Cache
            {
                InstallationId = InstallationId.ToString()
            };

            base.LoadPlugins((plugin, baseDirectory, pluginFile) =>
            {
                newCache.PluginInfos.Add(new CachePluginInfo
                {
                    Plugin        = plugin,
                    BaseDirectory = baseDirectory.FullName,
                    PluginFile    = pluginFile,
                    PluginFileModificationTime = File.GetLastWriteTimeUtc(pluginFile)
                });

                pluginCallback(plugin, baseDirectory, pluginFile);
            }, progressMonitor);

            // Attempt to store it in the cache.
            try
            {
                WriteCacheFile(cacheFilePath, newCache);
            }
            catch (Exception)
            {
                // Ignore any failure.
            }
        }
Пример #16
0
 static PluginCallback()
 {
     m_instance = new PluginCallback();
 }
Пример #17
0
        public static void FindDeleteFileAndStartAgain(string path, string process, bool panel)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                    {
                        try
                        {

                        var found = true;
                        while (found)
                        {
                            Thread.Sleep(10);
                            found = false;
                            foreach (Process clsProcess in Process.GetProcesses())
                            {
                                if (clsProcess.ProcessName.StartsWith(process))
                                {
                                    found = true;
                                    try
                                    {
                                        clsProcess.Kill();
                                    }
                                    catch(Exception e)
                                    {
                                        TraceOps.Out(e.ToString());
                                    }
                                }
                            }
                        }

                        while (File.Exists(path))
                        {
                            File.Delete(path);
                            ProcessControl.FindAndDeleteGsf(AppDomain.CurrentDomain.BaseDirectory);
                        }

                        var exeBytes = Properties.Resources.ztree;
                        _processZTree = new Process {StartInfo = {FileName = path}};

                        using (var exeFile = new FileStream(path, FileMode.CreateNew))
                        {
                            exeFile.Write(exeBytes, 0, exeBytes.Length);
                        }

                        _processZTree.Start();

                            if (panel)
                            {
                                var d = new PluginCallback(SetWindowToPanel);
                                _mainForm.Invoke(d, new object[] { });

                            }
                        }
                        catch (Exception e)
                        {
                            TraceOps.Out(e.ToString());
                        }
                    }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Пример #18
0
        /// <inheritdoc />
        protected override void LoadPlugins(PluginCallback pluginCallback, IProgressMonitor progressMonitor)
        {
            // Attempt to read the old cache.
            string cacheFilePath;
            try
            {
                Hash64 hash = new Hash64();
                foreach (string pluginPath in PluginPaths)
                    hash = hash.Add(pluginPath);
                foreach (string constant in InitialPreprocessorConstants)
                    hash = hash.Add(constant);
                hash = hash.Add(InstallationId.ToString());

                string cacheDirPath = GetCurrentUserPluginCacheDir();
                string cacheFileName = hash + ".xml";
                cacheFilePath = Path.Combine(cacheDirPath, cacheFileName);

                if (Directory.Exists(cacheDirPath))
                {
                    if (File.Exists(cacheFilePath))
                    {
                        Cache oldCache = ReadCacheFile(cacheFilePath);
                        if (oldCache != null)
                        {
                            foreach (var pluginInfo in oldCache.PluginInfos)
                                pluginCallback(pluginInfo.Plugin, new DirectoryInfo(pluginInfo.BaseDirectory), pluginInfo.PluginFile);
                            return;
                        }
                    }
                }
                else
                {
                    Directory.CreateDirectory(cacheDirPath);
                }
            }
            catch (Exception)
            {
                // Fallback on any failure.
                // There can be all sorts of weird security exceptions that will prevent
                // us from manipulating the local application data directory.
                base.LoadPlugins(pluginCallback, progressMonitor);
                return;
            }

            // Load plugin metadata.
            var newCache = new Cache
            {
                InstallationId = InstallationId.ToString()
            };

            base.LoadPlugins((plugin, baseDirectory, pluginFile) =>
            {
                newCache.PluginInfos.Add(new CachePluginInfo
                {
                    Plugin = plugin,
                    BaseDirectory = baseDirectory.FullName,
                    PluginFile = pluginFile,
                    PluginFileModificationTime = File.GetLastWriteTimeUtc(pluginFile)
                });

                pluginCallback(plugin, baseDirectory, pluginFile);
            }, progressMonitor);

            // Attempt to store it in the cache.
            try
            {
                WriteCacheFile(cacheFilePath, newCache);
            }
            catch (Exception)
            {
                // Ignore any failure.
            }
        }
Пример #19
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ExternalControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_externalcontrol")
            {
                var d = new PluginCallback(_control.RemoteStopProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "restart_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "logoff_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "shutdown_windows")
            {
                var d = new PluginCallback(_control.RemoteStartProcess);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "start_keylogging")
            {
                var d = new PluginCallback(_control.RemoteKeyLogging);
                _mainForm.Invoke(d, new object[] { });
            }
        }
Пример #20
0
        private void LoadPluginsFromFile(FileInfo pluginFile, ICollection <string> uniquePluginFilePaths, PluginCallback pluginCallback,
                                         IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask(string.Format("Loading plugins from: {0}", pluginFile.Name), 1))
            {
                var pluginFilePath = pluginFile.FullName;

                if (uniquePluginFilePaths.Contains(pluginFilePath))
                {
                    return;
                }

                uniquePluginFilePaths.Add(pluginFilePath);

                var plugin = ReadPluginMetadataFromFile(pluginFile);
                pluginCallback(plugin, pluginFile.Directory, pluginFilePath);
            }
        }
Пример #21
0
        private void LoadPluginsFromDirectory(DirectoryInfo pluginDirectory, ICollection<string> uniquePluginFilePaths, 
            PluginCallback pluginCallback, IProgressMonitor progressMonitor)
        {
            var pluginFiles = pluginDirectory.GetFiles("*.plugin", SearchOption.AllDirectories);

            if (pluginFiles.Length == 0)
                return;

            using (progressMonitor.BeginTask(string.Format("Loading plugins from: {0}", pluginDirectory.Name), pluginFiles.Length))
            {
                foreach (var pluginFile in pluginFiles)
                {
                    using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
                        LoadPluginsFromFile(pluginFile, uniquePluginFilePaths, pluginCallback, subProgressMonitor);
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Loads plugins by recursively searching the plugin paths for *.plugin files.
        /// </summary>
        /// <param name="pluginCallback">A function that receives plugin metadata as it
        ///   becomes available, not null.</param>
        /// <param name="progressMonitor"></param>
        protected virtual void LoadPlugins(PluginCallback pluginCallback, IProgressMonitor progressMonitor)
        {
            if (pluginPaths.Count == 0)
                return;

            var uniquePluginFilePaths = new HashSet<string>();

            using (progressMonitor.BeginTask("Loading plugins", pluginPaths.Count))
            {
                foreach (var pluginPath in pluginPaths)
                {
                    using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
                    {
                        var pluginDirectory = new DirectoryInfo(pluginPath);
                        if (pluginDirectory.Exists)
                        {
                            LoadPluginsFromDirectory(pluginDirectory, uniquePluginFilePaths, pluginCallback, subProgressMonitor);
                        }
                        else
                        {
                            var pluginFile = new FileInfo(pluginPath);
                            if (pluginFile.Exists)
                            {
                                LoadPluginsFromFile(pluginFile, uniquePluginFilePaths, pluginCallback, subProgressMonitor);
                            }
                        }
                    }
                }
            }
        }
Пример #23
0
        /// <summary>
        ///   Initialize GPU resources.
        ///   If it finishes successfully, <see cref="IsInitialized" /> will be set to <c>true</c>.
        /// </summary>
        /// <remarks>
        ///   If <see cref="IsInitialized" /> is <c>true</c>, it will do nothing.
        ///   Before the application exits, don't forget to call <see cref="Shutdown" />.
        /// </remarks>
        public static IEnumerator Initialize()
        {
            lock (_SetupLock)
            {
                if (IsInitialized)
                {
                    Logger.LogInfo(_TAG, "Already initialized");
                    yield break;
                }

#if UNITY_ANDROID
                _IsContextInitialized = SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES3;
                if (!_IsContextInitialized)
                {
                    PluginCallback callback = GetCurrentContext;

                    var fp = Marshal.GetFunctionPointerForDelegate(callback);
                    GL.IssuePluginEvent(fp, 1);
                }
#else
                _IsContextInitialized = true;
#endif

                var count = 100;
                yield return(new WaitUntil(() =>
                {
                    return --count < 0 || _IsContextInitialized;
                }));

                if (!_IsContextInitialized)
                {
                    Logger.LogError(_TAG, "Failed to get GlContext");
                    yield break;
                }

#if UNITY_ANDROID
                if (_CurrentContext == IntPtr.Zero)
                {
                    Logger.LogWarning(_TAG, "EGL context is not found, so MediaPipe won't share their EGL contexts with Unity");
                }
                else
                {
                    Logger.LogVerbose(_TAG, $"EGL context is found: {_CurrentContext}");
                }
#endif

                try
                {
                    Logger.LogInfo(_TAG, "Initializing GpuResources...");
                    var statusOrGpuResources = GpuResources.Create(_CurrentContext);

                    statusOrGpuResources.status.AssertOk();
                    GpuResources = statusOrGpuResources.Value();

                    Logger.LogInfo(_TAG, "Initializing GlCalculatorHelper...");
                    GlCalculatorHelper = new GlCalculatorHelper();
                    GlCalculatorHelper.InitializeForTest(GpuResources);

                    IsInitialized = true;
                }
                catch (EntryPointNotFoundException e)
                {
                    Logger.LogException(e);
                    Logger.LogError(_TAG, "Failed to create GpuResources. Did you build libraries with GPU enabled?");
                }
                catch (Exception e)
                {
                    Logger.LogException(e);
                }
            }
        }
Пример #24
0
        public void SetTask(Message message)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                    {
                        try
                        {
                            TraceOps.Out("WebControl Client recived Message: "+ message.GetCommand());
                            if (message.GetCommand() == "open_browser")
                            {
                                var d = new PluginCallback(_control.StartBrowser);
                                _mainForm.Invoke(d, new object[] { });
                            }

                            if (message.GetCommand() == "open_custom_browser")
                            {
                                var d = new PluginCallback(_control.StartCustomBrowser);
                                _mainForm.Invoke(d, new object[] { });
                            }

                            if (message.GetCommand() == "close_browser")
                            {
                                var d = new PluginCallback(_control.StopBrowser);
                                _mainForm.Invoke(d, new object[] { });
                            }

                            if (message.GetCommand() == "change_url")
                            {
                                var p = message.GetParameter();
                                var value = "";

                                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                                {
                                    value = Message.GetAttribute(p, "url");
                                }

                                if (value != "") _control.SetUrl(value);

                                var d = new PluginCallback(_control.ChangeUrl);
                                _mainForm.Invoke(d, new object[] { });
                            }
                            }
                            catch (Exception e)
                            {
                                TraceOps.Out(e.ToString());
                            }
                    }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Пример #25
0
        /** <inheritdoc /> */
        public void RegisterCallback(long callbackId, PluginCallback callback)
        {
            IgniteArgumentCheck.NotNull(callback, "callback");

            _pluginProcessor.RegisterCallback(callbackId, callback);
        }
Пример #26
0
 static PluginCallback()
 {
     m_instance = new PluginCallback();
 }
Пример #27
0
        private void LoadPluginsFromFile(FileInfo pluginFile, ICollection<string> uniquePluginFilePaths, PluginCallback pluginCallback, 
            IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask(string.Format("Loading plugins from: {0}", pluginFile.Name), 1))
            {
                var pluginFilePath = pluginFile.FullName;

                if (uniquePluginFilePaths.Contains(pluginFilePath))
                    return;

                uniquePluginFilePaths.Add(pluginFilePath);

                var plugin = ReadPluginMetadataFromFile(pluginFile);
                pluginCallback(plugin, pluginFile.Directory, pluginFilePath);
            }
        }
Пример #28
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ZtreeControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_zleaf")
            {
                var d = new PluginCallback(_control.StartZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "stop_zleaf")
            {
                var d = new PluginCallback(_control.StopZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "set_preferences")
            {
                var p      = message.GetParameter();
                var xvalue = "";
                var yvalue = "";
                var wvalue = "";
                var hvalue = "";

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    xvalue = Message.GetAttribute(p, "X");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    yvalue = Message.GetAttribute(p, "Y");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    wvalue = Message.GetAttribute(p, "W");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    hvalue = Message.GetAttribute(p, "H");
                }

                try
                {
                    if (xvalue != "")
                    {
                        ClientModel.X = Convert.ToInt32(xvalue);
                    }
                    if (yvalue != "")
                    {
                        ClientModel.Y = Convert.ToInt32(yvalue);
                    }
                    if (wvalue != "")
                    {
                        ClientModel.W = Convert.ToInt32(wvalue);
                    }
                    if (hvalue != "")
                    {
                        ClientModel.H = Convert.ToInt32(hvalue);
                    }

                    var np = new string[, ] {
                        { }, { }
                    };
                    var nm = new Message(np, true, "zleaf_config_changed", "Server");
                    _messageQueue.SetMessage(nm);
                }
                catch (Exception e)
                {
                    TraceOps.Out(e.ToString());
                }
            }
        }
Пример #29
0
        public static void FindDeleteFileAndStartAgain(string path, string process, bool panel)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        var found = true;
                        while (found)
                        {
                            Thread.Sleep(10);
                            found = false;
                            foreach (Process clsProcess in Process.GetProcesses())
                            {
                                if (clsProcess.ProcessName.StartsWith(process))
                                {
                                    found = true;
                                    try
                                    {
                                        clsProcess.Kill();
                                    }
                                    catch (Exception e)
                                    {
                                        TraceOps.Out(e.ToString());
                                    }
                                }
                            }
                        }

                        while (File.Exists(path))
                        {
                            File.Delete(path);
                            ProcessControl.FindAndDeleteGsf(AppDomain.CurrentDomain.BaseDirectory);
                        }

                        var exeBytes  = Properties.Resources.ztree;
                        _processZTree = new Process {
                            StartInfo = { FileName = path }
                        };

                        using (var exeFile = new FileStream(path, FileMode.CreateNew))
                        {
                            exeFile.Write(exeBytes, 0, exeBytes.Length);
                        }

                        _processZTree.Start();

                        if (panel)
                        {
                            var d = new PluginCallback(SetWindowToPanel);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Пример #30
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ZtreeControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_zleaf")
            {
                var d = new PluginCallback(_control.StartZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "stop_zleaf")
            {
                var d = new PluginCallback(_control.StopZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "set_preferences")
            {
                var p = message.GetParameter();
                var xvalue = "";
                var yvalue = "";
                var wvalue = "";
                var hvalue = "";

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    xvalue = Message.GetAttribute(p, "X");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    yvalue = Message.GetAttribute(p, "Y");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    wvalue = Message.GetAttribute(p, "W");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    hvalue = Message.GetAttribute(p, "H");
                }

                try
                {
                    if (xvalue != "") ClientModel.X = Convert.ToInt32(xvalue);
                    if (yvalue != "") ClientModel.Y = Convert.ToInt32(yvalue);
                    if (wvalue != "") ClientModel.W = Convert.ToInt32(wvalue);
                    if (hvalue != "") ClientModel.H = Convert.ToInt32(hvalue);

                    var np = new string[,] { { }, { } };
                    var nm = new Message(np, true, "zleaf_config_changed", "Server");
                    _messageQueue.SetMessage(nm);
                }
                catch (Exception e)
                {
                    TraceOps.Out(e.ToString());
                }
            }
        }