Ejemplo n.º 1
0
        protected override void Init()
        {
            PackageMakerState.InitState();

            RootLayout = new VerticalLayout("box");

            var editorView    = new VerticalLayout().AddTo(RootLayout);
            var uploadingView = new VerticalLayout().AddTo(RootLayout);
            // var finishView = new VerticalLayout().AddTo(RootLayout);

            // 当前版本号
            var versionLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("当前版本号").Width(100).AddTo(versionLine);
            new LabelView(mPackageVersion.Version).Width(100).AddTo(versionLine);

            // 发布版本号
            var publishedVersionLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("发布版本号")
            .Width(100)
            .AddTo(publishedVersionLine);

            new TextView(mPublishVersion)
            .Width(100)
            .AddTo(publishedVersionLine)
            .Content.Bind(v => mPublishVersion = v);

            // 类型
            var typeLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("类型").Width(100).AddTo(typeLine);

            var packageType = new EnumPopupView(mPackageVersion.Type).AddTo(typeLine);

            var accessRightLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("权限").Width(100).AddTo(accessRightLine);
            var accessRight = new EnumPopupView(mPackageVersion.AccessRight).AddTo(accessRightLine);

            new LabelView("发布说明:").Width(150).AddTo(editorView);

            var releaseNote = new TextAreaView().Width(250).Height(300).AddTo(editorView);

            PackageMakerState.InEditorView.BindWithInitialValue(value => { editorView.Visible = value; })
            .AddTo(mDisposableList);

            if (User.Logined)
            {
                new ButtonView("发布", () =>
                {
                    mPackageVersion.Readme.content = releaseNote.Content.Value;
                    mPackageVersion.AccessRight    = (PackageAccessRight)accessRight.ValueProperty.Value;
                    mPackageVersion.Type           = (PackageType)packageType.ValueProperty.Value;
                    mPackageVersion.Version        = mPublishVersion;

                    mControllerNode.SendCommand(new PublishPackageCommand(mPackageVersion));
                }).AddTo(editorView);
            }

            var notice = new LabelViewWithRect("", 100, 200, 200, 200).AddTo(uploadingView);

            PackageMakerState.NoticeMessage
            .BindWithInitialValue(value => { notice.Content.Value = value; }).AddTo(mDisposableList);

            PackageMakerState.InUploadingView.BindWithInitialValue(value => { uploadingView.Visible = value; })
            .AddTo(mDisposableList);
        }
Ejemplo n.º 2
0
        protected override void Init()
        {
            RootLayout = new VerticalLayout("box");

            BindKit.Init();

            var editorView    = new VerticalLayout().AddTo(RootLayout);
            var uploadingView = new VerticalLayout().AddTo(RootLayout);

            // var finishView = new VerticalLayout().AddTo(RootLayout);

            ;
            // 当前版本号
            var versionLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("当前版本号").Width(100).AddTo(versionLine);
            new LabelView(mPackageVersion.Version).Width(100).AddTo(versionLine);

            // 发布版本号
            var publishedVertionLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("发布版本号").Width(100).AddTo(publishedVertionLine);

            var version = new TextView().Width(100).AddTo(publishedVertionLine);

            // 类型
            var typeLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("类型").Width(100).AddTo(typeLine);

            var packageType = new EnumPopupView(mPackageVersion.Type).AddTo(typeLine);

            var accessRightLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("权限").Width(100).AddTo(accessRightLine);
            var accessRight = new EnumPopupView(mPackageVersion.AccessRight).AddTo(accessRightLine);



            new LabelView("发布说明:").Width(150).AddTo(editorView);

            var releaseNote = new TextAreaView().Width(250).Height(300).AddTo(editorView);


            var docLine = new HorizontalLayout().AddTo(editorView);

            new LabelView("文档地址:").Width(52).AddTo(docLine);
            var docUrl = new TextView(mPackageVersion.DocUrl).Width(150).AddTo(docLine);



            var pasteBtn = new ButtonView("Paste").AddTo(docLine);


            var bindingSet = BindKit.CreateBindingSet(this, new PackageMakerViewModel(mPackageVersion));

            bindingSet.Bind(editorView).For(v => v.Visible).To(vm => vm.InEditorView);
            bindingSet.Bind(version.Content).For(v => v.Value, v => v.OnValueChanged)
            .To(vm => vm.Version);
            bindingSet.Bind(packageType.ValueProperty).For(v => v.Value, v => v.OnValueChanged)
            .To(vm => vm.Type);


            bindingSet.Bind(accessRight.ValueProperty)
            .For(v => v.Value, v => v.OnValueChanged)
            .To(vm => vm.AccessRight);

            bindingSet.Bind(releaseNote.Content).For(v => v.Value, v => v.OnValueChanged)
            .To(vm => vm.ReleaseNote);
            bindingSet.Bind(docUrl.Content).For(v => v.Value, v => v.OnValueChanged)
            .To(vm => vm.DocUrl);
            bindingSet.Bind(pasteBtn).For(v => v.OnClick).To(vm => vm.Paste);

            if (User.Logined)
            {
                var publishBtn = new ButtonView("发布").AddTo(editorView);



                new ButtonView("发布并删除本地", () => { }).AddTo(editorView);

                bindingSet.Bind(publishBtn).For(v => v.OnClick).To(vm => vm.Publish)
                .CommandParameter(mPackageVersion);
            }


            var notice = new LabelViewWithRect("", 100, 200, 200, 200).AddTo(uploadingView);

            bindingSet.Bind(notice.Content).For(v => v.Value).To(vm => vm.NoticeMessage);

            bindingSet.Bind(uploadingView).For(v => v.Visible).To(vm => vm.InUploadingView);

            bindingSet.Build();
        }
        public void BuildItem()
        {
            container.Clear();


            if (data.state == ToDoData.ToDoState.NoStart)
            {
                var startBtn = new ImageButtonView(ImageButtonIcon.playIcon, () =>
                {
                    data.startTime = DateTime.Now;
                    data.state.Val = ToDoData.ToDoState.Started;                     //改变了state会自动储存
                    UpdateItem();
                }).Height(20).Width(40).BackgroundColor(Color.green);
                container.Add(startBtn);
            }
            else if (data.state == ToDoData.ToDoState.Started)
            {
                var finishedBtn = new ImageButtonView(ImageButtonIcon.finishIcon, () =>
                {
                    data.finishTime = DateTime.Now;
                    data.state.Val  = ToDoData.ToDoState.Done;
                    UpdateItem();
                }).Height(20).Width(40).BackgroundColor(Color.green);
                container.Add(finishedBtn);
            }
            else if (data.state == ToDoData.ToDoState.Done)
            {
                var resetBtn = new ImageButtonView(ImageButtonIcon.resetIcon, () =>
                {
                    data.createTime = DateTime.Now;
                    data.state.Val  = ToDoData.ToDoState.NoStart;
                    UpdateItem();
                }).Height(20).Width(40).BackgroundColor(Color.grey);
                container.Add(resetBtn);
            }

            var boxView = new BoxView("无").AddTo(container)
                          .TextMiddleCenter().Width(20).FontSize(12)
                          .FontColor(Color.white).FontBold();

            new CategoryComponent(data.category).AddTo(container);

            var contentLabel = new LabelView(data.content).Height(20).FontSize(15).TextMiddleCenter();

            container.Add(contentLabel);

            if (showTime)
            {
                new LabelView(data.finishTime.ToString("完成于 HH:mm:ss"))
                .Height(20).Width(80).TextMiddleLeft().FontBold();
                new LabelView(data.UsedTimeText)
                .Height(20).Width(100).TextMiddleLeft().AddTo(container);
            }

            var   priorityVal   = data.priority.Val;
            Color priorityColor = Color.clear;

            switch (priorityVal)
            {
            case ToDoData.ToDoPriority.A:
                boxView.Context = "A";
                priorityColor   = Color.red;
                boxView.BackgroundColor(Color.red);
                break;

            case ToDoData.ToDoPriority.B:
                boxView.Context = "B";
                priorityColor   = Color.yellow;
                boxView.BackgroundColor(Color.yellow);
                break;

            case ToDoData.ToDoPriority.C:
                boxView.Context = "C";
                priorityColor   = Color.cyan;
                boxView.BackgroundColor(Color.cyan);
                break;

            case ToDoData.ToDoPriority.D:
                boxView.Context = "D";
                priorityColor   = Color.blue;
                boxView.BackgroundColor(Color.blue);
                break;

            case ToDoData.ToDoPriority.None:
                boxView.Context = "无";
                priorityColor   = Color.gray;
                boxView.BackgroundColor(Color.gray);
                break;
            }


            var priority = new EnumPopupView <ToDoData.ToDoPriority>(priorityVal)
                           .Width(30).Height(20).BackgroundColor(priorityColor).AddTo(container);

            priority.ValueProperty.RegisterValueChanged((val) =>
            {
                data.priority.Val = val;

                switch (val)
                {
                case ToDoData.ToDoPriority.A:
                    boxView.Context = "A";
                    priority.BackgroundColor(Color.red);
                    boxView.BackgroundColor(Color.red);
                    break;

                case ToDoData.ToDoPriority.B:
                    boxView.Context = "B";
                    priority.BackgroundColor(Color.yellow);
                    boxView.BackgroundColor(Color.yellow);
                    break;

                case ToDoData.ToDoPriority.C:
                    boxView.Context = "C";
                    priority.BackgroundColor(Color.cyan);
                    boxView.BackgroundColor(Color.cyan);
                    break;

                case ToDoData.ToDoPriority.D:
                    boxView.Context = "D";
                    priority.BackgroundColor(Color.blue);
                    boxView.BackgroundColor(Color.blue);
                    break;

                case ToDoData.ToDoPriority.None:
                    boxView.Context = "无";
                    priority.BackgroundColor(Color.gray);
                    boxView.BackgroundColor(Color.gray);
                    break;
                }

                UpdateItem();
            });

            new ImageButtonView(ImageButtonIcon.editorIcon, () => { OpenSubWindow(); })
            .Width(25).Height(25).BackgroundColor(Color.black).AddTo(container);

            var deleteBtn = new ImageButtonView(ImageButtonIcon.deleteIcon, () =>
            {
                data.finished.ClearValueChanged();
                ToDoDataManager.RemoveToDoItem(data);
                deleteAct?.Invoke(data);
                UpdateItem();
            }).Height(25).Width(25).BackgroundColor(Color.red);

            container.Add(deleteBtn);
        }