示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GraphicsDevice(IHostControl host)
        {
            if (host == null)
                throw new ArgumentNullException("host");

            this.host = host;
        }
示例#2
0
        private List <IPluginInfo> LoadPluginsFromAssembly(string assemblyLocation, IHostControl hostControl)
        {
            List <IPluginInfo> retPlugins = new List <IPluginInfo>();

            //To avoid exception System.NotSupportedException
            byte[]   file    = File.ReadAllBytes(assemblyLocation);
            Assembly aPlugin = Assembly.Load(file);

            Localization.LocalizationProvider.Instance.AddAssembly(aPlugin.FullName);

            Type[] tPluginTypes = aPlugin.GetTypes();

            foreach (Type tPluginType in tPluginTypes)
            {
                if (tPluginType.GetInterface("IPlugin") != null)
                {
                    IPlugin plugin = Activator.CreateInstance(tPluginType) as IPlugin;

                    // If we have a new instance of a plugin, initialize it and add it to return list
                    if (plugin != null)
                    {
                        plugin.HostControl = hostControl;
                        plugin.Initialize();
                        retPlugins.Add(new PluginInfo(plugin, tPluginType.FullName, Path.GetFileName(assemblyLocation)));
                    }
                }
            }

            return(retPlugins);
        }
示例#3
0
        public bool LoadPlugins(IHostControl host)
        {
            // Default return value to failure
            bool bFailed = true;

            // Clear any existing plugins
            _Plugins = new List<IPluginInfo>();
            //_Plugins.Clear();
            string directoryPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
            if (directoryPath == null) return true;

            // Load core plugins.
            string corePluginsPath = Path.Combine(directoryPath, "GestureSign.CorePlugins.dll");
            if (File.Exists(corePluginsPath))
            {
                _Plugins.AddRange(LoadPluginsFromAssembly(corePluginsPath, host));
                bFailed = false;
            }

            // Load extra plugins.
            string extraPlugins = Path.Combine(directoryPath, "Plugins");
            if (Directory.Exists(extraPlugins))
                foreach (string sFilePath in Directory.GetFiles(extraPlugins, "*.dll"))
                {

                    _Plugins.AddRange(LoadPluginsFromAssembly(sFilePath, host));
                    bFailed = false;

                }

            return bFailed;
        }
示例#4
0
        public void Load(IHostControl host)
        {
            // Create empty list of plugins, then load as many as possible from plugin directory
            LoadPlugins(host);

            if (host == null) return;
            host.TouchCapture.GestureRecognized += TouchCapture_GestureRecognized;
        }
示例#5
0
        public void Load(IHostControl host)
        {
            // Create empty list of plugins, then load as many as possible from plugin directory
            LoadPlugins(host);

            if (host == null)
            {
                return;
            }
            host.TouchCapture.GestureRecognized += TouchCapture_GestureRecognized;
        }
示例#6
0
        public void Load(IHostControl host, SynchronizationContext syncContext = null)
        {
            _mainContext = syncContext;
            // Create empty list of plugins, then load as many as possible from plugin directory
            LoadPlugins(host);

            if (host == null)
            {
                return;
            }
            host.PointCapture.GestureRecognized += PointCapture_GestureRecognized;
        }
示例#7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="host"></param>
        public Mouse(IHostControl host)
        {
            if (host == null)
                throw new ArgumentNullException("host");

            this.host = host;

            this.DoubleClickRate = TimeSpan.FromMilliseconds(_GetDoubleClickTime());

            this.position = Point.Zero;
            this.oldPosition = Point.Zero;

            this.buttons = new bool[ButtonCount];
            this.oldButtons = new bool[ButtonCount];
        }
示例#8
0
        public bool LoadPlugins(IHostControl host)
        {
            // Default return value to failure
            bool bFailed = true;

            // Clear any existing plugins
            _Plugins = new List <IPluginInfo>();
            //_Plugins.Clear();
            string directoryPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            if (directoryPath == null)
            {
                return(true);
            }

            // Load core plugins.
            string corePluginsPath = Path.Combine(directoryPath, "GestureSign.CorePlugins.dll");

            if (File.Exists(corePluginsPath))
            {
                _Plugins.AddRange(LoadPluginsFromAssembly(corePluginsPath, host));
                bFailed = false;
            }

            var extraPluginsPath = Path.Combine(directoryPath, "Plugins");

            if (Directory.Exists(extraPluginsPath))
            {
                // Load extra plugins.
                foreach (string sFilePath in Directory.GetFiles(extraPluginsPath, "*.dll"))
                {
                    _Plugins.AddRange(LoadPluginsFromAssembly(sFilePath, host));
                    bFailed = false;
                }
            }


            return(bFailed);
        }
示例#9
0
        /// <summary>
        /// Called when the GraphicsManager is being disposed.
        /// </summary>
        /// <param name="disposing"></param>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.host != null)
                {
                    this.host.DisplaySizeChanged -= this.Host_DisplaySizeChanged;
                    this.host = null;
                }

                if (this.InternalDevice != null)
                {
                    this.InternalDevice.Dispose();
                    this.InternalDevice = null;
                }
            }
        }
示例#10
0
        private List<IPluginInfo> LoadPluginsFromAssembly(string assemblyLocation, IHostControl hostControl)
        {
            List<IPluginInfo> retPlugins = new List<IPluginInfo>();

            //To avoid exception System.NotSupportedException
            byte[] file = File.ReadAllBytes(assemblyLocation);
            Assembly aPlugin = Assembly.Load(file);

            Type[] tPluginTypes = aPlugin.GetTypes();

            foreach (Type tPluginType in tPluginTypes)
                if (tPluginType.GetInterface("IPlugin") != null)
                {
                    IPlugin plugin = Activator.CreateInstance(tPluginType) as IPlugin;

                    // If we have a new instance of a plugin, initialize it and add it to return list
                    if (plugin != null)
                    {
                        plugin.HostControl = hostControl;
                        plugin.Initialize();
                        retPlugins.Add(new PluginInfo(plugin, tPluginType.FullName, Path.GetFileName(assemblyLocation)));
                    }
                }

            return retPlugins;
        }