private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
// we can also use savefile
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "TextDocument|*.txt", ValidateNames = true })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
using (StreamWriter sw = new StreamWriter(sfd.FileName))
{
sw.WriteLineAsync(richTextBox1.Text);
}
}
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font, Brushes.Black, 12, 10);
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (richTextBox1.Text.Length>0)
{
cutToolStripMenuItem.Enabled = true;
copyToolStripMenuItem.Enabled = false;
}
}
private void helpToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Tomchi.
/*
* Created by SharpDevelop.
* User: SHOXSANAMXON
* Date: 20.04.2022
* Time: 20:59
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Tomchi_animatsiyasi
{
public partial class MainForm : Form
{
[DllImport("Gdi32.dll", EntryPoint="CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn(
int left,
int top,
int right,
int bottom,
int width,
int height
);
int [] rainSpeed={4, 6, 3, 5, 6, 7, 4};
int loadingSpeed=2;
float initialPercentage=0;
public MainForm()
{
InitializeComponent();
Region=System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 7, 7));
}
void MainFormLoad(object sender, EventArgs e)
{
timer1.Start();
timer2.Start();
}
void Timer1Tick(object sender, EventArgs e)
{
for (int i = 0; i <8; i++)
{
switch (i)
{
case 0:
pictureBox3.Location= new Point(pictureBox3.Location.X, pictureBox3.Location.Y + rainSpeed[i]);
if (pictureBox3.Location.Y>panel1.Size.Height+pictureBox3.Size.Height)
{
pictureBox3.Location=new Point(pictureBox3.Location.X, 0 -pictureBox3.Size.Height);
}
break;
case 1:
pictureBox4.Location= new Point(pictureBox4.Location.X, pictureBox4.Location.Y + rainSpeed[i]);
if (pictureBox4.Location.Y>panel1.Size.Height+pictureBox4.Size.Height)
{
pictureBox4.Location=new Point(pictureBox4.Location.X, 0 -pictureBox4.Size.Height);
}
break;
case 2:
pictureBox5.Location= new Point(pictureBox5.Location.X, pictureBox5.Location.Y + rainSpeed[i]);
if (pictureBox5.Location.Y>panel1.Size.Height+pictureBox5.Size.Height)
{
pictureBox5.Location=new Point(pictureBox5.Location.X, 0 -pictureBox5.Size.Height);
}
break;
case 3:
pictureBox6.Location= new Point(pictureBox6.Location.X, pictureBox6.Location.Y + rainSpeed[i]);
if (pictureBox6.Location.Y>panel1.Size.Height+pictureBox6.Size.Height)
{
pictureBox6.Location=new Point(pictureBox3.Location.X, 0 -pictureBox6.Size.Height);
}
break;
case 4:
pictureBox7.Location= new Point(pictureBox7.Location.X, pictureBox7.Location.Y + rainSpeed[i]);
if (pictureBox7.Location.Y>panel1.Size.Height+pictureBox7.Size.Height)
{
pictureBox7.Location=new Point(pictureBox7.Location.X, 0 -pictureBox7.Size.Height);
}
break;
case 5:
pictureBox8.Location= new Point(pictureBox8.Location.X, pictureBox8.Location.Y + rainSpeed[i]);
if (pictureBox8.Location.Y>panel1.Size.Height+pictureBox8.Size.Height)
{
pictureBox8.Location=new Point(pictureBox8.Location.X, 0 -pictureBox8.Size.Height);
}
break;
case 6:
pictureBox9.Location= new Point(pictureBox9.Location.X, pictureBox9.Location.Y + rainSpeed[i]);
if (pictureBox9.Location.Y>panel1.Size.Height+pictureBox9.Size.Height)
{
pictureBox9.Location=new Point(pictureBox9.Location.X, 0 -pictureBox9.Size.Height);
}
break;
}
}
}
void Timer2Tick(object sender, EventArgs e)
{
initialPercentage +=loadingSpeed;
float percentage=initialPercentage/pictureBox2.Height * 100;
label1.Text=(int)percentage + "%";
panel2.Location=new Point(panel2.Location.X, panel2.Location.Y+loadingSpeed);
if (panel2.Location.Y>pictureBox2.Location.Y+pictureBox2.Height)
{
label1.Text="100%";
this.timer2.Stop();
}
}
}
}
Do'stlaringiz bilan baham: |