private void userControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { try { if (!_alreadyLoaded) { ViewModelImagingSessionBase dc = this.DataContext as ViewModelImagingSessionBase; dc.ExportNewFileName = ""; DataTemplate usedTemplate; if (dc.Is3DImagingSession) { usedTemplate = viewbox3DContentControl.ContentTemplate; } else { usedTemplate = viewboxContentControl.ContentTemplate; } dc.ExportImageTemplate = usedTemplate; dc.IsSelectedImageOnly = false; dc.CheckImageStackExportFormat(); e.Handled = true; _alreadyLoaded = true; } } catch { } }
private void comparisonSessionGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (_model == null) { return; } ViewModelImagingSessionBase session = ((Grid)sender).DataContext as ViewModelImagingSessionBase; if (_model.CommandCopyPropertiesToAll.CanExecute(session)) { _model.CommandCopyPropertiesToAll.Execute(session); floatingToolTip.IsOpen = _model.ShowCopyPropertiesMouseToolTip; } else if (_model.CommandPrepareCopyProperties.CanExecute(session)) { _model.CommandPrepareCopyProperties.Execute(session); floatingToolTip.IsOpen = _model.ShowCopyPropertiesMouseToolTip; } else if (_model.CommandFinishCopyProperties.CanExecute(session)) { _model.CommandFinishCopyProperties.Execute(session); floatingToolTip.IsOpen = _model.ShowCopyPropertiesMouseToolTip; } }
private void okButton_Click(object sender, RoutedEventArgs e) { ViewModelImagingSessionBase dc = this.DataContext as ViewModelImagingSessionBase; ModalChildWindow.ShowDialog("File Name", new ViewMspExportName(), dc); CloseControl = true; }
private void previewComparisonImage_PreviewMouseDown(object sender, MouseButtonEventArgs e) { ListBoxItem item = sender as ListBoxItem; if (e.ChangedButton == MouseButton.Left) { try { ViewModelImagingSessionBase _node = item.DataContext as ViewModelImagingSessionBase; if (!_node.IsEmptyImagingSession) { if (_node.ClipboardPresetAvailable) { _node.CommandPasteImagingSettings.Execute(null); } else if (e.ClickCount == 1 && item.IsSelected) { if (OAMScanInformationClosingPopup.IsOpen) { closeScanInformation(); } else { _openPopupOnMouseUp = true; } } } } catch { } } }
private void ListBoxItem_TouchDown(object sender, TouchEventArgs e) { ListBoxItem item = sender as ListBoxItem; if (item.IsSelected) { if (OAMScanInformationClosingPopup.IsOpen) { closeScanInformation(); } else { ViewModelImagingSuperSession ss = item.DataContext as ViewModelImagingSuperSession; if (ss.VisualizationAndAnalysisType == VisualizationAndAnalysis.Visualization) { return; } ViewModelImagingSessionBase dc = ss.ImagingSessions[0]; openScanInformation(sender, dc); oamScanInformation.CaptureMouse(); oamScanInformation.ReleaseMouseCapture(); } e.Handled = true; } }
private void previewImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (!_openPopupOnMouseUp) { return; } ListBoxItem item = sender as ListBoxItem; ViewModelImagingSuperSession ss = item.DataContext as ViewModelImagingSuperSession; if (ss.VisualizationAndAnalysisType == VisualizationAndAnalysis.Visualization) { return; } ViewModelImagingSessionBase dc = ss.ImagingSessions[0]; openScanInformation(sender, dc); Task.Run(() => { Task.Delay(System.Windows.Forms.SystemInformation.DoubleClickTime).Wait(); Dispatcher.Invoke(new Action(() => { if (OAMScanInformationClosingPopup.IsOpen) { oamScanInformation.CaptureMouse(); oamScanInformation.ReleaseMouseCapture(); } })); }); _openPopupOnMouseUp = false; }
private void userControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { _model = e.NewValue as ViewModelImagingSessionBase; string resourceString = ""; if (e.NewValue != null) { if (e.NewValue.GetType() == typeof(ViewModelMsp3DImagingSession)) { resourceString = "Msp3DImageThumbDataTemplate"; } else if (e.NewValue.GetType() == typeof(ViewModelMspImagingSession)) { resourceString = "MspImageThumbDataTemplate"; } } if (string.IsNullOrWhiteSpace(resourceString)) { SetCurrentValue(ImageThumbDataTemplateProperty, null); } else { SetCurrentValue(ImageThumbDataTemplateProperty, Resources[resourceString]); } }
private void EmptySuperSessionOrReplaceSession_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("snapshotDragItem")) { Border item = sender as Border; ViewModelImagingSessionBase substituteImagingSession = item.DataContext as ViewModelImagingSessionBase; ViewModelImagingSuperSession ss = substituteImagingSession.Parent as ViewModelImagingSuperSession; ViewModelImagingSuperSession genericVM = (ViewModelImagingSuperSession)e.Data.GetData("snapshotDragItem"); if (ss.VisualizationAndAnalysisType == Xvue.MSOT.DataModels.Plugins.ProjectManager.VisualizationAndAnalysis.Visualization) { ss.MSOTService.UIStaticDispatcher.BeginInvoke(new Action(() => { ss.ReplaceNewImagingSessionCopyThread(substituteImagingSession, genericVM.ImagingSessions[0], true); })); } else { if (ss.VerifySavingOfDataModelChanges(true)) { ss.MSOTService.UIStaticDispatcher.BeginInvoke(new Action(() => { ViewModelStudyNode study = ss.Parent as ViewModelStudyNode; if (study != null) { study.SelectedSuperSession = genericVM; study.LoadSelectedSuperSession(); } })); } } item.SetCurrentValue(BorderBrushProperty, new SolidColorBrush(Colors.White)); e.Handled = true; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { ViewModelImagingSessionBase dc = this.DataContext as ViewModelImagingSessionBase; DataTemplate usedTemplate = viewboxContentControl.ContentTemplate; dc.ExportImageTemplate = usedTemplate; dc.IsSelectedImageOnly = true; dc.CheckImageStackExportFormat(); } catch { } }
private void AddReplaceSession_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("snapshotDragItem")) { ViewImagingSessionGeneric item = sender as ViewImagingSessionGeneric; ViewModelImagingSessionBase substituteImagingSession = item.DataContext as ViewModelImagingSessionBase; ViewModelImagingSuperSession ss = substituteImagingSession.Parent as ViewModelImagingSuperSession; ViewModelImagingSuperSession genericVM = (ViewModelImagingSuperSession)e.Data.GetData("snapshotDragItem"); ss.MSOTService.UIStaticDispatcher.BeginInvoke(new Action(() => { ss.ReplaceNewImagingSessionCopyThread(substituteImagingSession, genericVM.ImagingSessions[0], true); })); item.SessionBorder.SetCurrentValue(BorderBrushProperty, new SolidColorBrush(Colors.White)); e.Handled = true; } }
static async void exportImagesAsync(ViewModelImagingSessionBase dc) { dc.MSOTService.SystemBusy(true); Task t = Task.Run(() => { dc.MSOTService.UIStaticDispatcher.Invoke(new Action(() => { dc.PrepareExportedSelectedImage(); dc.PrepareSavingFormat(); })); }); await t; dc.MSOTService.SystemBusy(false); ModalChildWindow.ShowDialog( dc.IsExportTestImages ? (dc.Is3DImagingSession ? "Export Test 3D Image(s)" : "Export Test Image(s)") : "Export images", new ViewMspExportAllImages(), dc); }
private void previewComparisonImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (!_openPopupOnMouseUp) { return; } ListBoxItem item = sender as ListBoxItem; ViewModelImagingSessionBase dc = item.DataContext as ViewModelImagingSessionBase; if (dc.IsEmptyImagingSession) { _openPopupOnMouseUp = false; return; } openScanInformation(sender, dc); oamScanInformation.CaptureMouse(); oamScanInformation.ReleaseMouseCapture(); _openPopupOnMouseUp = false; }
internal void HandlePreviewKeyDown(object sender, KeyEventArgs e) { if (_model == null) { return; } try { if (e.Key == Key.Return) { //Use refrection to get IxExtendedKey //For Numpad Enter Key, IsExtendedKey = True //For Main Keyboard Enter Key, IsExtendedKey = False bool isExtended = (bool)typeof(KeyEventArgs).InvokeMember("IsExtendedKey", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, e, null); if (!isExtended) { return; } } Dictionary <Key, KeyboardShortcutDelegate> keyBindings; _affectedImagingSession = null; if (_model.ViewingLayout == SuperSessionViewingLayout.Layout1) { foreach (ViewModelImagingSessionBase session in _model.ImagingSessions) { if (session.IsVisible) { _affectedImagingSession = session; break; } } keyBindings = _singleViewKeyBindings; } else { for (int i = 0; i < imagingSessionsItemsControl.Items.Count; i++) { UIElement uiElement = (UIElement)imagingSessionsItemsControl.ItemContainerGenerator.ContainerFromIndex(i); if (uiElement.IsMouseOver) { _affectedImagingSession = (uiElement as FrameworkElement).DataContext as ViewModelImagingSessionBase; } } keyBindings = _multiViewKeyBindings; } if (_affectedImagingSession?.IsEmptyImagingSession ?? true) { return; } if (_affectedImagingSession.IsVisualizationRefreshing) { return; } ViewMSOTcSystem.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Info, "ViewImagingSuperSessionsGrid:HandlePreviewKeyDown", "Key: " + e.Key + ", SystemKey: " + e.SystemKey); KeyboardShortcutDelegate command; Key incomingKey; if (e.Key == Key.System) { incomingKey = e.SystemKey; } else { incomingKey = e.Key; } if (System.Windows.Forms.Control.IsKeyLocked(System.Windows.Forms.Keys.NumLock)) //show num lock status somewhere? { if (keyBindings.TryGetValue(incomingKey, out command)) { command(); e.Handled = true; } } } catch (Exception ex) { ViewMSOTcSystem.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Warning, "ViewImagingSuperSessionsGrid", "Exception executing shortcut:" + ex.Message); } }
private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) { ScrollViewer scrollViewer = sender as ScrollViewer; if (scrollViewer == null) { return; } if (imageSizeSlider.Value == 0) { return; } bool isVisibilityChanged = false; for (int i = 0; i < slicesGridArrangement.Items.Count; i++) { // position of your visual inside the scrollviewer GeneralTransform childTransform = (slicesGridArrangement.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem).TransformToAncestor(scrollViewer); Rect rectangle = childTransform.TransformBounds(new Rect(new Point(0, 0), (slicesGridArrangement.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem).RenderSize)); Rect rectangleScrollViewer = new Rect(new Point(0, 0), scrollViewer.RenderSize); rectangleScrollViewer.Height = rectangleScrollViewer.Height - 10; rectangleScrollViewer.Y = rectangleScrollViewer.Y + 5; //Check if the elements Rect intersects with that of the scrollviewer's Rect result = Rect.Intersect(rectangleScrollViewer, rectangle); //if result is Empty then the element is not in view if (result == Rect.Empty) { if ((slicesGridArrangement.Items[i] as ViewModelSliceInfo).IsVisible) { isVisibilityChanged = true; } (slicesGridArrangement.Items[i] as ViewModelSliceInfo).IsVisible = false; } else { if (!(slicesGridArrangement.Items[i] as ViewModelSliceInfo).IsVisible) { isVisibilityChanged = true; } (slicesGridArrangement.Items[i] as ViewModelSliceInfo).IsVisible = true; } } if (isVisibilityChanged) { ViewModelImagingSessionBase imagingSession = this.DataContext as ViewModelImagingSessionBase; if (_previousScrollOffset < scrollViewer.ContentVerticalOffset) { imagingSession.ReorderImagesForProcessing(true); } else { imagingSession.ReorderImagesForProcessing(); } _previousScrollOffset = scrollViewer.ContentVerticalOffset; } e.Handled = true; }