선택한 폴더의 파일들을 모니터링 하는 프로그램 입니다.

 

모니터링 할 경로를 설정 후

타입에는 파일 확장자를 입력한 다음 모니터링 ON 버튼을 클릭하면 동작합니다.

 

 

Winform 프로그레스바 입니다.

 

progress bar

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformApp
{
	public partial class MainForm : Form
	{
		private int number = 0;
		private string orgString = "";

		/// <summary>
		/// 생성자 입니다.
		/// </summary>
		public MainForm()
		{
			InitializeComponent();

			this.Load				+= mainForm_Load;
			this.button.Click	    += button_Click;
			this.cancelButton.Click += cancelButton_Click;
			
		}

		/// <summary>
		/// 진행 버튼 클릭시 동작합니다.
		/// </summary>
		/// <param name="sender">이벤트 발생자 입니다.</param>
		/// <param name="e">이벤트 인자 입니다.</param>
		private void button_Click(object sender, EventArgs e)
		{
			this.timer.Enabled = true;
			this.button.Enabled = false;

			this.timer.Tick += timer_Tick;
		}
		
		/// <summary>
		/// 타이머 틱 이벤트 입니다.
		/// </summary>
		/// <param name="sender">이벤트 발생자 입니다.</param>
		/// <param name="e">이벤트 인자 입니다.</param>
		private void timer_Tick(object sender, EventArgs e)
		{
			number++;

			if(number > 100)
			{ 
				this.timer.Enabled = false;
				this.button.Enabled = true;
				return ;
			}

			this.progressBar.Value = number;
			this.label.Text = orgString + number.ToString() + "%";
		}

		/// <summary>
		/// 폼 로드시 동작합니다.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void mainForm_Load(object sender, EventArgs e)
		{
			this.orgString = this.label.Text;
		}


	}
}
  1. hrsuh 2020.11.20 00:24

    도움되는 글 매우 잘 배우고 갑니다

차트의 Bar의 색상을 변경합니다.

 

using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

using DevExpress.XtraCharts;

namespace Dev_Sample
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();

            Load += mainForm_Load;
        }

        /// <summary>
        /// 메인폼 로드시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void mainForm_Load(object sender, EventArgs e)
        {
            ChartControl chart = new ChartControl();

            chart.DataSource = CreateChartData();

            chart.SeriesDataMember = "Month";
            chart.SeriesTemplate.ArgumentDataMember = "Section";
            chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Value" });

            chart.SeriesTemplate.View = new SideBySideBarSeriesView();

            chart.SeriesNameTemplate.BeginText = "Month : ";

            chart.SeriesNameTemplate.BeginText = "Month : ";

            chart.BoundDataChanged += chart_BoundDataChanged;

            chart.Dock = DockStyle.Fill;
            this.Controls.Add(chart);
        }

        private void chart_BoundDataChanged(object sender, EventArgs e)
        {
            ChartControl chart = (ChartControl)sender;

            for (int i = 0; i < chart.Series.Count; i++)
            {
                BarSeriesView view = (BarSeriesView)chart.Series[i].View;
                view.Color = Color.Blue;
                view.FillStyle.FillMode = FillMode.Gradient;
                ((GradientFillOptionsBase)view.FillStyle.Options).Color2 = Color.Beige;
            }
        }

        private DataTable CreateChartData()
        { 
            DataTable table = new DataTable("Table");

            table.Columns.Add("Month", typeof(string));
            table.Columns.Add("Section", typeof(string));
            table.Columns.Add("Value", typeof(Int32));

            table.Rows.Add(new object[] { "Jan"  , "Section1", 10 });
            table.Rows.Add(new object[] { "Jan"  , "Section2", 20 });
            table.Rows.Add(new object[] { "Jan"  , "Section3", 40 });
            table.Rows.Add(new object[] { "Feb"  , "Section1", 20 });
            table.Rows.Add(new object[] { "Feb"  , "Section2", 30 });
            table.Rows.Add(new object[] { "Feb"  , "Section3", 80 });
            table.Rows.Add(new object[] { "March", "Section1", 30 });
            table.Rows.Add(new object[] { "March", "Section2", 40 });
            table.Rows.Add(new object[] { "March", "Section3", 100 });

            return table;
        }
    }
}

 

차트에 spline, line, bar를 출력합니다.

using System;
using System.Data;
using System.Windows.Forms;

using DevExpress.XtraCharts;

namespace Dev_Sample
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();

            Load += mainForm_Load;
        }

        /// <summary>
        /// 메인폼 로드시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void mainForm_Load(object sender, EventArgs e)
        {
            ChartControl chart = new ChartControl();

            chart.DataSource = CreateChartData();

            chart.SeriesDataMember = "Month";
            chart.SeriesTemplate.ArgumentDataMember = "Section";
            chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Value" });

            chart.SeriesTemplate.View = new SideBySideBarSeriesView();

            chart.SeriesNameTemplate.BeginText = "Month : ";

            chart.SeriesNameTemplate.BeginText = "Month : ";

            chart.BoundDataChanged += chart_BoundDataChanged;

            chart.Dock = DockStyle.Fill;
            this.Controls.Add(chart);
        }

        private void chart_BoundDataChanged(object sender, EventArgs e)
        {
            ChartControl chart = (ChartControl)sender;

            Series series = chart.GetSeriesByName("Month : Feb");

            if(series != null)
                series.ChangeView(ViewType.Line);

            Series march = chart.GetSeriesByName("Month : March");

            if(march != null)
                march.ChangeView(ViewType.Spline);
        }

        private DataTable CreateChartData()
        { 
            DataTable table = new DataTable("Table");

            table.Columns.Add("Month", typeof(string));
            table.Columns.Add("Section", typeof(string));
            table.Columns.Add("Value", typeof(Int32));

            table.Rows.Add(new object[] { "Jan"  , "Section1", 10 });
            table.Rows.Add(new object[] { "Jan"  , "Section2", 20 });
            table.Rows.Add(new object[] { "Jan"  , "Section3", 40 });
            table.Rows.Add(new object[] { "Feb"  , "Section1", 20 });
            table.Rows.Add(new object[] { "Feb"  , "Section2", 30 });
            table.Rows.Add(new object[] { "Feb"  , "Section3", 80 });
            table.Rows.Add(new object[] { "March", "Section1", 30 });
            table.Rows.Add(new object[] { "March", "Section2", 40 });
            table.Rows.Add(new object[] { "March", "Section3", 100 });

            return table;
        }
    }
}

 

+ Recent posts