//因为外部更改了category 这个也要通过show 更新
        //所以需要show 才能展示
        protected override void OnShow()
        {
            Clear();

            var data = ToDoDataManager.Data;

            if (data.categoryList.Count > 0)
            {
                popupView = new PopupView(0,
                                          data.categoryList.Select(x => x.name).ToArray())
                            .Width(100f).Height(20).AddTo(this);
            }


            var inputTextArea = new TextAreaView(todoName).Height(20).FontSize(15);

            inputTextArea.Content.Bind(x => todoName = x);
            Add(inputTextArea);

            var addBtn = new ImageButtonView(ImageButtonIcon.addIcon, () =>
            {
                if (!string.IsNullOrEmpty(todoName))
                {
                    onInputClick?.Invoke(ToDoDataManager.ToDoCategoryAt(PopupIndex), todoName);
                    inputTextArea.Content.Val = string.Empty;
                    GUI.FocusControl(null);
                }
            }).Width(30).Height(20).BackgroundColor(Color.yellow);

            Add(addBtn);
        }
Beispiel #2
0
        private void ButtonTouch(object sender, EventArgs e)
        {
            ImageButtonView button = (ImageButtonView)sender;

            for (int i = 0; i < buttons.ChildCount; i++)
            {
                ImageButtonView imageButton = buttons.GetChildAt(i) as ImageButtonView;
                if (imageButton == null || imageButton.ImageId.TrimEnd('1').Equals(button.ImageId.TrimEnd('1')))
                {
                    continue;
                }
                else if (imageButton.ImageId.EndsWith("1", StringComparison.InvariantCulture))
                {
                    imageButton.ImageId = imageButton.ImageId.TrimEnd('1');
                    ImageView image   = imageButton.GetChildAt(0) as ImageView;
                    string    imageId = imageButton.ImageId + ".png";
                    if (imageId != null)
                    {
                        var imageData = LoadResource(imageId).ToArray();
                        image.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
                    }
                    imageButton.SetWillNotDraw(true);
                    imageButton.SetWillNotDraw(false);
                }
            }
            if (!button.ImageId.EndsWith("1", StringComparison.InvariantCulture))
            {
                SegmentType type = SegmentType.OrthoSegment;
                switch (button.ImageId)
                {
                case "DiagramStraight":
                    type = SegmentType.StraightSegment;
                    break;

                case "DiagramCurve":
                    type = SegmentType.CurveSegment;
                    break;
                }
                foreach (Connector connector in diagram.Connectors)
                {
                    connector.SegmentType = type;
                }
                button.ImageId = button.ImageId + "1";
                ImageView image   = button.GetChildAt(0) as ImageView;
                string    imageId = button.ImageId + ".png";
                if (imageId != null)
                {
                    var imageData = LoadResource(imageId).ToArray();
                    image.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
                }
                button.SetWillNotDraw(true);
                button.SetWillNotDraw(false);
            }
        }
Beispiel #3
0
        private void AddColor(string imageId)
        {
            ImageButtonView imageButton = new ImageButtonView(diagram.Context);

            imageButton.Click  += ButtonTouch;
            imageButton.ImageId = imageId;
            //imageButton.SetPadding((int)(10 * currentDensity), 0, (int)(10 * currentDensity), 0);
            imageButton.LayoutParameters = new ViewGroup.LayoutParams((int)(220 * currentDensity), (int)(200 * currentDensity));

            ImageView image = new ImageView(diagram.Context);

            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                image.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            image.Layout((int)(15 * currentDensity), (int)(15 * currentDensity), (int)(520 * MainActivity.Factor), (int)(500 * MainActivity.Factor));

            imageButton.AddView(image);

            scrollLayout.AddView(imageButton);
        }
Beispiel #4
0
        private void ButtonTouch(object sender, EventArgs e)
        {
            ImageButtonView view = sender as ImageButtonView;

            view.ButtonSelected = true;
            switch (view.ImageId)
            {
            case "mindmapconttree.png":
                simpleCurveTree = "contCurveTree";
                SfGraphicsPath path = new SfGraphicsPath();
                path.MoveTo(0, 0);
                path.MoveTo(0, 50);
                path.LineTo(100, 50);
                path.MoveTo(100, 100);
                gra.DrawPath(path);
                Pen pe = new Pen();
                pe.StrokeBrush = new SolidBrush(Color.ParseColor("#949494"));
                pe.StrokeWidth = 5;
                point.Add(new Point(0, 50));
                point.Add(new Point(100, 50));
                gra.DrawLines(pe, point);
                objShape1 = ShapeType.Ellipse;
                objShape2 = gra;
                objShape3 = gra;
                objShape4 = gra;
                objShape5 = gra;
                segment   = SegmentType.CurveSegment;
                TextStyleVerticalAlignment = VerticalAlignment.Top;
                Dectype   = DecoratorType.None;
                connColor = Color.Black;
                connLineApplyColorFrom = ApplyColorFrom.TargetBorder;
                connDecApplyColorFrom  = ApplyColorFrom.TargetBorder;
                break;

            case "mindmapDefault.png":
                simpleCurveTree            = "default";
                objShape1                  = ShapeType.RoundedRectangle;
                objShape2                  = ShapeType.RoundedRectangle;
                objShape3                  = ShapeType.RoundedRectangle;
                objShape4                  = ShapeType.RoundedRectangle;
                objShape5                  = ShapeType.RoundedRectangle;
                segment                    = SegmentType.CurveSegment;
                TextStyleVerticalAlignment = VerticalAlignment.Center;
                Dectype                    = DecoratorType.None;
                connColor                  = Color.Black;
                connLineApplyColorFrom     = ApplyColorFrom.TargetBorder;
                connDecApplyColorFrom      = ApplyColorFrom.TargetBorder;
                break;

            case "mindmaportho.png":
                simpleCurveTree            = "orthotree";
                objShape1                  = ShapeType.Rectangle;
                objShape2                  = ShapeType.Rectangle;
                objShape3                  = ShapeType.Rectangle;
                objShape4                  = ShapeType.Rectangle;
                objShape5                  = ShapeType.Rectangle;
                segment                    = SegmentType.OrthoSegment;
                TextStyleVerticalAlignment = VerticalAlignment.Center;
                Dectype                    = DecoratorType.None;
                connColor                  = Color.Black;
                connLineApplyColorFrom     = ApplyColorFrom.TargetBorder;
                connDecApplyColorFrom      = ApplyColorFrom.TargetBorder;
                break;

            case "mindmapsimpletree.png":
                simpleCurveTree            = "simpleCurveTree";
                objShape1                  = ShapeType.RoundedRectangle;
                objShape2                  = ShapeType.RoundedRectangle;
                objShape3                  = ShapeType.RoundedRectangle;
                objShape4                  = ShapeType.RoundedRectangle;
                objShape5                  = ShapeType.RoundedRectangle;
                segment                    = SegmentType.CurveSegment;
                TextStyleVerticalAlignment = VerticalAlignment.Center;
                Dectype                    = DecoratorType.None;
                connColor                  = Color.ParseColor("#949494");
                connLineApplyColorFrom     = ApplyColorFrom.Custom;
                connDecApplyColorFrom      = ApplyColorFrom.Custom;
                break;
            }
            UpdateTheme();

            for (int i = 0; i < scrollLayout.ChildCount; i++)
            {
                ImageButtonView childView = (ImageButtonView)scrollLayout.GetChildAt(i);
                if (childView.ImageId == view.ImageId)
                {
                    continue;
                }
                childView.ButtonSelected = false;
            }
        }
Beispiel #5
0
        public override View GetSampleContent(Context context)
        {
            m_context      = context;
            currentDensity = m_context.Resources.DisplayMetrics.Density;
            //Initialize the SfDiagram and set its background color.
            diagram = new SfDiagram(context);
            diagram.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            diagram.IsReadOnly       = true;
            ObservableCollection <Employee> employees = new ObservableCollection <Employee>();

            employees.Add(new Employee()
            {
                Name = "Elizabeth", EmpId = "1", ParentId = "", Designation = "CEO"
            });
            employees.Add(new Employee()
            {
                Name = "Christina", EmpId = "2", ParentId = "1", Designation = "Manager"
            });
            employees.Add(new Employee()
            {
                Name = "Yang", EmpId = "3", ParentId = "1", Designation = "Manager"
            });
            employees.Add(new Employee()
            {
                Name = "Yoshi", EmpId = "4", ParentId = "2", Designation = "Team Lead"
            });
            employees.Add(new Employee()
            {
                Name = "Yoshi", EmpId = "5", ParentId = "2", Designation = "Co-ordinator"
            });
            employees.Add(new Employee()
            {
                Name = "Philip", EmpId = "6", ParentId = "4", Designation = "Developer"
            });
            employees.Add(new Employee()
            {
                Name = "Philip", EmpId = "7", ParentId = "4", Designation = "Testing Engineer"
            });
            employees.Add(new Employee()
            {
                Name = "Roland", EmpId = "8", ParentId = "3", Designation = "Team Lead"
            });
            employees.Add(new Employee()
            {
                Name = "Yoshi", EmpId = "9", ParentId = "3", Designation = "Co-ordinator"
            });
            employees.Add(new Employee()
            {
                Name = "Yuonne", EmpId = "10", ParentId = "8", Designation = "Developer"
            });
            employees.Add(new Employee()
            {
                Name = "Philip", EmpId = "10", ParentId = "8", Designation = "Testing Engineer"
            });
            //Initializes the DataSourceSettings
            diagram.DataSourceSettings = new DataSourceSettings()
            {
                DataSource = employees, Id = "EmpId", ParentId = "ParentId"
            };
            //Initializes the Layout
            DirectedTreeLayout treelayout = new DirectedTreeLayout()
            {
                HorizontalSpacing = 80, VerticalSpacing = 50 * currentDensity, TreeOrientation = TreeOrientation.TopToBottom
            };

            diagram.LayoutManager = new LayoutManager()
            {
                Layout = treelayout
            };

            diagram.BeginNodeRender += Diagram_BeginNodeRender;

            diagram.Loaded += Diagram_Loaded;

            LinearLayout linearLayout = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Vertical
            };

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            layoutParams.TopMargin        = 25 * (int)MainActivity.factor;
            linearLayout.LayoutParameters = layoutParams;

            LinearLayout typesBar = new LinearLayout(context);

            typesBar.SetBackgroundColor(Color.Rgb(245, 245, 245));
            layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            typesBar.SetMinimumHeight(200 * (int)MainActivity.factor);
            typesBar.SetPadding(0, 10 * (int)MainActivity.factor, 0, 10 * (int)MainActivity.factor);
            TextView selectText = new TextView(context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent),
                Text             = "Connector Types:",
                TextAlignment    = TextAlignment.Gravity,
                Gravity          = GravityFlags.Center | GravityFlags.CenterVertical,
                TextSize         = 15 * MainActivity.factor
            };
            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density);

            selectText.SetMinimumWidth((int)(width * 0.4 * MainActivity.factor));

            ImageButtonView straightButton = new ImageButtonView(context);

            straightButton.Click           += ButtonTouch;
            straightButton.ImageId          = "DiagramStraight";
            straightButton.LayoutParameters = new ViewGroup.LayoutParams(180 * (int)MainActivity.factor, 180 * (int)MainActivity.factor);

            ImageView straightImage = new ImageView(context);
            var       imageId       = straightButton.ImageId + ".png";

            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                straightImage.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            straightImage.Layout((int)(40 * MainActivity.factor), (int)(40 * MainActivity.factor), (int)(110 * MainActivity.factor), (int)(110 * MainActivity.factor));

            straightButton.AddView(straightImage);

            ImageButtonView curveButton = new ImageButtonView(context);

            curveButton.Click           += ButtonTouch;
            curveButton.ImageId          = "DiagramCurve";
            curveButton.LayoutParameters = new ViewGroup.LayoutParams(180 * (int)MainActivity.factor, 180 * (int)MainActivity.factor);

            ImageView curveImage = new ImageView(context);

            imageId = curveButton.ImageId + ".png";
            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                curveImage.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            curveImage.Layout((int)(40 * MainActivity.factor), (int)(40 * MainActivity.factor), (int)(110 * MainActivity.factor), (int)(110 * MainActivity.factor));

            curveButton.AddView(curveImage);

            ImageButtonView edgeButton = new ImageButtonView(context);

            edgeButton.Click           += ButtonTouch;
            edgeButton.LayoutParameters = new ViewGroup.LayoutParams(180 * (int)MainActivity.factor, 180 * (int)MainActivity.factor);
            edgeButton.ImageId          = "DiagramEdge";

            ImageView edgeImage = new ImageView(context);

            imageId = edgeButton.ImageId + ".png";
            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                edgeImage.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            edgeImage.Layout((int)(40 * MainActivity.factor), (int)(40 * MainActivity.factor), (int)(110 * MainActivity.factor), (int)(110 * MainActivity.factor));

            edgeButton.AddView(edgeImage);

            buttons = new LinearLayout(context);
            buttons.SetMinimumWidth((int)(width - width * 0.4 * MainActivity.factor));
            buttons.SetBackgroundColor(Color.Transparent);
            buttons.AddView(straightButton);
            TextView view = new TextView(context);

            view.SetWidth(30 * (int)MainActivity.factor);
            view.SetBackgroundColor(Color.Transparent);
            buttons.AddView(view);
            buttons.AddView(curveButton);
            view = new TextView(context);
            view.SetWidth(30 * (int)MainActivity.factor);
            view.SetBackgroundColor(Color.Transparent);
            buttons.AddView(view);
            buttons.AddView(edgeButton);

            typesBar.AddView(selectText);
            typesBar.AddView(buttons);

            linearLayout.AddView(typesBar);
            linearLayout.AddView(diagram);
            for (int i = 0; i < diagram.Connectors.Count; i++)
            {
                diagram.Connectors[i].TargetDecoratorType = DecoratorType.None;
                diagram.Connectors[i].Style.StrokeWidth   = 1;
            }
            return(linearLayout);
        }
        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);
        }