Ejemplo n.º 1
0
        public bool Load(string Path, bool AssemblyOnly = false)
        {
            try
            {
                // 구성 파일 로드
                if (!AssemblyOnly)
                {
                    LoadConfig(Path);
                }

                if (AssemblyFile.Equals("local"))
                {
                    // 내부 어셈블리 사용
                    switch (AssemblyEntry)
                    {
                    case "WebView":
                        BorderContent.Background = Brushes.Black;
                        ChromiumWebBrowser WebView = new ChromiumWebBrowser();
                        WebView.Address     = AssemblyArgument;
                        BorderContent.Child = WebView;
                        break;
                    }
                }
                else
                {
                    // 외부 어셈블리 참조
                    Assembly WidgetAssembly = Assembly.LoadFrom(AssemblyFile);
                    Type[]   TypeList       = WidgetAssembly.GetTypes();
                    foreach (Type Target in TypeList)
                    {
                        if (Target.Name == AssemblyEntry)
                        {
                            // 어셈블리 진입점 검색 및 인스턴스 생성
                            _WidgetTarget  = Target;
                            _WidgetControl = Activator.CreateInstance(Target) as UserControl;

                            // 어셈블리에 전달할 인자가 존재하는 경우 메소드 호출
                            if (AssemblyArgument.Length > 0)
                            {
                                CallMethod("SetArgument", AssemblyArgument);
                            }

                            break;
                        }
                    }
                    ;

                    // 검색된 컨트롤을 현재 컨트롤에 추가
                    BorderContent.Child = WidgetControl;
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool Load(string Path)
        {
            try
            {
                // 위젯 분석
                INI    Widget = new INI(Path);
                string Local  = "<%LOCAL%>";
                _INI                  = Path;
                _Title                = Widget.GetValue("General", "Title");
                _Author               = Widget.GetValue("General", "Author");
                _Summary              = Widget.GetValue("General", "Summary");
                _AssemblyFile         = Widget.GetValue("Assembly", "File").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyEntry        = Widget.GetValue("Assembly", "Entry").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AssemblyArgument     = Widget.GetValue("Assembly", "Argument").Replace(Local, System.IO.Path.GetDirectoryName(Path)).Trim();
                _AppearanceWidth      = int.Parse(Widget.GetValue("Appearance", "Width"));
                _AppearanceHeight     = int.Parse(Widget.GetValue("Appearance", "Height"));
                _AppearanceExpandable = bool.Parse(Widget.GetValue("Appearance", "Expandable"));

                if (AssemblyFile.Equals("local"))
                {
                    // 내부 어셈블리 사용
                    switch (AssemblyEntry)
                    {
                    case "WebView":
                        ChromiumWebBrowser WebView = new ChromiumWebBrowser();
                        WebView.Address     = AssemblyArgument;
                        BorderContent.Child = WebView;
                        break;
                    }
                }
                else
                {
                    // 외부 어셈블리 참조
                    Assembly WidgetAssembly = Assembly.LoadFrom(AssemblyFile);
                    Type[]   TypeList       = WidgetAssembly.GetTypes();
                    foreach (Type Target in TypeList)
                    {
                        if (Target.Name == AssemblyEntry)
                        {
                            // 어셈블리 진입점 검색 및 인스턴스 생성
                            _WidgetTarget  = Target;
                            _WidgetControl = Activator.CreateInstance(Target) as UserControl;

                            // 어셈블리에 전달할 인자가 존재하는 경우 메소드 호출
                            if (AssemblyArgument.Length > 0)
                            {
                                CallMethod("SetArgument", AssemblyArgument);
                            }

                            break;
                        }
                    }
                    ;

                    // 검색된 컨트롤을 현재 컨트롤에 추가
                    BorderContent.Child = WidgetControl;
                }

                // 위젯 모양새 적용
                if (ParentDock != null)
                {
                    Width  = AppearanceWidth * ParentDock.GridWidth;
                    Height = AppearanceHeight * ParentDock.GridHeight;
                }
                else
                {
                    WidthColumn = AppearanceWidth;
                    HeightRow   = AppearanceHeight;
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }