本文整理汇总了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();
}
}
示例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();
}
示例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(); };
}
示例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();
}
}
示例5: ValidaCargaFormulario
public static void ValidaCargaFormulario(EEstadoFormulario iEstadoFormulario, Window iFormulario)
{
if (iEstadoFormulario == EEstadoFormulario.ErrorLoad)
{
iFormulario.Close();
}
}
示例6: CloseWindow
private void CloseWindow(Window window)
{
if (window != null)
{
window.Close();
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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("Невалидно въведено поле!");
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}