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


C# Windows.Window类代码示例

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


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

示例1: BringToFrontWhenCalled

        /// <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;
                    }));

                }
            });
        }
开发者ID:steven777400,项目名称:WPFSingleInstanceApplication,代码行数:29,代码来源:SingleInstanceApplication.cs

示例2: Main

		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);
		}	}
开发者ID:JonGonard,项目名称:snoopwpf,代码行数:35,代码来源:Main.cs

示例3: RepoteUnhandleException

 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();
 }
开发者ID:hinaloe,项目名称:TwitterVideoUploader,代码行数:32,代码来源:App.xaml.cs

示例4: OnClick

        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);
            }
              }
        }
开发者ID:alienlab,项目名称:Sitecore-Instance-Manager-Lite,代码行数:26,代码来源:RecycleAllButThisButton.cs

示例5: Editor

        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;
        }
开发者ID:andersjakobnilsson,项目名称:ParaPaint,代码行数:29,代码来源:Editor.xaml.cs

示例6: OnClick

        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);
            }
              }
        }
开发者ID:Brad-Christie,项目名称:Sitecore-Instance-Manager,代码行数:32,代码来源:KillAllButThisButton.cs

示例7: App_Startup

 void App_Startup(object sender, StartupEventArgs e)
 {
     Window = new MainWindow();
     SubscribeToWindowEvents();
     MainWindow = Window;
     Window.Show();
 }
开发者ID:paulomouat,项目名称:spikes,代码行数:7,代码来源:App.xaml.cs

示例8: ShowDialog

    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();
        }
      }
    }
开发者ID:krdbigsa,项目名称:NuGetPackageExplorer.Plugins,代码行数:29,代码来源:ViewModelBase.cs

示例9: CloseWindow

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

示例10: CreateEditorInstance

        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();
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:27,代码来源:EditorWindow.cs

示例11: StartDragDrop

        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;
        }
开发者ID:rmunn,项目名称:cog,代码行数:33,代码来源:ItemsControlDragDrop.cs

示例12: TrackInfoPoller

 public TrackInfoPoller(NowPlayingTrackInfoProvider Provider, CoverManager CoverManager, Window window)
 {
     this.nowPlayingProvider = Provider;
     this.coverManager = CoverManager;
     this.window = window;
     this.dispatcher = App.Current.Dispatcher;
 }
开发者ID:philippn,项目名称:now-playing-kiosk,代码行数:7,代码来源:MainWindow.xaml.cs

示例13: OnStartup

 protected override void OnStartup(StartupEventArgs args)
 {
     base.OnStartup(args);
     Window win = new Window();
     win.Title = "Inherit the App";
     win.Show();
 }
开发者ID:daejinseok,项目名称:Study_WPF,代码行数:7,代码来源:InheritTheApp.cs

示例14: SUUpdateAlert

        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;
        }
开发者ID:klm1,项目名称:SparkleDotNET,代码行数:30,代码来源:SUUpdateAlert.cs

示例15: UnderlyingAdd_Button_Click

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


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