Skip to content

Commit

Permalink
Small Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertKozak committed Jan 29, 2012
1 parent 4b3e05a commit 9da1ee9
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 42 deletions.
6 changes: 5 additions & 1 deletion Dialog/CellViews/Base/ListCellView.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public ListCellView(RectangleF frame) : base(frame)
{ {
} }


public override void Initialize()
{
}

public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath) public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath)
{ {
var source = Controller.TableView.Source as BaseDialogViewSource; var source = Controller.TableView.Source as BaseDialogViewSource;
Expand All @@ -63,7 +67,7 @@ public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath)
listSource.UpdateCell(cell, indexPath); listSource.UpdateCell(cell, indexPath);


cell.TextLabel.Text = Caption; cell.TextLabel.Text = Caption;

if (listSource.IsMultiselect) if (listSource.IsMultiselect)
{ {
cell.Accessory = listSource.Sections[0].DataContext.Count > 0 ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; cell.Accessory = listSource.Sections[0].DataContext.Count > 0 ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None;
Expand Down
5 changes: 5 additions & 0 deletions Dialog/DialogViewController/DataContextBinder.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public void HandleNotifyCollectionChanged(object sender, NotifyCollectionChanged


if (e.Action == NotifyCollectionChangedAction.Reset) if (e.Action == NotifyCollectionChangedAction.Reset)
{ {
foreach(var item in Section.DataContext)
{
RemovePropertyChangedHandler(item);
}

Section.DataContext.Clear(); Section.DataContext.Clear();
needsReload = true; needsReload = true;
} }
Expand Down
1 change: 1 addition & 0 deletions Dialog/DialogViewController/DialogViewController.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ public override void ViewDidAppear(bool animated)
// var activation = RootView as IActivation; // var activation = RootView as IActivation;
// if (activation != null) // if (activation != null)
// activation.Activated(); // activation.Activated();

} }
} }


Expand Down
4 changes: 3 additions & 1 deletion Dialog/DialogViewController/ListSource.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -354,11 +354,13 @@ public override void WillDisplay(UITableView tableView, UITableViewCell cell, NS
} }
else else
{ {
if (sectionData.Count > 0) if (sectionData.Count > 0 && sectionData[indexPath.Row] != null)
{ {
cell.TextLabel.AdjustsFontSizeToFitWidth = true; cell.TextLabel.AdjustsFontSizeToFitWidth = true;
cell.TextLabel.Text = sectionData[indexPath.Row].ToString(); cell.TextLabel.Text = sectionData[indexPath.Row].ToString();
} }
else
Console.WriteLine("No Data: for row {0}, section {1}", indexPath.Row, indexPath.Section);
} }
} }
} }
Expand Down
21 changes: 9 additions & 12 deletions Dialog/DialogViewController/MemberData.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,19 +121,16 @@ public void HandleNotifyPropertyChanged(object sender, PropertyChangedEventArgs
{ {
if (CanHandleNotifyPropertyChanged(e.PropertyName)) if (CanHandleNotifyPropertyChanged(e.PropertyName))
{ {
// Log.Time("MemberData NotifyPropertyChanged property = "+ e.PropertyName+ " sender: "+sender.ToString(), ()=> var value = GetValue();
// { if (_DataContextValue != null && _DataContextValue != value)
var value = GetValue(); {
if (_DataContextValue != null && _DataContextValue != value) ResetCollection(_DataContextValue as INotifyCollectionChanged, value as IList);
{ }
ResetCollection(_DataContextValue as INotifyCollectionChanged, value as IList);
}


if (_Value != null && _Value != value) if (_Value != null && _Value != value)
{ {
ResetCollection(_Value as INotifyCollectionChanged, value as IList); ResetCollection(_Value as INotifyCollectionChanged, value as IList);
} }
// });
} }
} }


Expand Down
8 changes: 1 addition & 7 deletions Dialog/DialogViewController/ViewSource.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath)
if (dc.DataContext != memberData) if (dc.DataContext != memberData)
dc.DataContext = memberData; dc.DataContext = memberData;
} }

// var updateable = view as IUpdateable;
// if (updateable != null)
// {
// updateable.UpdateCell(cell, indexPath);
// }


var themeable = view as IThemeable; var themeable = view as IThemeable;
if (themeable != null) if (themeable != null)
Expand Down Expand Up @@ -238,7 +232,7 @@ public override void WillDisplay(UITableView tableView, UITableViewCell cell, NS
} }
} }
} }

public override void RowSelected(UITableView tableView, NSIndexPath indexPath) public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{ {
MemberData memberData = null; MemberData memberData = null;
Expand Down
16 changes: 16 additions & 0 deletions Extensions/UIDeviceExtensions.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ public static float GetActualWidth(this UIDevice device)
else else
return UIScreen.MainScreen.Bounds.Width; return UIScreen.MainScreen.Bounds.Width;
} }

public static float GetActualHeight(this UIDevice device)
{
var orientation = device.Orientation;

var landscape = orientation == UIDeviceOrientation.LandscapeLeft || orientation == UIDeviceOrientation.LandscapeRight;

if (landscape)
{
return UIScreen.MainScreen.Bounds.Width;
}
else
{
return UIScreen.MainScreen.Bounds.Height;
}
}
} }
} }


21 changes: 0 additions & 21 deletions Extensions/UIImageExtensions.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,27 +41,6 @@ public static UIImage FromFile(this UIImage image, string filename, SizeF fitSiz


return imageFile.ImageToFitSize(fitSize); return imageFile.ImageToFitSize(fitSize);
} }

public static UIImage RemoveSharpEdges(this UIImage image, int radius)
{
var width = image.Size.Width;
UIGraphics.BeginImageContextWithOptions(new SizeF(width, width), false, 0f);
var context = UIGraphics.GetCurrentContext();

context.BeginPath();
context.MoveTo(width, width/2);
context.AddArcToPoint(width, width, width / 2, width, radius);
context.AddArcToPoint(0, width, 0, width / 2, radius);
context.AddArcToPoint(0, 0, width / 2, 0, radius);
context.AddArcToPoint(width, 0, width, width / 2, radius);
context.ClosePath();
context.Clip();

image.Draw(new PointF(0, 0));
var converted = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return converted;
}


public static UIImage ImageToFitSize(this UIImage image, float width, float height) public static UIImage ImageToFitSize(this UIImage image, float width, float height)
{ {
Expand Down

0 comments on commit 9da1ee9

Please sign in to comment.