void OnLoaded(object sender, RoutedEventArgs e)
 {
     editor = LayoutHelper.FindElementByName <DemoRichEditBox>(this, "PART_editbox");
     if (editor != null)
     {
         editor.Loaded += OnEditorLoaded;
     }
 }
Ejemplo n.º 2
0
        private static void HidePanels(object sender)
        {
            DockBarContainerControl control = LayoutHelper.FindElementByName(sender as FrameworkElement, "PART_BarContainerControl") as DockBarContainerControl;

            control.Visibility = System.Windows.Visibility.Collapsed;

            ClosedItemsPanel panel = LayoutHelper.FindElementByName(sender as FrameworkElement, "PART_ClosedItemsPanel") as ClosedItemsPanel;

            panel.Visibility = System.Windows.Visibility.Collapsed;
        }
        void UpdateSearchControl()
        {
            if (searchControl == null)
            {
                return;
            }
            BaseEdit edit = (BaseEdit)LayoutHelper.FindElementByName(searchControl, "editor");

            edit.NullText = NullText;
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
0
 private void DXWindow_Loaded(object sender, RoutedEventArgs e)
 {
     if (this.ShowButton)
     {
         // hide default close button
         StackPanel stackPanel = LayoutHelper.FindElementByName(sender as FrameworkElement, "stackPanel") as StackPanel;
         if (stackPanel != null)
         {
             stackPanel.Visibility = Visibility.Collapsed;
         }
     }
 }
Ejemplo n.º 6
0
        static DependencyObject FindObject(DependencyObject root, string elementName, bool useVisualTree)
        {
            if (GetObjectName(root) == elementName)
            {
                return(root);
            }
            DependencyObject res      = null;
            FrameworkElement fe       = root as FrameworkElement;
            FrameworkElement feParent = fe.Parent as FrameworkElement;
            FrameworkElement el       = feParent ?? fe;

#if !SILVERLIGHT && !NETFX_CORE
            try {
                res = LogicalTreeHelper.FindLogicalNode(el, elementName);
            } catch { }
            if (res != null)
            {
                return(res);
            }

            FrameworkContentElement fce = root as FrameworkContentElement;
            res = fce != null ? (DependencyObject)fce.FindName(elementName) : null;
            if (res != null)
            {
                return(res);
            }
#endif
            res = el != null ? (DependencyObject)el.FindName(elementName) : null;
            if (res != null)
            {
                return(res);
            }

            if (useVisualTree)
            {
                res = feParent != null?LayoutHelper.FindElementByName(feParent, elementName) : null;

                if (res != null)
                {
                    return(res);
                }

                res = fe != null?LayoutHelper.FindElementByName(fe, elementName) : null;

                if (res != null)
                {
                    return(res);
                }
            }

            return(null);
        }
        void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var scrollBar = (ScrollBar)LayoutHelper.FindElementByName(AssociatedObject, "PART_HorizontalScrollBar");

            if (e.Delta > 0)
            {
                ScrollBar.LineLeftCommand.Execute(null, scrollBar);
            }
            else if (e.Delta < 0)
            {
                ScrollBar.LineRightCommand.Execute(null, scrollBar);
            }
        }
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"]));
            });
        }
Ejemplo n.º 9
0
        void OnGridLoaded(object sender, RoutedEventArgs e)
        {
            GridView.Loaded -= OnGridLoaded;
            FilterPanelControl filterPanel = LayoutHelper.FindElementByName(GridView, "PART_FilterPanel") as FilterPanelControl;

            if (filterPanel == null)
            {
                return;
            }
            DXDockPanel dockPanel = filterPanel.Parent as DXDockPanel;

            if (dockPanel == null)
            {
                return;
            }
            DXDockPanel.SetDock(GridBottomControl, Dock.Bottom);
            dockPanel.Children.Insert(0, GridBottomControl);
        }
        private void richEditControl1_CustomMarkDraw(object sender, CustomMarkDrawEventArgs e)
        {
            Canvas surface = LayoutHelper.FindElementByName(richEditControl1, "Surface") as Canvas;

            if (surface == null)
            {
                return;
            }

            GeneralTransform  transform = surface.TransformToVisual(richEditControl1);
            RectangleGeometry clip      = new RectangleGeometry()
            {
                Rect = new Rect(transform.Transform(new Point(0, 0)), surface.RenderSize)
            };

            richEditCanvas.Children.Clear();
            richEditCanvas.Clip = clip;

            foreach (CustomMarkVisualInfo info in e.VisualInfoCollection)
            {
                Document   doc  = richEditControl1.Document;
                CustomMark mark = doc.CustomMarks.GetByVisualInfo(info);
                // Get a brush associated with the mark.
                Brush curBrush = info.UserData as Brush;
                // Use a different brush to draw custom marks located above the caret.
                if (mark.Position < doc.Selection.Start)
                {
                    curBrush = new SolidColorBrush(Colors.Green);
                }
                Rectangle rect = new Rectangle();
                rect.Width  = 2;
                rect.Height = info.Bounds.Height;
                rect.Fill   = curBrush;
                Canvas.SetLeft(rect, info.Bounds.X);
                Canvas.SetTop(rect, info.Bounds.Y);
                richEditCanvas.Children.Add(rect);
            }
        }
Ejemplo n.º 11
0
 private void richEditControl1_Loaded(object sender, RoutedEventArgs e)
 {
     richEditControl1.CreateCommand(RichEditCommandId.Find).Execute();
     searchPanel = (RichEditSearchPanel)LayoutHelper.FindElementByName(richEditControl1, "SearchPanel");
     searchPanel.LayoutUpdated += searchPanel_LayoutUpdated;
 }
 void OnEditorLoaded(object sender, RoutedEventArgs e)
 {
     scroll              = LayoutHelper.FindElementByName <ScrollViewer>(this, "PART_scroll");
     scroll.SizeChanged += OnSizeChanged;
     UpdateZoom();
 }
Ejemplo n.º 13
0
 T GetElementByName <T>(FrameworkElement root, string name) where T : FrameworkElement
 {
     return((T)LayoutHelper.FindElementByName(root, name));
 }
Ejemplo n.º 14
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.º 15
0
 protected override void OnApplyTemplate()
 {
     scroll         = LayoutHelper.FindElementByName <ScrollViewer>(this, "PART_Scroll");
     scroll.Loaded += Scroll_Loaded;
 }
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     scrollViewer = LayoutHelper.FindElementByName(sender as MainWindow, "documentPreviewScrollViewer") as ScrollViewer;
     EventRegistration.RootElement = scrollViewer;
 }