示例#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);
                    }
                }
            }
        }
示例#2
0
 //清除背景方法
 private void ClearBackground()
 {
     Visi.VisiCol(true, UI_BackGroundBorder);
     Se_BG_Alpha_Text.Foreground = Brushes.Silver;
     Se_BG_Alpha.IsEnabled       = false;
     RegeditRW.RegWrite("Background", "");
 }
示例#3
0
 //游戏版本选择
 private void UI_gameversion_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MWInit == true)
     {
         LoadGameVersionXml();
         RegeditRW.RegWrite("GameVersion", UI_gameversion.SelectedIndex);
     }
 }
示例#4
0
 //游戏版本选择
 private void UI_gameversion_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MWInit == true)
     {
         LoadGameVersionXml();
         RegeditRW.RegWrite("GameVersion", UI_gameversion.SelectedIndex);
         button_CS_Reset_Click(null, null);//模拟初始化
     }
 }
示例#5
0
 //修改字体
 private void Se_ComboBox_Font_SelectionChanged(Object sender, SelectionChangedEventArgs e)
 {
     if (loadFont == true)
     {
         List <string> Ls = new List <string>();
         foreach (TextBlock TB in Se_ComboBox_Font.Items)
         {
             Ls.Add(TB.Text);
         }
         mainWindow.FontFamily = new FontFamily(Ls[Se_ComboBox_Font.SelectedIndex]);
         RegeditRW.RegWrite("MainWindowFont", Ls[Se_ComboBox_Font.SelectedIndex]);
     }
 }
示例#6
0
 //窗口置顶
 private void Se_button_Topmost_Click(object sender, RoutedEventArgs e)
 {
     if (Topmost == false)
     {
         Topmost = true;
         Se_image_Topmost.Source   = RSN.PictureShortName(RSN.ShortName("Setting_Top_T"));
         Se_textblock_Topmost.Text = "永远置顶";
         RegeditRW.RegWrite("Topmost", 1);
     }
     else
     {
         Topmost = false;
         Se_image_Topmost.Source   = RSN.PictureShortName(RSN.ShortName("Setting_Top_F"));
         Se_textblock_Topmost.Text = "永不置顶";
         RegeditRW.RegWrite("Topmost", 0);
     }
 }
示例#7
0
 //MainWindow窗口尺寸改变
 private void mainWindow_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     //最大化
     if (WindowState == WindowState.Maximized)
     {
         WindowState = WindowState.Normal;
         UI_btn_maximized_Click(null, null);
     }
     //设置版本号位置
     UI_Version.Margin = new Thickness(10, mainWindow.ActualHeight - 35, 0, 0);
     //左侧面板高度
     LeftCanvas.Height    = mainWindow.ActualHeight - 2;
     LeftWrapPanel.Height = mainWindow.ActualHeight - 2;
     //Splitter高度
     UI_Splitter.Height = ActualHeight - 52;
     RegeditRW.RegWrite("MainWindowHeight", ActualHeight);
     RegeditRW.RegWrite("MainWindowWidth", ActualWidth);
 }
示例#8
0
        //设置背景方法
        public void SetBackground()
        {
            var OFD = new Microsoft.Win32.OpenFileDialog()
            {
                FileName   = "",                                                                    //默认文件名
                DefaultExt = ".png",                                                                // 默认文件扩展名
                Filter     = "图像文件 (*.bmp;*.gif;*.jpg;*.jpeg;*.png)|*.bmp;*.gif;*.jpg;*.jpeg;*.png" //文件扩展名过滤器
            };
            bool?result = OFD.ShowDialog();                                                         //显示打开文件对话框

            Visi.VisiCol(false, UI_BackGroundBorder);
            try
            {
                string PictruePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\JiHuangBaiKeCSharp\Background\"; //设置文件夹位置
                if ((Directory.Exists(PictruePath)) == false)                                                                               //若文件夹不存在
                {
                    Directory.CreateDirectory(PictruePath);
                }
                var filename = Path.GetFileName(OFD.FileName); //设置文件名
                try
                {
                    File.Copy(OFD.FileName, PictruePath + filename, true);
                }
                catch (Exception) { }
                var brush = new ImageBrush()
                {
                    ImageSource = new BitmapImage(new Uri(PictruePath + filename))
                };
                UI_BackGroundBorder.Background = brush;
                Se_BG_Alpha_Text.Foreground    = Brushes.Black;
                Se_BG_Alpha.IsEnabled          = true;
                RegeditRW.RegWrite("Background", PictruePath + filename);
            }
            catch (Exception)
            {
                MessageBox.Show("没有选择正确的图片");
            }
        }
示例#9
0
 //设置窗口透明度
 private void Se_Window_Alpha_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     Opacity = Se_Window_Alpha.Value / 100;
     Se_Window_Alpha_Text.Text = "窗口不透明度:" + (int)Se_Window_Alpha.Value + "%";
     RegeditRW.RegWrite("WindowAlpha", Se_Window_Alpha.Value + 1);
 }
示例#10
0
 //设置面板透明度
 private void Se_Panel_Alpha_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     RightGrid.Background.Opacity = Se_Panel_Alpha.Value / 100;
     Se_Panel_Alpha_Text.Text     = "面板不透明度:" + (int)Se_Panel_Alpha.Value + "%";
     RegeditRW.RegWrite("BGPanelAlpha", Se_Panel_Alpha.Value + 1);
 }
示例#11
0
 //设置背景透明度
 private void Se_BG_Alpha_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     UI_BackGroundBorder.Opacity = Se_BG_Alpha.Value / 100;
     Se_BG_Alpha_Text.Text       = "背景不透明度:" + (int)Se_BG_Alpha.Value + "%";
     RegeditRW.RegWrite("BGAlpha", Se_BG_Alpha.Value + 1);
 }
        //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
        }