Close() public méthode

public Close ( ) : void
Résultat void
 private void CloseWindow(Window windowToClose)
 {
     if (windowToClose != null)
     {
         windowToClose.Close();
     }
 }
Exemple #2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public WindowViewModel(Window window)
        {
            mWindow = window;

            // Listen out for the window resizing
            mWindow.StateChanged += (sender, e) =>
            {
                // Fire off events for all properties that are affected by a resize
                WindowResized();
            };

            // Create commands
            MinimizeCommand = new RelayCommand(param => mWindow.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(param =>
            {
                mWindow.WindowState ^= WindowState.Maximized;
            });
            CloseCommand = new RelayCommand(param => mWindow.Close());
            MenuCommand  = new RelayCommand(param => SystemCommands.ShowSystemMenu(mWindow, GetMousePosition()));

            // Fix window resize issue
            mWindowResizer = new WindowResizer(mWindow);

            // Listen out for dock changes
            mWindowResizer.WindowDockChanged += (dock) =>
            {
                // Store last position
                mDockPosition = dock;

                // Fire off resize events
                WindowResized();
            };

            CurrentOpenedWindow = window;
        }
Exemple #3
0
        public void OrientationDefaultValue()
        {
            Chart chart = new Chart();
            
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = TrendLineToTest;
            chart.TrendLines.Add(trendLine);
                 
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(Orientation.Horizontal, trendLine.Orientation);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Exemple #4
0
		public static Duration GetDuration(string fileName)
			{
			Duration naturalDuration = Duration.Automatic;
			Window w = new Window
				{
				Content = _videoElement = new MediaElement() { IsMuted = true },
				IsHitTestVisible = false,
				Width = 0,
				Height = 0,
				WindowStyle = WindowStyle.None,
				ShowInTaskbar = false,
				ShowActivated = false
				};
			_videoElement.MediaOpened += (sender, args) =>
				{
				naturalDuration = _videoElement.NaturalDuration;
				_videoElement.Close();
				w.Close();
				};
			_videoElement.LoadedBehavior = MediaState.Manual;
			_videoElement.UnloadedBehavior = MediaState.Manual;
			_videoElement.Source = new Uri(fileName);
			_videoElement.Play();
			w.ShowDialog();
			return naturalDuration;
			}
        private void AddQuantity(Window window)
        {
            try
            {
                var quantityAsDouble = double.Parse(Quantity);

                databaseHandlerService.UpdateProductAsync(product, quantityAsDouble);
                product.Quantity += quantityAsDouble;

                if (!product.Name.Contains("#") && quantityAsDouble != 0)
                {
                    databaseHandlerService.AddShipmentAsync(product, quantityAsDouble);
                }

                productsViewModel.UpdateProduct(product);

                var notifySuccessEvent = eventAggregator.GetEvent<NotifyOnSuccessEvent>();
                notifySuccessEvent.Publish("Наличността е променена успешно!");

                window.Close();
            }
            catch
            {
                var notifyErrorEvent = eventAggregator.GetEvent<NotifyOnErrorEvent>();
                notifyErrorEvent.Publish("Невалидно въведено поле!");
            }
        }
        /// <summary>
        ///     基础的 ViewModel
        /// </summary>
        /// <param name="window"> ViewModel 用来控制的 Window 类对象. </param>
        public WindowViewModel(System.Windows.Window window)
        {
            _window = window;
            _window.StateChanged += (sender, e) =>
            {
                // Fire off events for all properties that are affected by a resize
                OnPropertyChanged(nameof(ResizeBorderThickness));
                OnPropertyChanged(nameof(OuterMarginSize));
                OnPropertyChanged(nameof(OuterMarginSizeThickness));
                OnPropertyChanged(nameof(CornerRadius));
                OnPropertyChanged(nameof(WindowCornerRadius));
                // Trace.WriteLine($"window state: {_window.WindowState}" +
                //                 $"window size: {_window.ActualHeight} H * {_window.ActualWidth} W");
            };

            // 添加最小化 command action
            MinimizeCommand = new RelayCommand(() => _window.WindowState = WindowState.Minimized);
            // 这里进行了异或操作(相同返回0),如果当前状态 == max 状态相等,则设置当前状态为 0 (也就是 Normalize——
            // 如果当前状态并不是 Max 状态,则返回 Maximized
            MaximizeCommand = new RelayCommand(() => _window.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(() => _window.Close());
            MenuCommand     = new RelayCommand(() => SystemCommands.ShowSystemMenu(_window, GetMousePosition()));

            // 修复窗口可能覆盖控制栏的问题
            var windowResizer = new WindowResizer(_window);
        }
        private Task<LiveConnectSession> LoginAsync()
        {
            TaskCompletionSource<LiveConnectSession> taskCompletion = new TaskCompletionSource<LiveConnectSession>();

            var url = _client.GetLoginUrl(new[] { "wl.basic", "wl.signin", "onedrive.readonly", "wl.skydrive", "wl.photos" });

            WebBrowser browser = new WebBrowser();
            var window = new Window();
            window.Content = browser;

            NavigatingCancelEventHandler handler = null;
            handler = async (o, args) =>
            {
                if (args.Uri.AbsolutePath.Equals("/oauth20_desktop.srf"))
                {
                    browser.Navigating -= handler;
                    window.Close();

                    var session = await GetConnectSession(args.Uri.Query);
                    taskCompletion.SetResult(session);
                }
            };
            browser.Navigating += handler;
            browser.Navigate(url);
            window.Show();
            return taskCompletion.Task;
        }
Exemple #8
0
        public void CheckDefaultLineThickness()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);
            Ticks tick = new Ticks();
            Axis axis = new Axis();
            axis.Ticks.Add(tick);
            chart.AxesX.Add(axis);
              
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(0.5, tick.LineThickness);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Exemple #9
0
        public void ChartAxisViaXaml()
        {
            Object result = XamlReader.Load(new XmlTextReader(new StringReader(Resource.Chart_AxisXaml)));
            Assert.IsInstanceOfType(result, typeof(Chart));

            Chart chart = result as Chart;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(Convert.ToString(1), chart.AxesX[0].AxisMinimum);
                Assert.AreEqual(Convert.ToString(100), chart.AxesX[0].AxisMaximum);
                Assert.AreEqual(Convert.ToString(0), chart.AxesY[0].AxisMinimum);
                Assert.AreEqual(Convert.ToString(200), chart.AxesY[0].AxisMaximum);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();

        }
Exemple #10
0
        public frmPartNumberConfig(UserInformation userInformation, System.Windows.Window window, int entityPrimaryKey,
                                   OperationMode operationMode, string title = "Part Number Configuration")
        {
            try
            {
                InitializeComponent();
                CustPartNoDescription.Focus();

                PartNumberCode = entityPrimaryKey;
                PartNumberConfigViewModel vm = new PartNumberConfigViewModel(userInformation, PartNumberCode, operationMode);
                this.DataContext = vm;
                window.Closing  += vm.CloseMethodWindow;
                if (vm.CloseAction == null && window.IsNotNullOrEmpty())
                {
                    vm.CloseAction = new Action(() => window.Close());
                }

                bll = new PartNumberConfiguration(userInformation);

                List <ProcessDesigner.Model.V_TABLE_DESCRIPTION> lstTableDescription = bll.GetTableColumnsSize("PartNumberConfig");
                this.SetColumnLength <TextBox>(lstTableDescription);
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
        }
Exemple #11
0
        /// <summary>
        /// Prompt for the Amazon Keys
        /// </summary>
        /// <param name="callback">A callback if we got keys</param>
        /// <param name="cancel">A callback if the user didn't provide keys</param>
        public void AskForKeys(TurKit.startTaskDelegate callback, TurKit.noKeysDelegate cancel)
        {
            Amazon amazon = new Amazon();
            Window amazonWindow = new Window
            {
                Title = "Amazon Keys",
                Content = amazon,
                SizeToContent = SizeToContent.WidthAndHeight,
                ResizeMode = ResizeMode.NoResize
            };

               amazon.okButton.Click += (sender, e) => {
                AmazonKeys keys = new AmazonKeys();
                keys.amazonID = amazon.accessKey.Text;
                keys.secretKey = amazon.secretKey.Text;

                if (callback != null)
                {
                    callback(keys);
                }
                amazonWindow.Close();
            };

               amazon.cancelButton.Click += (sender, e) =>
               {
               if (cancel != null)
               {
                   cancel();
               }
               };

            amazonWindow.ShowDialog();
        }
        public void View_will_automatically_bind_to_corresponding_viewmodel()
        {
            var app = new Application();

            var container = new WindsorContainer();
            container.AddFacility(new ViewModelRegistrationFacility(Application.Current));

            container.Register(Component.For<SquareViewModel>().ImplementedBy<SquareViewModel>());

            var window = new Window();
            app.MainWindow = window;

            var contentPresenter = new ContentPresenter();
            window.Content = contentPresenter;
            var vm = new SquareViewModel();
            contentPresenter.Content = vm;

            window.Show();

            try
            {
                var child = VisualTreeHelper.GetChild(contentPresenter, 0);
                Assert.That(child, Is.InstanceOf<SquareView>());
                Assert.That(((Control) child).DataContext, Is.SameAs(vm));
            }
            finally
            {
                window.Close();
            }
        }
Exemple #13
0
        public WebBrowserOverlayWF(FrameworkElement placementTarget)
        {
            _placementTarget = placementTarget;
            Window owner = Window.GetWindow(placementTarget);
            Debug.Assert(owner != null);
            _owner = owner;

            _form = new Form();
            _form.Opacity = owner.Opacity;
            _form.ShowInTaskbar = false;
            _form.FormBorderStyle = FormBorderStyle.None;
            _wb.Dock = DockStyle.Fill;
            _form.Controls.Add(_wb);

            //owner.SizeChanged += delegate { OnSizeLocationChanged(); };
            owner.LocationChanged += delegate { OnSizeLocationChanged(); };
            _placementTarget.SizeChanged  += delegate { OnSizeLocationChanged(); };

            if (owner.IsVisible)
                InitialShow();
            else
                owner.SourceInitialized += delegate
                {
                     InitialShow();
                };

            DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(UIElement.OpacityProperty, typeof(Window));
            dpd.AddValueChanged(owner, delegate { _form.Opacity = _owner.Opacity; });

            _form.FormClosing += delegate { _owner.Close(); };
        }
        private void LoadAction(System.Windows.Window window)
        {
            if (SelectedOStructure == null)
            {
                MessageBox.Show("Structure file is not selected.", "Load Structure", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                switch (LoadType)
                {
                case LoadType.LoadFromServer:
                    StructureService.LoadModelToAppModelFromServer(SelectedOStructure.Id);
                    break;

                case LoadType.LoadFromLocal:
                    StructureService.LoadModelToApp(SelectedOStructure.Id);
                    break;

                default:
                    break;
                }

                window.DialogResult = true;
                window.Close();
            }
        }
Exemple #15
0
 public static void ValidaCargaFormulario(EEstadoFormulario iEstadoFormulario, Window iFormulario)
 {
     if (iEstadoFormulario == EEstadoFormulario.ErrorLoad)
     {
         iFormulario.Close();
     }
 }
Exemple #16
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this._disposed)
     {
         System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher;
         if (dispatcher != null)
         {
             dispatcher.BeginInvoke(new Action(() =>
             {
                 System.Windows.Window window = System.Windows.Window.GetWindow(this);
                 if (window != null)
                 {
                     window.Close();
                 }
                 else
                 {
                 }
             }), new object[0]);
         }
         else
         {
         }
         this._disposed = true;
     }
 }
Exemple #17
0
 private void CloseWindow(Window window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #18
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public WindowViewModel(System.Windows.Window window)
        {
            mWindow = window;

            // Listen out for the window resizing
            mWindow.StateChanged += (sender, e) =>
            {
                // Fire off events for all properties that are affected by a resize
                OnPropertyChanged(nameof(ResizeBorderThickness));
                OnPropertyChanged(nameof(OuterMarginSize));
                OnPropertyChanged(nameof(OuterMarginSizeThickness));
                OnPropertyChanged(nameof(WindowRadius));
                OnPropertyChanged(nameof(WindowCornerRadius));
            };

            // Create commands
            MinimizeCommand = new RelayCommand(() => mWindow.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(() => mWindow.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(() => mWindow.Close());
            MenuCommand     = new RelayCommand(() => SystemCommands.ShowSystemMenu(mWindow, GetMousePosition()));

            // Fix window resize issue
            var resizer = new WindowResizer(mWindow);

            resizer.WindowDockChanged += (dock) => { mDockPosition = dock; };
        }
Exemple #19
0
        public TrayIcon(Window window)
        {
            _icon = new NotifyIcon
            {
                Visible = true,
                Icon = Icon.FromHandle(Resources.ce16.GetHicon()),
                ContextMenu = new ContextMenu(new[]
                {
                    new MenuItem("&Show", (sender, args) => window.Show()),
                    new MenuItem("&Hide", (sender, args) => window.Hide()),
                    new MenuItem("Stay on &Top", (sender, args) =>
                    {
                        window.Topmost = !window.Topmost;
                        ((MenuItem) sender).Checked = window.Topmost;
                    }),
                    new MenuItem("-"),
                    new MenuItem("Settings", (sender, args) =>
                    {
                        var dlg = new SettingsWindow { Owner = window };
                        dlg.ShowDialog();
                    }),
                    new MenuItem("-"),
                    new MenuItem("&Exit", (sender, args) => window.Close())
                })
            };

            _icon.ContextMenu.MenuItems[2].Checked = ConfigManager.Config.StayOnTop;
        }
        private void Query_Click(object sender, RoutedEventArgs e)
        {
            DtoFileModel dto = projectHelper.GetDtoModel();

            projectHelper.CreateFile(new CreateFileInput()
            {
                AbsoluteNamespace    = dto.Namespace.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last(),
                Namespace            = dto.Namespace,
                ClassName            = dto.Name,
                KeyType              = ClassKeyType.Text,
                LocalName            = ClassLocalName.Text,
                Prefix               = NamespacePrefix.Text,
                DirectoryName        = dto.DirName,
                PropertyInfos        = DataList,
                Setting              = _setting,
                ValidationType       = _setting.ValidationType,
                Controller           = _setting.Controller,
                ApplicationService   = _setting.ApplicationService,
                DomainService        = _setting.DomainService,
                AuthorizationService = _setting.AuthorizationService,
                ExcelImportAndExport = _setting.ExcelImportAndExport,
                PictureUpload        = _setting.PictureUpload,
                IsStandardProject    = _setting.IsStandardProject
            });
            MessageBoxResult result = MessageBox.Show("代码生成成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);

            if (result == MessageBoxResult.OK)
            {
                //获取父窗体并关闭
                System.Windows.Window parentWindow = System.Windows.Window.GetWindow(this);
                parentWindow.Close();
                return;
            }
        }
Exemple #21
0
        private async void Register_Execute(System.Windows.Window window)
        {
            RegisterWindow registerWindow = window as RegisterWindow;
            string         password       = registerWindow.PassPB.Password;

            try
            {
                UserRecordArgs args = new UserRecordArgs()
                {
                    DisplayName = Name,
                    Email       = Email,
                    Password    = password,
                    PhoneNumber = Number,
                };

                User = await _model.RegisterUser(args);

                window.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                User = null;
            }
        }
        private void CreateOrganizationStructureAction(System.Windows.Window window)
        {
            StructureService.CreateOrganizationStructure(CompanyName);

            window.DialogResult = true;
            window.Close();
        }
Exemple #23
0
        public void TestDateTimeWithSingleDataPoint()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Random rand = new Random();

            DataSeries dataSeries = new DataSeries();
            DataPoint dataPoint = new DataPoint();
            dataPoint.XValue = new DateTime(2009, 1, 1);
            dataPoint.YValue = rand.Next(10, 100);
            dataSeries.DataPoints.Add(dataPoint);

            chart.Series.Add(dataSeries);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(1, chart.Series[0].DataPoints.Count);
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
        public searchCustomer(searchCustomerTypeEnum displayType)
        {
            InitializeComponent();
            dataContext = new searchCustomer_ModelView(displayType);
            this.DataContext = dataContext;

            dataContext.NewCustomerRequested += (s, a) =>
            {
                newCustomerUC = new NewCustomerUC(displayType);
                newCustomerWindow = new Window()
                {
                    Title = "Új ügyfél",
                    Content = newCustomerUC,
                    SizeToContent = SizeToContent.WidthAndHeight
                };
                newCustomerVM = newCustomerUC.DataContext as NewCustomer_ViewModel;
                newCustomerVM.CustomerInserted += (so, ar) =>
                {
                    dataContext.selectedCustomer = (CustomerBaseRepresentation)so;
                    dataContext.OnCustomerSelected(EventArgs.Empty);
                    newCustomerWindow.Close();
                };
                newCustomerWindow.Show();
            };

            DataProxy.Instance.CustomersChanged += (s, a) =>
            {
                dataContext.RefreshCustomerList();
            };
        }
Exemple #25
0
        private void SaveEncoding(object sender, EventArgs e)
        {
            //指定格式保存
            if (_saveWindow != null)
            {
                _saveWindow.Focus();
                _saveWindow.Show();
                return;
            }

            var dte = (DTE)ServiceProvider.GetService(typeof(DTE));

            var s = dte.ActiveDocument.FullName;

            var window         = new Window();
            var definitionPage = new EncodingPage();

            definitionPage.Closing += (_s, _e) =>
            {
                window.Close();
                _definitionWindow = null;
            };
            window.Closed += (_s, _e) => { _definitionWindow = null; };
            window.Title   = "指定保存格式";
            window.Content = definitionPage;
            window.Show();

            _saveWindow = window;
        }
        /// <summary>Checks for update and asks user if application should be updated 
        /// (this is currently beta: not localized and opens browser for download). </summary>
        public async Task CheckForUpdate(Window mainWindow)
        {
            try
            {
                var document = await Task.Run(() => XDocument.Load(_updateUri));
                var package = document.Descendants("package").First();

                var newVersionValue = package.Descendants("version").First().Value;
                var downloadLink = package.Descendants("download").First().Value;

                var newVersion = new Version(newVersionValue);
                if (_currentVersion < newVersion)
                {
                    var title = "New version is available";
                    var message = "A new version of the application is available: \n\n" +
                        "Current version: " + _currentVersion + "\n" +
                        "New version: " + newVersion + "\n\n" +
                        "Do you want to download the new version?";

                    if (MessageBox.Show(message, title, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        Process.Start(downloadLink);
                        mainWindow.Close();
                    }
                }
            }
            catch (Exception exception)
            {
                // ignore exceptions
                Debug.WriteLine("Exception in CheckForApplicationUpdate: " + exception.Message);
            }
        }
Exemple #27
0
        private void btn_baidu_login_Click(object sender, RoutedEventArgs a)
        {
            var b = new System.Windows.Forms.WebBrowser();

            b.Width           = 800;
            b.Height          = 600;
            b.AllowNavigation = true;
            var w = new System.Windows.Window();

            b.Navigated += (s, e) =>
            {
                try
                {
                    var m = new Regex("access_token=(.*?)&").Match(e.Url.ToString());
                    if (m.Success)
                    {
                        Global.AppSettings["baidu_access_token"] = m.Groups[1].Value;
                        w.Close();
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            };
            b.Navigate(new PCS_client().GetAccessTokenPage());
            var h = new System.Windows.Forms.Integration.WindowsFormsHost();

            h.Child   = b;
            w.Content = h;
            w.ShowDialog();
        }
Exemple #28
0
        public void LineThicknessDefaultValue()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);
            ChartGrid grid = new ChartGrid();
            Axis axis = new Axis();
            axis.Grids.Add(grid);
            chart.AxesY.Add(axis);
            
            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(0.25, grid.LineThickness);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Exemple #29
0
        private void OnShutdownTimerTick(object sender, EventArgs e)
        {
            this.playbackTimer.Stop();
            this.playbackTimer = null;

            // This causes the main window to close (and exit application).
            mainWindow.Close();
        }
 public void ExampleTest()
 {
     var window = new Window() {Width = 100, Height = 100};
     window.Show();
     window.Activate();
     window.Dispatcher.InvokeShutdown();
     window.Close();
 }
Exemple #31
0
        public Result OnShutdown(UIControlledApplication application)
        {
            if (Window != null)
            {
                Window.Close();
            }

            return(Result.Succeeded);
        }
Exemple #32
0
 private void CloseView(Window window, Window mainWindow)
 {
     Thread.Sleep(3000);
     this.Dispatcher.Invoke(new Action(() =>
     {
         window.Close();
         mainWindow.Show();
     }));
 }
Exemple #33
0
 private void CloseDialog()
 {
     if (DialogWindow != null)
     {
         //TODO gui thread
         DialogWindow.Close();
         DialogWindow = null;
     }
 }
Exemple #34
0
        public static async Task AssemblyCleanup()
        {
            await mainWindow.Dispatcher.InvokeAsync(() =>
            {
                mainWindow.Close();
            });

            await windowTask;
        }
        private static void window_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            UIWindow window = (UIWindow)sender;

            if (e.Key == GetCloseKey(window))
            {
                window.Close();
            }
        }
Exemple #36
0
        private void Cancel(System.Windows.Window o)
        {
            if (!CanShowCancelButton)
            {
                return;
            }

            MessageResult = MessageResult.Cancel;
            o.Close();
        }
Exemple #37
0
        private void No(System.Windows.Window o)
        {
            if (!CanShowNoButton)
            {
                return;
            }

            MessageResult = MessageResult.No;
            o.Close();
        }
Exemple #38
0
        private void OK(System.Windows.Window o)
        {
            if (!CanShowOKButton)
            {
                return;
            }

            MessageResult = MessageResult.OK;
            o.Close();
        }
Exemple #39
0
        private void Yes(System.Windows.Window o)
        {
            if (!CanShowYesButton)
            {
                return;
            }

            MessageResult = MessageResult.Yes;
            o.Close();
        }
Exemple #40
0
        public void OpenChat(Window window)
        {
            ChatViewModel chatViewModel = new ViewModelLocator().ChatView;
            chatViewModel.Username = Username;

            ChatView chatView = new ChatView();
            chatView.DataContext = chatViewModel;

            window.Close();
            chatView.Show();
        }
        /// <summary>
        /// Opens the specified window with the specifed view model.  If allowVMToClose is true, ShowWindow will provide a close action to the VM
        /// </summary>
        /// <param name="window"></param>
        /// <param name="viewModel"></param>
        public static void ShowWindow(Window window, object viewModel, bool allowVMToClose)
        {
            window.DataContext = viewModel;

            if(allowVMToClose && viewModel is ICloseable)
            {
                ((ICloseable)viewModel).CloseAction = new Action(() => window.Close());
            }

            window.Show();
        }
 // Save and publish "Database ID" of the seleceted Item ( to be loaded later )
 private void OnSelected(Window win) {
     foreach (SelectionDialogModel m in TableData) {
         if (m.SelectedRow != null) {
             int itemID = Int32.Parse(m.SelectedRow.Row["ID"].ToString());
             SelectedIDEventArgs eventargs = new SelectedIDEventArgs(itemID);
             eventargs.Addition = m.Table.TableName;
             this._eventAggregator.GetEvent<SelectedIDEvent>().Publish(eventargs);
             win.Close();
         }
     }
 }
 private void CheckLogin(Window window)
 {
     foreach (var it in Buyers)
     {
         if (it.Login == Login & it.Password == Password)
         {
             MainWindow mw = new MainWindow(it);
             mw.Show();
             window.Close();
         }
     }
 }
Exemple #44
0
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     MessageBoxResult result = defaultResult;
     Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(
                 () =>
               {
                 Window newWindow = new Window() { Topmost = true };
                 result = MessageBox.Show(newWindow, messageBoxText, caption, button, icon, defaultResult, options);
                 newWindow.Close();
               }));
     return (result);
 }
Exemple #45
0
 public static MessageBoxResult Show(string messageBoxText, string caption)
 {
     MessageBoxResult result = MessageBoxResult.None;
     Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(
                 () =>
               {
                 Window newWindow = new Window() { Topmost = true };
                 result = MessageBox.Show(newWindow, messageBoxText, caption);
                 newWindow.Close();
               }));
     return (result);
 }
        public frmProductReleaseDate(UserInformation userInformation, System.Windows.Window window, ProductInformationModel productInformationModel,
                                     ProcessDesigner.Common.OperationMode operationMode, string title = "Document Release Date")
        {
            InitializeComponent();

            vm = new ProductReleaseDateViewModel(userInformation, window, productInformationModel, operationMode, title);
            this.DataContext = vm;
            if (vm.CloseAction == null && window.IsNotNullOrEmpty())
            {
                vm.CloseAction = new Action(() => window.Close());
            }
        }
    private static void CloseApplication()
    {
      var window = new Window
      {
        WindowStyle = WindowStyle.None,
        Background = Brushes.Transparent,
        Left = 9999
      };

      window.Show();
      window.Close();
    }
Exemple #48
0
        public frmOperatorQualityAssurance(UserInformation userInformation, System.Windows.Window window, int entityPrimaryKey,
                                           OperationMode operationMode, string title = "Operator Quality Assurance Chart")
        {
            InitializeComponent();

            vm = new OperatorQualityAssuranceViewModel(userInformation, mdiChild, entityPrimaryKey, operationMode, title);
            this.DataContext = vm;
            if (vm.CloseAction == null && window.IsNotNullOrEmpty())
            {
                vm.CloseAction = new Action(() => window.Close());
            }
        }
Exemple #49
0
        private void ConnectUpClosing(IViewModel viewModel, Window window)
        {
            var supportClosing = viewModel as ISupportClosing;
            if (supportClosing == null) return;

            // ViewModel is closed, so close the Window
            supportClosing.ExecuteOnClosed(() => Task.Factory.StartNew(() => window.Close(), _scheduler.Dispatcher.TPL));

            // Window is closed, so close the ViewModel
            EventAsync.FromEvent(eh => window.Closed += eh, eh => window.Closed -= eh)
                      .Do(() => supportClosing.ClosingStrategy.Close(), _scheduler.Dispatcher.TPL);
        }
 public void OpenWindow(Window win)
 {
     //this.GetType().GetField(str).
     EventHandler handler = null;
     handler = delegate
     {
         this.RequestClose -= handler;
         win.Close();
     };
     this.RequestClose += handler;
     win.DataContext = this;
     win.Show();
 }
        public static void Close(this BaseMetroDialog dialog, Window parentDialogWindow = null)
        {
            Argument.IsNotNull(() => dialog);

            if (parentDialogWindow != null)
            {
                parentDialogWindow.Close();
            }
            else
            {
                var mainWindow = Application.Current.GetMainWindow();
                mainWindow.HideMetroDialogAsync(dialog);
            }
        }
Exemple #52
0
        private void Guardar(System.Windows.Window o)
        {
            if (MessageBox.Show("¿Deseas guardar el articulo?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                var r = _Datos.CatArticulosGuardar(this.ItemSeleccionado);

                MessageBox.Show(r.Mensaje, "", MessageBoxButton.OK, r.Valor ? MessageBoxImage.Information : MessageBoxImage.Exclamation);

                if (r.Valor)
                {
                    o.Close();
                }
            }
        }
Exemple #53
0
		public static void OuvrirEcran(Window parent,string nom,bool modal,bool fermeParent)
        {
            Type type = parent.GetType();
            Assembly assembly = type.Assembly;
            Window win = (Window)assembly.CreateInstance(type.Namespace + "." + nom);

            if (fermeParent)
                parent.Close();

            if (modal)
                win.ShowDialog();
            else
                win.Show();

        }
        public MainWindowViewModel()
        {
            AddToListCommand = new DelegateCommand(ExecuteAddToList, CanExecuteAddToList);
            RemoveSelectedFromListCommand = new DelegateCommand(ExecuteRemoveSelectedFromList, CanExecuteRemoveSelectedFromList);
            NetworkValueCollection = new BindableNetworkValueBag<string>(1337, "test");

            string showInput = "192.168.1.1";

            //IPAddress buffOutput;
            //do
            //{
            //    showInput = InputWindow.ShowInput("Connect to: ", EingabeModus.Text) as string;
            //    if (string.IsNullOrEmpty(showInput))
            //        break;
            //    var firstOrDefault = Dns.GetHostAddresses(showInput).FirstOrDefault();
            //    if (firstOrDefault != null)
            //        showInput = firstOrDefault.ToString();
            //} while (!IPAddress.TryParse(showInput, out buffOutput));

            NetworkValueCollection.Connect("192.168.1.1");

            new TCPIP().Show();
            new ActionTriggerWindow(NetworkValueCollection).Show();

            var rec = new Window();

            Application.Current.MainWindow.Closing += (sender, args) => rec.Close();

            rec.SizeToContent = SizeToContent.WidthAndHeight;
            rec.Title = "Reciever";
            var button = new Button();
            var recs = new ListBox();

            button.Content = "Refresh";
            button.Click += (sender, args) =>
            {
                recs.Items.Clear();
                foreach (var item in NetworkValueCollection.CollectionRecievers)
                {
                    recs.Items.Add(item);
                }
            };
            var dp = new DockPanel();
            dp.Children.Add(button);
            dp.Children.Add(recs);
            rec.Content = dp;
            rec.Show();
        }
Exemple #55
0
        /// <summary>
        /// Constructor for the base view model.
        /// </summary>
        public BaseWindowViewModel(System.Windows.Window window)
        {
            // Note that we are breaking MVVM concepts by accepting this parameter,
            // though this is not a viewmodel we will probably use in non-desktop
            // environments and everything here is specific to desktop style.
            TargetWindow  = window;
            WindowResizer = new WindowResizer(TargetWindow);

            /* Setup hooks for dock position change. */
            WindowResizer.WindowDockChanged += WindowDockChanged;

            // Implement Titlebar Buttons
            MinimizeCommand = new ActionCommand(() => { TargetWindow.WindowState = WindowState.Minimized; });
            MaximizeCommand = new ActionCommand(() => { TargetWindow.WindowState ^= WindowState.Maximized; });
            CloseCommand    = new ActionCommand(() => { TargetWindow.Close(); });
        }
Exemple #56
0
        private void Upgrade()
        {
            System.Windows.Window toto = new System.Windows.Window();
            toto        = new System.Windows.Window();
            toto.Width  = 250;
            toto.Height = 250;
            System.Windows.Controls.TextBlock test = new System.Windows.Controls.TextBlock()
            {
                Text = "Amélioration en cours"
            };
            test.HorizontalAlignment = HorizontalAlignment.Center;
            test.VerticalAlignment   = VerticalAlignment.Center;
            toto.Content             = test;
            toto.HorizontalAlignment = HorizontalAlignment.Center;
            toto.VerticalAlignment   = VerticalAlignment.Center;
            toto.Show();

            //if (this.UsineTask.IsCompleted == false)
            //{
            //    while (this.UsineTask.IsCompleted == false)
            //    {
            //    }

            //}
            if (toto.ShowActivated)
            {
                toto.Close();
            }

            this.RessourceProducer.Upgrade();
            System.Windows.MessageBox.Show(this.RessourceProducer.Name + " est passé au niveau " + this.RessourceProducer.Level);
            TokenSource    = new CancellationTokenSource();
            Token          = TokenSource.Token;
            this.UsineTask = new Task(() =>
            {
                GameViewModel.Instance.UsineProduction(RessourceProducer.ProductSpeed, RessourceProducer.QuantityProduct, TokenSource);
            }, Token);
            this.UsineTask.Start();

            if (RessourceProducer.Level == 5)
            {
                view.UpgradeButton.Content   = "Maxed";
                view.UpgradeButton.IsEnabled = false;
            }
        }
Exemple #57
0
        private void OnShutdownTimerTick(object sender, EventArgs e)
        {
            this.playbackTimer.Stop();
            this.playbackTimer = null;
            ChangeStateInternal(State.Stopped);

            // This causes the main window to close (and exit application).
            mainWindow.Close();

            // If there is an exception as the result of command playback,
            // then rethrow it here after closing the main window so that
            // calls like NUnit test cases can properly display the exception.
            //
            if (this.PlaybackException != null)
            {
                throw this.PlaybackException;
            }
        }
Exemple #58
0
        public frmFRCS(UserInformation userInformation, System.Windows.Window window, int entityPrimaryKey,
                       OperationMode operationMode, string title = "Feasibility Report and Cost Sheet")
        {
            InitializeComponent();

            vm = new FeasibleReportAndCostSheetViewModel(userInformation, mdiChild, entityPrimaryKey, operationMode, title);
            this.DataContext = vm;
            window.Closing  += vm.CloseMethodWindow;
            if (vm.CloseAction == null && window.IsNotNullOrEmpty())
            {
                vm.CloseAction = new Action(() => window.Close());
            }

            bll = new FeasibleReportAndCostSheet(userInformation);

            List <ProcessDesigner.Model.V_TABLE_DESCRIPTION> lstTableDescription = bll.GetTableColumnsSize("DDCI_INFO");

            this.SetColumnLength <TextBox>(lstTableDescription);
        }
Exemple #59
0
        public void Execute(VMS.TPS.Common.Model.API.ScriptContext context, System.Windows.Window window)
        {
           // XamlAssemblyLoader.LoadAssemblies();
            //var vm = new ConsoleViewModel();

            //new Splash().ShowDialog();

            ScriptContextX.Instance = context;

            var con = new Uab.VMS.Console.Views.Console();
            //con.DataContext = vm;
            con.ShowDialog();

            if (window != null)
            {
                window.Loaded += (sender, e) =>
                {
                    window.Close();
                };
            }
        }
        /// <summary>
        ///     This function is the callback used to execute the command when the menu item is clicked.
        ///     See the constructor to see how the menu item is associated with this function using
        ///     OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            if (_definitionWindow != null)
            {
                _definitionWindow.Focus();
                _definitionWindow.Show();
                return;
            }
            Window         window         = new Window();
            DefinitionPage definitionPage = new DefinitionPage();

            definitionPage.Closing += (_s, _e) =>
            {
                window.Close();
                _definitionWindow = null;
            };
            window.Closed += (_s, _e) => { _definitionWindow = null; };
            window.Title   = "编码规范工具设置";
            window.Content = definitionPage;
            window.Show();

            _definitionWindow = window;
        }