GSI


참고자료 : http://www.codeproject.com/KB/cs/control_e_appliances.aspx

1. hwinterface.ocx 를 regsvr32 를 통해서 등록한다.
2. Visual Studio 의 도구 상자에서 ocx 를 등록한다.
   - Hwinterface Control의 activex 컨트롤이 생긴다.
3. 해당 폼으로 가져와서 인스턴스를 생성한다.
4. 나머지 코드는 참고 자료의 링크에 존재 하는 파일을 참고 하기 바람

Posted by gsi
:

MD5 샘플 코드

C# 2009. 12. 23. 13:44 |


--선언--
using System.Security.Cryptography;

--코드--
        #region MD5 메소드
        static string getMd5Hash(string input)
        {
            // Create a new instance of the MD5CryptoServiceProvider object.
            MD5 md5Hasher = MD5.Create();

            // Convert the input string to a byte array and compute the hash.
            byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));

            // Create a new Stringbuilder to collect the bytes
            // and create a string.
            StringBuilder sBuilder = new StringBuilder();

            // Loop through each byte of the hashed data
            // and format each one as a hexadecimal string.
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }

            // Return the hexadecimal string.
            return sBuilder.ToString();
        }

        // Verify a hash against a string.
        static bool verifyMd5Hash(string input, string hash)
        {
            // Hash the input.
            string hashOfInput = getMd5Hash(input);

            // Create a StringComparer an comare the hashes.
            StringComparer comparer = StringComparer.OrdinalIgnoreCase;

            if (0 == comparer.Compare(hashOfInput, hash))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion

        #region MD5 테스트 블록
        private void button1_Click(object sender, EventArgs e)
        {
            // 암호화 문자열을 가져온다.
            string convmd5 = getMd5Hash(textBox1.Text);

            // 암호화된 내용을 출력한다.
            textBox2.Text = convmd5;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 해당 문자열을 가져와서 암호화된 내용과 비교 한다.
            if (verifyMd5Hash(textBox3.Text, textBox2.Text) == true)
            {
                MessageBox.Show("맞습니다.");
            }
            else
            {
                MessageBox.Show("틀립니다.");
            }
        }
        #endregion

Posted by gsi
:


WebBrowser를 사용해야 되는 부분이 생겨서
많이 자료를 보고 해봤지만 TopMost라는 특성 때문에 Winform, WPF 모두
원하는 효과를 낼수가 없더라구요.

그래서 여러가지 보고 테스트도 해봤지만.
어떤건 속도가 너무 느리더라구요.

아래 코드는 완전 해결한건 아니지만,
이것도 조금은 접근이 된거 같아요.

목표점은
- 스레드를 통한 백그라운드 처리를 통해서 다른 UI의 동작을 원할하게 처리
-  모자이크 처리로 화면에 출력함으로 해서 조금은 이펙트를 중점으로 한다.

아래의 코드는 일부 접근된 코드를 우선 올려 봅니다.

-- Code --
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        WebBrowser web = new WebBrowser();

        public Form1()
        {
            InitializeComponent();

            web.Width = 1000;
            web.Height = 1000;
            web.ScrollBarsEnabled = false;
            web.ScriptErrorsSuppressed = true;
            web.Navigate("http://dev.iamgsi.com/googlemap");

            timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //while (web.ReadyState != WebBrowserReadyState.Complete)
            //    System.Windows.Forms.Application.DoEvents();
            //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));

            int width = web.Document.Body.ScrollRectangle.Width;
            int height = web.Document.Body.ScrollRectangle.Height;
            web.Width = width;
            web.Height = height;

            System.Drawing.Bitmap bmp = new Bitmap(width, height);
            web.DrawToBitmap(bmp, new System.Drawing.Rectangle(0, 0, width, height));

            this.pictureBox1.Width = width;
            this.pictureBox1.Height = height;
            if (this.pictureBox1.Image != null)
            {
                this.pictureBox1.Image.Dispose();
            }
            this.pictureBox1.Image = null;
            this.pictureBox1.Image = bmp;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            web.Document.InvokeScript("MoveAddress", new object[] { "서울" });
        }

        private void button3_Click(object sender, EventArgs e)
        {
            web.Document.InvokeScript("MoveAddress", new object[] { "거창" });
        }

        private void button4_Click(object sender, EventArgs e)
        {
            web.Document.InvokeScript("MoveAddress", new object[] { "광주" });
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (web.ReadyState != WebBrowserReadyState.Complete)
                return;

            int width = web.Document.Body.ScrollRectangle.Width;
            int height = web.Document.Body.ScrollRectangle.Height;
            web.Width = width;
            web.Height = height;

            System.Drawing.Bitmap bmp = new Bitmap(width, height);
            web.DrawToBitmap(bmp, new System.Drawing.Rectangle(0, 0, width, height));

            this.pictureBox1.Width = width;
            this.pictureBox1.Height = height;
            if (this.pictureBox1.Image != null)
            {
                this.pictureBox1.Image.Dispose();
            }
            this.pictureBox1.Image = null;
            this.pictureBox1.Image = bmp;
        }
    }
}

Posted by gsi
:

C# USB 인식 심플한 코드

C# 2009. 12. 15. 18:25 |


    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            bool bFind = false;

            // USB 상태 체크
            DriveInfo [] diArray = DriveInfo.GetDrives();
            foreach (DriveInfo di in diArray)
            {
                if (di.IsReady == true && di.DriveType == DriveType.Removable)
                {
                    bFind = true;
                    break;
                }
            }

            label1.Text = (bFind == true) ? "존재합니다." : "없습니다.";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }
    }

Posted by gsi
:


구글이라던지 이곳저곳 찾아 보면 상당히 많은 예제가 나오는거 같다.
GsiClip을 제작중에 DB에 이미지를 데이터로 추가 해야 하는 부분에
단위 테스트에 사용한 소스 코드임. (테스트 수행)

        private void button1_Click(object sender, EventArgs e)
        {
            // 이미지를 DB로 저장한다.
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ImageSave(openFileDialog1.FileName);

                MessageBox.Show("저장완료");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 이미지를 DB에서 로드한다.
            dsImageTableAdapters.Test1TableAdapter adapter =
                new ImageSaveDB.dsImageTableAdapters.Test1TableAdapter();
            dsImage.Test1DataTable table =
                new dsImage.Test1DataTable();

            adapter.Fill(table);

            if (table.Count > 0)
            {
                pictureBox1.Image = byteArrayToImage(table[0].Content2);
            }
        }

        public Image byteArrayToImage(byte[] byteArrayIn)
        {
            MemoryStream ms = new MemoryStream(byteArrayIn);
            Image returnImage = Image.FromStream(ms);
            return returnImage;
        }

        byte[] ReadFile(string sPath)
        {
            byte[] data = null;

            //
            FileInfo fInfo = new FileInfo(sPath);
            long numBytes = fInfo.Length;
            //
            FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);
            //
            BinaryReader br = new BinaryReader(fStream);
            //
            data = br.ReadBytes((int)numBytes);

            return data;
        }

        private void ImageSave(string filename)
        {
            byte[] imageData = ReadFile(filename);

            //
            dsImageTableAdapters.Test1TableAdapter adapter =
                new ImageSaveDB.dsImageTableAdapters.Test1TableAdapter();

            adapter.Insert(imageData);
        }

Posted by gsi
:


string의 값을 byte로 변환하는 것이 C#은 참 복잡하다는 생각이 든다.
왜 Marshal을 이용하는지는 댓글 달아 주심 감사 ^^.

우선 아래 코드는 사용법에 대해서만 작성합니다.

byte[] MsgAscii = System.Text.Encoding.GetEncoding(0).GetBytes(obj);
byte[] arr = new byte[100];
...
for( int i = 0; i < MsgAscii.Length; ++i)
{
    Marshal.WriteByte(arr, i, MsgAscii[i]);
}

Posted by gsi
:

System.Object & 오버라이딩

C# 2008. 12. 6. 17:25 |

System.Object

System.Object는 모든 .NET의 최상위 클래스이다.
즉, .NET에 있는 모든 참조 타입은 이 클래스를 상속하게 된다.

근데 상속이라고 하면
class A : Object
{
...
이런걸 생각 하겠지만 사실 이렇게 하지 않아도 내부적으로는 Object를 상속 받게 되는 것이다.

우선 기본 멤버들을 보게 되면,
  • Equal : 두 객체 인스턴스가 서로 같은지를 검사한다. 값이 아닌 참조를 비교한다.
  • Finalize : 객체가 제거될때 자동으로 실행되는 protected virtual 메소드
    이 메소드는 오버라이딩이 되지 않으며, C++과 비슷하게 소멸자를 통해서 처리가 됨
  • GetHashCode : 객체에 대한 해쉬 코드를 생성
  • GetType : 객체의 타입을 리턴한다.
  • MemberwiseClone : 객체의 일부분에 대한 복사본을 리턴한다.
  • ReferenceEquals : 두 객체 인스턴스가 동일한 인스턴스를 가리키는지 테스트 하는 public static 메소드
  • ToString() : 객체를 표현하는 스트링을 리턴

System.Object 오버라이딩

public class Pixel {
  public Pixel (byte x, byte y) {
    this.x = x;
    this.y = y;
  }

  private byte x;
  private byte y;

  public override string ToString() {
    return "(" + x + "," + y + ")";
  }

  public override bool Equal(object o) {
    try {
      Pixel p = (Pixel)o;
      return p.x = x && p.y == y;
    } catch (Exception) {
      return false;
    }
  }

  public override int GetHashCode() {
    return (x<<8) + y;
  }
}

ToString() 내부에서 x, y 좌표값을 콤마로 구분해서 보여줍니다.
만약 이게 선언되어 있지 않다면, 클래스 이름만을 리턴합니다.

Pixel p = new Pixel(200, 250);
Console.WriteLine(p); //"(200,250)" 을 출력한다.

Equal() 메소드는 내부에서 해당 값들을 비교해서 같다면
true를 리턴하게 됩니다.

Pixel을 선언한 두개의 변수가 있다고 하지만 이것은 어디까지나 참조 타입으로
참조 주소가 두개가 틀리게 되기 때문에 내부의 값이 같은지 비교 하기 위해서는
Equal을 오버라이딩 해줘야 하는 것입니다.

Finalization
참조 타입은 힙에 생성된다. 힙은 런타임이 알아서 관리 한다.
힙 공간을 좀 더 확보할려면 사용하지 않는 객체에 대해 가비지 컬렉션을 수행해야 한다.
System.Object에 있는 Protected visual 인스턴스 메소드인 Finalize를
"오버라이드" 하여, 가비지 컬렉션에 의해 객체가 제거되기 전에 사용한 자원을 리턴할 수 있다.
하지만 ToString(), Equal()등의 메소드와 같이 일반적으로 오버라이드가 불가능하며
소멸자 기호를 사용해야 한다.

Finalization & Dispose 메소드
객체를 제거하기 전, 사용한 리소스를 명시적으로 해제해야 할 경우, .NET 관련 문서에서는
Dispose 메소드를 작성한 후 이를 호출해 주는 방법을 권장하고 있다.
이때 System.IDisposable 인터페이스를 사용하게 된다.

Dispose 메소드에서는 GC.SuppressFinalize(this) 라는 static 메소드를 호출함으로써 더 이상의
finalization이 진행되지 못하도록 할 수도 있다.


결과적으로 Dispose를 통해서 특정한 자원을 리턴하거나, finalization 을 사용해서
프로세스에 맏기도록 선택할 수 있다.

즉, 더이상 사용할 필요가 없는 객체를 완전히 제거하려는 경우에는 Dispose 메소드를 이용하는 것이 좋다.
Finalization은 어느정도의 시간이 소모되기 때문에 가급적 명시적으로 자원을 리턴해야 하는 경우만 사용하자.


이잉
Posted by gsi
:

저번주에 값, 참조 타입에 대해서 스터디를 했다.
한번더 복습의 경험이 된거 같다.

우선 여기서 적을 것은 참조 타입의 주소 참조를 통해서 일어나는
몇가지를 적을 생각이다.

string 의 경우 값을 여러개 대입하거나 += 연산자를 통해서
해당 값들을 추가 할때 참조타입이기 때문에 메모리 공간에 값이 추가 되면서
string의 변수가 참조를 하게 된다.

이때 값을 대입하거나, += 을 통해서 대입되는 값들은
새로운 메모리 공간을 또 요구 하게 된다. 즉, 나머지 이전의 참조 값들은
더이상 참조가 되지 않는 것 뿐이며, 그 값은 가비지 컬렉터를 통해서
지워지게 된다.
그렇다 보니 그 값은 지워지지 않은 상태에서 많은 메모리를 소비 하게 된다.

string은 대입을 한번만 하고 해당 정보를 가져다 쓸때만 사용하는 것이 좋다.
만약 여러번의 대입을 사용할 경우는 StringBuilder 을 쓰는게 좋다.
이건 메모리를 충분히 잡아 놓은 상태에서 해당 값들을 계속해서
추가 하더라도 string보다는 메모리 소비가 적게 된다.

Posted by gsi
:

맨날 도구상자에 있는 컨트롤만 쓰고 있는 나로서는..
새로운 UI를 구상할때면.. 좀 난감해 지네요 ^^..

이번에는 ListBox를 확장해야할듯 해서

바로 위와 같이 하나의 아이템에 복합적인 데이터가 들어가있다고 가정을 하고 작업을 해야 됩니다.
이미지 정보와 해당 이름 또는 나이 저노하 번호 등등..
이걸 위해서는 DrawItem()을 따로 구현해 줘야 되네요.

사용자 삽입 이미지

우선 데이터를 집어 넣을때는
listBox1.Items.Add(new TestTemplate("손병욱", "d:\\a.bmp"));
이와 같이 하나의 데이터 템플릿 클래스를 제작하고 그기에 맞도록 해당 데이터를 추가 해야 됩니다.

그리고 DrawItem()을 가능하게 하기 위한 ListBox의 설정또한 잊지 말아야 하구요.. ^^

간단하게 DrawItem의 드로잉 하는 부분을 아래와 같이 처리 하면 되는군요.

   private void listBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
  {
   if(listBox1.Items.Count <= 0)
    return;

   // Set the DrawMode property to draw fixed sized items.
   listBox1.DrawMode = DrawMode.OwnerDrawVariable;
   // Draw the background of the ListBox control for each item.
   e.DrawBackground();

   // Create a new Brush and initialize to a Black colored brush by default.
   Brush myBrush = Brushes.Black;

   // Determine the color of the brush to draw each item based on the index of the item to draw.
   switch (e.Index)
   {
    case 0:
     myBrush = Brushes.Red;
     break;
    case 1:
     myBrush = Brushes.Orange;
     break;
    case 2:
     myBrush = Brushes.Purple;
     break;
   }

    // 이 부분에서 해당 값을 가져 올때 TestTemplate의 값으로 형변환 한 후에 값을 접근가능..
   TestTemplate tt = (TestTemplate)listBox1.Items[e.Index];

   // Draw the current item text based on the current Font and the custom brush settings.
   e.Graphics.DrawImage(new Bitmap(tt.path), e.Bounds);
   e.Graphics.DrawString(tt.name, e.Font, myBrush,e.Bounds,StringFormat.GenericDefault);
   // If the ListBox has focus, draw a focus rectangle around the selected item.
   e.DrawFocusRectangle();
  }

이때 이미지와 여러가지를 표현하기 위해서는 아래의 함수도 오버라이딩 해서 변경해줘야 하네요.

  private void listBox1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e)
  {
   e.ItemHeight = 100;
  }

위의 내용을 토대로 샘플을 하나 만들어 볼까 합니다.

하지만 고려되어야 하는 사항은 이미지가 들어가기 때문에
많은 양의 데이터를 읽어 들일때 UI가 블락킹 되는 현상이 불현듯 보이네요..
백그라운드 쓰레드나 일반 쓰레드를 통해서 따로 돌려야 할듯 합니다.
그러면 조금더 나은 UI 및 컨트롤을 구현할 수 있을거 같습니다.

개봉박두~~~..
 

Posted by gsi
:

[C#] Round Rectangle 처리하기

C# 2008. 8. 21. 17:04 |

사용자 삽입 이미지

RoundPanel 클래스를 제작했습니다.
Panel을 상속해서 처리 했습니다.

Round 하는 코드는 아래의 코드를 참조 하시면 됩니다.       

        static public GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
        {
            int diameter = 2 * radius;
            Rectangle arcRect =
                new Rectangle(rect.Location, new Size(diameter, diameter));

            GraphicsPath path = new GraphicsPath();

            path.AddArc(arcRect, 180, 90);

            arcRect.X = rect.Right - diameter;
            path.AddArc(arcRect, 270, 90);

            arcRect.Y = rect.Bottom - diameter;
            path.AddArc(arcRect, 0, 90);

            arcRect.X = rect.Left;
            path.AddArc(arcRect, 90, 90);

            path.CloseFigure();

            return path;
        }

Panel 함수에서 드로잉 하는 코드 입니다.
       

        private void roundPanel_title_Paint(object sender, PaintEventArgs e)
        {
            RoundPanel panel = (RoundPanel)sender;

            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.HighQuality;

            int width = panel.ClientRectangle.Width;
            int height = panel.ClientRectangle.Height;

            Rectangle rect = new Rectangle(0, 0, width-1, height-1);
            using (GraphicsPath path = RoundPanel.GetRoundedRectPath(rect, 8))
            {
                using (Brush brush = new LinearGradientBrush(
                                            new Rectangle(0, 0, panel.ClientRectangle.Width, panel.ClientRectangle.Height),
                                            Color.FromArgb(panel.Opcity, 102, 102, 102),
                                            Color.FromArgb(panel.Opcity, 0, 0, 0),
                                            90.0f))
                {
                    //graphics.FillRectangle(brush, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);
                    g.FillPath(brush, path);
                }

                //g.FillPath(Brushes.Yellow, path);
                Pen pen = new Pen(Color.FromArgb(panel.Opcity, 255, 255, 255));
                g.DrawPath(pen, path);
            }
        }

이걸 처리 하다 보면 화면을 전환 하거나 리프레쉬할때 플리커 현상이 생기기도 합니다.
이걸 해결하기 위해서 RoundPanel에 더블버퍼링 처리 코드를 추가 했습니다.

        public RoundPanel()
        {
            ...
            this.SetStyle(  ControlStyles.UserPaint |
                            ControlStyles.AllPaintingInWmPaint |
                            ControlStyles.DoubleBuffer, true);
        }

실행 파일 :



.
관련 코드 :


.
 

Posted by gsi
:

Panel에 두장의 이미지(Bitmap)를 추가한 후에
위의 이미지에 알파값을 추가해서 블랜딩 효과를 줘봤습니다.

사용자 삽입 이미지


코드는 아래와 같아요..


        private void panel_before_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.DrawImage(beforeLeftImage, new PointF(0, 0));

            float[][] ptsArray =
            {
                new float[] { 1, 0, 0, 0, 0},
                new float[] { 0, 1, 0, 0, 0},
                new float[] { 0, 0, 1, 0, 0},
                new float[] { 0, 0, 0, 0.7f, 0},
                new float[] { 0, 0, 0, 0, 1}
            };

            ColorMatrix clrMatrix = new ColorMatrix(ptsArray);
            ImageAttributes imageAtrr = new ImageAttributes();
            imageAtrr.SetColorMatrix(clrMatrix,
                ColorMatrixFlag.Default,
                ColorAdjustType.Bitmap);

            g.DrawImage(beforeXrayLeftIamge,
                new Rectangle(50, 50, beforeXrayLeftIamge.Width, beforeXrayLeftIamge.Height),
                0, 0, beforeXrayLeftIamge.Width, beforeXrayLeftIamge.Height,
                GraphicsUnit.Pixel,
                imageAtrr);

        }

Posted by gsi
:

C#의 Winfor에서 DataSet을 사용할때 BindingSource를 적용할 수 있습니다.
솔직히 아직까지 많은 부분 제대로 파악되지 않은듯 하지만.
참 편한듯 하지만 아직까지 사용하기 힘드네요.

우선 아래의 이미지 처름 MS Access의 파일을 사용해서
member, detail의 테이블을 제작했습니다.

사용자 삽입 이미지
사용자 삽입 이미지

member의 "_name"와 detail의 "_name"의 연결이 되어 있습니다.
잘 몰라서 "관계" 대화창에서 "관계만" 이걸로만 연결했습니다.
사용자 삽입 이미지

문제는 여기서 member의 _name의 정보를 사용해서 삭제 할때
detail의 _name가 같은 경우 모두 삭제를 해야 하는데요.

같은 이름의 내용을 모두 삭제 해야 하는데 자동으로 되는건지 모르겠네요.



그래서 우선 아래와 같이 해결했습니다.
1. member의 항목을 선택한다.
2. member의 memberBindingSource.Current의 값을 얻어 와서 해당 "_name"를 구합니다.
3. detail의 "_name"의 같은 이름을 구해옵니다.(쿼리함수 생성)
4. 구해온 detailDataTable의 정보를 사용해서 detailTableAdapter.Delete() 에서 삭제합니다.
5. memberBindingSource.RemoveCurrent()를 사용해서 member의 데이터를 삭제합니다.
6. .EndEdit()를 통해서 편집을 마칩니다.
7. tableAdapterManager.UpdateAll()를 통해서 값을 업데이트 합니다.

코드는 아래와 같습니다.
private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DataRowView drv = (DataRowView)this.memberBindingSource.Current;
                TestJoinDataSet.memberRow memberRow = (TestJoinDataSet.memberRow)drv.Row;

                TestJoinDataSet.detailDataTable ddt =
                    this.detailTableAdapter.GetDataBy(memberRow._name);

                foreach (TestJoinDataSet.detailRow row in ddt.Rows)
                {
                    this.detailTableAdapter.Delete(row.ID, row._name, row._info);
                }

                this.memberBindingSource.RemoveCurrent();
                this.memberBindingSource.EndEdit();
                this.detailBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.testJoinDataSet);
            }
            catch (InvalidOperationException oex)
            {
                MessageBox.Show(oex.Message);
            }
            catch (NotSupportedException nex)
            {
                MessageBox.Show(nex.Message);
            }
            catch (DataException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

이렇게 하는게 맞는지 조언 부탁해요 ^^

Posted by gsi
:

[C#] OpenGL 코드 연동하기

C# 2008. 8. 8. 12:50 |

사용자 삽입 이미지


관련코드 :


.
Posted by gsi
:

C#을 이용한 FTP로 파일 업로드 하는 코드 입니다.
MSDN에 있는
              ...........
            StreamReader sourceStream = new StreamReader("testfile.txt");
            byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
             .............
이런 코드를 사용하니까. 인코딩에서 데이터가 제대로 전달되지 못하는 문제가 발생합니다.
그래서 아래와같이 처리 했습니다.

        private void btnFileUploadTest_Click(object sender, EventArgs e)
        {
            Upload("blue.jpg");
            Upload("크기변환_dddd.png");
            Upload("zskin.txt");

            MessageBox.Show("Upload 가 완료되었습니다.");
        }

        private void Upload(string filename)
        {
            FileInfo fileInf = new FileInfo(filename);
            string uri = "ftp://192.168.0.3:8451/" + fileInf;
            FtpWebRequest reqFTP;

            UriBuilder URI = new UriBuilder(uri);
            URI.Scheme = "ftp";

            reqFTP = (FtpWebRequest)FtpWebRequest.Create(URI.Uri);
            reqFTP.Credentials = new NetworkCredential("administrator", "0000");
            reqFTP.KeepAlive = false;
            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
            reqFTP.UseBinary = true;
            reqFTP.ContentLength = fileInf.Length;
            reqFTP.UsePassive = true;

            int buffLength = 2048;
            byte[] buff = new byte[buffLength];
            int contentLen;

            FileStream fs = fileInf.OpenRead();

            try
            {
                Stream strm = reqFTP.GetRequestStream();
                contentLen = fs.Read(buff, 0, buffLength);

                while (contentLen != 0)
                {
                    strm.Write(buff, 0, contentLen);
                    contentLen = fs.Read(buff, 0, buffLength);
                }

                strm.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                throw;
            }
        }

Posted by gsi
:

사용자 삽입 이미지

기본 UI만 구현해 봤어요.

UserControl의 기능을 처리 하기 위해서 의존 프로퍼티도 있어야 할거 같은데요. Click 버튼을 누르면 UserControl의 시작 스토리 보드 객체를 Begin() 하면 될듯, 더 내용을 추가 하고 몇가지 테스트를 해보면서 조금씩 기본기를 익혀야 할거 같다.

관련 코드
Posted by gsi
: