Click here to Skip to main content
15,913,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: Catching MouseMove Event Pin
Nouman Bhatti14-Jan-08 22:26
Nouman Bhatti14-Jan-08 22:26 
QuestionHow to upgrade existing application ...? Pin
Pankaj - Joshi14-Jan-08 21:13
Pankaj - Joshi14-Jan-08 21:13 
AnswerRe: How to upgrade existing application ...? Pin
led mike15-Jan-08 4:56
led mike15-Jan-08 4:56 
GeneralRe: How to upgrade existing application ...? Pin
Pankaj - Joshi15-Jan-08 23:23
Pankaj - Joshi15-Jan-08 23:23 
GeneralRe: How to upgrade existing application ...? Pin
led mike16-Jan-08 5:42
led mike16-Jan-08 5:42 
QuestionAssigning WPF Styles at runtime [modified] Pin
AlexZ7114-Jan-08 20:57
AlexZ7114-Jan-08 20:57 
QuestionNot Able to Send Mail Through C# Code Pin
Neeraj Kr14-Jan-08 20:30
Neeraj Kr14-Jan-08 20:30 
GeneralRe: Not Able to Send Mail Through C# Code Pin
Abhijit Jana14-Jan-08 20:31
professionalAbhijit Jana14-Jan-08 20:31 
GeneralRe: Not Able to Send Mail Through C# Code Pin
Neeraj Kr14-Jan-08 22:21
Neeraj Kr14-Jan-08 22:21 
GeneralRe: Not Able to Send Mail Through C# Code Pin
justintimberlake14-Jan-08 21:05
justintimberlake14-Jan-08 21:05 
QuestionSetting the color of a component (R:G:B) Pin
Programm3r14-Jan-08 20:24
Programm3r14-Jan-08 20:24 
GeneralRe: Setting the color of a component (R:G:B) Pin
Abhijit Jana14-Jan-08 20:30
professionalAbhijit Jana14-Jan-08 20:30 
GeneralRe: Setting the color of a component (R:G:B) Pin
Programm3r14-Jan-08 20:44
Programm3r14-Jan-08 20:44 
QuestionCompiling .Net 1.1 Pin
Muammar©14-Jan-08 20:17
Muammar©14-Jan-08 20:17 
GeneralRe: Compiling .Net 1.1 Pin
Ajay.k_Singh14-Jan-08 21:53
Ajay.k_Singh14-Jan-08 21:53 
GeneralRe: Compiling .Net 1.1 Pin
Muammar©14-Jan-08 23:51
Muammar©14-Jan-08 23:51 
GeneralRe: Compiling .Net 1.1 Pin
PIEBALDconsult15-Jan-08 15:42
mvePIEBALDconsult15-Jan-08 15:42 
GeneralRe: Compiling .Net 1.1 Pin
Muammar©15-Jan-08 18:40
Muammar©15-Jan-08 18:40 
GeneralRe: Compiling .Net 1.1 Pin
mav.northwind15-Jan-08 19:14
mav.northwind15-Jan-08 19:14 
GeneralRe: Compiling .Net 1.1 Pin
Muammar©15-Jan-08 21:42
Muammar©15-Jan-08 21:42 
GeneralRe: Compiling .Net 1.1 Pin
mav.northwind16-Jan-08 8:02
mav.northwind16-Jan-08 8:02 
GeneralRe: Compiling .Net 1.1 Pin
Muammar©18-Jan-08 19:27
Muammar©18-Jan-08 19:27 
QuestionHow can i write application in Doc/view architecture in C# ? Pin
Yanshof14-Jan-08 19:14
Yanshof14-Jan-08 19:14 
AnswerRe: How can i write application in Doc/view architecture in C# ? Pin
Pete O'Hanlon15-Jan-08 3:16
mvePete O'Hanlon15-Jan-08 3:16 
You create a document, then map a view onto that document. Although, you may be better off considering the Model View Controller pattern, as this allows you to connect multiple views to one model (document). Here's a pseudo .NET 3.5 version.
public abstract class ModelBase
{
  public ModelBase() 
  {
    Title = string.Empty;
    FileLocation = string.Empty;
  }

  public string Title{ get ; set; }
  public string FileLocation { get ; set; }
  public abstract void FileSave();
}

public class MyDocument : ModelBase
{
  public MyDocument() : base() {}
  public override void FileSave() 
  { // Do something
  }
  // There'll be some events in here for model based operations.
}

public abstract class ViewBase<T> where T : ModelBase, new()
{
  public ViewBase(T model)
  {
    Model = model;
  }
  protected T Model { get ; set ; }
  public abstract void Refresh() {}
}

public class MyView : ViewBase<MyDocument>
{
  public MyView (MyDocument doc) : base (doc) 
  {
    // The view will be hooked up to some of the model events...
  }

  // Based on an event (such as a new item being added) the view will update
  public override void Refresh()
  {
    // Do something to refresh the view...
  }
}

public class ControllerBase<T, U>
  where T : ModelBase
  where U : ViewBase
{
  private T _model;
  private List<U> _views = new List&lt;U&gt;();
  public ControllerBase(T model)
  {
    _model = model;
  }
  public void AttachView(U view)
  {
    _views.Add(view);
  }

  // The event handlers will react to the model updating to trigger the refreshes here.
  public void RefreshAll()
  {
    foreach (ViewBase view in _views)
    {
      view.Refresh();
    }
  }
}
I've just typed this into IE, so I apologise if the syntax isn't 100% correct but this should get you started.


Deja View - the feeling that you've seen this post before.

My blog | My articles



QuestionNative XP/Vista Menu Pin
KienNT7814-Jan-08 17:53
KienNT7814-Jan-08 17:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.