Example #1
0
        public Boolean ProcessUpperCommand()
        {
            if (!Const.PopupMenuEnabled)
            {
                return(false);
            }

            TableViewModel tvm       = (this.DataContext as TableViewModel);
            Boolean        processed = false;

            switch (upperSelected)
            {
            case (Command.Left):
                tvm.MainPageViewModel.SheetViewModel.BringFront(ColumnViewModel);
                tvm.MainPageViewModel.ReflectAll(ReflectReason.ColumnShown);
                UpperLeftMenuElement.Unhighlight();
                tvm.CancelIndexing(true);
                processed = true;
                break;

            case (Command.Right):
                tvm.MainPageViewModel.SheetViewModel.SetAside(ColumnViewModel);
                tvm.MainPageViewModel.ReflectAll(ReflectReason.ColumnHidden);
                UpperRightMenuElement.Unhighlight();
                tvm.CancelIndexing(true);
                processed = true;
                break;

            case (Command.Down):
                tvm.MainPageViewModel.SheetViewModel.Sort(ColumnViewModel, SortOption.Ascending);
                tvm.MainPageViewModel.ReflectAll(ReflectReason.ColumnSorted);
                UpperDownMenuElement.Unhighlight();
                tvm.CancelIndexing(true);
                processed = true;
                break;
            }

            upperSelected = Command.None;
            UpperDownMenuElement.Hide();
            UpperLeftMenuElement.Hide();
            UpperRightMenuElement.Hide();
            return(processed);
        }
Example #2
0
        public void Update(ColumnViewModel columnViewModel)
        {
            ColumnViewModel = columnViewModel;

            TableViewModel tvm = (this.DataContext as TableViewModel);

            Canvas.SetTop(LowerColumnHeaderWrapperElement, tvm.Height - Const.ColumnHeaderHeight);

            if (columnViewModel != null)
            {
                Int32 columnIndex = columnViewModel.Index;
                Int32 index       = 0;

                foreach (RowViewModel rowViewModel in tvm.ActivatedRowViewModels)
                {
                    TextBlock cell;
                    if (index < TableCanvas.Children.Count)
                    {
                        cell            = TableCanvas.Children[index] as TextBlock;
                        cell.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        cell = new TextBlock()
                        {
                            Style = Const.CellStyle
                        };
                        TableCanvas.Children.Add(cell);
                    }

                    String text = rowViewModel.Cells[columnIndex].Content.ToString();
                    cell.Text  = text;
                    cell.Width = columnViewModel.Width;
                    Canvas.SetTop(cell, rowViewModel.Y);
                    index++;
                }

                for (Int32 i = index; i < TableCanvas.Children.Count; ++i)
                {
                    TableCanvas.Children[i].Visibility = Visibility.Collapsed;
                }

                Double left = columnViewModel.X - tvm.ScrollLeft;

                if (left - columnViewModel.Width / 2 <= 0)
                {
                    UpperColumn.RenderTransformOrigin = new Point(0, 0);
                    LowerColumnHeaderWrapperElement.RenderTransformOrigin = new Point(0, 1);

                    Canvas.SetLeft(UpperPopupElement, 60);
                    Canvas.SetLeft(LowerPopupElement, 60);
                }
                else if (left + columnViewModel.Width * 3 / 2 >= tvm.SheetViewWidth)
                {
                    UpperColumn.RenderTransformOrigin = new Point(1, 0);
                    LowerColumnHeaderWrapperElement.RenderTransformOrigin = new Point(1, 1);

                    Canvas.SetLeft(UpperPopupElement, columnViewModel.Width - 60);
                    Canvas.SetLeft(LowerPopupElement, columnViewModel.Width - 60);
                }
                else
                {
                    UpperColumn.RenderTransformOrigin = new Point(0.5, 0);
                    LowerColumnHeaderWrapperElement.RenderTransformOrigin = new Point(0.5, 1);

                    Canvas.SetLeft(UpperPopupElement, columnViewModel.Width / 2);
                    Canvas.SetLeft(LowerPopupElement, columnViewModel.Width / 2);
                }

                Canvas.SetLeft(MagnifiedColumn, left);

                UpperColumnHeaderWrapperElement.Width       = LowerColumnHeaderWrapperElement.Width = MagnifiedColumn.Width = columnViewModel.Width;
                UpperColumnHeaderWrapperElement.DataContext = LowerColumnHeaderWrapperElement.DataContext = columnViewModel;

                Canvas.SetTop(UpperPopupElement, Const.ColumnHeaderHeight * 0.2);
                Canvas.SetTop(LowerPopupElement, columnViewModel.MainPageViewModel.Bounds.Height - Const.ColumnHeaderHeight * 1.7);

                Wrapper.Visibility = Visibility.Visible;

                TableScrollViewer.Height = tvm.SheetViewHeight;
                TableScrollViewer.ChangeView(null, tvm.ScrollTop, null, true);

                if (Const.PopupMenuEnabled)
                {
                    if (columnViewModel.IsHidden)
                    {
                        UpperRightMenuElement.Visibility = Visibility.Collapsed;
                        UpperLeftMenuElement.Visibility  = Visibility.Visible;
                        LowerRightMenuElement.Visibility = Visibility.Collapsed;
                        LowerLeftMenuElement.Visibility  = Visibility.Visible;
                    }
                    else
                    {
                        UpperRightMenuElement.Visibility = Visibility.Visible;
                        UpperLeftMenuElement.Visibility  = Visibility.Collapsed;
                        LowerRightMenuElement.Visibility = Visibility.Visible;
                        LowerLeftMenuElement.Visibility  = Visibility.Collapsed;
                    }
                }

                Brighten.Stop();
                if (Darken.GetCurrentState() != ClockState.Active)
                {
                    Darken.Begin();
                }
            }
            else
            {
                TableScrollViewer.Height = tvm.SheetViewHeight;
                if (Brighten.GetCurrentState() != ClockState.Active)
                {
                    Brighten.Begin();
                }
                Darken.Stop();

                if (Const.PopupMenuEnabled)
                {
                    UpperDownMenuElement.Hide();
                    UpperLeftMenuElement.Hide();
                    UpperRightMenuElement.Hide();

                    LowerUpMenuElement.Hide();
                    LowerLeftMenuElement.Hide();
                    LowerRightMenuElement.Hide();
                }
            }
        }