Ejemplo n.º 1
0
 private void LowerColumnHeaderWrapperElement_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     if (e.Pointer.PointerDeviceType != PointerDeviceType.Touch)
     {
         return;
     }
     LowerColumnHeaderWrapperElement.CapturePointer(e.Pointer);
     if (!Const.PopupMenuEnabled)
     {
         return;
     }
     LowerUpMenuElement.Show();
     LowerRightMenuElement.Show();
     LowerLeftMenuElement.Show();
 }
Ejemplo n.º 2
0
        void HighlightLowerMenu(Command command)
        {
            switch (command)
            {
            case Command.Up:
                LowerUpMenuElement.Highlight();
                break;

            case Command.Left:
                LowerLeftMenuElement.Highlight();
                break;

            case Command.Right:
                LowerRightMenuElement.Highlight();
                break;
            }
        }
Ejemplo n.º 3
0
        public Boolean ProcessLowerCommand()
        {
            if (!Const.PopupMenuEnabled)
            {
                return(false);
            }

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

            switch (lowerSelected)
            {
            case (Command.Left):
                tvm.MainPageViewModel.SheetViewModel.BringFront(ColumnViewModel);
                tvm.MainPageViewModel.ReflectAll(ReflectReason.ColumnShown);    // 2.SelectionChanged);
                LowerLeftMenuElement.Unhighlight();
                tvm.CancelIndexing(true);
                processed = true;
                break;

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

            case (Command.Up):
                tvm.MainPageViewModel.SheetViewModel.Sort(ColumnViewModel, SortOption.Descending);
                tvm.MainPageViewModel.ReflectAll(ReflectReason.ColumnSorted);     // 2.SelectionChanged);
                LowerUpMenuElement.Unhighlight();
                tvm.CancelIndexing(true);
                processed = true;
                break;
            }

            lowerSelected = Command.None;
            LowerUpMenuElement.Hide();
            LowerLeftMenuElement.Hide();
            LowerRightMenuElement.Hide();
            return(processed);
        }
Ejemplo n.º 4
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();
                }
            }
        }