Beispiel #1
0
        //设置背景拉伸方式
        private void Se_ComboBox_Background_Stretch_SelectionChanged(Object sender, SelectionChangedEventArgs e)
        {
            string bg = RegeditRW.RegReadString("Background");

            if (MWInit == true)
            {
                if (bg == "")
                {
                    Se_BG_Alpha_Text.Foreground = Brushes.Silver;
                    Se_BG_Alpha.IsEnabled       = false;
                }
                else
                {
                    Se_BG_Alpha_Text.Foreground = Brushes.Black;
                    try
                    {
                        var brush = new ImageBrush();
                        brush.ImageSource = new BitmapImage(new Uri(bg));
                        brush.Stretch     = (Stretch)Se_ComboBox_Background_Stretch.SelectedIndex;
                        UI_BackGroundBorder.Background = brush;
                        RegeditRW.RegWrite("BackgroundStretch", Se_ComboBox_Background_Stretch.SelectedIndex + 1);
                    }
                    catch
                    {
                        Visi.VisiCol(true, UI_BackGroundBorder);
                    }
                }
            }
        }
Beispiel #2
0
        //MainWindow窗口加载
        private void mainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            new KeyboardHandler(this);   //加载快捷键
            foreach (string str in rF()) //加载字体
            {
                TextBlock TB = new TextBlock();
                TB.Text       = str;
                TB.FontFamily = new FontFamily(str);
                Se_ComboBox_Font.Items.Add(TB);
            }
            string        mainWindowFont = RegeditRW.RegReadString("MainWindowFont");
            List <string> Ls             = new List <string>();

            foreach (TextBlock TB in Se_ComboBox_Font.Items)
            {
                Ls.Add(TB.Text);
            }
            Se_ComboBox_Font.SelectedIndex = Ls.IndexOf(mainWindowFont);
            loadFont = true;
            LoadGameVersionXml();//加载游戏版本Xml文件
        }
        //MainWindow构造函数
        public MainWindow()
        {
            #region "读取注册表(必须在初始化之前读取)"
            //背景图片
            string bg        = RegeditRW.RegReadString("Background");
            double bgStretch = RegeditRW.RegRead("BackgroundStretch");
            //透明度
            double bgAlpha      = RegeditRW.RegRead("BGAlpha");
            double bgPanelAlpha = RegeditRW.RegRead("BGPanelAlpha");
            double windowAlpha  = RegeditRW.RegRead("WindowAlpha");
            //窗口大小
            double mainWindowHeight = RegeditRW.RegRead("MainWindowHeight");
            double mainWindowWidth  = RegeditRW.RegRead("MainWindowWidth");
            //字体
            string mainWindowFont = RegeditRW.RegReadString("MainWindowFont");
            //设置菜单
            double winTopmost = RegeditRW.RegRead("Topmost");
            //游戏版本
            double gameVersion = RegeditRW.RegRead("GameVersion");
            #endregion
            //初始化
            InitializeComponent();
            //窗口缩放
            SourceInitialized += delegate(object sender, EventArgs e) { _HwndSource = PresentationSource.FromVisual((Visual)sender) as HwndSource; };
            MouseMove         += new System.Windows.Input.MouseEventHandler(Window_MouseMove);
            //mainWindow初始化标志
            MWInit = true;
            #region "读取设置"
            //设置字体
            if (mainWindowFont == "" || mainWindowFont == null)
            {
                RegeditRW.RegWrite("MainWindowFont", "微软雅黑");
                mainWindowFont = "微软雅黑";
            }
            mainWindow.FontFamily = new FontFamily(mainWindowFont);
            //版本初始化
            UI_Version.Text = "v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            //窗口可视化计时器
            VisiTimer.Enabled  = true;
            VisiTimer.Interval = 200;
            VisiTimer.Tick    += new EventHandler(VisiTimerEvent);
            VisiTimer.Start();
            //设置光标资源字典路径
            cursorDictionary.Source = new Uri("Dictionary/CursorDictionary.xaml", UriKind.Relative);
            //显示窗口
            MWVisivility = true;
            //右侧面板Visibility属性初始化
            RightPanelVisibility("Welcome");

            //窗口置顶
            if (winTopmost == 1)
            {
                Se_button_Topmost_Click(null, null);
            }
            //设置背景
            if (bg == "")
            {
                Se_BG_Alpha_Text.Foreground = Brushes.Silver;
                Se_BG_Alpha.IsEnabled       = false;
            }
            else
            {
                Se_BG_Alpha_Text.Foreground = Brushes.Black;
                try
                {
                    var brush = new ImageBrush()
                    {
                        ImageSource = new BitmapImage(new Uri(bg))
                    };
                    UI_BackGroundBorder.Background = brush;
                }
                catch
                {
                    Visi.VisiCol(true, UI_BackGroundBorder);
                }
            }
            //设置背景拉伸方式
            if (bgStretch == 0)
            {
                bgStretch = 2;
            }
            Se_ComboBox_Background_Stretch.SelectedIndex = (int)bgStretch - 1;
            //设置背景透明度
            if (bgAlpha == 0)
            {
                bgAlpha = 101;
            }
            Se_BG_Alpha.Value           = bgAlpha - 1;
            Se_BG_Alpha_Text.Text       = "背景不透明度:" + (int)Se_BG_Alpha.Value + "%";
            UI_BackGroundBorder.Opacity = (bgAlpha - 1) / 100;
            //设置面板透明度
            if (bgPanelAlpha == 0)
            {
                bgPanelAlpha = 61;
            }
            Se_Panel_Alpha.Value         = bgPanelAlpha - 1;
            Se_Panel_Alpha_Text.Text     = "面板不透明度:" + (int)Se_Panel_Alpha.Value + "%";
            RightGrid.Background.Opacity = (bgPanelAlpha - 1) / 100;
            //设置窗口透明度
            if (windowAlpha == 0)
            {
                windowAlpha = 101;
            }
            Se_Window_Alpha.Value     = windowAlpha - 1;
            Se_Window_Alpha_Text.Text = "窗口不透明度:" + (int)Se_Window_Alpha.Value + "%";
            Opacity = (windowAlpha - 1) / 100;
            //设置高度和宽度
            Width  = mainWindowWidth;
            Height = mainWindowHeight;
            //设置游戏版本
            UI_gameversion.SelectedIndex = (int)gameVersion;
            #endregion
        }