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


C# MainWindow.Close方法代码示例

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


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

示例1: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var window = new MainWindow();

            var viewModel =
                Bootstrapper.CreateContainer(ConfigurationManager.AppSettings["modules"].Split(';')).Resolve
                    <MainWindowViewModel>();

            // When the ViewModel asks to be closed,
            // close the window.
            EventHandler handler = null;
            handler = delegate
                          {
                              viewModel.RequestClose -= handler;
                              window.Close();
                          };
            viewModel.RequestClose += handler;

            // Allow all controls in the window to
            // bind to the ViewModel by setting the
            // DataContext, which propagates down
            // the element tree.
            window.DataContext = viewModel;

            window.Show();
        }
开发者ID:Raconeisteron,项目名称:bakopanos,代码行数:28,代码来源:App.xaml.cs

示例2: OnStartup

        protected override void OnStartup(System.Windows.StartupEventArgs e)
        {
            base.OnStartup(e);

            var window = new MainWindow();
            this.MainWindow = window;
            this.ShutdownMode = ShutdownMode.OnMainWindowClose;

            var vm = new MainWindowViewModel(new WindowsDialogServiceFactory());
            vm.RequestClose += (sender, eArgs) =>
            {
                window.Close();
            };
            window.DataContext = vm;
            window.Show();
        }
开发者ID:Lovesan,项目名称:Organizer,代码行数:16,代码来源:OrganizerApplication.xaml.cs

示例3: Main

        public static void Main(string[] args)
        {
            var app = new App { ShutdownMode = ShutdownMode.OnLastWindowClose };
            app.InitializeComponent();

               var tempWindowToGetDispatcher = new MainWindow();

            var container = new Container(x => x.AddRegistry<AppRegistry>());
            container.Configure(x => x.For<Dispatcher>().Add(tempWindowToGetDispatcher.Dispatcher));
            container.GetInstance<StartupController>();

            var factory = container.GetInstance<WindowFactory>();
            var window = factory.Create();

            tempWindowToGetDispatcher.Close();
            window.Show();
            app.Run();
        }
开发者ID:RomanBlyshchyk,项目名称:TailBlazer,代码行数:18,代码来源:BootStrap.cs

示例4: ApplicationStartup

        /// <summary>
        /// The startup of the application.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.StartupEventArgs"/> instance containing the event data.</param>
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            var mainWindow = new MainWindow();

            var catalog = new AggregateCatalog(new DirectoryCatalog("."), new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            var container = new CompositionContainer(catalog);
            var modules = container.GetExportedValues<IModule>();

            var viewModel = new MainWindowViewModel(modules);

            //close stuff
            EventHandler handler = null;
            handler = delegate
                          {
                              viewModel.RequestClose -= handler;
                              mainWindow.Close();

                          };
            viewModel.RequestClose += handler;

            mainWindow.DataContext = viewModel;
            mainWindow.Show();
        }
开发者ID:Rutix,项目名称:Avalon,代码行数:28,代码来源:App.xaml.cs

示例5: Init

        public async Task<bool?> Init(MetroWindow win)
        {
            try
            {
                parentWindow = win as MainWindow;

                authMgr = new Manager();
                authMgr["consumer_key"] = ConsumerKey;
                authMgr["consumer_secret"] = ConsumerSecret;
                authMgr.AcquireRequestToken(RequestTokenURL, "POST");
                MetroDialogSettings settings = new MetroDialogSettings()
                {
                    AnimateHide = true,
                    AnimateShow = true,
                    AffirmativeButtonText = "확인",
                    NegativeButtonText = "종료"
                };

                MessageDialogResult result = await DialogManager.ShowMessageAsync(parentWindow, "인증", "인증을 위해 웹브라우저를 통해 트위터에 로그인합니다.",
                    MessageDialogStyle.AffirmativeAndNegative, settings);

                if (result == MessageDialogResult.Affirmative)
                {
                    System.Diagnostics.Process.Start($"{RequestPinURL}{authMgr["token"]}");
                    settings = new MetroDialogSettings()
                    {
                        AnimateHide = true,
                        AnimateShow = true,
                        AffirmativeButtonText = "인증",
                        NegativeButtonText = "취소 및 종료"
                    };
                    
                    string pin = await DialogManager.ShowInputAsync(parentWindow, "PIN", "웹브라우저 상에 표시된 PIN을 입력합니다.", settings);

                    try
                    {
                        authMgr.AcquireAccessToken(AccessTokenURL, "POST", pin);
                    }
                    catch(Exception ex)
                    {
                        parentWindow.Close();
                    }

                    IsInit = true;

                    // Get Screen Name
                    dynamic obj = await GetJson("https://api.twitter.com/1.1/account/settings.json", "GET");
                    string name = obj.screen_name;

                    // GetProfile
                    dynamic json = await GetJson($"https://api.twitter.com/1.1/users/show.json?screen_name={name}", "GET");
                    parentWindow.UserNameBlock.Text = json.name;
                    parentWindow.ScreenNameBlock.Text = $"@{json.screen_name}";
                    parentWindow.ProfileDescBlock.Text = json.description;
                    string imageUrl = json.profile_image_url;
                    ProfileImage = new BitmapImage();
                    ProfileImage.BeginInit();
                    ProfileImage.UriSource = new Uri(imageUrl.Replace("_normal", ""));
                    ProfileImage.DownloadCompleted +=
                        (s, ev) => OnPropertyChanged("ProfileImage");
                    ProfileImage.EndInit();
                }
                else
                {
                    parentWindow.Close();
                }

                return IsInit;
            }
            catch (Exception e)
            {
                await DialogManager.ShowMessageAsync(parentWindow, "Error", $"= Message{e.Message}\n\n= Stack Trace\n{e.StackTrace}");
                IsInit = false;
                return false;
            }
        }
开发者ID:Aosamesan,项目名称:twitter_app,代码行数:76,代码来源:MainWindow.xaml.cs

示例6: OpenSettings

        public async void OpenSettings(object sender = null, EventArgs e = null)
        {
            if (SettingsWindow != null)
            {
                SettingsWindow.Focus();
                return;
            }

            var kc = new KonamiCodeStateMachine();
            SettingsWindow = new MainWindow(Data, Poller);
            SettingsWindow.KeyDown += (o, args) => kc.KeyPressed(args.Key);

            if (PollerService.IsRunning)
                await PollerService.Stop();

            kc.KonamiCodeEntered += o =>
            {
                SettingsWindow.Close();
                OpenConsole();
            };

            try
            {
                SettingsWindow.ShowDialog(); //TODO: Win32Exception The Operation Completed Successfully
            }
            catch (Win32Exception) { }

            PollerService.Start();
            _notifyIcon.ShowBalloonTip(2000, "Jenkins Observer", "Polling in Background", ToolTipIcon.Info);

            SettingsWindow = null;
        }
开发者ID:haroldhues,项目名称:JenkinsObserver,代码行数:32,代码来源:App.xaml.cs


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