⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slashform.h

📁 MegaSplash fgd gh d hdgh dg hd gh
💻 H
字号:
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading;

namespace MegaSplash {

	/// <summary>
	/// Summary for SlashForm
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class SlashForm : public System::Windows::Forms::Form
	{
	public:
		SlashForm(void)
		{
			InitializeComponent();
			//
			m_dblOpacityIncrement = 0.05;
			m_dblOpacityDecrement = 0.1;
			TIMER_INTERVAL = 50;

			//this->ClientSize = this->BackgroundImage->Size;
			
			this->Opacity = 0.0;
			timer1->Interval = TIMER_INTERVAL;
			timer1->Start();	

			//
		}
	private: System::Windows::Forms::Panel^  pnlStatus;
	public: 

	public: String^ m_sStatus;	

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~SlashForm()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Timer^  timer1;
	private: System::Windows::Forms::Label^  lblStatus;
	protected: 
	private: System::ComponentModel::IContainer^  components;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(SlashForm::typeid));
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			this->lblStatus = (gcnew System::Windows::Forms::Label());
			this->pnlStatus = (gcnew System::Windows::Forms::Panel());
			this->SuspendLayout();
			// 
			// timer1
			// 
			this->timer1->Tick += gcnew System::EventHandler(this, &SlashForm::timer1_Tick);
			// 
			// lblStatus
			// 
			this->lblStatus->AutoSize = true;
			this->lblStatus->Location = System::Drawing::Point(60, 203);
			this->lblStatus->Name = L"lblStatus";
			this->lblStatus->Size = System::Drawing::Size(35, 13);
			this->lblStatus->TabIndex = 0;
			this->lblStatus->Text = L"label1";
			// 
			// pnlStatus
			// 
			this->pnlStatus->BackColor = System::Drawing::Color::Transparent;
			this->pnlStatus->Location = System::Drawing::Point(24, 18);
			this->pnlStatus->Name = L"pnlStatus";
			this->pnlStatus->Size = System::Drawing::Size(343, 41);
			this->pnlStatus->TabIndex = 1;
			this->pnlStatus->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &SlashForm::pnlStatus_Paint);
			// 
			// SlashForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"$this.BackgroundImage")));
			this->ClientSize = System::Drawing::Size(379, 326);
			this->Controls->Add(this->pnlStatus);
			this->Controls->Add(this->lblStatus);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
			this->Name = L"SlashForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"SlashForm";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

	public:

		double m_dblOpacityIncrement;
		double m_dblOpacityDecrement;
		int TIMER_INTERVAL;
		
	
		double m_dblCompletionFraction;
		Rectangle^ m_rProgress ;




	private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) 
			 {

				 lblStatus->Text = m_sStatus;

				  if( m_dblOpacityIncrement > 0 )
					  {
						if( this->Opacity < 1 )
						  this->Opacity += m_dblOpacityIncrement;
					  }
					  else
					  {
						if( this->Opacity > 0 )
						  this->Opacity += m_dblOpacityIncrement;
						else
						  this->Close();
					  }


				  int width = (int)Math::Floor( pnlStatus->ClientRectangle.Width * m_dblCompletionFraction );
				  int height = pnlStatus->ClientRectangle.Height;
				  int x = pnlStatus->ClientRectangle.X;
				  int y = pnlStatus->ClientRectangle.Y;
				  if( width > 0 && height > 0 )
				  {
					m_rProgress = gcnew Rectangle( x, y, width, height);
					pnlStatus->Invalidate( *m_rProgress );                // 右巫腿臆
				  }



			 }

	private: System::Void pnlStatus_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
			 {
				/*  if( e->ClipRectangle.Width > 0 && m_iActualTicks > 1  )
				  {
					  System::Drawing::Drawing2D::LinearGradientBrush brBackground = gcnew System::Drawing::Drawing2D::LinearGradientBrush::LinearGradientBrush( &m_rProgress, Color::FromArgb(50, 50, 200), Color::FromArgb(150, 150, 255), LinearGradientMode::Horizontal);
					e->Graphics.FillRectangle(brBackground, m_rProgress);
				  }
				*/
			}


};


	public ref class ptrSplashScreen : public System::Windows::Forms::Form
	{
	public:
		static SlashForm^ ms_frmSplash = nullptr;
		static Thread^ ms_oThread = nullptr;


		// Static method for updating the progress percentage.
	static public double Progress_get() 
		  {
			if( ms_frmSplash != nullptr )
			  return ms_frmSplash->m_dblCompletionFraction; 
			return 100.0;
		  } 
	static public void Progress_set( double value ) 
		  {
			if( ms_frmSplash != nullptr )
			  ms_frmSplash->m_dblCompletionFraction = value;
		  }
		
	};
	

	// A static method to set the status.
	static public String^ SetStatus(String^ newStatus)
	{
	  if( ptrSplashScreen::ms_frmSplash == nullptr )
		return nullptr;
	  ptrSplashScreen::ms_frmSplash->m_sStatus = newStatus;
	}


	// A static entry point to launch SplashScreen.
	static private void ShowForm()
	{
		ptrSplashScreen::ms_frmSplash = gcnew SlashForm( );
		Application::Run( ptrSplashScreen::ms_frmSplash );
	}

	// A static method to close the SplashScreen
	static public void CloseForm()
	{
		//	ptrSplashScreen::ms_frmSplash->Close();
		if( ptrSplashScreen::ms_frmSplash != nullptr )
		  {
				// Make it start going away.
				ptrSplashScreen::ms_frmSplash->m_dblOpacityIncrement = -ptrSplashScreen::ms_frmSplash->m_dblOpacityDecrement;
		  }
		  ptrSplashScreen::ms_oThread = nullptr;  // we do not need these any more.
		  ptrSplashScreen::ms_frmSplash = nullptr;

	}

	static public void ShowSplashScreen()
	{
	  // Make sure it is only launched once.
		if( ptrSplashScreen::ms_frmSplash != nullptr )
		return;

		ptrSplashScreen::ms_oThread = gcnew Thread( gcnew ThreadStart( ShowForm ));
		ptrSplashScreen::ms_oThread->IsBackground = true;
		ptrSplashScreen::ms_oThread->ApartmentState = ApartmentState::STA;
		ptrSplashScreen::ms_oThread->Start();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -