Пример #1
0
        public void Open(object o)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                IDataExchange gvService  = ServiceContainer.CreateInstance().Resolve <IDataExchange>("DataExchangeService");
                string        selectPath = fbd.SelectedPath;
                string        treepath   = Path.Combine(selectPath, treeSvaeName);
                string        propPath   = Path.Combine(selectPath, prooertyName);
                string        dataPath   = Path.Combine(selectPath, data);
                if (File.Exists(treepath))
                {
                    service.Invoke("panel11", "LoadFromFile", new object[1] {
                        treepath
                    });
                }
                if (File.Exists(propPath))
                {
                    service.Invoke("panel12", "LoadFromFile", new object[1] {
                        propPath
                    });
                }
                if (File.Exists(dataPath))
                {
                    gvService.LoadFromFile(dataPath);
                }
                gvService["ProjectPath"] = fbd.SelectedPath;
            }
        }
Пример #2
0
 public object CreateInstance(Type type,
                              IEnumerable <KeyValuePair <string, object> > values = null,
                              IServiceProvider serviceProvider = null,
                              params Attribute[] attributes)
 {
     return(_services.CreateInstance(type, values, serviceProvider, attributes));
 }
        private object callControlMethod(InvokeMethodAssembly s, params object[] o)
        {
            if (cAddressService == null)
            {
                cAddressService = ServiceContainer.CreateInstance().Resolve <IControlAddress>("ControlAddressService");


                //pmanager = ServiceContainer.CreateInstance().Resolve<Plugin.IPluginManager>("PluginManagerService");
            }

            Component c         = null;
            string    panelName = cAddressService.GetNameByTypeName(s.TypeName, null);

            if (panelName == null)
            {
                c = cAddressService.GetUserControlInPanel(s.TypeName);
            }
            else
            {
                c = cAddressService.GetUserControlInPanel(panelName);
            }

            MethodInfo minfo = c.GetType().GetMethod(s.Method);

            return(minfo.Invoke(c, o));
        }
 public void EventDefinedBarToggleSwitchItem_CheckedChanged(object sender, ItemClickEventArgs e)
 {
     if (!string.IsNullOrEmpty(this.ChangeMethodName))
     {
         IInvokeMethod service = ServiceContainer.CreateInstance().Resolve <IInvokeMethod>("InvokeMethodService");
         service.Invoke(this.ChangeMethodName, new object[1] {
             sender
         });
     }
 }
Пример #5
0
 public void button_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (!string.IsNullOrEmpty(this.ItemClickMethodName))
     {
         IInvokeMethod service = ServiceContainer.CreateInstance().Resolve <IInvokeMethod>("InvokeMethodService");
         service.Invoke(this.ItemClickMethodName, new object[1] {
             sender
         });
     }
 }
Пример #6
0
        public ScanSettingForm()
        {
            InitializeComponent();

            _container = new ServiceContainer();
            _container.Bind(typeof(IStreamProvider), typeof(SaraffStreamProvider));
            _twain = _container.CreateInstance <Twain32>();
            bindingSource.DataSource   = typeof(ScanSetting);
            bindingSRouting.DataSource = typeof(Routing);
        }
 public void EventDefinedSkinRibbonGalleryBarItem_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (!string.IsNullOrEmpty(this.MouseClickMethodName))
     {
         IInvokeMethod service = ServiceContainer.CreateInstance().Resolve <IInvokeMethod>("InvokeMethodService");
         service.Invoke(this.MouseClickMethodName, new object[1] {
             sender
         });
     }
 }
Пример #8
0
        public NewScanForm()
        {
            InitializeComponent();

            _container = new ServiceContainer();
            _container.Bind(typeof(IStreamProvider), typeof(SaraffStreamProvider));
            _twain                   = _container.CreateInstance <Twain32>();
            _twain.EndXfer          += EndXfer;
            _twain.AcquireCompleted += AcquireCompleted;
            _imageIndex              = 0;
            _images                  = new List <Image>();
            _scannedItems            = new List <ScannedImage>();
            _settingsManager         = new ScanSettingsManager();
            _previewing              = false;
            _closingWindow           = false;
        }
Пример #9
0
        public void testDataExchange()
        {
            IDataExchange gvService = ServiceContainer.CreateInstance().Resolve <IDataExchange>("DataExchangeService");
            //获取值
            string projectPath = gvService["ProjectPath"];

            //设置值

            //保存到文件
            MessageBox.Show(projectPath);
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                gvService["ProjectPath"] = fbd.SelectedPath;
                gvService.SaveToFile(null);
            }
        }
Пример #10
0
        private void LoadSample(int sampleIndex)
        {
            EndSample();
            CloseWindows();

            var type = _samples[sampleIndex];

            // Use the service container to create an instance of the sample. The service
            // container will automatically provide the sample constructor with the necessary
            // arguments.
            try
            {
                _sample = (Sample)_services.CreateInstance(type);
            }
            catch (TargetInvocationException exception)
            {
                // Samples are created using reflection. If the sample constructor throws an exception,
                // we land here.

                // Throw inner exception, which is more useful.
                throw exception.InnerException;

                // To break at the actual code line which caused the exception, you can tell the Visual
                // studio debugger to break at "first chance" exceptions:
                // Open the exception settings in Visual Studio using the menu
                //   Debug > Windows > Exception Settings (VS 2015)
                // or
                //   Debug > Exceptions... (VS 2013 and older)
                // and check the check box next to "Common Language Runtime Exceptions".
                // If you run the game again, then the debugger should break where the
                // inner exception is created and not on this line.
            }

            _sampleIndex     = sampleIndex;
            _nextSampleIndex = sampleIndex;
            _game.Components.Add(_sample);

            UpdateHelp();

            if (_optionsTabControl.Items.Count > 1)
            {
                _optionsTabControl.SelectedIndex = _optionsTabControl.Items.Count - 1;
            }
        }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="typeName">配置的type元素的Name属性</param>
        /// <param name="methodName">调用的方法名</param>
        /// <param name="param">调用方法的输入参数</param>
        /// <returns>调用方法的返回值</returns>
        public object Invoke(string typeName, string methodName, object[] param)
        {
            InvokeMethodAssembly s = null;
            string key             = string.Format("{0}_{1}", typeName, methodName);

            if (callBackAssemblyCache.ContainsKey(key))
            {
                s = callBackAssemblyCache[key];
                if (s.FromXml)
                {
                    IControlAddress controlAddress = ServiceContainer.CreateInstance().Resolve <IControlAddress>("ControlAddressService");
                    string          name           = controlAddress.GetNameByTypeName(typeName, typeName);

                    s = callBackAssemblyCache[key];

                    if (s.IsPlugin)
                    {
                        return(callControlMethod(s, param));
                    }
                    else
                    {
                        return(callNormalMethod(s, param));
                    }
                }
                else
                {
                    if (s.IsPlugin)
                    {
                        return(callControlMethod(s, param));
                    }
                    else
                    {
                        return(callNormalMethod(s, param));
                    }
                }
            }

            if (s == null)
            {
                throw new ApplicationException("找不到调用方法,方法调用失败");
            }

            return(null);
        }
Пример #12
0
        private void FanRibbonFormContainer_FormClosed(object sender, FormClosedEventArgs e)
        {
            //string xml = Directory.GetCurrentDirectory() + "\\Config\\layout.xml";
            //this.dockManager1.SaveLayoutToXml(xml);

            HookHolder.Dispose();

            IControlAddress controlAddressService = ServiceContainer.CreateInstance().Resolve <IControlAddress>("ControlAddressService");

            if (controlAddressService != null)
            {
                controlAddressService.Unregister();
            }

            this.image16Collection.Images.Clear();
            this.image32Collection.Images.Clear();

            GlobalParamService.Clear();
        }
Пример #13
0
        private void LoadSample(int sampleIndex)
        {
            EndSample();

            var type = _samples[sampleIndex];

            // Use the service container to create and instance of the sample. The service
            // container will automatically provide the sample constructor with the necessary
            // arguments.
            // If this code throws an exception, then open the Visual Studio menu
            //   Debug > Exceptions...
            // and check the check box next to "Common Language Runtime Exceptions".
            // If you run the game again, then the debugger should break where the
            // inner exception is created and not on this line.
            _sample          = (GameComponent)_services.CreateInstance(type);
            _sampleIndex     = sampleIndex;
            _nextSampleIndex = sampleIndex;
            Game.Components.Add(_sample);
        }
Пример #14
0
        public void Save(object o)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                IDataExchange gvService = ServiceContainer.CreateInstance().Resolve <IDataExchange>("DataExchangeService");
                gvService["ProjectPath"] = fbd.SelectedPath;
                string treepath = Path.Combine(gvService["ProjectPath"], treeSvaeName);
                string propPath = Path.Combine(gvService["ProjectPath"], prooertyName);
                string dataPath = Path.Combine(gvService["ProjectPath"], data);

                service.Invoke("panel11_SaveToFile", new object[1] {
                    treepath
                });


                service.Invoke("panel12_SaveToFile", new object[1] {
                    propPath
                });

                gvService.SaveToFile(dataPath);
            }
        }
 private IControlAddress GetAddressService()
 {
     return(ServiceContainer.CreateInstance().Resolve <IControlAddress>("ControlAddressService"));
 }