Window FindOwner() { Window result = WindowObject as Window; if (result != null) { return(result); } bool visualTreeSearch = SplashScreenOwner.GetPreferVisualTreeForOwnerSearch(WindowObject); if (visualTreeSearch) { result = LayoutHelper.FindParentObject <Window>(WindowObject); } if (result == null) { result = Window.GetWindow(WindowObject); } if (!visualTreeSearch && result != null && SplashScreenOwner.GetPreferVisualTreeForOwnerSearch(result)) { visualTreeSearch = true; var newWindow = LayoutHelper.FindParentObject <Window>(WindowObject); if (newWindow != null) { result = newWindow; } } return(result); }
private void tileLayoutControl1_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } TileLayoutControl tileLayoutControl = sender as TileLayoutControl; Point mousePos = e.GetPosition(tileLayoutControl1); Rect rect = new Rect( (point.X - SystemParameters.MinimumHorizontalDragDistance), (point.Y - (int)SystemParameters.MinimumVerticalDragDistance), SystemParameters.MinimumHorizontalDragDistance * 2, SystemParameters.MinimumVerticalDragDistance * 2); if (!rect.Contains(mousePos)) { IInputElement hitTest = tileLayoutControl.InputHitTest(mousePos); Tile tile = LayoutHelper.FindParentObject <Tile>((DependencyObject)hitTest) as Tile; if (tile != null) { DataObject dragData = new DataObject("LCToGrid", tile.Content); SetToZero(); DragDrop.DoDragDrop(tileLayoutControl, dragData, DragDropEffects.Copy); } } }
protected override void OnMouseUp(MouseButtonEventArgs e) { FrameEx.AllowNavigateOnChangeSet = true; // set true to give message regarding changeset when click on button BreadcrumbBar bar = LayoutHelper.FindParentObject <BreadcrumbBar>(this); if (bar != null && bar.TargetFrame != null) { IRibbonPage page = bar.TargetFrame.Content as IRibbonPage; if (page != null && page.CanSave() && FrameEx.AllowNavigateOnChangeSet) { if (CommonMethods.ShowMessageOnNavigated(page)) { e.Handled = true; return; } FrameEx.AllowNavigateOnChangeSet = false; } } e.Handled = true; if (isPressed) { RoutedEventArgs args = new RoutedEventArgs(BreadcrumbButton.ClickEvent); RaiseEvent(args); selectCommand.Execute(null, this); } IsPressed = isPressed = false; base.OnMouseUp(e); }
static void gallery_Drop(object sender, DragEventArgs e) { e.Handled = true; if (dragableItem != null) { HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, e.GetPosition((GalleryControl)sender)); if (res.VisualHit == null) { return; } GalleryItemControl target = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit); if (target != null && target.Item != dragableItem) { GalleryItemCollection targetCollection = target.Item.Group.Items; GalleryItemCollection sourceCollection = dragableItem.Group.Items; int targetIndex = targetCollection.IndexOf(target.Item); if (targetCollection == sourceCollection) { targetCollection.Move(originalIndex, targetIndex); } else { sourceCollection.Remove(dragableItem); targetCollection.Insert(targetIndex, dragableItem); } dragableItem = null; } } }
protected override object Convert(object sender, InitNewRowEventArgs e) { TableView view = LayoutHelper.FindParentObject <TableView>(e.OriginalSource as DependencyObject); GridControl grid = LayoutHelper.FindParentObject <GridControl>(e.OriginalSource as DependencyObject); return(new InitNewRowDataClass(grid, e, view)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { WindowContentHolder wch = LayoutHelper.FindParentObject <WindowContentHolder>((DependencyObject)value); Application.Current.Dispatcher.BeginInvoke(new StartAnimationEventDelegate(Animate), wch); wch.IsVisibleChanged += new DependencyPropertyChangedEventHandler(wch_IsVisibleChanged); return(wch.Background); }
protected override object Convert(object sender, EventArgs e) { MouseButtonEventArgs args = (MouseButtonEventArgs)e; TableView view = LayoutHelper.FindParentObject <TableView>(args.OriginalSource as DependencyObject); int rowHandle = view.GetRowHandleByMouseEventArgs(args); return(view.Grid.GetRow(rowHandle) as SampleData); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { Column column = (Column)item; #if SILVERLIGHT return((DataTemplate)LayoutHelper.FindParentObject <UserControl>(container).Resources[column.Settings + "ColumnTemplate"]); #else return((DataTemplate)((Control)container).FindResource(column.Settings + "ColumnTemplate")); #endif }
private void Preview_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { string name = Common.Core.GetFileName(Common.Core.FileOutputType.Contract); DevExpress.Xpf.Printing.PrintableControlLink link = Common.Core.GetPrintableLink(this.tableView); link.ShowPrintPreviewDialog(LayoutHelper.FindParentObject <Window>(this)); //Window owner = LayoutHelper.FindParentObject<Window>(this); //DevExpress.Xpf.Grid.Printing.PrintHelper.ShowPrintPreviewDialog(owner, this.tableView); }
void list_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ListBoxEdit listBoxEdit = (ListBoxEdit)sender; DependencyObject hitObject = listBoxEdit.InputHitTest(e.GetPosition(listBoxEdit)) as DependencyObject; FrameworkElement hitItem = LayoutHelper.FindParentObject <ListBoxEditItem>(hitObject); if (hitItem != null) { isDragStarted = true; } }
public HitTestResultBehavior CallBack(HitTestResult result) { ListBoxEditItem item = LayoutHelper.FindParentObject <ListBoxEditItem>(result.VisualHit); if (item != null) { Element = item; return(HitTestResultBehavior.Stop); } return(HitTestResultBehavior.Continue); }
public override void OnApplyTemplate() { if (TitleElement != null) { TitleElement.MouseLeftButtonUp -= OnTitleElementMouseLeftButtonUp; } base.OnApplyTemplate(); TitleElement = LayoutHelper.FindParentObject <LayoutGroup>(GetTemplateChild("MaximizeElement")); if (TitleElement != null) { TitleElement.MouseLeftButtonUp += new MouseButtonEventHandler(OnTitleElementMouseLeftButtonUp); } }
UIElement GetUIVisualHit(DependencyObject d) { if (d == null) { return(null); } UIElement element = d as UIElement; if (element != null) { return(element); } return(LayoutHelper.FindParentObject <UIElement>(d)); }
void AssertShowExpressionEditor(string expectedExpression) { View.UnboundExpressionEditorCreated += UnboundExpressionEditorHandler; try { UIAutomationActions.ClickButton(UnboundColumnsModule.showExpressionEditorButton); UpdateLayoutAndDoEvents(); Assert.IsTrue(expressionEditorControl.IsVisible); Assert.AreEqual(expectedExpression, expressionEditorControl.Expression); UIAutomationActions.ClickButton(LayoutHelper.FindParentObject <DialogControl>(expressionEditorControl).CancelButton); UpdateLayoutAndDoEvents(); Assert.IsFalse(expressionEditorControl.IsVisible); expressionEditorControl = null; } finally { View.UnboundExpressionEditorCreated -= UnboundExpressionEditorHandler; } }
void gridControl_PreviewMouseDown(object sender, MouseButtonEventArgs e) { popup.IsOpen = false; FrameworkElement header = LayoutHelper.FindParentObject <IndicatorColumnHeader>(e.OriginalSource as DependencyObject); if (Mouse.LeftButton == MouseButtonState.Pressed && header != null) { popup.PlacementTarget = header; popup.Child = new ListBox() { ItemsSource = gridControl.Columns, ItemTemplate = FindResource("itemTemplate") as DataTemplate }; popup.IsOpen = true; e.Handled = true; } }
private void grid_MouseLeftButtonUp(object sender, MouseEventArgs e) { if (popup == null) { initializePopup(); } FrameworkElement header = LayoutHelper.FindParentObject <IndicatorColumnHeader>(e.OriginalSource as DependencyObject); if (header != null) { Point pos = e.GetPosition(this); popup.VerticalOffset = pos.Y; popup.HorizontalOffset = pos.X; popup.IsOpen = true; } }
void CreateCheckFilterControlDemoActions() { AddLoadModuleActions(typeof(FilterControl)); AddSimpleAction(delegate() { Assert.IsTrue(View.AllowFilterEditor); CriteriaOperator filterCriteria = new BinaryOperator("OrderID", 10248, BinaryOperatorType.Equal); Assert.AreEqual(filterCriteria, FilterControlModule.filterEditor.FilterCriteria); Assert.AreEqual(filterCriteria, GridControl.FilterCriteria); Assert.AreEqual(false, FilterControlModule.showGroupCommandsIcon.IsChecked); Assert.AreEqual(false, FilterControlModule.showOperandTypeIcon.IsChecked); Assert.AreEqual(true, FilterControlModule.showToolTips.IsChecked); Assert.IsFalse(FilterControlModule.filterEditor.ShowGroupCommandsIcon); Assert.IsFalse(FilterControlModule.filterEditor.ShowOperandTypeIcon); Assert.IsTrue(FilterControlModule.filterEditor.ShowToolTips); EditorsActions.ToggleCheckEdit(FilterControlModule.showGroupCommandsIcon); UpdateLayoutAndDoEvents(); Assert.IsTrue(FilterControlModule.filterEditor.ShowGroupCommandsIcon); EditorsActions.ToggleCheckEdit(FilterControlModule.showOperandTypeIcon); UpdateLayoutAndDoEvents(); Assert.IsTrue(FilterControlModule.filterEditor.ShowOperandTypeIcon); EditorsActions.ToggleCheckEdit(FilterControlModule.showToolTips); UpdateLayoutAndDoEvents(); Assert.IsFalse(FilterControlModule.filterEditor.ShowToolTips); filterCriteria = new BinaryOperator("OrderID", 10249L, BinaryOperatorType.Equal); FilterControlModule.filterEditor.FilterCriteria = filterCriteria; UpdateLayoutAndDoEvents(); UIAutomationActions.ClickButton(FilterControlModule.ApplyFilterButton); Assert.AreEqual(filterCriteria, GridControl.FilterCriteria); filterCriteria = new BinaryOperator("OrderID", 10250L, BinaryOperatorType.Equal); GridControl.FilterCriteria = filterCriteria; UpdateLayoutAndDoEvents(); Assert.AreEqual(filterCriteria, FilterControlModule.filterEditor.FilterCriteria); View.FilterEditorCreated += new DevExpress.Xpf.Grid.FilterEditorEventHandler(View_FilterEditorCreated); View.ShowFilterEditor(null); UpdateLayoutAndDoEvents(); Assert.IsNotNull(FilterEditorFromGrid); Assert.IsTrue(FilterEditorFromGrid.ShowGroupCommandsIcon); Assert.IsTrue(FilterEditorFromGrid.ShowOperandTypeIcon); Assert.IsFalse(FilterEditorFromGrid.ShowToolTips); DialogControl filterDialogControl = LayoutHelper.FindParentObject <DialogControl>(FilterEditorFromGrid); Assert.IsNotNull(filterDialogControl); UIAutomationActions.ClickButton(filterDialogControl.CancelButton); }); }
private void GalleryControl_MouseRightButtonUp_1(object sender, MouseButtonEventArgs e) { HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, e.GetPosition((GalleryControl)sender)); if (res.VisualHit == null) { return; } GalleryItemControl galleryItemControl = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit); if (galleryItemControl != null) { object capt = galleryItemControl.ActualCaption; GalleryItem tmpIt = MyDict[capt]; tmpIt.IsChecked = !tmpIt.IsChecked; } }
static void Gallery_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { clickPoint = e.GetPosition((GalleryControl)sender); HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, clickPoint); if (res.VisualHit == null) { return; } gic = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit); if (gic != null) { dragableItem = gic.Item; container = dragableItem.Group; originalIndex = container.Items.IndexOf(dragableItem); } }
bool RaiseFlowDocumentClick(UIElement element) { if (element == null || element.GetType().FullName != "MS.Internal.Documents.FlowDocumentView") { return(false); } ScrollViewer scrollViewer = LayoutHelper.FindParentObject <ScrollViewer>(element); RichTextBox rtb = LayoutHelper.FindParentObject <RichTextBox>(element); if (scrollViewer == null || rtb == null || rtb.Document == null) { return(false); } Point position = Mouse.GetPosition(scrollViewer); foreach (System.Windows.Documents.Block block in rtb.Document.Blocks) { System.Windows.Documents.Paragraph paragraph = block as System.Windows.Documents.Paragraph; if (paragraph == null) { continue; } foreach (System.Windows.Documents.Inline inline in paragraph.Inlines) { System.Windows.Documents.Hyperlink hyperlink = inline as System.Windows.Documents.Hyperlink; if (hyperlink == null) { continue; } Rect start = hyperlink.ContentStart.GetCharacterRect(System.Windows.Documents.LogicalDirection.Forward); Rect end = hyperlink.ContentEnd.GetCharacterRect(System.Windows.Documents.LogicalDirection.Backward); if (position.X < start.Left || position.X > end.Right) { continue; } if (position.Y < start.Top || position.Y > end.Bottom) { continue; } RaiseHyperlinkClick(hyperlink); return(true); } } return(false); }
private void GridColumnHeader_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2) { GridColumnHeader header = LayoutHelper.FindParentObject <GridColumnHeader>((DependencyObject)e.OriginalSource); GridColumn gc = (GridColumn)header.DataContext; List <ColumnBase> lst = new List <ColumnBase>(gc.View.ColumnChooserColumns); for (int i = 0; i < lst.Count; i++) { if (gc.ActualColumnChooserHeaderCaption == lst[i].ActualColumnChooserHeaderCaption) { lst[i].Visible = true; break; } } } }
void DragItem(DragEventArgs args) { AdornerPosition = new Position(); var mousePoint = args.GetPosition(NavBar); var item = args.Data.GetData(F_FLAG) as NavBarItem; var dropSource = args.OriginalSource; var itemControl = LayoutHelper.FindParentObject <NavBarItemControl>(dropSource as DependencyObject); var groupHeader = LayoutHelper.FindParentObject <NavBarGroupHeader>(dropSource as DependencyObject); var navBarItem = new NavBarItem(); if (itemControl != null) { var frameworkElement = itemControl as FrameworkElement; GeneralTransform generalTransform = frameworkElement.TransformToVisual(NavBar); Rect rectangle = generalTransform.TransformBounds(new Rect(new Point(frameworkElement.Margin.Left, frameworkElement.Margin.Top), frameworkElement.RenderSize)); var center = rectangle.Y + rectangle.Height / 2; if (mousePoint.Y > center) { AdornerPosition = Position.Bottom; } else { AdornerPosition = Position.Top; } SetAdorner(itemControl as FrameworkElement, AdornerPosition); } else { DeleteAdorner(); } if (!args.Data.GetDataPresent(F_FLAG)) { args.Effects = DragDropEffects.None; } }
void ICustomizationService.HideCustomizationMenu(object target) { if (_decorator == null) { return; } if (target == null) { _decorator.CustomizationHelper.HideCustomizationMenus(); } else { var barControl = target as BarControl; if (barControl != null && MayBe.Return(barControl.Bar, x => x.AllowCustomizationMenu, () => false)) { _decorator.CustomizationHelper.HideToolbarsCustomizationMenu(barControl); } else { var customizationButton = target as BarQuickCustomizationButton; if (customizationButton != null) { if (_decorator.CustomizationHelper.IsCustomizationMode) { _decorator.CustomizationHelper.HideCustomizationMenu(); } else { LayoutHelper.FindParentObject <BarControl>(customizationButton); _decorator.CustomizationHelper.HideCustomizationMenu(customizationButton); } } else { var barItemLinkControl = target as BarItemLinkControl; if (barItemLinkControl == null) { return; } _decorator.CustomizationHelper.HideItemCustomizationMenu(barItemLinkControl); } } } }
bool RaiseButtonClick(UIElement element) { ButtonBase button = element == null ? null : LayoutHelper.FindParentObject <ButtonBase>(element); if (button == null) { return(false); } RoutedEventArgs click = new RoutedEventArgs(ButtonBase.ClickEvent, button); button.RaiseEvent(click); ICommand command = button.Command; if (command != null && command.CanExecute(button.CommandParameter) && button.IsEnabled) { command.Execute(button.CommandParameter); } return(true); }
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; } }
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); }
private void SelectCommandExecuted(object sender, ExecutedRoutedEventArgs e) { BreadcrumbBar bar = LayoutHelper.FindParentObject <BreadcrumbBar>(this); if (bar != null && bar.TargetFrame != null) { IRibbonPage page = bar.TargetFrame.Content as IRibbonPage; if (page != null && page.CanSave() && FrameEx.AllowNavigateOnChangeSet) { if (CommonMethods.ShowMessageOnNavigated(page)) { e.Handled = true; return; } FrameEx.AllowNavigateOnChangeSet = false; } } SelectedItem = null; RoutedEventArgs args = new RoutedEventArgs(Button.ClickEvent); RaiseEvent(args); }
void item_Click(object sender, RoutedEventArgs e) { BreadcrumbBar bar = LayoutHelper.FindParentObject <BreadcrumbBar>(this); if (bar != null && bar.TargetFrame != null) { IRibbonPage ribbonpage = bar.TargetFrame.Content as IRibbonPage; if (ribbonpage != null && ribbonpage.CanSave() && FrameEx.AllowNavigateOnChangeSet) { if (CommonMethods.ShowMessageOnNavigated(ribbonpage)) { return; } FrameEx.AllowNavigateOnChangeSet = false; } } MenuItem item = e.Source as MenuItem; object dataItem = item.DataContext; RemoveSelectedItem(dataItem); SelectedItem = dataItem; }
private void ChartControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { SeriesPresentation series = LayoutHelper.FindParentObject <SeriesPresentation>(e.OriginalSource as FrameworkElement); if (series == null) { return; } Expenses.ViewModel.INavigationService service = ServiceLocator.Current.GetService <Expenses.ViewModel.INavigationService>() as Expenses.ViewModel.INavigationService; switch (series.Series.DisplayName) { case "Past": service.ShowPastExpenseReports(); break; case "Saved": service.ShowSavedExpenseReports(); break; case "Pending": service.ShowPendingExpenseReports(); break; } }
private void OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { var listbox = sender as ListBoxEdit; if (listbox == null) { return; } var uie = listbox.InputHitTest(e.GetPosition(listbox)) as FrameworkElement; if (uie == null) { return; } var item = LayoutHelper.FindParentObject <ListBoxEditItem>(uie); if (item == null) { return; } //if (!item.IsSelected) // item.IsSelected = true; //if (!item.IsFocused) // item.Focus(); var data = item.DataContext as PmMethodViewModel.CheckedPmMethod; if (data == null) { return; } data.IsChecked = !data.IsChecked; e.Handled = true; }