Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPropertyChangeNotify delegate test. #220

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 48 additions & 24 deletions WreckGui/Model/GuiModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,61 +165,85 @@ private void NotifyPropertyChanged(String propertyName)
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

bool v;
if(propertyName.Equals("MetadataTags"))
v = MetadataTags;
else if(propertyName.Equals("FileSystemAttributes"))
v = FileSystemAttributes;
else if(propertyName.Equals("Custom"))
v = Custom;
else if(propertyName.Equals("Creation"))
v = Creation;
else if(propertyName.Equals("Modified"))
v = Modified;
else if(propertyName.Equals("Accessed"))
v = Accessed;
else
v = false;

LOG.InfoFormat("{0} = {1}", propertyName, v);
}
}

public bool MetadataTags
{
get { return SourceModel[SourceEnum.METADATA]; }
set { SourceModel[SourceEnum.METADATA] = value; }
set
{
if (value != SourceModel[SourceEnum.METADATA])
{
SourceModel[SourceEnum.METADATA] = value;
NotifyPropertyChanged("MetadataTags");
}
}
}

public bool FileSystemAttributes
{
get { return SourceModel[SourceEnum.FILE_SYSTEM]; }
set { SourceModel[SourceEnum.FILE_SYSTEM] = value; }
set
{
if (value != SourceModel[SourceEnum.FILE_SYSTEM])
{
SourceModel[SourceEnum.FILE_SYSTEM] = value;
NotifyPropertyChanged("FileSystemAttributes");
}
}
}

public bool Custom
{
get { return SourceModel[SourceEnum.CUSTOM]; }
set { SourceModel[SourceEnum.CUSTOM] = value; }
set
{
if (value != SourceModel[SourceEnum.CUSTOM])
{
SourceModel[SourceEnum.CUSTOM] = value;
NotifyPropertyChanged("Custom");
}
}
}

public bool Creation
{
get { return CorrectionModel[CorrectionEnum.CREATION]; }
set { CorrectionModel[CorrectionEnum.CREATION] = value; }
set
{
if (value != CorrectionModel[CorrectionEnum.CREATION])
{
CorrectionModel[CorrectionEnum.CREATION] = value;
NotifyPropertyChanged("Creation");
}
}
}

public bool Modified
{
get { return CorrectionModel[CorrectionEnum.MODIFIED]; }
set { CorrectionModel[CorrectionEnum.MODIFIED] = value; }
set
{
if (value != CorrectionModel[CorrectionEnum.MODIFIED])
{
CorrectionModel[CorrectionEnum.MODIFIED] = value;
NotifyPropertyChanged("Modified");
}
}
}

public bool Accessed
{
get { return CorrectionModel[CorrectionEnum.ACCESSED]; }
set { CorrectionModel[CorrectionEnum.ACCESSED] = value; }
set
{
if (value != CorrectionModel[CorrectionEnum.ACCESSED])
{
CorrectionModel[CorrectionEnum.ACCESSED] = value;
NotifyPropertyChanged("Accessed");
}
}
}

public string GetBindingDataMember(SourceEnum s)
Expand Down
25 changes: 25 additions & 0 deletions WreckGui/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

using System;
using System.ComponentModel;
using System.Windows.Forms;

using log4net;
using log4net.Config;
using Wreck.Controller;
Expand Down Expand Up @@ -60,6 +62,29 @@ private static void Main(string[] args)

controller = new GuiController(model, view);

model.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
{
bool? v = new bool?();
if(e.PropertyName.Equals("MetadataTags"))
v = model.MetadataTags;
else if(e.PropertyName.Equals("FileSystemAttributes"))
v = model.FileSystemAttributes;
else if(e.PropertyName.Equals("Custom"))
v = model.Custom;
else if(e.PropertyName.Equals("Creation"))
v = model.Creation;
else if(e.PropertyName.Equals("Modified"))
v = model.Modified;
else if(e.PropertyName.Equals("Accessed"))
v = model.Accessed;
else
log.ErrorFormat("Unknown property: {0}", e.PropertyName);

log.DebugFormat("{0} = {1}",
e.PropertyName,
v.HasValue? v.Value.ToString(): "?");
};

Application.Run(view.GetMain());
}

Expand Down