示例#1
0
        public static BindingSet <TView, TViewModel> CreateBindingSet <TView, TViewModel>(TView view,
                                                                                          TViewModel viewModel) where TView : class
        {
            var binder = mContainer.Resolve <IBinder>();

            var bindContext = new BindingContext(view, binder)
            {
                DataContext = viewModel
            };

            BindingContexts.Add(view, bindContext);

            return(new BindingSet <TView, TViewModel>(bindContext, view));
        }
示例#2
0
        public static NodeConfigBase GetNodeConfig(this IQFrameworkContainer container, Type nodeType)
        {
            var config = container.Resolve <NodeConfigBase>(nodeType.Name);

            if (config == null)
            {
                var nodeconfigType = typeof(NodeConfig <>).MakeGenericType(nodeType);
                var nodeConfig     = Activator.CreateInstance(nodeconfigType, container) as NodeConfigBase;
                nodeConfig.NodeType = nodeType;
                container.RegisterInstance(nodeConfig, nodeType.Name);
                //nodeConfig.Section(string.Empty, _ => _.PersistedItems.OfType<GenericConnectionReference>(), false);
                return(nodeConfig);
            }
            return(config);
        }
示例#3
0
            public void Init(IQFrameworkContainer container)
            {
                EasyIMGUI.Label().Text(LocaleText.ResKit).FontSize(12).Parent(this);

                var verticalLayout = new VerticalLayout("box").Parent(this);

                var persistLine = EasyIMGUI.Horizontal();

                EasyIMGUI.Label().Text("PersistantPath:").Parent(persistLine).Width(100);
                EasyIMGUI.TextField().Text(Application.persistentDataPath).Parent(persistLine);
                persistLine.Parent(verticalLayout);

                EasyIMGUI.Button()
                .Text(LocaleText.GoToPersistent)
                .OnClick(() => { EditorUtility.RevealInFinder(Application.persistentDataPath); })
                .Parent(verticalLayout);

                mResVersion          = EditorPrefs.GetString(KEY_QAssetBundleBuilder_RESVERSION, "100");
                mEnableGenerateClass = EditorPrefs.GetBool(KEY_AUTOGENERATE_CLASS, true);

                switch (EditorUserBuildSettings.activeBuildTarget)
                {
                case BuildTarget.WSAPlayer:
                    mBuildTargetIndex = 4;
                    break;

                case BuildTarget.WebGL:
                    mBuildTargetIndex = 3;
                    break;

                case BuildTarget.Android:
                    mBuildTargetIndex = 2;
                    break;

                case BuildTarget.iOS:
                    mBuildTargetIndex = 1;
                    break;

                default:
                    mBuildTargetIndex = 0;
                    break;
                }

                EasyIMGUI.Toolbar()
                .AddMenu("Windows/MacOS")
                .AddMenu("iOS")
                .AddMenu("Android")
                .AddMenu("WebGL")
                .AddMenu("WSAPlayer")
                .Index(mBuildTargetIndex)
                .Parent(verticalLayout);

                EasyIMGUI.Toggle()
                .Text(LocaleText.AutoGenerateClass)
                .IsOn(mEnableGenerateClass)
                .Parent(verticalLayout)
                .ValueProperty.Bind(v => mEnableGenerateClass = v);

                EasyIMGUI.Toggle()
                .Text(LocaleText.SimulationMode)
                .IsOn(ResKitEditorAPI.SimulationMode)
                .Parent(verticalLayout)
                .ValueProperty.Bind(v => ResKitEditorAPI.SimulationMode = v);

                // EasyIMGUI.Toggle()
                //    .Text(LocaleText.EncryptAB)
                //    .IsOn(GetConfig().EncryptAB)
                //    .Parent(verticalLayout)
                //    .ValueProperty.Bind(v => GetConfig().EncryptAB = v);


                // var aesLine = EasyIMGUI.Horizontal();
                // EasyIMGUI.Label().Text("AES秘钥:").Parent(aesLine).Width(100);
                // EasyIMGUI.TextField().Text(GetConfig().AESKey).Parent(aesLine).Content.OnValueChanged.AddListener(_=>GetConfig().AESKey=_);
                // aesLine.Parent(verticalLayout);

                // EasyIMGUI.Toggle()
                //    .Text(LocaleText.EncryptKey)
                //    .IsOn(GetConfig().EncryptKey)
                //    .Parent(verticalLayout)
                //    .ValueProperty.Bind(v => GetConfig().EncryptKey = v);

                var resVersionLine = new HorizontalLayout()
                                     .Parent(verticalLayout);

                // EasyIMGUI.Label().Text("ResVesion:").Parent(resVersionLine).Width(100);

                EasyIMGUI.TextField().Text(mResVersion).Parent(resVersionLine)
                .Content.Bind(v => mResVersion = v);

                EasyIMGUI.Button()
                .Text(LocaleText.GenerateClass)
                .OnClick(() =>
                {
                    BuildScript.WriteClass();
                    AssetDatabase.Refresh();
                }).Parent(verticalLayout);

                EasyIMGUI.Button()
                .Text(LocaleText.Build)
                .OnClick(() =>
                {
                    EditorLifecycle.PushCommand(() =>
                    {
                        var window = container.Resolve <EditorWindow>();

                        if (window)
                        {
                            window.Close();
                        }

                        ResKitEditorAPI.BuildAssetBundles();
                        //if (GetConfig().EncryptAB)
                        //{
                        //    string key = GetConfig().EncryptKey ? RSA.RSAEncrypt("", GetConfig().AESKey): GetConfig().AESKey;
                        //    BundleHotFix.EncryptAB(key);
                        //}
                    });
                }).Parent(verticalLayout);

                EasyIMGUI.Button()
                .Text(LocaleText.ForceClear)
                .OnClick(ResKitEditorAPI.ForceClearAssetBundles)
                .Parent(verticalLayout);

                verticalLayout.AddChild(EasyIMGUI.Space().Pixel(10));
                verticalLayout.AddChild(EasyIMGUI.Label().Text(LocaleText.MarkedAB).FontBold().FontSize(15));



                var scrollView = EasyIMGUI.Scroll().Parent(verticalLayout);

                mMarkedPathList = new VerticalLayout("box")
                                  .Parent(scrollView);

                ReloadMarkedList();
            }
示例#4
0
 public static WorkspaceConfiguration WorkspaceConfig <TWorkspaceType>(this IQFrameworkContainer container)
 {
     return(container.Resolve <WorkspaceConfiguration>(typeof(TWorkspaceType).Name) ?? container.AddWorkspaceConfig <TWorkspaceType>(typeof(TWorkspaceType).Name));
 }
示例#5
0
        public void Init(IQFrameworkContainer container)
        {
            Container = container;
            var localPackageVersionModel = this.GetModel <ILocalPackageVersionModel>();

            // 左侧
            mLeftLayout = EasyIMGUI.Vertical()
                          .AddChild(EasyIMGUI.Area().WithRectGetter(() => mLeftRect)
                                    // 间距 20
                                    .AddChild(EasyIMGUI.Vertical()
                                              .AddChild(EasyIMGUI.Space().Pixel(20)))
                                    // 搜索
                                    .AddChild(EasyIMGUI.Horizontal()
                                              .AddChild(EasyIMGUI.Label().Text("搜索:")
                                                        .FontBold()
                                                        .FontSize(12)
                                                        .Width(40)
                                                        ).AddChild(EasyIMGUI.TextField()
                                                                   .Height(20)
                                                                   .Self(search =>
            {
                search.Content
                .Bind(key => { this.SendCommand(new SearchCommand(key)); })
                .AddToDisposeList(mDisposableList);
            })
                                                                   )
                                              )

                                    // 权限
                                    .AddChild(EasyIMGUI.Toolbar()
                                              .Menus(new List <string>()
            {
                "All", PackageAccessRight.Public.ToString(), PackageAccessRight.Private.ToString()
            })
                                              .Self(self =>
            {
                self.IndexProperty.Bind(value =>
                {
                    PackageManagerState.AccessRightIndex.Value = value;
                    this.SendCommand(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddToDisposeList(mDisposableList);
            }))
                                    // 分类
                                    .AddChild(
                                        EasyIMGUI.Horizontal()
                                        .AddChild(PopupView.Create()
                                                  .ToolbarStyle()
                                                  .Self(self =>
            {
                self.IndexProperty.Bind(value =>
                {
                    PackageManagerState.CategoryIndex.Value = value;
                    this.SendCommand(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddToDisposeList(mDisposableList);

                mCategoriesSelectorView = self;
            }))
                                        )
                                    .AddChild(EasyIMGUI.Scroll()
                                              .AddChild(EasyIMGUI.Custom().OnGUI(() =>
            {
                PackageManagerState.PackageRepositories.Value
                .OrderByDescending(p =>
                {
                    var installedVersion = localPackageVersionModel.GetByName(p.name);

                    if (installedVersion == null)
                    {
                        return(-1);
                    }
                    else if (installedVersion.VersionNumber < p.VersionNumber)
                    {
                        return(2);
                    }
                    else if (installedVersion.VersionNumber == p.VersionNumber)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                })
                .ThenBy(p => p.name)
                .ForEach(p =>
                {
                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(p.name);
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EasyIMGUI.Box().Text(p.latestVersion)
                        .Self(self => self.BackgroundColor = Color.green)
                        .DrawGUI();

                        GUILayout.FlexibleSpace();

                        var installedVersion = localPackageVersionModel.GetByName(p.name);

                        if (installedVersion == null)
                        {
                            if (GUILayout.Button(LocaleText.Import))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new ImportPackageCommand(p));
                                });
                            }
                        }
                        else if (installedVersion.VersionNumber < p.VersionNumber)
                        {
                            if (GUILayout.Button(LocaleText.Update))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new UpdatePackageCommand(p));
                                });
                            }
                        }
                        else if (installedVersion.VersionNumber == p.VersionNumber)
                        {
                            if (GUILayout.Button(LocaleText.Reimport))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new ReimportPackageCommand(p));
                                });
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    var rect = GUILayoutUtility.GetLastRect();

                    if (mSelectedPackageRepository == p)
                    {
                        GUI.Box(rect, "", mSelectionRect);
                    }

                    if (rect.Contains(Event.current.mousePosition) &&
                        Event.current.type == EventType.MouseUp)
                    {
                        mSelectedPackageRepository = p;
                        Event.current.Use();
                    }
                });
            }))
                                              )
                                    );

            // var skin = AssetDatabase.LoadAssetAtPath<GUISkin>(
            var skin = AssetDatabase.LoadAssetAtPath <GUISkin>(
                // "Assets/QFramework/Framework/Plugins/Editor/Markdown/Skin/MarkdownViewerSkin.guiskin");
                "Assets/QFramework/Framework/Plugins/Editor/Markdown/Skin/MarkdownSkinQS.guiskin");


            mMarkdownViewer = new MarkdownViewer(skin, string.Empty, "");
            // 右侧
            mRightLayout = EasyIMGUI.Vertical()
                           .AddChild(EasyIMGUI.Area().WithRectGetter(() => mRightRect)
                                     // 间距 20
                                     .AddChild(EasyIMGUI.Vertical()
                                               .AddChild(EasyIMGUI.Space().Pixel(20))
                                               )
                                     // 详细信息
                                     .AddChild(EasyIMGUI.Vertical()
                                               .WithVisibleCondition(() => mSelectedPackageRepository != null)
                                               // 名字
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => mSelectedPackageRepository.name)
                                                         .FontSize(30)
                                                         .FontBold())
                                               .AddChild(EasyIMGUI.Space())
                                               // 服务器版本
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "服务器版本: " + mSelectedPackageRepository.latestVersion)
                                                         .FontSize(15))
                                               // 本地版本
                                               .AddChild(EasyIMGUI.Label()
                                                         .WithVisibleCondition(() =>
                                                                               localPackageVersionModel.GetByName(mSelectedPackageRepository.name).IsNotNull())
                                                         .TextGetter(() =>
                                                                     "本地版本:" + localPackageVersionModel.GetByName(mSelectedPackageRepository.name).Version)
                                                         .FontSize(15))
                                               // 作者
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "作者:" + mSelectedPackageRepository.author)
                                                         .FontSize(15))
                                               // 权限
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "权限:" + mSelectedPackageRepository.accessRight)
                                                         .FontSize(15))
                                               // 主页
                                               .AddChild(
                                                   EasyIMGUI.Horizontal()
                                                   .AddChild(EasyIMGUI.Label()
                                                             .FontSize(15)
                                                             .Text("插件主页:"))
                                                   .AddChild(EasyIMGUI.Button()
                                                             .TextGetter(() => UrlHelper.PackageUrl(mSelectedPackageRepository))
                                                             .FontSize(15)
                                                             .OnClick(() =>
            {
                this.SendCommand(new OpenDetailCommand(mSelectedPackageRepository));
            })
                                                             )
                                                   .AddChild(EasyIMGUI.FlexibleSpace())
                                                   )
                                               // 描述
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "描述:")
                                                         .FontSize(15)
                                                         )
                                               .AddChild(EasyIMGUI.Space())
                                               // 描述内容
                                               .AddChild(EasyIMGUI.Custom().OnGUI(() =>
            {
                mMarkdownViewer.UpdateText(mSelectedPackageRepository.description);
                var lastRect = GUILayoutUtility.GetLastRect();
                mMarkdownViewer.DrawWithRect(new Rect(lastRect.x, lastRect.y + lastRect.height,
                                                      mRightRect.width - 210, mRightRect.height - lastRect.y - lastRect.height));
                // mMarkdownViewer.Draw();
            }))
                                               )
                                     );

            mPackageKitWindow = EditorWindow.GetWindow <PackageKitWindow>();

            this.SendCommand <PackageManagerInitCommand>();


            PackageManagerState.Categories.Bind(value =>
            {
                mCategoriesSelectorView.Menus(value);
                Container.Resolve <PackageKitWindow>().Repaint();
            }).AddToDisposeList(mDisposableList);


            // 创建双屏
            mSplitView = mSplitView = new VerticalSplitView
            {
                Split   = 240,
                fistPan = rect =>
                {
                    mLeftRect = rect;
                    mLeftLayout.DrawGUI();
                },
                secondPan = rect =>
                {
                    mRightRect = rect;
                    mRightLayout.DrawGUI();
                }
            };
        }
示例#6
0
            public void Init(IQFrameworkContainer container)
            {
                var expendLayout = new TreeNode(true, LocaleText.ResKit)
                                   .AddTo(this);

                var verticalLayout = new VerticalLayout("box");

                expendLayout.Add2Spread(verticalLayout);

                var persistLine = new HorizontalLayout();

                new LabelView("PersistantPath:").AddTo(persistLine).Width(100);
                new TextView(Application.persistentDataPath).AddTo(persistLine);
                persistLine.AddTo(verticalLayout);

                new ButtonView(LocaleText.GoToPersistent,
                               () => { EditorUtility.RevealInFinder(Application.persistentDataPath); }).AddTo(verticalLayout);

                mResVersion          = EditorPrefs.GetString(KEY_QAssetBundleBuilder_RESVERSION, "100");
                mEnableGenerateClass = EditorPrefs.GetBool(KEY_AUTOGENERATE_CLASS, true);

                switch (EditorUserBuildSettings.activeBuildTarget)
                {
                case BuildTarget.WebGL:
                    mBuildTargetIndex = 3;
                    break;

                case BuildTarget.Android:
                    mBuildTargetIndex = 2;
                    break;

                case BuildTarget.iOS:
                    mBuildTargetIndex = 1;
                    break;

                default:
                    mBuildTargetIndex = 0;
                    break;
                }

                new ToolbarView(mBuildTargetIndex)
                .AddMenu("win/osx", (_) => { })
                .AddMenu("iOS", (_) => { })
                .AddMenu("Android", (_) => { })
                .AddMenu("WebGL", (_) => { })
                .AddTo(verticalLayout);

                new ToggleView(LocaleText.AutoGenerateClass, mEnableGenerateClass)
                .AddTo(verticalLayout)
                .Toggle.Bind(v => mEnableGenerateClass = v);

                new ToggleView(LocaleText.SimulationMode, ResKitAssetsMenu.SimulateAssetBundleInEditor)
                .AddTo(verticalLayout)
                .Toggle.Bind(v => ResKitAssetsMenu.SimulateAssetBundleInEditor = v);

                var resVersionLine = new HorizontalLayout()
                                     .AddTo(verticalLayout);

                new LabelView("ResVesion:").AddTo(resVersionLine).Width(100);

                new TextView(mResVersion).AddTo(resVersionLine)
                .Content.Bind(v => mResVersion = v);

                new ButtonView(LocaleText.GenerateClass, () =>
                {
                    BuildScript.WriteClass();
                    AssetDatabase.Refresh();
                }).AddTo(verticalLayout);

                new ButtonView(LocaleText.Build, () =>
                {
                    EditorLifecycle.PushCommand(() =>
                    {
                        var window = container.Resolve <EditorWindow>();

                        if (window)
                        {
                            window.Close();
                        }

                        BuildWithTarget(EditorUserBuildSettings.activeBuildTarget);
                    });
                }).AddTo(verticalLayout);

                new ButtonView(LocaleText.ForceClear, () => { ForceClear(); }).AddTo(verticalLayout);

                verticalLayout.AddChild(new SpaceView(10));
                verticalLayout.AddChild(new LabelView("已标记 AB 列表:").FontBold().FontSize(15));


                var scrollView = new ScrollLayout().AddTo(verticalLayout);

                mMarkedPathList = new VerticalLayout("box")
                                  .AddTo(scrollView);

                ReloadMarkedList();
            }
 // 为了防止进行 clrbinding
 public static string ToJson <T>(this T obj) where T : class
 {
     return(SerializeContainer.Resolve <IJsonSerializer>().SerializeJson(obj));
 }
示例#8
0
            public void Init(IQFrameworkContainer container)
            {
                EasyIMGUI.Label().Text(LocaleText.ResKit).FontSize(12).AddTo(this);

                var verticalLayout = new VerticalLayout("box").AddTo(this);

                var persistLine = new HorizontalLayout();

                EasyIMGUI.Label().Text("PersistantPath:").AddTo(persistLine).Width(100);
                EasyIMGUI.TextField().Text(Application.persistentDataPath).AddTo(persistLine);
                persistLine.AddTo(verticalLayout);

                EasyIMGUI.Button()
                .Text(LocaleText.GoToPersistent)
                .OnClick(() => { EditorUtility.RevealInFinder(Application.persistentDataPath); })
                .AddTo(verticalLayout);

                mResVersion          = EditorPrefs.GetString(KEY_QAssetBundleBuilder_RESVERSION, "100");
                mEnableGenerateClass = EditorPrefs.GetBool(KEY_AUTOGENERATE_CLASS, true);

                switch (EditorUserBuildSettings.activeBuildTarget)
                {
                case BuildTarget.WebGL:
                    mBuildTargetIndex = 3;
                    break;

                case BuildTarget.Android:
                    mBuildTargetIndex = 2;
                    break;

                case BuildTarget.iOS:
                    mBuildTargetIndex = 1;
                    break;

                default:
                    mBuildTargetIndex = 0;
                    break;
                }

                EasyIMGUI.Toolbar()
                .AddMenu("win/osx")
                .AddMenu("iOS")
                .AddMenu("Android")
                .AddMenu("WebGL")
                .Index(mBuildTargetIndex)
                .AddTo(verticalLayout);

                EasyIMGUI.Toggle()
                .Text(LocaleText.AutoGenerateClass)
                .IsOn(mEnableGenerateClass)
                .AddTo(verticalLayout)
                .ValueProperty.Bind(v => mEnableGenerateClass = v);

                EasyIMGUI.Toggle()
                .Text(LocaleText.SimulationMode)
                .IsOn(AssetBundleSettings.SimulateAssetBundleInEditor)
                .AddTo(verticalLayout)
                .ValueProperty.Bind(v => AssetBundleSettings.SimulateAssetBundleInEditor = v);

                var resVersionLine = new HorizontalLayout()
                                     .AddTo(verticalLayout);

                EasyIMGUI.Label().Text("ResVesion:").AddTo(resVersionLine).Width(100);

                EasyIMGUI.TextField().Text(mResVersion).AddTo(resVersionLine)
                .Content.Bind(v => mResVersion = v);

                EasyIMGUI.Button()
                .Text(LocaleText.GenerateClass)
                .OnClick(() =>
                {
                    BuildScript.WriteClass();
                    AssetDatabase.Refresh();
                }).AddTo(verticalLayout);

                EasyIMGUI.Button()
                .Text(LocaleText.Build)
                .OnClick(() =>
                {
                    EditorLifecycle.PushCommand(() =>
                    {
                        var window = container.Resolve <EditorWindow>();

                        if (window)
                        {
                            window.Close();
                        }

                        BuildWithTarget(EditorUserBuildSettings.activeBuildTarget);
                    });
                }).AddTo(verticalLayout);

                EasyIMGUI.Button()
                .Text(LocaleText.ForceClear)
                .OnClick(() => { ForceClear(); })
                .AddTo(verticalLayout);

                verticalLayout.AddChild(EasyIMGUI.Space().Pixel(10));
                verticalLayout.AddChild(EasyIMGUI.Label().Text("已标记 AB 列表:").FontBold().FontSize(15));


                var scrollView = EasyIMGUI.Scroll().AddTo(verticalLayout);

                mMarkedPathList = new VerticalLayout("box")
                                  .AddTo(scrollView);

                ReloadMarkedList();
            }
示例#9
0
 public T GetModel <T>() where T : class, IModel
 {
     return(mContainer.Resolve <T>());
 }
示例#10
0
 T IArchitecture.GetModel <T>()
 {
     return(mContainer.Resolve <T>());
 }
示例#11
0
 public static T GetController <T>() where T : Controller
 {
     return(mContainer.Resolve <T>());
 }