コード例 #1
0
		public void InitViewModels ()
		{
			_matrixControl = new MatrixControl (this);
			cnvMatrix.Content = _matrixControl;
			ViewModel.SetMatrixControl (_matrixControl);
		}
コード例 #2
0
        void OnZxNavRecieved(MatrixControl sender, string zxName)
        {
            foreach (var s in Segments.Where(s => s.Key > 0))
            {

                var existItem = s.Value.NavItems.FirstOrDefault(x => x.Title == zxName);
                if (existItem != null)
                {
                    if (s.Value.SelectedItem == null || s.Value.Status != NavSegmentStatus.Current)
                    {
                        s.Value.SelectedItem = existItem;

                        OnNavMenuClick(s.Value, new NavMenuEventArgs()
                        {
                            CurrentLevel = s.Value.CurrentLevel,
                            CurrentSelectedId = existItem.Id
                        });
                    }
                }
            }
        }
コード例 #3
0
		public void SetMatrixControl (MatrixControl control)
		{
			_matrixControl = control;
		}
コード例 #4
0
        public void DrawMatrix(TreeMapRootGroup data)
        {
            if (_inProgress)
                return;

            _rootCanvas.Children.Clear ();

            if (data != null && data.children != null && data.children.Any ()) {
                data.SetPrimaryValue (GetPrimaryPropertyName (), GetColorValuePropertyName (), GetRValuePropertyName ());

                _inProgress = true;

                var groupItemsValues = data.children.Select (gr => new MatrixInputData () {
                    ParentId = gr.name,
                    ChildValues = gr.children.Select (ch => ch.PrimaryValue.Value).ToArray ()
                });

                var groupRects = SquarifiedAlgorithm.CalculateRectangles (groupItemsValues, new Size (Width - 2, Height));

                _parentView.SetZxRects (groupRects);

                var matrixList = new List<View> ();

                foreach (var rect in groupRects) {
                    var existGroup = data.children.FirstOrDefault (gr => rect.ParentId == gr.name);
                    if (existGroup != null) {
                        if (existGroup.children.Any ()) {
                            var matrixCell = new MatrixControl (_parentView) {
                                HeightRequest = rect.Height,
                                WidthRequest = rect.Width
                            };
                            matrixCell.GroupTitle = existGroup.text;
                            matrixCell.Children = existGroup.children;

                            matrixList.Add (matrixCell);
                            var boundsRect = new Rectangle (rect.X, rect.Y, rect.Width, rect.Height);

                            AbsoluteLayout.SetLayoutBounds (matrixCell, boundsRect);

                            _rootCanvas.Children.Add (matrixCell);
                        }
                    }
                }

                foreach (var m in matrixList.OfType<MatrixControl>()) {
                    m.CalculateChildrenRect (m.Children);
                    m.DrawMatrix (m.Children);
                }

                _inProgress = false;
            }
        }