1/13/2010

Error Handle

Warning 1 The designer cannot process the code at line 39, please see the Task List for details. The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\bkyungnam\Desktop\TestProgram\WindowsFormsApplication1\WindowsFormsApplication1\Form2.Designer.cs 40 0



이런 에러를 발견했다 -_-^ 이것때문에 하루종일 매달렸지만 원인은

non printing ascii code를 TextBox.Text 속성에 복사해서 붙여넣었기 때문이었다.
난 behind source쪽은 건드리지도 않았는데 계속 이런 에러를 받으니 속이 뒤집어지는 줄 알았다.

짧은 영어로나마 에러 피드백을 했다.

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=524784

고쳐지면 좋겠는데 말이지..ㅎ

에러 발생 소스코드를 보자
behind 소스이다.

Form2.Designer.cs file
namespace WindowsFormsApplication1
{
    partial class Form2
    {
        /// 
        /// Required designer variable.
        /// 
        private System.ComponentModel.IContainer components = null;

        /// 
        /// Clean up any resources being used.
        /// 
        /// 

true if managed resources should be disposed; otherwise, false.protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// 
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// 
        private void InitializeComponent()
        {
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(12, 12);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(100, 20);
            this.textBox1.TabIndex = 3;
            this.textBox1.Text = "12      "; //<--이것이 문제라는 말씀!!!
            // 
            // Form2
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(124, 50);
            this.Controls.Add(this.textBox1);
            this.Name = "Form2";
            this.Text = "Form2";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.TextBox textBox1;
    }
}

문제의 아래 소스코드를 보자
this.textBox1.Text = "12      ";
위에서 눈에보이는
"12[공백][공백][공백]" 만 있는것이 아니라
"12[non printing ascii code][공백][공백][공백][non printing ascii code]"
이렇게 들어있단 말씀

이 값을 복사해서 넣으면 암만 error message를 읽어도 해결안되는 에러를 보게된다는 말씀!!
게다가 주석처리를 해도 에러는 여전히 생겼었다. -_-a
저 라인을 삭제하지 않는 이상 에러를 계속 보게 될 것이다. ㅠ
ㅠㅠ

1/06/2010

MVP Model (Model View Presenter Design Pattern)

MVP Model (Model View Presenter Design Pattern)

View와 Business Logic을 최대한 독립적으로 만들기 위한 Design Pattern
MVC(Model View Control) Model의 진화형

Program.cs file
static class Program
{
    /// 
    /// The main entry point for the application.
    /// 
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        // IView 
        ProcessForm view = new ProcessForm();

        // IService
        Service reqText = new Service();

        // Presenter (View, Service)
        ProcessPresenter presenter = new ProcessPresenter(view, reqText);

        // Run
        Application.Run((Form)presenter.view);
    }
}

IProcessView.cs file
public interface IProcessView
{
    void NotifyUpdate(string msg);

    event EventHandler Process;
}


ProcessForm.cs file
public partial class ProcessForm : Form, IProcessView
{
    public event EventHandler Process;

    public ProcessForm()
    {
        InitializeComponent();
    }

    private void processButton_Click(object sender, EventArgs e)
    {
        EventHandler handler = this.Process;
        if (handler != null) handler(this, new EventArgs());
    }

    public void NotifyUpdate(string msg)
    {
        this.labelProcess.Text = msg;
    }
}


ProcessPresenter.cs file
public class ProcessPresenter
{
    public IProcessView view;
    public IReq req;

    public ProcessPresenter(IProcessView view, IReq req)
    {
        this.view = view;
        this.req = req;

        this.view.Process += this.OnProcess;
    }

    private void OnProcess(object source, EventArgs args)
    {
        this.view.NotifyUpdate(this.req.ToString());
    }
}