private void WindowPlus_Loaded(object sender, RoutedEventArgs e) { UpdateLayerSize(); UpdateLayerLocation(); SizeChanged += WindowPlus_SizeChanged; //WindowStyleHelper.SetOpacity(this, 0.6); if (SystemHelper.IsWindow10 && Aero) { aeroLayer.Show(); Owner = aeroLayer; AeroHelper.EnableAero(aeroLayer, Shadow); } else { SetShadowRadius(ShadowRadius); SetShadowOpacity(ShadowOpacity); shadowLayer.Show(); Owner = shadowLayer; } if (WindowEntrance == WindowEntrance.Fade) { DoubleAnimation showAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(WindowEntranceTime))); showAnimation.CurrentTimeInvalidated += (s, e2) => { WindowStyleHelper.SetOpacity(aeroLayer, Opacity); }; showAnimation.Completed += (s, e2) => { WindowStyleHelper.SetOpacity(aeroLayer, Opacity); }; BeginAnimation(OpacityProperty, showAnimation); } else if (WindowEntrance == WindowEntrance.None) { Opacity = 1; shadowLayer.Opacity = 1; } Focus(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { mainWindow.Closed += (s, ee) => { try { Close(); } catch { } }; string bgPath = Environment.CurrentDirectory + ConfigSetting.GetXmlValue("skinBg", "path"); SetBackgroundFromName(bgPath); //(backOpPanel.Background as ImageBrush).ImageSource = new BitmapImage(new Uri(bgPath, UriKind.Absolute)); if (SystemHelper.IsWindow10)//判断是否为win10 { //CompositionTarget.Rendering += WindowPositionChangeWithAero; AeroHelper.EnableAero(this, true); Width = Width - ShadowMargin.Left - ShadowMargin.Right - 2; Height = Height - ShadowMargin.Top - ShadowMargin.Bottom - 2; mainGrid.Margin = new Thickness(-1, -25, -1, -1); ShadowMargin = new Thickness(0); backOpPanel.SetValue(Grid.RowSpanProperty, 1); backBlur.SetValue(Grid.RowSpanProperty, 1); backWhite.SetValue(Grid.RowSpanProperty, 1); WindowEntranceBackgroundMode = 5; } else { //CompositionTarget.Rendering += WindowPositionChange; } mainWindow.Show(); OnLocationChanged(new EventArgs()); mainGrid.Visibility = Visibility.Visible; }