/// <summary>
        /// 设置背景拉伸方式
        /// </summary>
        private void Se_ComboBox_Background_Stretch_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var bg = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Skin", "Background");

            if (!MwInit)
            {
                return;
            }
            if (bg == "")
            {
                Se_button_Background_Clear_Click(null, null);
            }
            else
            {
                SeBgAlphaText.Foreground = Brushes.Black;
                try
                {
                    var brush = new ImageBrush()
                    {
                        ImageSource = new BitmapImage(new Uri(bg)),
                        Stretch     = (Stretch)SeComboBoxBackgroundStretch.SelectedIndex
                    };
                    UiBackGroundBorder.Background = brush;
                    UiTitle.Foreground            = new SolidColorBrush(Colors.Black);
                    IniFileIo.IniFileWrite("DedicatedServerConfigure", "Skin", "BackgroundStretch", (SeComboBoxBackgroundStretch.SelectedIndex + 1).ToString());
                }
                catch
                {
                    Se_button_Background_Clear_Click(null, null);
                }
            }
        }
 /// <summary>
 /// MainWindow窗口加载
 /// </summary>
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     #region 加载字体
     foreach (var str in ReadFont())
     {
         var textBlock = new TextBlock
         {
             Text       = str,
             FontFamily = new FontFamily(str)
         };
         SeComboBoxFont.Items.Add(textBlock);
     }
     var mainWindowFont = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Font", "FontFamily");
     var stringList     = (from TextBlock textBlock in SeComboBoxFont.Items select textBlock.Text).ToList();
     SeComboBoxFont.SelectedIndex = stringList.IndexOf(mainWindowFont);
     var mainWindowFontWeight = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Font", "FontWeight");
     SeCheckBoxFontWeight.IsChecked = mainWindowFontWeight == "True";
     LoadFont = true;
     #endregion
 }
            private static void App_Startup(object sender, StartupEventArgs e)
            {
                #region 设置全局字体
                var mainWindowFont = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Font", "FontFamily");
                Global.FontFamily = !string.IsNullOrEmpty(mainWindowFont) ? new FontFamily(mainWindowFont) : new FontFamily("微软雅黑");
                #endregion

                #region 淡紫色透明光标
                var mainWindowLavenderCursor = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Others", "LavenderCursor");
                if (string.IsNullOrEmpty(mainWindowLavenderCursor))
                {
                    mainWindowLavenderCursor = "True";
                    IniFileIo.IniFileWrite("DedicatedServerConfigure", "Others", "LavenderCursor", "True");
                }
                ResourceDictionary CursorDictionary;
                if (mainWindowLavenderCursor == "True")
                {
                    CursorDictionary = new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/Cursor/CursorDictionary.xaml",
                            UriKind.Absolute)
                    };
                }
                else
                {
                    CursorDictionary = new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/Cursor/DefaultCursorDictionary.xaml",
                            UriKind.Absolute)
                    };
                    Current.Resources.MergedDictionaries.Add(CursorDictionary);
                }
                foreach (var key in CursorDictionary.Keys)
                {
                    var cursor = ((TextBlock)CursorDictionary[key]).Cursor;
                    CursorDictionary.Remove(key);
                    CursorDictionary.Add(key, cursor);
                }
                Current.Resources.MergedDictionaries.Add(CursorDictionary);
                #endregion

                #region 读取资源字典
                var resourceDictionaries = new Collection <ResourceDictionary>
                {
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/ComboBoxDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/WindowDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediLeftPanelRadioButtonDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediModBoxDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediRightPanelButtonDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediRightPanelRadioButtonDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediRightPanelTextBoxDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediScrollViewerDictionary.xaml",
                            UriKind.Absolute)
                    },
                    new ResourceDictionary
                    {
                        Source = new Uri(
                            "pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/DediSelectBoxDictionary.xaml",
                            UriKind.Absolute)
                    }
                };
                foreach (var resourceDictionary in resourceDictionaries)
                {
                    Current.Resources.MergedDictionaries.Add(resourceDictionary);
                }
                #endregion

                var mainWindowShow = new MainWindow();
                mainWindowShow.InitializeComponent();
                mainWindowShow.Show();
                mainWindowShow.Activate();
            }
 public MainWindow()
 {
     Application.Current.MainWindow = this;
     #region "读取注册表(必须在初始化之前读取)"
     // 背景图片
     var bg        = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Skin", "Background");
     var bgStretch = IniFileIo.IniFileReadDouble("DedicatedServerConfigure", "Skin", "BackgroundStretch");
     // 透明度
     var bgAlpha = IniFileIo.IniFileReadDouble("DedicatedServerConfigure", "Skin", "BackgroundAlpha");
     //var bgPanelAlpha = RegeditRw.RegRead("BGPanelAlpha");
     var windowAlpha = IniFileIo.IniFileReadDouble("DedicatedServerConfigure", "Skin", "WindowAlpha");
     // 窗口大小
     var mainWindowHeight = IniFileIo.IniFileReadDouble("DedicatedServerConfigure", "Window", "Height");
     var mainWindowWidth  = IniFileIo.IniFileReadDouble("DedicatedServerConfigure", "Window", "Width");
     // 字体
     var mainWindowFont       = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Font", "FontFamily");
     var mainWindowFontWeight = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Font", "FontWeight");
     // 淡紫色透明光标
     var mainWindowLavenderCursor = IniFileIo.IniFileReadString("DedicatedServerConfigure", "Others", "LavenderCursor");
     // 设置菜单
     var winTopmost = IniFileIo.IniFileReadDouble("DedicatedServerConfigure", "Others", "Topmost");
     // 设置
     //Settings.HideToNotifyIcon = RegeditRw.RegReadString("HideToNotifyIcon") == "True";
     //Settings.HideToNotifyIconPrompt = RegeditRw.RegReadString("HideToNotifyIconPrompt") == "True";
     //Settings.SmallButtonMode = RegeditRw.RegReadString("SmallButtonMode") == "True";
     #endregion
     // 初始化
     InitializeComponent();
     // 窗口缩放
     SourceInitialized += delegate(object sender, EventArgs e) { _hwndSource = PresentationSource.FromVisual((Visual)sender) as HwndSource; };
     MouseMove         += Window_MouseMove;
     // mainWindow初始化标志
     MwInit = true;
     #region "读取设置"
     // 设置字体
     if (string.IsNullOrEmpty(mainWindowFont))
     {
         IniFileIo.IniFileWrite("DedicatedServerConfigure", "Font", "FontFamily", "微软雅黑");
         mainWindowFont = "微软雅黑";
     }
     mainWindow.FontFamily = new FontFamily(mainWindowFont);
     ((TextBlock)((VisualBrush)FindResource("HelpBrush")).Visual).FontFamily = mainWindow.FontFamily;
     // 设置字体加粗
     if (string.IsNullOrEmpty(mainWindowFontWeight))
     {
         IniFileIo.IniFileWrite("DedicatedServerConfigure", "Font", "FontWeight", "False");
     }
     mainWindow.FontWeight = mainWindowFontWeight == "True" ? FontWeights.Bold : FontWeights.Normal;
     ((TextBlock)((VisualBrush)FindResource("HelpBrush")).Visual).FontWeight = mainWindow.FontWeight;
     Global.FontWeight = mainWindow.FontWeight;
     // 设置淡紫色透明光标
     SeCheckBoxLavenderCursor.IsChecked = mainWindowLavenderCursor == "True";
     // 版本初始化
     UiTitle.Text = "饥荒开服工具" + Assembly.GetExecutingAssembly().GetName().Version;
     // 窗口可视化计时器
     _visiTimer.Enabled  = true;
     _visiTimer.Interval = 200;
     _visiTimer.Tick    += VisiTimerEvent;
     _visiTimer.Start();
     // 设置光标资源字典路径
     if (SeCheckBoxLavenderCursor.IsChecked == true)
     {
         CursorDictionary.Source =
             new Uri("pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/Cursor/CursorDictionary.xaml",
                     UriKind.Absolute);
     }
     else
     {
         CursorDictionary.Source =
             new Uri("pack://application:,,,/饥荒开服工具ByTpxxn;component/Dictionary/Cursor/DefaultCursorDictionary.xaml",
                     UriKind.Absolute);
     }
     // 显示窗口
     MwVisibility = true;
     // 窗口置顶
     if (winTopmost == 1)
     {
         Se_button_Topmost_Click(null, null);
     }
     // 设置背景
     if (bg == "")
     {
         Se_button_Background_Clear_Click(null, null);
     }
     else
     {
         try
         {
             var brush = new ImageBrush
             {
                 ImageSource = new BitmapImage(new Uri(bg))
             };
             UiBackGroundBorder.Background = brush;
             UiTitle.Foreground            = new SolidColorBrush(Colors.Black);
         }
         catch
         {
             Se_button_Background_Clear_Click(null, null);
         }
     }
     // 设置背景拉伸方式
     if (bgStretch == 0)
     {
         bgStretch = 2;
     }
     SeComboBoxBackgroundStretch.SelectedIndex = (int)bgStretch - 1;
     // 设置背景透明度
     if (bgAlpha == 0)
     {
         bgAlpha = 101;
     }
     SeBgAlpha.Value            = bgAlpha - 1;
     SeBgAlphaText.Text         = "背景不透明度:" + (int)SeBgAlpha.Value + "%";
     UiBackGroundBorder.Opacity = (bgAlpha - 1) / 100;
     // 设置面板透明度
     //if (bgPanelAlpha == 0)
     //{
     //    bgPanelAlpha = 61;
     //}
     //SePanelAlpha.Value = bgPanelAlpha - 1;
     //SePanelAlphaText.Text = "面板不透明度:" + (int)SePanelAlpha.Value + "%";
     // 设置窗口透明度
     if (windowAlpha == 0)
     {
         windowAlpha = 101;
     }
     SeWindowAlpha.Value    = windowAlpha - 1;
     SeWindowAlphaText.Text = "窗口不透明度:" + (int)SeWindowAlpha.Value + "%";
     Opacity = (windowAlpha - 1) / 100;
     // 设置高度和宽度
     Width  = mainWindowWidth;
     Height = mainWindowHeight;
     #endregion
     // 设置托盘区图标
     //SetNotifyIcon();
     // Frame导航
     Global.DedicatedServerFrame = DedicatedServerFrame;
     DedicatedServerFrame.Navigate(new DedicatedServerPage());
     // 是否显示开服工具
     //if (Global.TestMode)
     //    SidebarDedicatedServer.Visibility = Visibility.Visible;
     // 检测新版本
     //UpdatePan.UpdateNow();
 }