Beispiel #1
0
 public void SetContSize(int arrsize, int MaxWid, RootData rda)
 {
     MaximumWid = MaxWid;
     if (_Child != null)
     {
         IModuleInterface imi = _Child.GetComponent <IModuleInterface>();
         imi.HeightAllowance = arrsize;
         int size = imi.DesiredWidth + arrsize;
         if (size < MaximumWid)
         {
             MaxWid = size;
         }
     }
     _ContRT.pivot         = new Vector2(0, 1);
     _ContRT.sizeDelta     = new Vector2(MaxWid - arrsize, arrsize);
     _ContRT.localPosition = new Vector3(arrsize, 0, 0);
     if (_Child != null)
     {
         RectTransform rt = _Child.GetComponent <RectTransform>();
         rt.pivot         = new Vector2(0, 1);
         rt.sizeDelta     = _ContRT.sizeDelta;
         rt.localPosition = new Vector3(arrsize, 0, 0);
         IModuleInterface imi = _Child.GetComponent <IModuleInterface>();
         imi.SizeEvent(_ContRT);
     }
     _Width = MaxWid;
 }
Beispiel #2
0
        void LoadModules()
        {
            //Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder
            //FileInfo fi = new FileInfo()
            //string modulePath = string.Format(@"{0}\Modules\UI\", AppDomain.CurrentDomain.BaseDirectory);
            string modulePath = string.Format(@"{0}\Modules\UI\", Directory.GetCurrentDirectory());

            string[] strModuleLst = Directory.GetFiles(modulePath, "*.dll", SearchOption.TopDirectoryOnly);
            Assembly plugin;

            Type[] types;
            foreach (string strModule in strModuleLst)
            {
                //C# load dll method
                plugin = Assembly.LoadFrom(strModule);
                types  = plugin.GetTypes();

                foreach (Type t in types)
                {
                    //Check Module interface
                    if (t.GetInterface("IModuleInterface", true) == null)
                    {
                        continue;
                    }
                    //Check is main user control
                    if (!typeof(System.Windows.Controls.UserControl).IsAssignableFrom(t))
                    {
                        continue;
                    }
                    //Check main user control name
                    if (t.Name != "MainControl")
                    {
                        continue;
                    }
                    IModuleInterface iModule = (IModuleInterface)t.InvokeMember(null,
                                                                                BindingFlags.DeclaredOnly |
                                                                                BindingFlags.Public | BindingFlags.NonPublic |
                                                                                BindingFlags.Instance | BindingFlags.CreateInstance,
                                                                                null, null, null);
                    //Check module is support and load into memory
                    if (iModule.isPlatformSupported())
                    {
                        Button btnModule = new Button();
                        btnModule.Name    = string.Format("btn{0}", iModule.moduleName);
                        btnModule.Content = iModule.moduleName;
                        spModules.Children.Add(btnModule);
                        btnModule.Click += BtnModule_Click;;
                        UserControl uc = (UserControl)iModule;
                        uc.Name       = iModule.moduleName;
                        uc.Visibility = Visibility.Collapsed;
                        gdModlueUI.Children.Add(uc);
                    }
                }
                //reset temp.
                plugin = null;
                types  = null;
            }
            //Use Update as main module.
            ShowModule("Update");
        }
Beispiel #3
0
 internal void Uninitialize()
 {
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize begin all");
     ProfilingUtility.BeginSample("ModuleManager.Uninitialize");
     for (int i = mAllModules.Count - 1; i >= 0; i--)
     {
         IModuleInterface m = mAllModules[i];
         if (m.status == EModuleStatus.PostInitialize)
         {
             DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize begin : " + m.moduleName);
             ProfilingUtility.BeginSample("ModuleManager.Uninitialize_", m.moduleName);
             try
             {
                 m.Uninitialize();
             }
             catch (System.Exception ex)
             {
                 DebugUtility.LogException(ex);
             }
             m.status = EModuleStatus.Loaded;
             ProfilingUtility.EndSample();
             DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize end : " + m.moduleName);
         }
     }
     ProfilingUtility.EndSample();
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize end all");
 }
Beispiel #4
0
    public FoldObject CreateObject(string Path, object[] Args, string Type)
    {
        if (!rd.PrefabDic.ContainsKey(Type))
        {
            return(null);
        }
        if (ValidString(Path))
        {
            string[] pth = ParsePath(Path);
            if (pth[1] == "")
            {
                Transform df = CreateNewDropFold();
                df.SetParent(this.transform, false);
                Transform        obj = AttachChild(df, Args, Type);
                IModuleInterface imi = obj.GetComponent <IModuleInterface>();



                FoldObject fo = new FoldObject();
                fo.DataManager = df.GetComponent <FoldManager>();
                fo.Name        = Path;
                string[] splitname = DividePath(Path);
                fo.NameSimple        = splitname[1];
                fo.Path              = splitname[0];
                fo.ChildObj          = obj;
                fo.Obj               = df;
                fo.Params            = Args;
                imi.ParameterChange += fo.InternalParameterSet;

                fo.MyType        = new KeyValuePair <string, Transform>(Type, rd.PrefabDic[Type]);
                fo.VisualManager = df.GetComponent <DropControl>();
                fo.VisualManager.InstallRD(rd);

                Folds.Add(fo);
                FoldNames.Add(pth[0], fo);
                rd.CurrentFolds.Add(Path, fo);
                fo.DataManager.PassChild(obj);

                FoldStateChanged();

                return(fo);
            }
            else
            {
                if (FoldNames.ContainsKey(pth[0]))
                {
                    return(FoldNames[pth[0]].DataManager.CreateObjectPrivate(pth[1], Args, Type, Path));
                }
                else
                {
                    return(null);
                }
            }
        }
        else
        {
            return(null);
        }
    }
Beispiel #5
0
 public RebortService()
 {
     _userServices    = GetInstance <ISignUserServices>();
     _logsServices    = GetInstance <ISignLogsServices>();
     _keyWordServices = GetInstance <ILianKeyWordsServices>();
     _moduleInterface = GetInstance <IModuleInterface>();
     _speakerServices = GetInstance <ISpeakerServices>();
 }
Beispiel #6
0
 internal IModuleInterface AddModule(IModuleInterface module)
 {
     if (module.status == EModuleStatus.None)
     {
         mAllModules.Add(module);
         module.StartupModule();
         module.status = EModuleStatus.Loaded;
         return(module);
     }
     return(null);
 }
Beispiel #7
0
    private Transform AttachChild(Transform DropFold, object[] args, string Type)
    {
        Transform        newobj = (Transform)GameObject.Instantiate(rd.PrefabDic[Type], Vector3.zero, Quaternion.identity);
        IModuleInterface imi    = newobj.GetComponent <IModuleInterface>();

        imi.Parameters = args;
        RectTransform rtt = newobj.GetComponent <RectTransform>();

        rtt.localScale = new Vector3(1, 1, 1);
        return(newobj);
    }
Beispiel #8
0
        public void AbandonModule(string moduleName)
        {
            ProfilingUtility.BeginSample("ModuleManager.AbandonModule_", moduleName);
            IModuleInterface m = GetModule(moduleName);

            if (m != null)
            {
                if (m.status != EModuleStatus.None)
                {
                    m.ShutdownModule(EModuleShutdownReason.Runtime);
                    m.status = EModuleStatus.None;
                }
            }
            ProfilingUtility.EndSample();
        }
Beispiel #9
0
        public TModuleInterface GetModuleChecked <TModuleInterface>(string moduleName) where TModuleInterface : ModuleInterface <TModuleInterface>, new()
        {
            IModuleInterface module = GetModule(moduleName);

            if (module is TModuleInterface)
            {
                TModuleInterface result = (TModuleInterface)module;

                DebugUtility.AssertFormat(result != null, "Failded to call GetModuleChecked({0})", moduleName);
                DebugUtility.AssertFormat(result.status >= EModuleStatus.Initialize, "Failded to call GetModuleChecked({0}), please ensure that the module has initialized", moduleName);
                return(result);
            }

            DebugUtility.AssertFormat(false, "Failded to call GetModuleChecked({0})", moduleName);
            return(default(TModuleInterface));
        }
Beispiel #10
0
        public void Start()
        {
            if (AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.Equals("FerramAerospaceResearch", StringComparison.InvariantCultureIgnoreCase)))
            {
                aeroModule = new FARModule(part);
            }
            else
            {
                aeroModule = new StockModule(part.Modules.GetModule <ModuleControlSurface>());
            }

            if (deflectionAtPressure == null)
            {
                deflectionAtPressure = new List <AeroPair>();
                defaults             = defaults ?? new ConfigNode(EditorWindow.nodeName);
                LoadConfig(defaults, true);
            }
            loaded = true;
        }
Beispiel #11
0
 internal void OnApplicationQuit()
 {
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit begin all");
     ProfilingUtility.BeginSample("ModuleManager.OnApplicationQuit");
     for (int i = mAllModules.Count - 1; i >= 0; i--)
     {
         IModuleInterface m = mAllModules[i];
         DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit begin : " + m.moduleName);
         ProfilingUtility.BeginSample("ModuleManager.OnApplicationQuit_", m.moduleName);
         try
         {
             m.OnApplicationQuit();
         }
         catch (System.Exception ex)
         {
             DebugUtility.LogException(ex);
         }
         ProfilingUtility.EndSample();
         DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit end : " + m.moduleName);
     }
     ProfilingUtility.EndSample();
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit end all");
 }
Beispiel #12
0
 /**
  *  Event handler volany po dokonceni nacitavania stranky/modulu.
  */
 private void Content_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
 {
     current = (IModuleInterface) e.Content;
     current.initialize(stateChanged, playlist);
     current.changedVolume(VolumeSlider.Value / 10);
 }
        /// <summary>
        /// Search *.dll under Modules\UI\ folder and load into Main process.
        /// </summary>
        void LoadModules()
        {
            //FileInfo fi = new FileInfo()
            string modulePath = string.Format(@"{0}Modules\UI\", AppDomain.CurrentDomain.BaseDirectory);

            string[] strModuleLst = Directory.GetFiles(modulePath, "*.dll", SearchOption.TopDirectoryOnly);
            Assembly plugin;

            Type[] types = null;
            foreach (string strModule in strModuleLst)
            {
                //C# load dll method
                Utilities.Logger(CommonUIConsts.LogUtilityFileName, strModule);
                plugin = Assembly.LoadFrom(strModule);
                try
                {
                    types = plugin.GetTypes();
                }
                catch (Exception ex)
                {
                    Utilities.Logger(CommonUIConsts.LogUtilityFileName, $"Error {ex.Message}");
                    continue;
                }
                foreach (Type t in types)
                {
                    //Check Module interface
                    if (t.GetInterface("IModuleInterface", true) == null)
                    {
                        continue;
                    }
                    //Check is main user control
                    if (!typeof(System.Windows.Controls.UserControl).IsAssignableFrom(t))
                    {
                        continue;
                    }
                    //Check main user control name
                    //if (t.Name != "MainControl")
                    //{
                    //    continue;
                    //}
                    IModuleInterface iModule = (IModuleInterface)t.InvokeMember(null,
                                                                                BindingFlags.DeclaredOnly |
                                                                                BindingFlags.Public | BindingFlags.NonPublic |
                                                                                BindingFlags.Instance | BindingFlags.CreateInstance,
                                                                                null, null, null);
                    //Check module is support and load into memory
                    if (iModule.isPlatformSupported())
                    {
                        Button btnModule = new Button();
                        btnModule.Name    = $"btn{iModule.moduleName}";
                        btnModule.Content = iModule.moduleName;
                        spModules.Children.Add(btnModule);
                        btnModule.Click += BtnModule_Click;
                        UserControl uc = (UserControl)iModule;
                        uc.Name       = iModule.moduleName;
                        uc.Visibility = Visibility.Hidden;
                        gdModlueUI.Children.Add(uc);
                        iModule.initialize();
                    }
                }
                //reset temp.
                plugin = null;
                types  = null;
            }
            //Use Update as main module.
            ShowModule("Update");
        }