From 9da1ee993f1c7e597cab6cde9a6cc3882449655d Mon Sep 17 00:00:00 2001 From: Robert Kozak Date: Sun, 29 Jan 2012 15:32:03 -0800 Subject: [PATCH] Small Fixes --- Dialog/CellViews/Base/ListCellView.cs | 6 +++++- .../DialogViewController/DataContextBinder.cs | 5 +++++ .../DialogViewController.cs | 1 + Dialog/DialogViewController/ListSource.cs | 4 +++- Dialog/DialogViewController/MemberData.cs | 21 ++++++++----------- Dialog/DialogViewController/ViewSource.cs | 8 +------ Extensions/UIDeviceExtensions.cs | 16 ++++++++++++++ Extensions/UIImageExtensions.cs | 21 ------------------- 8 files changed, 40 insertions(+), 42 deletions(-) diff --git a/Dialog/CellViews/Base/ListCellView.cs b/Dialog/CellViews/Base/ListCellView.cs index a1cbd24..ade612b 100644 --- a/Dialog/CellViews/Base/ListCellView.cs +++ b/Dialog/CellViews/Base/ListCellView.cs @@ -49,6 +49,10 @@ public ListCellView(RectangleF frame) : base(frame) { } + public override void Initialize() + { + } + public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath) { var source = Controller.TableView.Source as BaseDialogViewSource; @@ -63,7 +67,7 @@ public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath) listSource.UpdateCell(cell, indexPath); cell.TextLabel.Text = Caption; - + if (listSource.IsMultiselect) { cell.Accessory = listSource.Sections[0].DataContext.Count > 0 ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; diff --git a/Dialog/DialogViewController/DataContextBinder.cs b/Dialog/DialogViewController/DataContextBinder.cs index b955da9..48f6f01 100644 --- a/Dialog/DialogViewController/DataContextBinder.cs +++ b/Dialog/DialogViewController/DataContextBinder.cs @@ -94,6 +94,11 @@ public void HandleNotifyCollectionChanged(object sender, NotifyCollectionChanged if (e.Action == NotifyCollectionChangedAction.Reset) { + foreach(var item in Section.DataContext) + { + RemovePropertyChangedHandler(item); + } + Section.DataContext.Clear(); needsReload = true; } diff --git a/Dialog/DialogViewController/DialogViewController.cs b/Dialog/DialogViewController/DialogViewController.cs index 7c3222c..637e7a8 100644 --- a/Dialog/DialogViewController/DialogViewController.cs +++ b/Dialog/DialogViewController/DialogViewController.cs @@ -534,6 +534,7 @@ public override void ViewDidAppear(bool animated) // var activation = RootView as IActivation; // if (activation != null) // activation.Activated(); + } } diff --git a/Dialog/DialogViewController/ListSource.cs b/Dialog/DialogViewController/ListSource.cs index feaa089..df2022d 100644 --- a/Dialog/DialogViewController/ListSource.cs +++ b/Dialog/DialogViewController/ListSource.cs @@ -354,11 +354,13 @@ public override void WillDisplay(UITableView tableView, UITableViewCell cell, NS } else { - if (sectionData.Count > 0) + if (sectionData.Count > 0 && sectionData[indexPath.Row] != null) { cell.TextLabel.AdjustsFontSizeToFitWidth = true; cell.TextLabel.Text = sectionData[indexPath.Row].ToString(); } + else + Console.WriteLine("No Data: for row {0}, section {1}", indexPath.Row, indexPath.Section); } } } diff --git a/Dialog/DialogViewController/MemberData.cs b/Dialog/DialogViewController/MemberData.cs index 6f1587d..e87c00e 100644 --- a/Dialog/DialogViewController/MemberData.cs +++ b/Dialog/DialogViewController/MemberData.cs @@ -121,19 +121,16 @@ public void HandleNotifyPropertyChanged(object sender, PropertyChangedEventArgs { if (CanHandleNotifyPropertyChanged(e.PropertyName)) { -// Log.Time("MemberData NotifyPropertyChanged property = "+ e.PropertyName+ " sender: "+sender.ToString(), ()=> -// { - var value = GetValue(); - if (_DataContextValue != null && _DataContextValue != value) - { - ResetCollection(_DataContextValue as INotifyCollectionChanged, value as IList); - } + var value = GetValue(); + if (_DataContextValue != null && _DataContextValue != value) + { + ResetCollection(_DataContextValue as INotifyCollectionChanged, value as IList); + } - if (_Value != null && _Value != value) - { - ResetCollection(_Value as INotifyCollectionChanged, value as IList); - } -// }); + if (_Value != null && _Value != value) + { + ResetCollection(_Value as INotifyCollectionChanged, value as IList); + } } } diff --git a/Dialog/DialogViewController/ViewSource.cs b/Dialog/DialogViewController/ViewSource.cs index 16a203c..06d430e 100644 --- a/Dialog/DialogViewController/ViewSource.cs +++ b/Dialog/DialogViewController/ViewSource.cs @@ -182,12 +182,6 @@ public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath) if (dc.DataContext != memberData) dc.DataContext = memberData; } - -// var updateable = view as IUpdateable; -// if (updateable != null) -// { -// updateable.UpdateCell(cell, indexPath); -// } var themeable = view as IThemeable; if (themeable != null) @@ -238,7 +232,7 @@ public override void WillDisplay(UITableView tableView, UITableViewCell cell, NS } } } - + public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { MemberData memberData = null; diff --git a/Extensions/UIDeviceExtensions.cs b/Extensions/UIDeviceExtensions.cs index 0df87de..9f9727c 100644 --- a/Extensions/UIDeviceExtensions.cs +++ b/Extensions/UIDeviceExtensions.cs @@ -97,6 +97,22 @@ public static float GetActualWidth(this UIDevice device) else 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; + } + } } } diff --git a/Extensions/UIImageExtensions.cs b/Extensions/UIImageExtensions.cs index d667217..d2496f4 100644 --- a/Extensions/UIImageExtensions.cs +++ b/Extensions/UIImageExtensions.cs @@ -41,27 +41,6 @@ public static UIImage FromFile(this UIImage image, string filename, SizeF fitSiz 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) {