public void GetVisualParents()
        {
#endif
            Grid           grid           = new Grid();
            ContentControl contentControl = new ContentControl();
            TextBox        textBox;
            Window.Content = grid;
            grid.Children.Add(contentControl);
            contentControl.ContentTemplate = textBoxTemplate;
#if NETFX_CORE
            await
#endif
            EnqueueShowWindow();
            EnqueueCallback(() => {
                textBox = (TextBox)LayoutHelper.FindElement(contentControl, x => x is TextBox);
                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x is ContentControl).First());
                Assert.AreSame(grid, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x is Grid).First());
                Assert.AreSame(Window, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x.GetType() == Window.GetType()).First());

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBox, contentControl).Where(x => x is ContentControl).First());
                Assert.IsNull(LayoutTreeHelper.GetVisualParents(textBox, contentControl).Where(x => x is Grid).FirstOrDefault());

                var presenter = LayoutTreeHelper.GetVisualChildren(contentControl).First();
                Assert.IsTrue(new[] { presenter }.SequenceEqual(LayoutTreeHelper.GetVisualParents(textBox, presenter)));
            });
            EnqueueTestComplete();
        }
Ejemplo n.º 2
0
        private void AssertAdditionalElements()
        {
            GridControl.Columns[0].GroupIndex = 0;
            UpdateLayoutAndDoEvents();
            MouseActions.MouseMove(View.GetRowElementByRowHandle(-1), View.GetRowElementByRowHandle(-1).ActualWidth / 2, View.GetRowElementByRowHandle(-1).ActualHeight / 2);
            Assert.AreEqual(4, HitTestModule.hitIfoItemsControl.Items.Count);
            Assert.AreEqual("-1 (group row)", GetHitInfoNameTextControl(2).TextValue);
            Assert.AreEqual(null, GetHitInfoNameTextControl(3).TextValue);

            MouseActions.MouseMove(LayoutHelper.FindElement(View.GetRowElementByRowHandle(-1), element => (string)element.GetValue(System.Windows.Controls.TextBlock.TextProperty) == "ID: 10248"), 5, 5);
            Assert.AreEqual(5, HitTestModule.hitIfoItemsControl.Items.Count);
            Assert.AreEqual("GroupValue", GetHitInfoNameTextControl(4).NameValue);
            Assert.AreEqual("OrderID: 10248", GetHitInfoNameTextControl(4).TextValue);

            MouseActions.MouseMove(LayoutHelper.FindElement(View.GetRowElementByRowHandle(-1), element => (string)element.GetValue(System.Windows.Controls.TextBlock.TextProperty) == "Count=3"), 5, 5);
            Assert.AreEqual(5, HitTestModule.hitIfoItemsControl.Items.Count);
            Assert.AreEqual("GroupSummary", GetHitInfoNameTextControl(4).NameValue);
            Assert.AreEqual("Count=3", GetHitInfoNameTextControl(4).TextValue);

            GridControl.ClearGrouping();
            UpdateLayoutAndDoEvents();
            MouseActions.MouseMove(LayoutHelper.FindElement(View, element => (string)element.GetValue(System.Windows.Controls.TextBlock.TextProperty) == "Count=2155"), 5, 5);
            Assert.AreEqual(4, HitTestModule.hitIfoItemsControl.Items.Count);
            Assert.AreEqual("FixedTotalSummary", GetHitInfoNameTextControl(3).NameValue);
            Assert.AreEqual("Count=2155", GetHitInfoNameTextControl(3).TextValue);
        }
 public static NavPanePopup GetPopup(NavBarControl nControl)
 {
     if (nControl == null || !(nControl.View is NavigationPaneView))
     {
         return(null);
     }
     return(LayoutHelper.FindElement(nControl, fe => fe is NavPanePopup) as NavPanePopup);
 }
        void ScrollLogToEnd()
        {
            ScrollViewer sv = (ScrollViewer)LayoutHelper.FindElement(log, IsScrollViewer);

            if (sv == null)
            {
                return;
            }
            sv.ScrollToVerticalOffset(sv.ScrollableHeight);
        }
Ejemplo n.º 5
0
        private void searchPanel_LayoutUpdated(object sender, EventArgs e)
        {
            TextBlock  lbPrompt       = LayoutHelper.FindElement(searchPanel, (element) => element is TextBlock && ((TextBlock)element).Text.Contains("Find")) as TextBlock;
            ButtonEdit tbSearchString = (ButtonEdit)LayoutHelper.FindElementByName(searchPanel, "tbSearchString");

            if (lbPrompt != null && tbSearchString != null)
            {
                lbPrompt.FontSize          = 16;
                tbSearchString.EditValue   = "test";
                searchPanel.LayoutUpdated -= searchPanel_LayoutUpdated;
            }
        }
 protected override void CreateSetCurrentDemoActions(ModuleDescription module, bool checkMemoryLeaks)
 {
     base.CreateSetCurrentDemoActions(module, checkMemoryLeaks);
     AddConditionAction(DocumentBuildCompletedConditionFactory.Create(this), null);
     AddSimpleAction(delegate() {
         if (DemoBaseTesting.CurrentDemoModule != null)
         {
             DocumentPreviewControl activePreview = LayoutHelper.FindElement(DemoBaseTesting.CurrentDemoModule, IsDocumentViewer) as DocumentPreviewControl;
             Assert.IsNotNull(activePreview);
         }
     });
 }
Ejemplo n.º 7
0
 void EnsurePivot()
 {
     if (PivotGridControl != null)
     {
         return;
     }
     DemoModuleControl.DemoContent = DemoModuleControl.FindDemoContent(typeof(PivotGridControl), (DependencyObject)Content);
     if (DemoModuleControl.DemoContent as FrameworkElement == null)
     {
         return;
     }
     PivotGridControl = LayoutHelper.FindElement(((FrameworkElement)DemoModuleControl.DemoContent), IsPivot) as PivotGridControl;
 }
Ejemplo n.º 8
0
        void CreateCheckUnboundColumnsDemoActions()
        {
            AddLoadModuleActions(typeof(GridDemo.UnboundColumns));
            AddSimpleAction(delegate() {
                Assert.AreEqual(0, GridControl.Columns["OrderID"].GroupIndex);
                Assert.AreEqual(1, GridControl.GroupCount);
                Assert.IsTrue(GridControl.IsGroupRowExpanded(-1));
                Assert.IsTrue(GridControl.IsGroupRowExpanded(-2));
                Assert.IsTrue(GridControl.IsGroupRowExpanded(-3));
                Assert.IsTrue(UnboundColumnsModule.showExpressionEditorButton.IsEnabled);
                Assert.IsTrue(GridControl.Columns["Total"].AllowUnboundExpressionEditor);
                Assert.IsTrue(GridControl.Columns["DiscountAmount"].AllowUnboundExpressionEditor);
                Assert.AreEqual(3, UnboundColumnsModule.columnsList.Items.Count);

                System.Windows.Controls.ListBox listBox;
                listBox = (System.Windows.Controls.ListBox)LayoutHelper.FindElement(UnboundColumnsModule.columnsList, IsListBox);

                Assert.AreEqual("Discount Amount", ((System.Windows.Controls.ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(0)).Content);
                Assert.AreEqual("Total", ((System.Windows.Controls.ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(1)).Content);
                Assert.AreEqual("Total Scale", ((System.Windows.Controls.ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(2)).Content);
                Assert.AreEqual("DiscountAmount", ((System.Windows.Controls.ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(0)).Tag);
                Assert.AreEqual("Total", ((System.Windows.Controls.ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(1)).Tag);
                Assert.AreEqual("TotalScale", ((System.Windows.Controls.ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(2)).Tag);

                Assert.IsNull(LayoutHelper.FindElementByName(View.GetCellElementByRowHandleAndColumn(3, GridControl.Columns["Total"]), "arrow"));
                Assert.IsNotNull(LayoutHelper.FindElementByName(View.GetCellElementByRowHandleAndColumn(4, GridControl.Columns["Total"]), "arrow"));
                Assert.AreEqual((decimal)0.0, GridControl.GetCellValue(0, GridControl.Columns["DiscountAmount"]));
                Assert.AreEqual((decimal)168.0, GridControl.GetCellValue(0, GridControl.Columns["Total"]));
                Assert.AreEqual((decimal)0.4, GridControl.GetCellValue(0, GridControl.Columns["TotalScale"]));
                Assert.IsTrue(Math.Abs((double)223.0 - Convert.ToDouble(GridControl.GetCellValue(6, GridControl.Columns["DiscountAmount"]))) < 0.001);
                Assert.IsTrue(Math.Abs((double)1261.4 - Convert.ToDouble(GridControl.GetCellValue(6, GridControl.Columns["Total"]))) < 0.001);
                Assert.IsTrue(Math.Abs((double)0.7614 - Convert.ToDouble(GridControl.GetCellValue(6, GridControl.Columns["TotalScale"]))) < 0.001);

                AssertShowExpressionEditor("Round([UnitPrice] * [Quantity] - [Total])");
                UnboundColumnsModule.columnsList.SelectedIndex = 1;
                UpdateLayoutAndDoEvents();
                AssertShowExpressionEditor("[UnitPrice] * [Quantity] * (1 - [Discount])");
                UnboundColumnsModule.columnsList.SelectedIndex = 2;
                UpdateLayoutAndDoEvents();
                AssertShowExpressionEditor("Iif([Total] < 1000, 0.4, Min(0.5 + ([Total] - 1000) / 1000, 1.2))");

                GridControl.Columns["DiscountAmount"].UnboundExpression = "[UnitPrice] * [Quantity] * (1 - [Discount])+[Discount][[Discount]]";
                UpdateLayoutAndDoEvents();
                Assert.AreEqual(DevExpress.Data.UnboundErrorObject.Value, GridControl.GetCellValue(0, GridControl.Columns["DiscountAmount"]));
            });
        }
        public void GetVisualChildren()
        {
            Grid           grid           = new Grid();
            ContentControl contentControl = new ContentControl();
            TextBox        textBox;

            Window.Content = grid;
            grid.Children.Add(contentControl);
            contentControl.ContentTemplate = textBoxTemplate;
            EnqueueShowWindow();
            EnqueueCallback(() => {
                textBox = (TextBox)LayoutHelper.FindElement(contentControl, x => x is TextBox);

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualChildren(grid).Where(x => x is ContentControl).FirstOrDefault());
                Assert.AreSame(textBox, LayoutTreeHelper.GetVisualChildren(grid).Where(x => x is TextBox).FirstOrDefault());
            });
            EnqueueTestComplete();
        }
        void IDropTarget.Drop(UIElement source, Point pt)
        {
            ColumnBase dropColumn = GetColumnByDragElement(source);

            if (dropColumn.Visible)
            {
                Point            bottomLinePrevElement = new Point(0, 0);
                ColumnList       list = LayoutHelper.FindParentObject <ColumnList>(source as DependencyObject) as ColumnList;
                GridColumnHeader bottomColumnHeader = null;
                bottomColumnHeader = (GridColumnHeader)LayoutHelper.FindElement(list, new Predicate <FrameworkElement>(delegate(FrameworkElement element) {
                    return((element is GridColumnHeader) && PointOnColumn(list, element, pt, ref bottomLinePrevElement));
                }));
                ColumnBase bottomColumn = GetColumnByDragElement(bottomColumnHeader);
                dropColumn.VisibleIndex = bottomColumn.VisibleIndex;
            }
            else
            {
                dropColumn.Visible = true;
            }
        }
        GridColumn FindVisibleColumn(Func <double, bool> cond, ref double columnsWidth)
        {
            columnsWidth = 0d;
            GridColumn res = null;

            if (!View.AutoWidth)
            {
                columnsWidth += LayoutHelper.FindElement(View, IsFitContent).ActualWidth;
            }
            foreach (GridColumn gc in View.VisibleColumns)
            {
                columnsWidth += gc.ActualHeaderWidth;
                if (cond(columnsWidth))
                {
                    res = gc;
                    break;
                }
            }
            return(res);
        }
 protected override void OnAttached()
 {
     base.OnAttached();
     DetailGrid.Dispatcher.BeginInvoke(new Action(() => {
         onAttached++;
         {
             MasterGrid               = LayoutHelper.FindParentObject <GridControl>(DetailGrid.TemplatedParent);
             widthAdjustmentValue     = (MasterGrid.View as TableView).ExpandDetailButtonWidth;
             FrameworkElement content = LayoutHelper.FindElement(MasterGrid, (element) => element is ContentPresenter && element.Name == "content");
             if (content != null)
             {
                 widthAdjustmentValue += content.Margin.Left;
             }
             SetWidthBindings();
             DetailGrid.ItemsSourceChanged        += DetailGrid_ItemsSourceChanged;
             DetailGrid.Columns.CollectionChanged += DetailGridColumns_CollectionChanged;
             MasterGrid.Columns.CollectionChanged += MasterGridColumns_CollectionChanged;
         }
         onAttached--;
     }), DispatcherPriority.Render);
 }
Ejemplo n.º 13
0
        void AddToStack(string str, CheckEdit checkEdit)
        {
            if (!IsLoaded || !(bool)checkEdit.IsChecked)
            {
                return;
            }
            logQueue.Enqueue(str);
            if (logQueue.Count > logEntriesCount)
            {
                logQueue.Dequeue();
            }
            textBox.Text = string.Empty;
            StringBuilder builder = new StringBuilder();

            foreach (string text in logQueue)
            {
                builder.Append((builder.Length != 0 ? Environment.NewLine : string.Empty) + text);
            }
            textBox.Text = builder.ToString();
            TextBox textBoxCore = (TextBox)LayoutHelper.FindElement(textBox, (element) => (element is TextBox));

            textBoxCore.ScrollToEnd();
        }
        void OnViewLayoutUpdated(object sender, EventArgs e)
        {
            if (Grid.SelectionMode == MultiSelectMode.None)
            {
                IsLogicBlocked = true;
            }
            DataArea = LayoutHelper.FindElement(View, IsScrollContentPresenterAndHasRowPresenterGridAsParent);
            if (DataArea == null)
            {
                return;
            }
            ScrollElement = (DataPresenter)LayoutHelper.FindElement(DataArea, IsDataPresenter);
            if (ScrollElement == null)
            {
                return;
            }

            View.LayoutUpdated -= OnViewLayoutUpdated;

            Grid.PreviewMouseMove += OnGridPreviewMouseMove;
            Grid.PreviewMouseDown += OnGridPreviewMouseDown;
            Grid.PreviewMouseUp   += OnGridPreviewMouseUp;
        }
        public void GetVisualParents2()
        {
            Grid           grid           = new Grid();
            ContentControl contentControl = new ContentControl();
            TextBlock      textBox;

            System.Windows.Documents.Inline textBoxContent = null;
            Window.Content = grid;
            grid.Children.Add(contentControl);
            contentControl.ContentTemplate = textBlockTemplate;
            EnqueueShowWindow();
            EnqueueCallback(() => {
                textBox        = (TextBlock)LayoutHelper.FindElement(contentControl, x => x is TextBlock);
                textBoxContent = textBox.Inlines.First();

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBoxContent).Where(x => x is ContentControl).First());
                Assert.AreSame(grid, LayoutTreeHelper.GetVisualParents(textBoxContent).Where(x => x is Grid).First());
                Assert.AreSame(Window, LayoutTreeHelper.GetVisualParents(textBoxContent).Where(x => x.GetType() == Window.GetType()).First());

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBoxContent, contentControl).Where(x => x is ContentControl).First());
                Assert.IsNull(LayoutTreeHelper.GetVisualParents(textBoxContent, contentControl).Where(x => x is Grid).FirstOrDefault());
            });
            EnqueueTestComplete();
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 让 DataLayoutControl 第一个元素聚焦
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DataLayoutControl_Loaded(object sender, RoutedEventArgs e)
 {
     ((DataLayoutItem)LayoutHelper.FindElement(sender as FrameworkElement, elem => elem is DataLayoutItem)).Content.Focus();
 }
 PopupListBox GetListBox()
 {
     return((PopupListBox)LayoutHelper.FindElement((FrameworkElement)PopupBaseEditHelper.GetPopup(customizationLayouts).PopupContent, IsListBox));
 }
Ejemplo n.º 18
0
        void CreateCheckHitTestDemoActions()
        {
            AddLoadModuleActions(typeof(GridDemo.HitTesting));
            AddSimpleAction(delegate() {
                Assert.IsTrue(HitTestModule.showHitInfoCheckEdit.IsChecked.Value);
                Assert.AreEqual(0, HitTestModule.viewsListBox.SelectedIndex);
                Assert.AreEqual(GridControl, HitTestModule.hitInfoPopup.PlacementTarget);
                Assert.AreEqual(PlacementMode.Mouse, HitTestModule.hitInfoPopup.Placement);
                MouseActions.MouseMove(GridControl, -5, -5);
                Assert.IsFalse(HitTestModule.hitInfoPopup.IsOpen);
                MouseActions.MouseMove(GridControl, 5, 5);
                Assert.IsTrue(HitTestModule.hitInfoPopup.IsOpen);
                Assert.AreEqual(0d, HitTestModule.hitInfoPopup.HorizontalOffset);
                Assert.AreEqual(0d, HitTestModule.hitInfoPopup.VerticalOffset);

                EditorsActions.ToggleCheckEdit(HitTestModule.showHitInfoCheckEdit);
                Assert.IsFalse(HitTestModule.hitInfoPopup.IsOpen);
                EditorsActions.ToggleCheckEdit(HitTestModule.showHitInfoCheckEdit);
                Assert.IsTrue(HitTestModule.hitInfoPopup.IsOpen);

                MouseActions.LeftMouseDown(GridControlHelper.GetColumnHeaderElements(GridControl, GridControl.Columns[0])[0], 5, 5);
                MouseActions.MouseMove(GridControlHelper.GetColumnHeaderElements(GridControl, GridControl.Columns[0])[0], 25, 5);
                Assert.IsFalse(HitTestModule.hitInfoPopup.IsOpen);
                MouseActions.LeftMouseUp(GridControlHelper.GetColumnHeaderElements(GridControl, GridControl.Columns[0])[0], 5, 5);
                Assert.IsTrue(HitTestModule.hitInfoPopup.IsOpen);

                TableView.ShowColumnChooser();
                UpdateLayoutAndDoEvents();
                Assert.IsFalse(HitTestModule.hitInfoPopup.IsOpen);
                TableView.HideColumnChooser();
                UpdateLayoutAndDoEvents();
                Assert.IsTrue(HitTestModule.hitInfoPopup.IsOpen);

                Assert.AreEqual(4, HitTestModule.hitIfoItemsControl.Items.Count);
                Assert.AreEqual("HitTest", GetHitInfoNameTextControl(0).NameValue);
                Assert.AreEqual("ColumnHeader", GetHitInfoNameTextControl(0).TextValue);
                Assert.AreEqual("Column", GetHitInfoNameTextControl(1).NameValue);
                Assert.AreEqual("ID", GetHitInfoNameTextControl(1).TextValue);
                Assert.AreEqual("RowHandle", GetHitInfoNameTextControl(2).NameValue);
                Assert.AreEqual("No row", GetHitInfoNameTextControl(2).TextValue);
                Assert.AreEqual("CellValue", GetHitInfoNameTextControl(3).NameValue);
                Assert.AreEqual("", GetHitInfoNameTextControl(3).TextValue);

                MouseActions.MouseMove(LayoutHelper.FindElementByName(GridControl, "PART_NewItemRow"), 35, 5);
                Assert.AreEqual(4, HitTestModule.hitIfoItemsControl.Items.Count);
                Assert.AreEqual("New Item Row", GetHitInfoNameTextControl(2).TextValue);

                MouseActions.MouseMove(LayoutHelper.FindElementByName(GridControl, "PART_FilterRow"), 35, 5);
                Assert.AreEqual(4, HitTestModule.hitIfoItemsControl.Items.Count);
                Assert.AreEqual("Auto Filter Row", GetHitInfoNameTextControl(2).TextValue);

                MouseActions.MouseMove(View.GetCellElementByRowHandleAndColumn(0, GridControl.Columns[0]), 35, 5);
                Assert.AreEqual(4, HitTestModule.hitIfoItemsControl.Items.Count);
                Assert.AreEqual("0 (data row)", GetHitInfoNameTextControl(2).TextValue);
                Assert.AreEqual("10248", GetHitInfoNameTextControl(3).TextValue);

                AssertAdditionalElements();

                MouseActions.MouseMove(LayoutHelper.FindElement(LayoutHelper.FindElement(GridControl, IsGroupGridRow), e => e is DevExpress.Xpf.Grid.GroupRowIndicator), 5, 5);
                Assert.AreEqual(5, HitTestModule.hitIfoItemsControl.Items.Count);
                Assert.AreEqual("RowIndicatorState", GetHitInfoNameTextControl(4).NameValue);
                Assert.AreEqual("Focused", GetHitInfoNameTextControl(4).TextValue);

                HitTestModule.viewsListBox.SelectedIndex = 1;
                CardView.CardLayout = DevExpress.Xpf.Grid.CardLayout.Rows;
                UpdateLayoutAndDoEvents();
                Assert.IsNotNull(CardView);
                AssertAdditionalElements();
            });
        }
Ejemplo n.º 19
0
 T FindElement <T>(FrameworkElement element) where T : FrameworkElement
 {
     return((T)LayoutHelper.FindElement(element, d => d.GetType() == typeof(T)));
 }
Ejemplo n.º 20
0
 GridControl GetDetailGrid(FrameworkElement rowElement)
 {
     return(LayoutHelper.FindElement(rowElement, (el) => el is GridControl) as GridControl);
 }