• silverlight乐动魔方 实战八 .


    好了··上次讲到···childwindows 干啥的?~》

    这次就看看··吧··

    如果你之前下载了····PicBtn 这个文件,···那就应该会有以下的图片

    接着就是他的XAML布局

    <controls:ChildWindow x:Class="SilverlightMusicHit.ChildMusicMsg"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
               Width="400" Height="300" 
               Opacity="0.9" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input">
        <Grid x:Name="LayoutRoot" Margin="2" LostFocus="LayoutRoot_LostFocus">
            <Grid.RowDefinitions>
                <RowDefinition Height="150"/>
                <RowDefinition Height="50"/>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Button x:Name="btnStart" Content="START" Width="126" Height="63" HorizontalAlignment="Right" Margin="0,0,125,-28" Grid.Row="2" Opacity="0.5" MouseLeave="btn_MouseLeave" MouseMove="btn_MouseMove" Click="btnStart_Click" />
            <Image Height="150" Width="150" HorizontalAlignment="Left" Margin="0,0,0,0" Name="imgMusic" Stretch="Fill" VerticalAlignment="Top" Grid.Row="0" Source="../Image/PicBtn/musicMsg.png"/>
            <TextBlock Height="140" HorizontalAlignment="Left" Margin="150,10,0,0" Name="txtMusicTitle" VerticalAlignment="Top" Width="230" FontSize="32" Text="txt" TextWrapping="Wrap" />
        </Grid>
    </controls:ChildWindow>

    - = 怎么越讲越少,····怎么说呢···其实这些布局···应该还看得懂吧。

    进入···ChildMusicMsg.cs才是重点

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    using System.Threading;
    
    namespace SilverlightMusicHit
    {
        public partial class ChildMusicMsg : ChildWindow
        {
            #region 变量
            /// <summary>
            /// 音乐信息索引
            /// </summary>
            private static int _musicIndex = 0; 
            #endregion
    
            public ChildMusicMsg(int musicIndex)
            {
                InitializeComponent();
                _musicIndex = musicIndex;
    
                //读取音乐信息
                txtMusicTitle.Text = Common._MusicValue[_musicIndex].MusicName;
            }
    
            /// <summary>
            /// 鼠标移过按钮高亮
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btn_MouseMove(object sender, MouseEventArgs e)
            {
                ((Button)sender).Opacity = 1;
            }
    
            /// <summary>
            /// 鼠标离开按钮恢复
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btn_MouseLeave(object sender, MouseEventArgs e)
            {
                ((Button)sender).Opacity = 0.5;
            }
    
            private void btnStart_Click(object sender, RoutedEventArgs e)
            {
                ((App)(Application.Current)).RedirectTo(new Game(_musicIndex));
                this.DialogResult = true;
            }
    
            private void LayoutRoot_LostFocus(object sender, RoutedEventArgs e)
            {
                this.DialogResult = true;
            }
        }
    }

    噢··还有错误,···,嗯,还要创建一个新的窗体,··Game , 进入游戏了··呵呵··· - =  不过下一章才讲~

    好了··就这样吧···

    name:5+x

    参考文章与书籍:

    WPF葵花宝典

  • 相关阅读:
    filter的用法
    刚下载好的 vscode 不能运行,一片黑 以及终端不能输入 解决办法
    JS获取光标在input 或 texterea 中下标位置
    JS 数组去重
    字符串操作函数:JSON.parse()、JSON.stringify()、toString 的区别,字符串转数组 str.split(','),数组转字符串String(),以及对象拼接合并Object.assign(),数组拼接合并concat()
    创建标准化工程目录脚本
    configParse模块
    json与api- 天气api 博客词频分析
    文件读写
    os模块、文件压缩 、匹配文件后缀名:fnmatch glob
  • 原文地址:https://www.cnblogs.com/cheng5x/p/2842986.html
Copyright © 2020-2023  润新知