private void SkinPage_Loaded(object sender, EventArgs e) { var files = Directory.EnumerateFiles(Environment.CurrentDirectory + "\\Contents\\bg\\bg", "*.*", SearchOption.AllDirectories); string nowPath = ConfigSetting.GetXmlValue("skinBg", "path"); foreach (string item in files) { if (Path.GetExtension(item) == ".png" || Path.GetExtension(item) == ".jpg" || System.IO.Path.GetExtension(item) == ".bmp") { ImageRadioButton imageRadioButton = new ImageRadioButton() { Source = new BitmapImage(new Uri(item)), GroupName = "images" }; imageRadioButton.Checked += ImageRadioButton_Checked; defPanel.Children.Insert(defPanel.Children.Count - 1, imageRadioButton); if (nowPath == item) { imageRadioButton.IsChecked = true; } } } }
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; }