【代码】完整版的Splash.cs(包含XML注释)

Kwan.Delegates:
namespace  Kwan.Delegates
{
    
///   <summary>
    
///  Encapsulates a method that has one parameter and doesn't return a value.
    
///   </summary>
    
///   <typeparam name="T"> The type of the parameter of the method that this delegate encapsulates. </typeparam>
    
///   <param name="val"> The parameter of the method that this delegate encapsulates. </param>
     public   delegate   void  Action < T > (T val);

    
///   <summary>
    
///  Encapsulates a method that has two parameters and doesn't return a value
    
///  , which is used to find a property on the object by name and set its value
    
///   </summary>
    
///   <typeparam name="T"> The type of the parameter of the method that this delegate encapsulates. </typeparam>
    
///   <param name="propertyName"> The name of the property </param>
    
///   <param name="val"> The parameter of the method that this delegate encapsulates. </param>
     public   delegate   void  Set < T > ( string  propertyName, T val);
}

Splash.cs:

namespace  Kwan.Winform
{
    
using  System;
    
using  System.Threading;
    
using  System.Windows.Forms;
    
using  System.Reflection;
    
using  Kwan.Delegates;

    
///   <summary>
    
///  A bridge class that connect a main form with a splash form
    
///   </summary>
    
///   <typeparam name="TForm"> Type of the splash form </typeparam>
    
///   <example>
    
///  In the entry method of the application:
    
///   <code>
    
///  [STAThread]
    
///  static void Main()
    
///  {
    
///      Application.EnableVisualStyles();
    
///      Application.SetCompatibleTextRenderingDefault(false);
    
///  
    
///      Splash&lt;MySplashForm&gt;.Show();
    
///      MainForm form = new MainForm();
    
///      Application.Run(form);
    
///  }
    
///   </code>
    
///  And terminate the splash form in the loading code of the main form:
    
///   <code>
    
///  private void MainForm_Load(object sender, EventArgs e)
    
///  {
    
///      Splash&lt;MySplashForm&gt;.Close();
    
///  }
    
///   </code>
    
///   </example>
    
///   <remarks> TO-DO: Ensure thread-safety of cross-thread calls in this class </remarks>
     public   class  Splash < TForm >   where  TForm : Form,  new ()
    {
        
#region  Fields

        
///   <summary>
        
///  The splash form
        
///   </summary>
         private   static  TForm _splashForm  =   null ;

        
///   <summary>
        
///  The splash working thread
        
///   </summary>
         private   static  Thread _splashThread  =   null ;

        
#endregion

        
#region  Properties

        
///   <value>
        
///  Get the reference of the splash form
        
///   </value>
        
///   <remarks> Programmers must warrant the thread-safety of cross-thread calls </remarks>
         public   static  TForm SplashForm
        {
            
get  {  return  _splashForm; }
        }

        
#endregion

        
#region  Public Methods

        
///   <summary>
        
///  Show the splash
        
///   </summary>
         public   static   void  Show()
        {
            
if  (_splashThread  !=   null )
                
return ;

            _splashThread 
=   new  Thread(
                () 
=>
                {
                    _splashForm 
=   new  TForm();
                    Application.Run(_splashForm);
                });

            _splashThread.IsBackground 
=   true ;
            _splashThread.SetApartmentState(ApartmentState.STA);
            _splashThread.Start();
        }

        
///   <summary>
        
///  Close the splash form
        
///   </summary>
        
///   <remarks> This method is called from the main form </remarks>
         public   static   void  Close()
        {
            
if  (_splashThread  ==   null return ;
            
if  (_splashForm  ==   null return ;

            
try
            {
                _splashForm.Invoke(
new  MethodInvoker(_splashForm.Close));
            }
            
catch  (Exception ex) { }

            _splashThread 
=   null ;
            _splashForm 
=   null ;
        }

        
///   <summary>
        
///  Set the property of the splash form 
        
///   </summary>
        
///   <typeparam name="T"> Type of the input value </typeparam>
        
///   <param name="propertyName"> The name of the property to be set </param>
        
///   <param name="val"> The value of the input value </param>
        
///   <example>
        
///  First expose the value of the progress bar control in the splash form:
        
///   <code>
        
///  public int Progress
        
///  {
        
///     get { return _progressBar.Value; }
        
///     set { _progressBar.Value = value; }
        
///  }
        
///   </code>
        
///  Set the properties of the splash form, simulating the loading procedure:
        
///   <code>
        
///  private void MainForm_Load(object sender, EventArgs e)
        
///  {
        
///     Splash&lt;MySplashForm&gt;.Set&lt;string&gt;("Text", "Loading");
        
///     int p=1;
        
///     while (Splash&lt;MySplashForm&gt;.SplashForm.Progress &lt; 100)
        
///     {
        
///         System.Threading.Thread.Sleep(20);
        
///         Splash&lt;MySplashForm&gt;.Set&lt;int&gt;("Progress", p);
        
///         p++;
        
///     }
        
///  }
        
///   </code>
        
///   </example>
        
///   <exception cref="InvalidOperationException"> Property cannot be found </exception>
        
///   <exception cref="InvalidOperationException"> The type of input value does not match the property type </exception>
         public   static   void  Set < T > ( string  propertyName, T val)
        {
            PropertyInfo property 
=   typeof (TForm).GetProperty(propertyName);

            
if  (property  ==   null )
                
throw   new  InvalidOperationException( " Property cannot be found " );

            
if  (property.PropertyType  !=   typeof (T))
                
throw   new  InvalidOperationException( " The type of input value does not match the property type " );

            
if  (_splashForm.InvokeRequired)
                _splashForm.Invoke(
new  Set < T > (Splash < TForm > .Set < T > ),  new   object [] { propertyName, val });
            
else
                property.SetValue(_splashForm, val, 
null );
        }

        
#endregion
    }
}
### 回答1: 修改splash.img是指修改安卓系统开机动画的图片文件。一般来说,我们需要按照以下步骤进行操作: 首先,我们需要将手机连接到电脑上,并进入刷机模式。这可以通过按住手机上的特定组合按键进入引导模式来实现。同时,确保在电脑上安装了相应的驱动程序以正确识别手机。 接下来,我们需要下载一个适合我们手机型号的splash.img文件。这可以从开源社区或手机ROM开发者网站上找到。确保选择一个与你手机型号完全匹配的文件,以免造成不兼容或损坏。 然后,我们需要使用特定的刷机工具来将splash.img文件刷入手机的系统分区。这些刷机工具可以从互联网上下载,并根据工具的使用说明进行操作。刷机过程中,需要注意备份重要数据,以免造成数据丢失。 最后,完成刷机后,重启手机即可看到新的开机动画生效。如果不喜欢新的开机动画,可以通过同样的方式将原始的splash.img文件刷回系统。如果在操作过程中出现问题,可以寻求相关论坛或技术支持的帮助。 总之,修改splash.img需要一定的技术知识和操作经验,同时需要注意备份数据和谨慎操作,以免对手机系统造成不可逆的影响。 ### 回答2: 要修改splash.img,首先需要了解splash.img是什么。splash.img是Android系统中的启动画面文件,也称为开机画面或启动图。每次手机开机时,系统会显示这个图片作为欢迎界面。 修改splash.img可以更换手机开机画面,给手机注入个性化和创意。以下是修改splash.img的步骤: 1.备份原始的splash.img文件:在修改前,建议首先将原始的splash.img文件备份到电脑或云端,以防错误操作导致系统无法正常启动,可以通过连接手机到电脑并复制该文件来进行备份。 2.找到合适的启动画面图片:在互联网上寻找一个合适的启动画面图片,可以是自己设计的或从其他来源获取的。确保选择的图片大小和分辨率适配手机屏幕。 3.将新图片重命名为splash.img:将选好的启动画面图片重命名为splash.img。 4.将新的splash.img替换原始文件:将新的splash.img文件复制到手机的系统分区,覆盖原始的splash.img文件。(要进入系统分区需要对手机进行root操作,并使用root文件管理工具) 5.重启手机:完成文件替换后,可重启手机验证修改。如果成功,开机时将显示新的启动画面,如果失败或出现问题,可通过将备份的原始文件重新复制到系统分区来还原系统。 需要注意的是,修改splash.img属于系统文件的操作,需要具备一定的技术和操作风险,如果不了解相关知识,建议不要随意修改系统文件,以免出现问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值