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

Fixes to compile and run #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions OpenFlowSharp/ImageUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using System.Drawing;
using MonoTouch.ObjCRuntime;

namespace OpenFlowSharp
{
Expand Down
7 changes: 1 addition & 6 deletions OpenFlowSharp/OpenFlowSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A8CE55FC-1D12-4DB5-A5F8-836928F7BCD9}</ProjectGuid>
<ProjectTypeGuids>{E613F3A2-FE9C-494F-B74E-F63BCB86FEA6};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>OpenFlowSharp</RootNamespace>
<MainNibFile>MainWindow.xib</MainNibFile>
<AssemblyName>OpenFlowSharp</AssemblyName>
<MtouchSdkVersion>3.0</MtouchSdkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
Expand All @@ -22,7 +21,6 @@
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<MtouchLink>None</MtouchLink>
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
Expand All @@ -32,7 +30,6 @@
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<MtouchLink>None</MtouchLink>
<MtouchDebug>False</MtouchDebug>
</PropertyGroup>
Expand All @@ -44,7 +41,6 @@
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
Expand All @@ -54,7 +50,6 @@
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>False</MtouchDebug>
</PropertyGroup>
Expand Down
44 changes: 33 additions & 11 deletions OpenFlowSharp/OpenFlowView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public int NumberOfImages {
set {
numberOfImages = value;
scrollView.ContentSize = new SizeF ((float)(value * coverSpacing + Bounds.Size.Width), Bounds.Size.Height);
if (selectedCoverView == null)
if (selectedCoverView == null && numberOfImages != 0 )
SetSelectedCover (0);
Layout ();
}
Expand Down Expand Up @@ -130,6 +130,8 @@ public OpenFlowView (RectangleF bounds, IOpenFlowDataSource dataSource) : base (

this.dataSource = dataSource;
SetupInitialState ();

this.BackgroundColor=UIColor.Clear;

#if AUTOMATIC_DEMO
Thread t = new Thread (delegate (object a) {
Expand Down Expand Up @@ -316,6 +318,7 @@ public void SetSelectedCover (int newSelectedCover)
UpdateCoverImage (cover);
scrollView.Layer.AddSublayer (cover.Layer);
LayoutCover (cover, newSelectedCover, false);
this.BringSubviewToFront(cover);
}

lowerVisibleCover = newLowerBound;
Expand Down Expand Up @@ -435,16 +438,32 @@ public UIImage this [int idx] {
return coverImages [idx];
}
set {
var imageWithReflection = ImageUtils.AddImageReflection (value, kReflectionFraction);
coverImages [idx] = imageWithReflection;
coverImageHeights [idx] = value.Size.Height;

// If the image is onscreen, set its image and call layoutCover
ItemView aCover;

if (onscreenCovers.TryGetValue (idx, out aCover)){
aCover.SetImage (imageWithReflection, value.Size.Height, kReflectionFraction);
LayoutCover (aCover, selectedCoverView.Number, false);
if( value != null )
{
UIImage img;
if( coverImages.TryGetValue( idx-15, out img ))
{
img=null;
coverImages.Remove(idx-15);
}
if( coverImages.TryGetValue( idx+15, out img ))
{
img=null;
coverImages.Remove(idx+15);
}


var imageWithReflection = ImageUtils.AddImageReflection (value, kReflectionFraction);
coverImages [idx] = imageWithReflection;
coverImageHeights [idx] = value.Size.Height;

// If the image is onscreen, set its image and call layoutCover
ItemView aCover;

if (onscreenCovers.TryGetValue (idx, out aCover)){
aCover.SetImage (imageWithReflection, value.Size.Height, kReflectionFraction);
LayoutCover (aCover, selectedCoverView.Number, false);
}
}
}
}
Expand Down Expand Up @@ -500,6 +519,7 @@ public override void TouchesMoved (MonoTouch.Foundation.NSSet touches, UIEvent e
}

public event EventHandler Changed;
public event EventHandler SingleTap;

public override void TouchesEnded (MonoTouch.Foundation.NSSet touches, UIEvent evt)
{
Expand All @@ -513,6 +533,8 @@ public override void TouchesEnded (MonoTouch.Foundation.NSSet touches, UIEvent e

if (targetCover != null && (targetCover.Number != selectedCoverView.Number))
SetSelectedCover (targetCover.Number);
if( this.SingleTap != null )
this.SingleTap(this,new EventArgs());
}
CenterOnSelectedCover (true);

Expand Down
78 changes: 78 additions & 0 deletions OpenFlowSharp/backup/OpenFlowSharp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A8CE55FC-1D12-4DB5-A5F8-836928F7BCD9}</ProjectGuid>
<ProjectTypeGuids>{E613F3A2-FE9C-494F-B74E-F63BCB86FEA6};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>OpenFlowSharp</RootNamespace>
<MainNibFile>MainWindow.xib</MainNibFile>
<AssemblyName>OpenFlowSharp</AssemblyName>
<MtouchSdkVersion>3.0</MtouchSdkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<MtouchLink>None</MtouchLink>
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<MtouchLink>None</MtouchLink>
<MtouchDebug>False</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>False</MtouchDebug>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
</ItemGroup>
<ItemGroup>
<Compile Include="ItemView.cs" />
<Compile Include="OpenFlowView.cs" />
<Compile Include="ImageUtils.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="IPhone" />
</MonoDevelop>
</ProjectExtensions>
</Project>
8 changes: 8 additions & 0 deletions Sample/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSMainNibFile</key>
<string>MainWindow</string>
</dict>
</plist>
7 changes: 4 additions & 3 deletions Sample/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ public partial class AppDelegate : UIApplicationDelegate
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
sample = new SampleViewController ();
window.AddSubview (sample.View);

this.window.RootViewController = sample;
window.MakeKeyAndVisible ();

//ViewDidLoad was not fired at start
sample.ViewDidLoad ();
return true;
}

Expand Down
10 changes: 6 additions & 4 deletions Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BBBC1BB1-9A6B-452F-9894-0D4FD75D7921}</ProjectGuid>
<ProjectTypeGuids>{E613F3A2-FE9C-494F-B74E-F63BCB86FEA6};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>Sample</RootNamespace>
<MainNibFile>MainWindow.xib</MainNibFile>
<AssemblyName>Sample</AssemblyName>
<MtouchSdkVersion>3.0</MtouchSdkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
Expand Down Expand Up @@ -79,8 +78,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="MainWindow.xib" />
<Page Include="SampleViewController.xib" />
<InterfaceDefinition Include="MainWindow.xib" xmlns="" />
<InterfaceDefinition Include="SampleViewController.xib" xmlns="" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenFlowSharp\OpenFlowSharp.csproj">
Expand Down Expand Up @@ -127,4 +126,7 @@
<Properties InternalTargetFrameworkVersion="IPhone" />
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
</Project>
47 changes: 27 additions & 20 deletions Sample/SampleViewController.xib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public partial class SampleViewController : UIViewController, IOpenFlowDataSourc
OpenFlowView flowView;
AutoResetEvent signal = new AutoResetEvent (false);
Queue<NSAction> tasks = new Queue<NSAction> ();

#region IOpenFlowDataSource implementation
UIImage PrepareFlickrPhoto (UIImage image, SizeF cropSize)
{
Expand Down Expand Up @@ -139,7 +139,6 @@ UIImage IOpenFlowDataSource.GetDefaultImage ()
{
return UIImage.FromFile ("default.png");
}

#endregion

#region Constructors
Expand All @@ -162,14 +161,21 @@ void Initialize ()
{
flowView = new OpenFlowView (UIScreen.MainScreen.Bounds, this);
View = flowView;

using (var alertView = new UIAlertView ("OpenFlowSharp Demo Data Source",
"Would you like to download images from Flickr or use 30 sample images included with this project?",
null, "Flickr",
"Samples (all at once)",
"Samples (using threads)")){
}

public void ViewDidLoad ()
{
base.ViewDidLoad( );

Console.WriteLine ("ViewDidLoad");

var alertView = new UIAlertView ("OpenFlowSharp Demo Data Source",
"Would you like to download images from Flickr or use 30 sample images included with this project?",
null, "Flickr",
"Samples (all at once)",
"Samples (using threads)");
alertView.Dismissed += delegate(object sender, UIButtonEventArgs e) {
switch (e.ButtonIndex){
switch (e.ButtonIndex) {
// Flickr
case 0:
flickr = new Flickr (apiKey, sharedSecret);
Expand All @@ -191,23 +197,23 @@ void Initialize ()
});
break;

// Load images on demand on a worker thread
// Load images on demand on a worker thread
case 2:
flowView.NumberOfImages = 30;
break;

// Sync case, load all images at startup
// Sync case, load all images at startup
case 1:
LoadAllImages ();
return;
}

// Start our thread queue system
new Thread (Worker).Start ();
signal.Set ();

};
alertView.Show ();
}
alertView.Show ();

// Start our thread queue system
new Thread (Worker).Start ();
signal.Set ();
}

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
Expand All @@ -222,21 +228,22 @@ void Worker ()
// Create the NSAutoreleasePool so that any NSObjects that
// the ObjC runtime creates are disposed using it, otherwise
// ObjC just leaks them.
using (var releasePool = new NSAutoreleasePool ()){
while (signal.WaitOne ()){
while (true){
NSAction task;

lock (tasks){
if (tasks.Count > 0)
task = tasks.Dequeue ();
else
break;
}
using (var releasePool = new NSAutoreleasePool ()){
task ();
}
task=null;
}
}
}
}
#endregion
}
Expand Down
Loading