Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WinFormExpl
- {
- public partial class Form1 : Form
- {
- FileInfo loadedFile = null;
- int counter;
- readonly int counterInitialValue;
- public Form1()
- {
- InitializeComponent();
- counterInitialValue = 40;
- }
- private void miOpen_Click(object sender, EventArgs e)
- {
- InputDialog dlg = new InputDialog();
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- string result = dlg.Path;
- //MessageBox.Show(result);
- // TODO: további lépések...
- listView1.Items.Clear();
- if(Directory.Exists(result))
- {
- foreach (string s in Directory.GetFiles(result))
- {
- FileInfo fi = new FileInfo(s);
- var item = listView1.Items.Add(new ListViewItem(new string[] {fi.Name, fi.Length.ToString()}));
- item.Tag = fi.FullName;
- }
- }
- }
- }
- private void miExit_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if(listView1.SelectedItems.Count == 0)
- {
- lName.Text = "Name:";
- lCreated.Text = "Created:";
- }
- else
- {
- string name = listView1.SelectedItems[0].Text;
- lName.Text = "Name: " + name;
- FileInfo fi = new FileInfo(listView1.SelectedItems[0].Tag.ToString());
- lCreated.Text = "Created: " + fi.CreationTime;
- }
- }
- private void listView1_DoubleClick(object sender, EventArgs e)
- {
- if (listView1.SelectedItems.Count == 1)
- {
- counter = counterInitialValue;
- loadedFile = new FileInfo(listView1.SelectedItems[0].Tag.ToString());
- reloadTimer.Start();
- try
- {
- tContent.Text = File.ReadAllText(listView1.SelectedItems[0].Tag.ToString());
- }
- catch (Exception ex)
- {
- }
- }
- else
- {
- tContent.Clear();
- }
- }
- private void reloadTimer_Tick(object sender, EventArgs e)
- {
- counter--;
- // Fontos! Ez váltja ki a Paint eseményt és ezzel a
- // a téglalap újrarajzolását
- detailsPanel.Invalidate();
- if (counter <= 0)
- {
- counter = counterInitialValue;
- tContent.Text = File.ReadAllText(loadedFile.FullName);
- }
- }
- private void detailsPanel_Paint(object sender, PaintEventArgs e)
- {
- //((counterInitialValue-counter)/counterInitialValue)*120
- if (loadedFile != null)
- e.Graphics.FillRectangle(new SolidBrush(Color.Green), 0, 0, (1-((counterInitialValue - counter) / counterInitialValue)) * 120, 5);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement