private static void CreateEditorInstance(EditorTestRequest a, ManualResetEventSlim evt) { try { CoreEditor = new CoreEditor(a.Text, a.FileName, a.ContentType); Window = new Window(); if (Screen.AllScreens.Length == 1) { Window.Left = 0; Window.Top = 50; } else { Screen secondary = Screen.AllScreens.FirstOrDefault(x => !x.Primary); Window.Left = secondary.WorkingArea.Left; Window.Top = secondary.WorkingArea.Top + 50; } Window.Width = 800; Window.Height = 600; Window.Title = "R Editor - " + (a.FileName ?? "Untitled"); Window.Content = CoreEditor.Control; } finally { evt.Set(); } Window.Topmost = true; Window.ShowDialog(); }
static Point GetLocationRelativeToOwner(Window window) { Point ownerLocation = GetOwnerLocation(window); // TODO : do we need special support for maximized child windows? // window.Left / window.Top do not return the proper values if the window is maximized return new Point(window.Left - ownerLocation.X, window.Top - ownerLocation.Y); }
public void CloseExists() { CreateContainerWithRealMessageBus(); var title = Guid.NewGuid().ToString(); var viewModel = Substitute.For<ITitledViewModel>(); viewModel.Title.Returns(title); var view = new FrameworkElement(); view.DataContext = viewModel; var viewTarget = ViewTargets.DefaultView; var viewResult = new ViewResult(view, viewTarget); var viewBuilder = Substitute.For<IViewFactory>(); viewBuilder.Build(Arg.Any<ViewTargets>(), Arg.Any<Object>()) .Returns(viewResult); ComponentContainer.Container.Register(Component.For<IViewFactory>().Instance(viewBuilder)); var window = new Window(); var tabControl = new TabControl(); var viewController = new ViewPlacer(window, tabControl); var newTabItem = new TabItem() { Header = title }; tabControl.Items.Add(newTabItem); var message = new CloseViewMessage(title); _MessageBus.Publish<CloseViewMessage>(message); Assert.AreEqual(0, tabControl.Items.Count); }
/// <summary> /// Helper method for WPF methods. Provide a WPF window and this event handler, when called, /// will bring that window forward to the normal state. /// </summary> public static EventHandler BringToFrontWhenCalled(Window w) { return new EventHandler((obj, e) => { if (w != null) { // We won't be on the dispatcher thread, so invoke across w.Dispatcher.BeginInvoke(new Action(() => { // expand if minimized if (w.WindowState == WindowState.Minimized) { w.WindowState = WindowState.Normal; } bool top = w.Topmost; // make our form jump to the top of everything w.Topmost = true; // set it back to whatever it was w.Topmost = top; })); } }); }
public TrackInfoPoller(NowPlayingTrackInfoProvider Provider, CoverManager CoverManager, Window window) { this.nowPlayingProvider = Provider; this.coverManager = CoverManager; this.window = window; this.dispatcher = App.Current.Dispatcher; }
public void ShowDialog() { object view = Context.Container.ResolveView(this.GetType()); if (view != null) { if (view is Window) { Window window = (Window)view; window.DataContext = this; window.ShowDialog(); } else if (view is FrameworkElement) { Window window = new Window(); window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.ResizeMode = ResizeMode.NoResize; window.SizeToContent = SizeToContent.WidthAndHeight; window.ShowInTaskbar = false; window.Topmost = true; FrameworkElement control = (FrameworkElement)view; window.Height = control.Height; window.Width = control.Width; window.Content = control; control.DataContext = this; window.ShowDialog(); } } }
private void OnLoaded(object sender, RoutedEventArgs e) { //Get references to window, screen, toastNotification and mainViewModel window = Window.GetWindow(this); screen = window.GetScreen(); toastNotification = VisualAndLogicalTreeHelper.FindLogicalChildren<ToastNotification>(this).First(); var mainViewModel = DataContext as MainViewModel; //Handle ToastNotification event mainViewModel.ToastNotification += (o, args) => { SetSizeAndPosition(); Title = args.Title; Content = args.Content; NotificationType = args.NotificationType; Action closePopup = () => { if (IsOpen) { IsOpen = false; if (args.Callback != null) { args.Callback(); } } }; AnimateTarget(args.Content, toastNotification, closePopup); IsOpen = true; }; }
private void UnderlyingAdd_Button_Click(object sender, RoutedEventArgs e) { Window w = new Window(); //Excel_underlyingLoaderView e_ulv = new Excel_underlyingLoaderView(); Excel_underlyingLoaderViewModel e_ulvm = new Excel_underlyingLoaderViewModel(); w.Width = 600; w.Height = 400; w.Content = e_ulvm.view(); if (w.ShowDialog() == true) { string underType = e_ulvm.SelectedUnderlyingVM_.Excel_type_; string code = e_ulvm.SelectedUnderlyingVM_.KrCode_; // default로 basePrice effective일로 함. e_ulvm.SelectedUnderlyingVM_.BasePrice_ = Excel_loaderViewModel.loadMarketData(this.viewModel_.EffectiveDate_, underType, code); this.viewModel_.addUnderlyingInfoVM(e_ulvm.SelectedUnderlyingVM_); } else { } //this.viewModel_.Excel_underlyingInfoViewModel_.Add(); }
public PlatformWpf() : base(null, true) { var app = new Application (); var slCanvas = new Canvas (); var win = new Window { Title = Title, Width = Width, Height = Height, Content = slCanvas }; var cirrusCanvas = new CirrusCanvas(slCanvas, Width, Height); MainCanvas = cirrusCanvas; win.Show (); EntryPoint.Invoke (null, null); var timer = new DispatcherTimer (); timer.Tick += runDelegate; timer.Interval = TimeSpan.FromMilliseconds (1); timer.Start (); app.Run (); }
public void OnClick(Window mainWindow, Instance instance) { Assert.ArgumentNotNull(mainWindow, "mainWindow"); var instances = InstanceManager.Instances; Assert.IsNotNull(instances, "instances"); var otherInstances = instances.Where(x => x.ID != instance.ID); foreach (var otherInstance in otherInstances) { try { if (otherInstance == null) { continue; } Log.Info("Recycling instance " + otherInstance, this); otherInstance.Recycle(); } catch (Exception ex) { Log.Warn("An error occurred", this, ex); } } }
public Editor() { InitializeComponent(); projectsMenu.DataContext = program.Projects; undoStackWindow = new Window(); undoStackWindow.ShowInTaskbar = false; undoStackWindow.Title = "Undo Stack"; undoStackWindow.Topmost = true; undoStackWindow.Width = 200; undoStackWindow.Height = 300; undoStackWindow.WindowStyle = System.Windows.WindowStyle.ToolWindow; undoStackControl = new UndoStackControl(); undoStackWindow.Content = undoStackControl; // Make sure our components interact properly colorPicker.ForegroundChanged += (s, paletteColor) => { program.ActiveColors[0] = paletteColor; }; colorPicker.BackgroundChanged += (s, paletteColor) => { program.ActiveColors[1] = paletteColor; }; tileSelector.TileSelected += (s, tile) => { program.ActiveTile = tile; }; program.PropertyChanged += (s, e) => { // TODO: Should we consider all the active properties to be updated in group? We make many assumptions now... if (e.PropertyName == "ActiveUndoStack") { undoStackControl.SetUndoStack(program.ActiveUndoStack); } if (e.PropertyName == "ActiveProject") { levelsMenu.DataContext = program.ActiveProject.Levels; tileSelector.SetTiles(program.ActiveProject.Tiles); } if (e.PropertyName == "ActiveLevel") { level0.SetLevel(program.ActiveLevel, program.ActiveProject.Tiles, program.ActiveUndoStack); } }; DataContext = program; }
public static void Main() { // original (doesn't work with snoop, well, can't find a window to own the snoop ui) Window window = new Window(); window.Title = "Say Hello"; window.Show(); Application application = new Application(); application.Run(); // setting the MainWindow directly (works with snoop) // Window window = new Window(); // window.Title = "Say Hello"; // window.Show(); // // Application application = new Application(); // application.MainWindow = window; // application.Run(); // creating the application first, then the window (works with snoop) // Application application = new Application(); // Window window = new Window(); // window.Title = "Say Hello"; // window.Show(); // application.Run(); // creating the application first, then the window (works with snoop) // Application application = new Application(); // Window window = new Window(); // window.Title = "Say Hello"; // application.Run(window); } }
private void RepoteUnhandleException(Exception ex) { Button b= new Button() ; Window w = new Window {Width = 0x258,Height = 0x1f4,Padding = new Thickness(0x14),Title = String.Format("{0} - {1}","予期せぬエラー","TwVideoUp")}; StackPanel m = new StackPanel() { Orientation = Orientation.Vertical, Children = { new TextBlock() { Text = "予期せぬエラーが発生しました。以下のStackTraceをIssueとして提出いただけると嬉しいです。(ユーザー名などが含まれている場合は伏せていただいて構いません。)", TextWrapping = TextWrapping.Wrap }, new TextBox() { Text = ex.ToString(), IsReadOnly = true, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(10), MaxHeight = 380, VerticalScrollBarVisibility = ScrollBarVisibility.Auto }, b }, }; b.Click += (sender, args) => Clipboard.SetText(ex.ToString()); b.Content = new TextBlock() {Text = "Copy to Clipboard."}; w.Content = m; w.ShowDialog(); Shutdown(); }
public void Init(Window win) { this.CurrentWindow = win; this.CurrentWindow.StateChanged += CurrentWindow_StateChanged; this.OldwinState = this.CurrentWindow.WindowState; IsInit = true; }
void App_Startup(object sender, StartupEventArgs e) { Window = new MainWindow(); SubscribeToWindowEvents(); MainWindow = Window; Window.Show(); }
public void Initialize(Window window) { var w = window; w.Icon = this.Icon; w.Closing += Window_Closing; this.InitializeProperty(window); }
public DockManager(Window window, DockingSide dockingSide) { _basewindow = window; CurrentSide = dockingSide; _mouseHook = new MouseHook(); _mouseHook.MouseMove += MouseHookOnMouseMove; }
private void CloseWindow(Window windowToClose) { if (windowToClose != null) { windowToClose.Close(); } }
public void OnClick(Window mainWindow, Instance instance) { Assert.ArgumentNotNull(mainWindow, "mainWindow"); var instances = InstanceManager.PartiallyCachedInstances ?? InstanceManager.Instances; Assert.IsNotNull(instances, "instances"); var otherInstances = instances.Where(x => x.ID != instance.ID); foreach (var otherInstance in otherInstances) { if (otherInstance == null) { continue; } try { var processIds = otherInstance.ProcessIds; foreach (var processId in processIds) { var process = Process.GetProcessById(processId); Log.Info("Killing process " + processId, this); process.Kill(); } } catch (Exception ex) { Log.Warn("An error occurred", this, ex); } } }
public void StartDragDrop(ItemsControl source, FrameworkElement sourceItemContainer, object draggedData, Point initialMousePosition) { _topWindow = Window.GetWindow(source); Debug.Assert(_topWindow != null); _source = source; _sourceItemContainer = sourceItemContainer; _initialMousePosition = initialMousePosition; _initialMouseOffset = _initialMousePosition - _sourceItemContainer.TranslatePoint(new Point(0, 0), _topWindow); var data = new DataObject(Format.Name, draggedData); // Adding events to the window to make sure dragged adorner comes up when mouse is not over a drop target. bool previousAllowDrop = _topWindow.AllowDrop; _topWindow.AllowDrop = true; _topWindow.DragEnter += TopWindow_DragEnter; _topWindow.DragOver += TopWindow_DragOver; _topWindow.DragLeave += TopWindow_DragLeave; DragDrop.DoDragDrop(_source, data, DragDropEffects.Move); // Without this call, there would be a bug in the following scenario: Click on a data item, and drag // the mouse very fast outside of the window. When doing this really fast, for some reason I don't get // the Window leave event, and the dragged adorner is left behind. // With this call, the dragged adorner will disappear when we release the mouse outside of the window, // which is when the DoDragDrop synchronous method returns. RemoveDraggedAdorner(); _topWindow.AllowDrop = previousAllowDrop; _topWindow.DragEnter -= TopWindow_DragEnter; _topWindow.DragOver -= TopWindow_DragOver; _topWindow.DragLeave -= TopWindow_DragLeave; }
private static void CreateWindowInstance(ControlTestRequest request, ManualResetEventSlim evt) { try { Window = new Window(); if (Screen.AllScreens.Length == 1) { Window.Left = 0; Window.Top = 50; } else { Screen secondary = Screen.AllScreens.FirstOrDefault(x => !x.Primary); Window.Left = secondary.WorkingArea.Left; Window.Top = secondary.WorkingArea.Top + 50; } Window.Width = 800; Window.Height = 600; Component = Activator.CreateInstance(request.ControlType); if (Component is Control) { Control = Component as Control; } else { Control = Component.GetType().GetProperty("Control").GetValue(Component) as Control; } Window.Title = "Control - " + request.ControlType; Window.Content = Control; } finally { evt.Set(); } Window.Topmost = true; Window.ShowDialog(); }
public FeatureDisplayCommand(DatasetInformation information) : base(null, AlwaysPass) { m_information = information; m_window = null; m_name = "Features " + information.DatasetName; }
public SUUpdateAlert(Window window, SUHost host, SUAppcastItem item) : base(window) { Window.TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo(); Window.Closing += WindowShouldClose; Window.Icon = host.Icon; Window.Topmost = true; status = WindowStatus.WaitingForInitialAction; mainViewController = new SUUpdateAlertWindowViewController(new SUUpdateAlertWindowView()); ViewController = mainViewController; buttons = new SUUpdateAlertActionButtonsViewController(new SUUpdateAlertActionButtonsView()); buttons.InstallButton.Click += DownloadButtonClicked; buttons.RemindLaterButton.Click += RemindLaterButtonClicked; buttons.SkipVersionButton.Click += SkipVersionButtonClicked; downloadingViewController = new SUUpdateAlertDownloadProgressViewController(new SUUpdateAlertDownloadProgressView()); downloadingViewController.CancelButton.Click += CancelDownloadClicked; indeterminateViewController = new SUUpdateAlertIndeterminateProgressViewController(new SUUpdateAlertIndeterminateProgressView()); readyToInstallViewController = new SUUpdateAlertReadyToInstallViewController(new SUUpdateAlertReadyToInstallView()); readyToInstallViewController.InstallButton.Click += InstallButtonClicked; mainViewController.ActionViewController = buttons; mainViewController.Host = host; mainViewController.Item = item; }
protected override void OnStartup(StartupEventArgs args) { base.OnStartup(args); Window win = new Window(); win.Title = "Inherit the App"; win.Show(); }
private void returnUnderlyingCalcSetBtn_Click(object sender, RoutedEventArgs e) { Window w = new Window(); w.Width = 500; w.Height = 200; Excel_underlyingCalcIDLoaderView e_ucIDlv = this.viewModel_.Excel_underlyingCalcIDViewModel_.loaderView(); //e_ucIDlv.Excel_underlyingCalcInfoViewModel_ = this.viewModel_.Excel_underlyingCalcInfoViewModel_; //e_ucIDlv.SelectedUnderCalcIDTypeViewModel_ = this.viewModel_.Excel_underlyingCalcIDViewModel_.Clone(); w.Content = e_ucIDlv; if (w.ShowDialog() == true) { this.viewModel_.Excel_underlyingCalcIDViewModel_ = e_ucIDlv.SelectedUnderCalcIDTypeViewModel_; this.viewModel_.Excel_underlyingCalcIDViewModel_.descriptionUpdate(); this.returnUnderCalcDescriptionTxb_.Text = this.viewModel_.Excel_underlyingCalcIDViewModel_.Description_; } else { } }
void OnWinSysTypeChanged(WinSysType newValue) { if (window == null) window = Window.GetWindow(this); if (window == null && DesignerProperties.GetIsInDesignMode(this)) return; switch (newValue) { case WinSysType.Minimize: CurrentWinSysType = CurrentWinSysType.Minimize; break; case WinSysType.Maximize: CurrentWinSysType = window.WindowState == WindowState.Maximized ? CurrentWinSysType.Restore : CurrentWinSysType.Maximize; break; case WinSysType.Close: CurrentWinSysType = CurrentWinSysType.Close; break; default: throw new ArgumentException("Invalid WinSysType"); } }
/// <summary> /// Show or hide the bezel and cursor for specified window. /// </summary> /// <param name="window"> /// Window for which bezel will be hidden. /// </param> /// <param name="showBezel"> /// true if window bezel should be shown, false if it should be hidden. /// </param> public static void UpdateBezel(Window window, bool showBezel) { if (window == null) { throw new ArgumentNullException("window"); } if (showBezel) { window.WindowStyle = WindowStyle.SingleBorderWindow; window.Cursor = Cursors.Arrow; } else { window.WindowStyle = WindowStyle.None; // If the window is already full-screen, we must set it again else the window will appear under the Windows taskbar. if (window.WindowState == WindowState.Maximized) { window.WindowState = WindowState.Normal; window.WindowState = WindowState.Maximized; } window.Cursor = Cursors.None; } }
public DateCorrectAmbiguous(FileDatabase database, Window owner) { this.InitializeComponent(); this.ambiguousDatesList = new List<AmbiguousDate>(); this.database = database; this.displayingPreview = false; this.Owner = owner; // set callbacks in code behind to avoid invoking callbacks when the dialog is created this.OriginalDate.Checked += this.DateBox_Checked; this.SwappedDate.Checked += this.DateBox_Checked; // find the ambiguous dates in the current selection if (this.FindAllAmbiguousDatesInSelectedImages() == true) { this.Abort = false; } else { this.Abort = true; } // Start displaying from the first ambiguous date. this.ambiguousDatesListIndex = 0; }
public AddCameraModel(Window addCameraWindow) { _addCameraWindow = addCameraWindow; SetContents(); SetCommands(); }
public static WpfScreen GetScreenFrom(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle); WpfScreen wpfScreen = new WpfScreen(screen); return wpfScreen; }
public static void Show(NativeWindow owner, string message, string caption, Action <MessageWindowResult> onMessageResult) { ShowImpl(owner, new MessageWindowOptions(message, caption, MessageWindowButtons.OK, MessageBoxImage.None, MessageWindowResultKind.None), onMessageResult); }
public static void Show(NativeWindow owner, MessageWindowOptions options, Action <MessageWindowResult> onMessageResult) { ShowImpl(owner, options, onMessageResult); }
private void cofnij(object sender, RoutedEventArgs e) { System.Windows.Window glowneOkno = System.Windows.Application.Current.MainWindow; glowneOkno.DataContext = new MojePojazdy(); }
static public void centerWindow(System.Windows.Window w1, System.Windows.Window w) { w1.Top = w.Top + ((w.Height - w1.Height) / 2); w1.Left = w.Left + ((w.Width - w1.Width) / 2); }
/// <summary> /// Metodo que crea el notifyIcon, se pasa el form sobre el que se va aplicar. /// </summary> /// <param name="form">Formulario que se aplica al NotifyIcon</param> /// <returns>torna un objecto de tipo NotifyIcon</returns> /// <history> /// [michan] 25/04/2016 Created /// </history> public static NotifyIcon Notify(System.Windows.Application app = null, System.Windows.Window form = null, string title = null) { /// Objeto del tipo NotifyIcon System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon(); //_frm = form; ///icono que muestra la nube de notificación. será tipo info, pero existen warning, error, etc.. notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; string strTitle = ""; ///la ruta del icono que se va a mostrar cuando la app esté minimizada. if (form != null) { if (form.Icon != null) { Uri iconUri = new Uri(form.Icon.ToString(), UriKind.RelativeOrAbsolute); System.IO.Stream iconStream = System.Windows.Application.GetResourceStream(new Uri(form.Icon.ToString())).Stream; notifyIcon.Icon = new System.Drawing.Icon(iconStream); } strTitle = form.Title.ToString(); } // AppContext.BaseDirectory else if (app != null) { notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath); } if (title != null) { strTitle = title; } //notifyIcon.Icon = new System.Drawing.Icon(iconStream);//@"M:\PalaceResorts\Client4.6\IntelligenceMarketing\IM.Base\Images\IM.ico"); /// Mensaje que se muestra al minimizar al formulario notifyIcon.BalloonTipTitle = "Information"; notifyIcon.Text = (!String.IsNullOrEmpty(strTitle) && !String.IsNullOrWhiteSpace(strTitle)) ? strTitle : "The application"; notifyIcon.BalloonTipText = "Running " + strTitle; notifyIcon.Visible = true; /// Evento clic para mostrar la ventana cuando se encuentre minimizada. notifyIcon.Click += new EventHandler( (s, e) => { if (notifyIcon != null) { /// cuando se pulse el boton mostrará informacion, cambiaremos los textos para que muestre que la app esta trabajando... notifyIcon.BalloonTipIcon = ToolTipIcon.Warning; notifyIcon.BalloonTipText = strTitle + " is working..."; notifyIcon.BalloonTipTitle = "Wait..."; notifyIcon.ShowBalloonTip(400); notifyIcon.BalloonTipIcon = ToolTipIcon.Info; notifyIcon.BalloonTipText = strTitle + " Running..."; notifyIcon.BalloonTipTitle = "Information"; } } ); notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler( (s, e) => { if (notifyIcon != null) { if (form != null) { form.Show(); form.WindowState = WindowState.Normal; form.Activate(); } else if (app != null) { app.MainWindow.Show(); app.MainWindow.WindowState = WindowState.Normal; app.MainWindow.Activate(); } notifyIcon.Visible = true; notifyIcon.ContextMenu.MenuItems[0].Visible = false; notifyIcon.ContextMenu.MenuItems[1].Visible = true; } } ); // agrgegamos el menu en el notyficon notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu( /// Menu contextual que sera visible en el icono new System.Windows.Forms.MenuItem[] { new System.Windows.Forms.MenuItem( "Show",// opcion de abrir para cuando la ventana este minimizada (s, e) => { if (form != null) { //Se agrega al menu la opcion para mostrar el formulario form.Show(); form.WindowState = WindowState.Normal; form.Activate(); } else if (app != null) { app.MainWindow.Show(); app.MainWindow.WindowState = WindowState.Normal; app.MainWindow.Activate(); } notifyIcon.Visible = true; notifyIcon.ContextMenu.MenuItems[0].Visible = false; notifyIcon.ContextMenu.MenuItems[1].Visible = true; } ), new System.Windows.Forms.MenuItem( "Hide",// opcion para mostrar la ventana cuando se encuentre maximizada (s, e) => { if (form != null) { // Se agrega en el menu la opcion para ocultar el form form.Hide(); form.WindowState = WindowState.Minimized; } else if (app != null) { app.MainWindow.Hide(); app.MainWindow.WindowState = WindowState.Minimized; } notifyIcon.Visible = true; notifyIcon.ShowBalloonTip(400); notifyIcon.ContextMenu.MenuItems[0].Visible = true; notifyIcon.ContextMenu.MenuItems[1].Visible = false; } ), new System.Windows.Forms.MenuItem("-"), new System.Windows.Forms.MenuItem("Close", (s, e) => { if (form != null) { form.Close(); } else if (app != null) { app.Shutdown(); } } ) } ); notifyIcon.ContextMenu.MenuItems[0].Visible = false; notifyIcon.ContextMenu.MenuItems[1].Visible = true; return(notifyIcon); }
private static void OnSizeLocationChanged(System.Windows.FrameworkElement placementTarget, System.Windows.Window webHost) { //Here we set the location and size of the borderless Window hosting the WebBrowser control. // This is based on the location and size of the child grid of the NTWindow. When the grid changes, // the hosted WebBrowser changes to match. if (webHost.Visibility == System.Windows.Visibility.Visible) { webHost.Show(); } webHost.Owner = Window.GetWindow(placementTarget); Point locationFromScreen = placementTarget.PointToScreen(new System.Windows.Point(0, 0)); PresentationSource source = PresentationSource.FromVisual(webHost); if (source != null && source.CompositionTarget != null) { Point targetPoints = source.CompositionTarget.TransformFromDevice.Transform(locationFromScreen); webHost.Left = targetPoints.X; webHost.Top = targetPoints.Y; } webHost.Width = placementTarget.ActualWidth; webHost.Height = placementTarget.ActualHeight; }
/// <summary> /// Sets the owner window of a specific window via the Window class, but /// also sets the focus on the first control. /// </summary> /// <param name="window">Reference to the current window.</param> /// <param name="owner">New owner window.</param> /// <param name="forceNewOwner">If true, the new owner will be forced. Otherwise, if the /// window currently has an owner, that owner will be respected (and thus not changed).</param> public static void SetOwnerWindowAndFocus(this SystemWindow window, SystemWindow owner, bool forceNewOwner = false) { SetOwnerWindowByWindow(window, owner, forceNewOwner, true); }
private void cofnij(object sender, RoutedEventArgs e) { System.Windows.Window glowneOkno = System.Windows.Application.Current.MainWindow; glowneOkno.DataContext = new StatystykiPojazdu(car1, userPermission); }
private void Dodaj_Pracownika(object sender, RoutedEventArgs e) { System.Windows.Window glowneOkno = System.Windows.Application.Current.MainWindow; glowneOkno.DataContext = new DodajPracownika(); }
public EditSourcesOfExpenseViewModel(DBDataOperation myBd, System.Windows.Window w2) { bd = myBd; SourceOfExpenseDataGrid = bd.GetALLEXPENSE_GUIDES(App.id); w = w2; }
/// <summary> /// sets the owner of a System.Windows.Forms.Form to a System.Windows.Window /// </summary> /// <param name="form"></param> /// <param name="owner"></param> public static void SetOwner(System.Windows.Forms.Form form, System.Windows.Window owner) { WindowInteropHelper helper = new WindowInteropHelper(owner); SetWindowLong(new HandleRef(form, form.Handle), -8, helper.Handle.ToInt32()); }
public void Execute(ScriptContext context, System.Windows.Window window, ScriptEnvironment environment) { // Retrieve the count of plans displayed in Scope Window int scopePlanCount = context.PlansInScope.Count(); if (scopePlanCount == 0) { MessageBox.Show("Scope Window does not contain any plans."); return; } // Retrieve names for different types of plans List <string> externalPlanIds = new List <string>(); List <string> brachyPlanIds = new List <string>(); List <string> protonPlanIds = new List <string>(); foreach (var ps in context.PlansInScope) { // KK: "is" compares the type. Equiv to ps.GetType() == typeof(BrachyPlanSetup)) if (ps is BrachyPlanSetup) { brachyPlanIds.Add(ps.Id); } else if (ps is IonPlanSetup) { protonPlanIds.Add(ps.Id); } else { externalPlanIds.Add(ps.Id); } } // Construct output message string message = string.Format("Hello {0}, the number of plans in Scope Window is {1}.", context.CurrentUser.Name, scopePlanCount); if (externalPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are external beam plans.", string.Join(", ", externalPlanIds)); } if (brachyPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are brachytherapy plans.", string.Join(", ", brachyPlanIds)); } if (protonPlanIds.Count > 0) { message += string.Format("\nPlan(s) {0} are proton plans.", string.Join(", ", protonPlanIds)); } // Display additional information. Use the active plan if available. PlanSetup plan = context.PlanSetup != null ? context.PlanSetup : context.PlansInScope.ElementAt(0); message += string.Format("\n\nAdditional details for plan {0}:", plan.Id); // Access the structure set of the plan if (plan.StructureSet != null) { Common.Model.API.Image image = plan.StructureSet.Image; var structures = plan.StructureSet.Structures; message += string.Format("\n* Image ID: {0}", image.Id); message += string.Format("\n* Size of the Structure Set associated with the plan: {0}.", structures.Count()); string structureNames = ""; foreach (var s in structures) { structureNames += String.Format("\n\t{0}: volume is {1:F2} cc.", s.Id, s.Volume); } message += structureNames; } message += string.Format("\n* Number of Fractions: {0}.", plan.NumberOfFractions); message += string.Format("\n \t Dose per Fraction: {0}.", plan.DosePerFraction); // Handle brachytherapy plans separately from external beam plans if (plan is BrachyPlanSetup) { BrachyPlanSetup brachyPlan = (BrachyPlanSetup)plan; var catheters = brachyPlan.Catheters; var seedCollections = brachyPlan.SeedCollections; message += string.Format("\n* Number of Catheters: {0}.", catheters.Count()); message += string.Format("\n* Number of Seed Collections: {0}.", seedCollections.Count()); } else { var beams = plan.Beams; message += string.Format("\n* Number of Beams: {0}.", beams.Count()); string beamNames = ""; foreach (var b in beams.OrderBy(x => x.BeamNumber)) { beamNames += String.Format("\n\t{0} has {1} MU.", b.Id, b.Meterset.Value); } message += beamNames; } if (plan is IonPlanSetup) { IonPlanSetup ionPlan = plan as IonPlanSetup; IonBeam beam = ionPlan.IonBeams.FirstOrDefault(); if (beam != null) { message += string.Format("\n* Number of Lateral Spreaders in first beam: {0}.", beam.LateralSpreadingDevices.Count()); message += string.Format("\n* Number of Range Modulators in first beam: {0}.", beam.RangeModulators.Count()); message += string.Format("\n* Number of Range Shifters in first beam: {0}.", beam.RangeShifters.Count()); } } //MessageBox.Show(message); window.Background = Brushes.Blue; window.Content = new TextBlock { Foreground = Brushes.White, FontFamily = new FontFamily("Ariel"), FontSize = 18, Text = message }; //window.Content = message; }
public bool Run(OpenFileDialogData data) { var parent = data.TransientFor ?? MessageService.RootWindow; CommonFileDialog dialog; if (data.Action == FileChooserAction.Open) { dialog = new CustomCommonOpenFileDialog(); } else { dialog = new CommonSaveFileDialog(); } SelectFileDialogHandler.SetCommonFormProperties(data, dialog); CustomCommonFileDialogComboBox encodingCombo = null; if (data.ShowEncodingSelector) { var group = new CommonFileDialogGroupBox("encoding", "Encoding:"); encodingCombo = new CustomCommonFileDialogComboBox(); BuildEncodingsCombo(encodingCombo, data.Action != FileChooserAction.Save, data.Encoding); group.Items.Add(encodingCombo); dialog.Controls.Add(group); encodingCombo.SelectedIndexChanged += (sender, e) => { if (encodingCombo.SelectedIndex == encodingCombo.Items.Count - 1) { var dlg = new System.Windows.Window { Title = "Choose encodings", Content = new SelectEncodingControl(), SizeToContent = SizeToContent.WidthAndHeight }; if (dlg.ShowDialog().Value) { BuildEncodingsCombo(encodingCombo, data.Action != FileChooserAction.Save, data.Encoding); dialog.ApplyControlPropertyChange("Items", encodingCombo); } } }; } CustomCommonFileDialogComboBox viewerCombo = null; CommonFileDialogCheckBox closeSolution = null; if (data.ShowViewerSelector && data.Action == FileChooserAction.Open) { var group = new CommonFileDialogGroupBox("openWith", "Open with:"); viewerCombo = new CustomCommonFileDialogComboBox { Enabled = false }; group.Items.Add(viewerCombo); dialog.Controls.Add(group); if (IdeApp.Workspace.IsOpen) { var group2 = new CommonFileDialogGroupBox(); // "Close current workspace" is too long and splits the text on 2 lines. closeSolution = new CommonFileDialogCheckBox("Close workspace", true) { Visible = false }; group2.Items.Add(closeSolution); dialog.Controls.Add(group2); } dialog.SelectionChanged += (sender, e) => { try { var files = GetSelectedItems(dialog); var file = files.Count == 0 ? null : files[0]; bool hasBench = FillViewers(viewerCombo, file); if (closeSolution != null) { closeSolution.Visible = hasBench; } dialog.ApplyControlPropertyChange("Items", viewerCombo); } catch (Exception ex) { LoggingService.LogError(e.ToString()); } }; } if (!GdkWin32.RunModalWin32Dialog(dialog, parent)) { return(false); } SelectFileDialogHandler.GetCommonFormProperties(data, dialog); if (encodingCombo != null) { data.Encoding = ((EncodingComboItem)encodingCombo.Items [encodingCombo.SelectedIndex]).Encoding; } if (viewerCombo != null) { if (closeSolution != null) { data.CloseCurrentWorkspace = closeSolution.Visible && closeSolution.IsChecked; } data.SelectedViewer = ((ViewerComboItem)viewerCombo.Items [viewerCombo.SelectedIndex]).Viewer; } return(true); }
public void ShowSettings(System.Windows.Window ParentWindow) { }
public void BitmapSourceSample() { const int size = 250; BitmapSource bs8, bs16; Scalar blueColor8 = new Scalar(128, 0, 0); Scalar greenColor8 = new Scalar(0, 128, 0); Scalar redColor8 = new Scalar(0, 0, 128); Scalar whiteColor8 = new Scalar(255, 255, 255); using (var mat = new Mat(size, size, MatType.CV_8UC3, new Scalar(128, 128, 128))) { mat.Rectangle(new Rect(15, 10, 100, 100), blueColor8, -1); mat.PutText("B", new Point(50, 70), HersheyFonts.HersheyComplex, 1, whiteColor8); mat.Rectangle(new Rect(130, 10, 100, 100), greenColor8, -1); mat.PutText("G", new Point(165, 70), HersheyFonts.HersheyComplex, 1, whiteColor8); mat.Rectangle(new Rect(75, 130, 100, 100), redColor8, -1); mat.PutText("R", new Point(110, 190), HersheyFonts.HersheyComplex, 1, whiteColor8); bs8 = OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(mat); } Scalar blueColor16 = new Scalar(32767, 0, 0); Scalar greenColor16 = new Scalar(0, 32767, 0); Scalar redColor16 = new Scalar(0, 0, 32767); Scalar whiteColor16 = new Scalar(65535, 65535, 65535); using (var mat = new Mat(size, size, MatType.CV_16UC3, new Scalar(32767, 32767, 32767))) { mat.Rectangle(new Rect(15, 10, 100, 100), blueColor16, -1); mat.PutText("B", new Point(50, 70), HersheyFonts.HersheyComplex, 1, whiteColor16); mat.Rectangle(new Rect(130, 10, 100, 100), greenColor16, -1); mat.PutText("G", new Point(165, 70), HersheyFonts.HersheyComplex, 1, whiteColor16); mat.Rectangle(new Rect(75, 130, 100, 100), redColor16, -1); mat.PutText("R", new Point(110, 190), HersheyFonts.HersheyComplex, 1, whiteColor16); bs16 = OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(mat); } var image8 = new Image { Source = bs8 }; var image16 = new Image { Source = bs16 }; var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.RowDefinitions.Add(new RowDefinition()); Grid.SetRow(image8, 0); Grid.SetColumn(image8, 0); grid.Children.Add(image8); Grid.SetRow(image16, 0); Grid.SetColumn(image16, 1); grid.Children.Add(image16); var window = new System.Windows.Window { Title = "Left:8bit Right:16bit", Width = size * 2, Height = size, Content = grid }; var app = new Application(); app.Run(window); }
/// <summary> /// Returns whether the window currently has an owner. /// </summary> /// <param name="window">Window to check.</param> /// <returns> /// True if the window has an owner, otherwise false. /// </returns> private static bool HasOwner(SystemWindow window) { return((window.Owner != null) || (new WindowInteropHelper(window).Owner != IntPtr.Zero)); }
/// <summary> /// Sets the owner window to the main window of the current process, but /// also sets the focus on the first control. /// </summary> /// <param name="window">Reference to the current window.</param> /// <param name="forceNewOwner">If true, the new owner will be forced. Otherwise, if the /// window currently has an owner, that owner will be respected (and thus not changed).</param> /// <param name="focusFirstControl"></param> public static void SetOwnerWindowAndFocus(this SystemWindow window, bool forceNewOwner = false, bool focusFirstControl = true) { SetOwnerWindow(window, forceNewOwner, focusFirstControl); }
/// <summary> /// Sets the owner window of a specific window. It will first try to set the owner via /// the <paramref name="ownerWindow"/>. If the <paramref name="ownerWindow"/> is not available, /// this method will use the <paramref name="ownerHandle"/> to set the parent. /// </summary> /// <param name="window">Reference to the current window.</param> /// <param name="ownerWindow">New owner window.</param> /// <param name="ownerHandle">The owner handle.</param> /// <param name="forceNewOwner">If true, the new owner will be forced. Otherwise, if the /// window currently has an owner, that owner will be respected (and thus not changed).</param> /// <param name="focusFirstControl">If true, the first control will automatically be focused.</param> private static void SetOwnerWindow(SystemWindow window, SystemWindow ownerWindow, IntPtr ownerHandle, bool forceNewOwner, bool focusFirstControl) { if (focusFirstControl) { window.FocusFirstControl(); } if (!forceNewOwner && HasOwner(window)) { return; } try { if (ownerWindow != null) { if (ReferenceEquals(ownerWindow, window)) { Log.Warning("Cannot set owner window to itself, no owner window set"); return; } if (window.Dispatcher.GetThreadId() != ownerWindow.Dispatcher.GetThreadId()) { Log.Warning("The owner window '{0}' is not created on the same thread as the current window '{1}', cannot set owner window", ownerWindow.GetType().GetSafeFullName(false), window.GetType().GetSafeFullName(false)); return; } window.Owner = ownerWindow; } else { // Set owner via interop helper var interopHelper = new WindowInteropHelper(window); interopHelper.Owner = ownerHandle; // Get handler (so we can nicely unsubscribe) RoutedEventHandler onWindowLoaded = null; onWindowLoaded = delegate(object sender, RoutedEventArgs e) { // Since this owner type doesn't support WindowStartupLocation.CenterOwner, do // it manually if (window.WindowStartupLocation == WindowStartupLocation.CenterOwner) { // Get the parent window rect RECT ownerRect; if (GetWindowRect(ownerHandle, out ownerRect)) { // Get some additional information int ownerWidth = ownerRect.Right - ownerRect.Left; int ownerHeight = ownerRect.Bottom - ownerRect.Top; int ownerHorizontalCenter = (ownerWidth / 2) + ownerRect.Left; int ownerVerticalCenter = (ownerHeight / 2) + ownerRect.Top; // Set the location to manual window.WindowStartupLocation = WindowStartupLocation.Manual; // Now we know the location of the parent, center the window window.Left = ownerHorizontalCenter - (window.ActualWidth / 2); window.Top = ownerVerticalCenter - (window.ActualHeight / 2); } } ((SystemWindow)sender).Loaded -= onWindowLoaded; }; window.Loaded += onWindowLoaded; } } catch (Exception ex) { Log.Error(ex, "Failed to set the owner window"); } }
private void AddClick(object sender, RoutedEventArgs e) { System.Windows.Window glowneOkno = System.Windows.Application.Current.MainWindow; glowneOkno.DataContext = new DodajKontraktora(); InitializeList(); }
/// <summary> /// Determines whether the <see cref="SystemWindow.DialogResult"/> property can be set. /// </summary> /// <param name="window">The window to check.</param> /// <returns><c>true</c> if the dialog result can be set; otherwise, <c>false</c>.</returns> public static bool CanSetDialogResult(this SystemWindow window) { Argument.IsNotNull("window", window); return(ComponentDispatcher.IsThreadModal); }
/// <summary> /// Metodo para controlar las acciones de las combinaciones de teclas para los formularios. /// </summary> /// <param name="window">Ventana que se desea implementar</param> /// <param name="blnNotifycon">True si desea implementar notifycon</param> /// <history> /// [michan] 17/05/2016 Created /// </history> public static void EventsKeys(System.Windows.Window window, bool?blnNotifycon = false) { #region Manejo de la ventana //parametros para el manejo de la ventana // Si la ventana al minimizar ocultar aplicación en el menu de iconos de la barra de tarea. //System.Windows.Forms.NotifyIcon _notifyIconFormTransfers = (blnNotifycon.Value) ? Notify(form:window) : null; // bandera si se pulso la tecla control bool pushCtrl = false; bool pushCtrlE = false; #endregion window.KeyDown += new System.Windows.Input.KeyEventHandler( (s, e) => { if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl || e.Key == Key.LeftAlt || e.Key == Key.RightAlt) { pushCtrl = true; } if ((e.Key == Key.F4) && (e.Key == Key.LeftAlt || e.Key == Key.RightAlt)) { // Se minimiza el formulario al presionar la combinación de teclas: // Alt + F4 window.WindowState = WindowState.Minimized; } if (e.Key == Key.E && pushCtrl) { // Se cierra la aplicacion se se pulsaron las teclas: // Cntrl + E pushCtrlE = true; window.Close(); } else if (e.Key == Key.P && pushCtrl) { // Abre información del usuario si se pulso la tecla: // Cntrl + P ShowInfoUser(); } else if (e.Key == Key.S && pushCtrl) { // Se abre la configuracion de setup si se pulsaron las teclas: // Cntrl + S UIHelper.ShowMessage("Setup"); } } ); window.Closing += new System.ComponentModel.CancelEventHandler( (s, e) => { // minimiza el formulario si se pulsa el boton de cerrar. e.Cancel = !pushCtrlE; window.WindowState = WindowState.Minimized; } ); // evento para controlar las acciones del formulario // es utilizado para el notifycon /*window.StateChanged += new EventHandler( * (s, e) => { * // Si la ventana fue minimizada * if (window.WindowState == WindowState.Minimized) * { * // Se oculta el formulario en el menu de icionos * window.Hide(); * window.WindowState = WindowState.Minimized; * // si tiene notificon muestra el mensaje de que ha sido ocultado el formulario * if (_notifyIconFormTransfers != null) * { * _notifyIconFormTransfers.ContextMenu.MenuItems[0].Visible = true; * _notifyIconFormTransfers.ShowBalloonTip(400); * } * } * });*/ }
public void Snippets() { #region Execute a command IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_editing_ShowAttributes"); var command = wrapper as ICommand; // tool and command(Button) supports this if ((command != null) && command.CanExecute(null)) { command.Execute(null); } #endregion #region Set the current tool // use SetCurrentToolAsync FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool"); // or use ICommand.Execute ICommand cmd = FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByRectangleTool") as ICommand; if ((cmd != null) && cmd.CanExecute(null)) { cmd.Execute(null); } #endregion #region Activate a tab FrameworkApplication.ActivateTab("esri_mapping_insertTab"); #endregion bool activate = true; #region Activate/Deactivate a state - to modify a condition // Define the condition in the DAML file based on the state if (activate) { FrameworkApplication.State.Activate("someState"); } else { FrameworkApplication.State.Deactivate("someState"); } #endregion #region Determine if the application is busy // The application is considered busy if a task is currently running on the main worker thread or any // pane or dock pane reports that it is busy or intiializing. // Many Pro styles (such as Esri_SimpleButton) ensure that a button is disabled when FrameworkApplication.IsBusy is true // You would use this property to bind to the IsEnabled property of a control (such as a listbox) on a dockpane or pane in order // to disable it from user interaction while the application is busy. bool isbusy = FrameworkApplication.IsBusy; #endregion #region Get the Application main window System.Windows.Window window = FrameworkApplication.Current.MainWindow; // center it Rect rect = System.Windows.SystemParameters.WorkArea; FrameworkApplication.Current.MainWindow.Left = rect.Left + (rect.Width - FrameworkApplication.Current.MainWindow.ActualWidth) / 2; FrameworkApplication.Current.MainWindow.Top = rect.Top + (rect.Height - FrameworkApplication.Current.MainWindow.ActualHeight) / 2; #endregion #region Close ArcGIS Pro FrameworkApplication.Close(); #endregion #region Get ArcGIS Pro version //"GetEntryAssembly" should be ArcGISPro.exe string version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); #endregion #region Close a specific pane string _viewPaneID = "my pane"; //DAML ID of your pane //You could have multiple instances (InstanceIDs) of your pane. //So you can iterate through the Panes to get "your" panes only IList <uint> myPaneInstanceIDs = new List <uint>(); foreach (Pane pane in FrameworkApplication.Panes) { if (pane.ContentID == _viewPaneID) { myPaneInstanceIDs.Add(pane.InstanceID); //InstanceID of your pane, could be multiple, so build the collection } } foreach (var instanceID in myPaneInstanceIDs) //close each of "your" panes. { FrameworkApplication.Panes.ClosePane(instanceID); } #endregion #region Activate a pane var mapPanes = ProApp.Panes.OfType <IMapPane>(); foreach (Pane pane in mapPanes) { if (pane.Caption == "MyMap") { pane.Activate(); break; } } #endregion }
static public void locateOnScreen(System.Windows.Window window) { window.Left = (System.Windows.SystemParameters.PrimaryScreenWidth - window.Width) / 2; window.Top = (System.Windows.SystemParameters.PrimaryScreenHeight - window.Height) / 2; }
void WidgetDragOverHandler(object sender, System.Windows.DragEventArgs e) { var types = e.Data.GetFormats().Select(t => t.ToXwtTransferType()).ToArray(); var pos = e.GetPosition(Widget).ToXwtPoint(); var proposedAction = DetectDragAction(e.KeyStates); e.Handled = true; // Prevent default handlers from being used. if (Adorner != null) { var w = GetParentWindow(); var v = (UIElement)w.Content; if (w != AdornedWindow) { AdornedLayer.Remove(Adorner); AdornedWindow.AllowDrop = false; AdornedWindow.DragOver -= AdornedWindowOnDragOver; AdornedWindow = w; AdornedWindow.AllowDrop = true; AdornedWindow.DragOver += AdornedWindowOnDragOver; AdornedLayer = AdornerLayer.GetAdornerLayer(v); AdornedLayer.Add(Adorner); } Adorner.Offset = e.GetPosition(v); } if ((enabledEvents & WidgetEvent.DragOverCheck) > 0) { var checkArgs = new DragOverCheckEventArgs(pos, types, proposedAction); Toolkit.Invoke(delegate { eventSink.OnDragOverCheck(checkArgs); }); if (checkArgs.AllowedAction == DragDropAction.None) { e.Effects = currentDragEffect = DragDropEffects.None; return; } if (checkArgs.AllowedAction != DragDropAction.Default) { e.Effects = currentDragEffect = checkArgs.AllowedAction.ToWpfDropEffect(); return; } } if ((enabledEvents & WidgetEvent.DragOver) > 0) { var store = new TransferDataStore(); FillDataStore(store, e.Data, DragDropInfo.TargetTypes); var args = new DragOverEventArgs(pos, store, proposedAction); OnDragOver(sender, args); if (args.AllowedAction == DragDropAction.None) { e.Effects = currentDragEffect = DragDropEffects.None; return; } if (args.AllowedAction != DragDropAction.Default) { e.Effects = currentDragEffect = args.AllowedAction.ToWpfDropEffect(); return; } } e.Effects = currentDragEffect = proposedAction.ToWpfDropEffect(); }
/// <summary> /// Sets the owner window of a specific window via the window handle. /// </summary> /// <param name="window">Reference to the current window.</param> /// <param name="owner">New owner window.</param> /// <param name="forceNewOwner">If true, the new owner will be forced. Otherwise, if the /// window currently has an owner, that owner will be respected (and thus not changed).</param> /// <param name="focusFirstControl">If true, the first control will automatically be focused.</param> private static void SetOwnerWindowByHandle(SystemWindow window, IntPtr owner, bool forceNewOwner = false, bool focusFirstControl = true) { SetOwnerWindow(window, null, owner, forceNewOwner, focusFirstControl); }
public static void Show(NativeWindow owner, string message, string caption, MessageWindowButtons buttons, MessageBoxImage image, MessageWindowResultKind defaultResult, Action <MessageWindowResult> onMessageResult) { ShowImpl(owner, new MessageWindowOptions(message, caption, buttons, image, defaultResult), onMessageResult); }
/// <summary> /// Sets the owner window of a specific window via the window handle, but /// also sets the focus on the first control. /// </summary> /// <param name="window">Reference to the current window.</param> /// <param name="owner">New owner window.</param> /// <param name="forceNewOwner">If true, the new owner will be forced. Otherwise, if the /// window currently has an owner, that owner will be respected (and thus not changed).</param> public static void SetOwnerWindowAndFocus(this SystemWindow window, IntPtr owner, bool forceNewOwner = false) { SetOwnerWindowByHandle(window, owner, forceNewOwner, true); }
/// <summary> /// Sets the owner window of a specific window. /// </summary> /// <param name="window">Reference to the current window.</param> /// <param name="owner">New owner window.</param> /// <param name="forceNewOwner">If true, the new owner will be forced. Otherwise, if the /// window currently has an owner, that owner will be respected (and thus not changed).</param> /// <param name="focusFirstControl">If true, the first control will automatically be focused.</param> private static void SetOwnerWindowByWindow(SystemWindow window, SystemWindow owner, bool forceNewOwner = false, bool focusFirstControl = true) { SetOwnerWindow(window, owner, IntPtr.Zero, forceNewOwner, focusFirstControl); }
public static void SetMessageBoxResult(System.Windows.Window target, bool?value) { target.SetValue(MessageBoxResultProperty, value); }
private void TreeView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (e.Source is RosControl.UI.TreeViewItemSeparator) { return; } else if (e.Source is System.Windows.Controls.TreeViewItem) { switch (Convert.ToString(БыстроеМеню.SelectedValue)) { case "Статистика": { var window = new System.Windows.Window() { Title = "Статистика", Content = new Статистика(), Width = 800, Height = 600, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.NoResize }; window.ShowDialog(); } break; //case "API": // { // var dialog = new SaveFileDialog() // { // FileName = string.Format("RosService.API.{0}", RosService.Client.Domain), // Filter = "Ros.API (*.dll)|*.dll", // RestoreDirectory = true, // AddExtension = true, // DefaultExt = "dll" // }; // if (dialog.ShowDialog().Value) // { // using (RosService.Client client = new RosService.Client()) // { // var source = client.Конфигуратор.ПолучитьСборкуApi(client.Пользователь, client.Домен); // File.WriteAllText(dialog.FileName + ".cs", source.ToString()); // using (var codeProvider = new Microsoft.CSharp.CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v4.0" } })) // { // //add compiler parameters // var compilerParams = new System.CodeDom.Compiler.CompilerParameters(); // compilerParams.CompilerOptions = "/target:library /optimize"; // compilerParams.GenerateExecutable = false; // compilerParams.GenerateInMemory = false; // compilerParams.IncludeDebugInformation = false; // compilerParams.OutputAssembly = dialog.FileName; // // add some basic references // compilerParams.ReferencedAssemblies.Add("mscorlib.dll"); // compilerParams.ReferencedAssemblies.Add("System.dll"); // compilerParams.ReferencedAssemblies.Add("System.Data.dll"); // compilerParams.ReferencedAssemblies.Add("System.Xml.dll"); // compilerParams.ReferencedAssemblies.Add(System.Reflection.Assembly.GetAssembly(typeof(RosService.Client)).Location); // var results = codeProvider.CompileAssemblyFromSource(compilerParams, source.ToString()); // if (results.Errors.Count > 0) // { // var errors = new List<string>(); // foreach (System.CodeDom.Compiler.CompilerError error in results.Errors) // errors.Add(string.Format("Line: {0}; Compile Error: {1}", error.Line, error.ErrorText)); // throw new Exception(String.Join("\n", errors.ToArray())); // } // } // } // MessageBox.Show(string.Format("Сборка сохранена, имя '{0}'", dialog.FileName)); // } // } // break; default: { if (БыстроеМеню.SelectedItem is RosControl.UI.TreeViewItem) { if (((RosControl.UI.TreeViewItem)БыстроеМеню.SelectedItem).ОткрытьВОкне) { RosControl.Helper.СоздатьОкно(БыстроеМеню.SelectedValue, Хранилище.Конфигурация, 0); } else { var tab = RosControl.Helper.СоздатьВкладку(БыстроеМеню.SelectedValue, Хранилище.Конфигурация, true); if ("ГруппыПользователей".Equals(БыстроеМеню.SelectedValue)) { tab.IsFull = true; } } } } break; } } }