当前位置: 首页>>代码示例>>C#>>正文


C# Window.Close方法代码示例

本文整理汇总了C#中System.Windows.Window.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Window.Close方法的具体用法?C# Window.Close怎么用?C# Window.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Window的用法示例。


在下文中一共展示了Window.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloseWindow

 private void CloseWindow(Window windowToClose)
 {
     if (windowToClose != null)
     {
         windowToClose.Close();
     }
 }
开发者ID:EnriqueRivera,项目名称:MyDentDiagnostics,代码行数:7,代码来源:MainWindow.xaml.cs

示例2: LineThicknessDefaultValue

        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();
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:26,代码来源:ChartGridTest.cs

示例3: WebBrowserOverlayWF

        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(); };
        }
开发者ID:jyanpdi,项目名称:Test,代码行数:31,代码来源:WebBrowserOverlayWF.cs

示例4: View_will_automatically_bind_to_corresponding_viewmodel

        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();
            }
        }
开发者ID:ArildF,项目名称:Core,代码行数:30,代码来源:ViewModelRegistrationFacilityTest.cs

示例5: ValidaCargaFormulario

 public static void ValidaCargaFormulario(EEstadoFormulario iEstadoFormulario, Window iFormulario)
 {
     if (iEstadoFormulario == EEstadoFormulario.ErrorLoad)
     {
         iFormulario.Close();
     }
 }
开发者ID:aecodi,项目名称:SHomies,代码行数:7,代码来源:FuncionFormulario.cs

示例6: CloseWindow

 private void CloseWindow(Window window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
开发者ID:Lampati,项目名称:Simpleza,代码行数:7,代码来源:AboutUsViewModel.cs

示例7: CheckForUpdate

        /// <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);
            }
        }
开发者ID:yukiyuki,项目名称:MyToolkit,代码行数:34,代码来源:ApplicationUpdater.cs

示例8: AskForKeys

        /// <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();
        }
开发者ID:tummykung,项目名称:soylent,代码行数:38,代码来源:SoylentRibbon.cs

示例9: ChartAxisViaXaml

        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();

        }
开发者ID:zhangzy0193,项目名称:visifire,代码行数:25,代码来源:AxisTest.cs

示例10: OrientationDefaultValue

        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();
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:26,代码来源:TrendLineTest.cs

示例11: AddQuantity

        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("Невалидно въведено поле!");
            }
        }
开发者ID:svstoichkov,项目名称:Eugenie-v2,代码行数:27,代码来源:AddQuantityViewModel.cs

示例12: LoginAsync

        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;
        }
开发者ID:skendrot,项目名称:CloudBackup,代码行数:27,代码来源:Authenticator.cs

示例13: CheckDefaultLineThickness

        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();
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:26,代码来源:MajorTicksTest.cs

示例14: TrayIcon

        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;
        }
开发者ID:misaxi,项目名称:elmah-tracker,代码行数:28,代码来源:TrayIcon.cs

示例15: GetDuration

		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;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:26,代码来源:MediaInfo.cs


注:本文中的System.Windows.Window.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。