Ejemplo n.º 1
0
        public override void OpenFunction(string AssemblyName)
        {
            _ExistFunction = _Functions.FirstOrDefault(a => a.FunctionName.ToLowerInvariant().Equals(AssemblyName.ToLowerInvariant()));
            if (_ExistFunction == null)
            {
                return;
            }

            _ExistVM = this.Workspaces.FirstOrDefault(vm => vm.GetType().Name.ToLowerInvariant().Equals(_ExistFunction.EntryTypeName.ToLowerInvariant()));
            if (_ExistVM != null)
            {
                SetActiveWorkspace(_ExistVM);
                return;
            }

            if (!_FunctionTypeDictionary.TryGetValue(_ExistFunction.EntryTypeName, out _ExistType))
            {
                try
                {
                    _TemObj = Application.LoadComponent(new Uri(_ExistFunction.AssemblyUri, UriKind.Relative));
                    Application.Current.Resources.MergedDictionaries.Add(_TemObj as ResourceDictionary);
                }
                catch
                {
                    return;
                }
                if (_TemObj != null && _TemObj is ResourceDictionary)
                {
                    _TemAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                    if (_TemAssemblies != null)
                    {
                        _ExistAssembly = _TemAssemblies.FirstOrDefault(a => a.GetName().Name.ToLowerInvariant() == _ExistFunction.AssemblyName.ToLowerInvariant());
                        if (_ExistAssembly != null)
                        {
                            _ExistType = _ExistAssembly.GetTypes().FirstOrDefault(a => a.Name.ToLowerInvariant().Equals(_ExistFunction.EntryTypeName.ToLowerInvariant()));
                        }
                    }
                }
            }

            if (_ExistType != null)
            {
                _TemObj = Activator.CreateInstance(_ExistType);
                if (_TemObj != null && _TemObj is ViewModelBase)
                {
                    _TempVM = (_TemObj as ViewModelBase);
                    _TempVM.Title = _ExistFunction.FunctionTitle;
                    _TempVM.InitializeSpecific();
                    if (!_FunctionTypeDictionary.ContainsKey(_ExistFunction.EntryTypeName))
                    {
                        _FunctionTypeDictionary.Add(_ExistFunction.EntryTypeName, _ExistType);
                    }
                    Workspaces.Add(_TempVM);
                    SetActiveWorkspace(_TempVM);
                }
            }
        }
Ejemplo n.º 2
0
 public VM_MainFrame(FunctionInfo[] functions, VO_WF_CZYB vo_WF_CZYB)
 {
     this.Title = "工作流管理";
     _Functions = functions;
     _D_CZY = vo_WF_CZYB;
 }
Ejemplo n.º 3
0
 private void OpenMainFrame(FunctionInfo[] functions, VO_WF_CZYB vo_WF_CZYB)
 {
     this.HostWindow.Hide();
     var v = new WX.WFA.MainFrame.W_MainFrame();
     var vm = new WX.WFA.MainFrame.VM_MainFrame(functions, vo_WF_CZYB);
     Application.Current.MainWindow = v;
     v.DataContext = vm;
     vm.MainWindow = v;
     vm.InitializeSpecific();
     v.WindowStartupLocation = WindowStartupLocation.CenterScreen;
     v.WindowState = WindowState.Maximized;
     v.Show();
 }