Commit 75412a54 authored by Paolo Pecis's avatar Paolo Pecis

Finished Xamarin Custom Action

parent 54b2e11e
...@@ -3,16 +3,14 @@ ...@@ -3,16 +3,14 @@
<Files> <Files>
<File FileName="XAMARINCustomAction/MainPage.xaml.cs" Line="23" Column="50" /> <File FileName="XAMARINCustomAction/MainPage.xaml.cs" Line="23" Column="50" />
<File FileName="XAMARINCustomAction/ICustomAction.cs" /> <File FileName="XAMARINCustomAction/ICustomAction.cs" />
<File FileName="XAMARINCustomAction.iOS/CustomActionIos.cs" Line="31" Column="17" /> <File FileName="XAMARINCustomAction.iOS/CustomActionIos.cs" Line="22" Column="6" />
<File FileName="XAMARINCustomAction.iOS/Info.plist" /> <File FileName="XAMARINCustomAction.iOS/Info.plist" />
</Files> </Files>
<Pads> <Pads>
<Pad Id="ProjectPad"> <Pad Id="ProjectPad">
<State name="__root__"> <State name="__root__">
<Node name="XAMARINCustomAction" expanded="True"> <Node name="XAMARINCustomAction" expanded="True">
<Node name="XAMARINCustomAction" expanded="True"> <Node name="XAMARINCustomAction" expanded="True" />
<Node name="MainPage.xaml" expanded="True" />
</Node>
<Node name="XAMARINCustomAction.iOS" expanded="True"> <Node name="XAMARINCustomAction.iOS" expanded="True">
<Node name="CustomActionIos.cs" selected="True" /> <Node name="CustomActionIos.cs" selected="True" />
</Node> </Node>
...@@ -21,12 +19,12 @@ ...@@ -21,12 +19,12 @@
</Pad> </Pad>
</Pads> </Pads>
</MonoDevelop.Ide.Workbench> </MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.ItemProperties.XAMARINCustomAction.Android AndroidDesignerPreferredTheme="Theme.AppCompat.Light.NoActionBar" FirstBuild="True" PreferredExecutionTarget="Android.galaxy_s9" /> <MonoDevelop.Ide.ItemProperties.XAMARINCustomAction.Android AndroidDesignerPreferredTheme="Theme.AppCompat.Light.NoActionBar" PreferredExecutionTarget="Android.galaxy_s9" />
<MonoDevelop.Ide.DebuggingService.PinnedWatches /> <MonoDevelop.Ide.DebuggingService.PinnedWatches />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.DebuggingService.Breakpoints> <MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore /> <BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints> </MonoDevelop.Ide.DebuggingService.Breakpoints>
<MultiItemStartupConfigurations /> <MultiItemStartupConfigurations />
<MonoDevelop.Ide.ItemProperties.XAMARINCustomAction.iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget.460FFED4-D83A-483B-AAED-00139629E88A" /> <MonoDevelop.Ide.ItemProperties.XAMARINCustomAction.iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget.6A0D46CD-3857-45D7-84A7-211D7D713F41" />
</Properties> </Properties>
\ No newline at end of file
...@@ -19,28 +19,53 @@ namespace XAMARINCustomAction.iOS ...@@ -19,28 +19,53 @@ namespace XAMARINCustomAction.iOS
mainpage = page; mainpage = page;
var iospage = page.GetRenderer().ViewController; var iospage = page.GetRenderer().ViewController;
UIAccessibilityCustomAction up = new UIAccessibilityCustomAction(name: "Increment", target: iospage, selector: new Selector("Increment:")); UIAccessibilityCustomAction up = new UIAccessibilityCustomAction("Increment", actionHandler: Increment);
UIAccessibilityCustomAction down = new UIAccessibilityCustomAction(name: "Decrement", target: iospage, selector: new Selector("Decrement:")); UIAccessibilityCustomAction down = new UIAccessibilityCustomAction("Decrement", actionHandler: Decrement);
iospage.AccessibilityCustomActions = new UIAccessibilityCustomAction[2] { up, down }; iospage.AccessibilityCustomActions = new UIAccessibilityCustomAction[2] { up, down };
Debug.WriteLine($"PIPPO: DS, counter = {MainPage.counter.Text}");
} }
[Export("Increment:")] private bool Increment(UIAccessibilityCustomAction customAction)
private void Increment() {
int n = Int32.Parse(MainPage.counter.Text) + 1;
Debug.WriteLine("PIPPO: clicked increment");
MainPage.counter.Text = "" + (n);
return true;
}
private bool Decrement(UIAccessibilityCustomAction customAction)
{
int n = Int32.Parse(MainPage.counter.Text);
if (n <= 0)
{
return false;
}
Debug.WriteLine("PIPPO: clicked decrement");
n--;
MainPage.counter.Text = "" + (n);
return true;
}
/*private bool Increment()
{ {
int n = Int32.Parse(mainpage.counter.Text); int n = Int32.Parse(mainpage.counter.Text);
Console.WriteLine($"PIPPO: clicked on increment {n}"); Console.WriteLine("PIPPO: clicked on increment");
Debug.WriteLine($"PIPPO: clicked on increment {n}"); Debug.WriteLine($"PIPPO: clicked on increment {n}");
mainpage.counter.Text = "" + (n++); mainpage.counter.Text = "" + (n++);
}
[Export("Decrement:")] }*/
/*[Export("Decrement:")]
private void Decrement() private void Decrement()
{ {
Console.WriteLine("PIPPO: clicked on decrement"); Console.WriteLine("PIPPO: clicked on decrement");
int n = Int32.Parse(mainpage.counter.Text); int n = Int32.Parse(mainpage.counter.Text);
mainpage.counter.Text = "" + (n--); mainpage.counter.Text = "" + (n--);
} }*/
} }
} }
...@@ -14,7 +14,7 @@ namespace XAMARINCustomAction ...@@ -14,7 +14,7 @@ namespace XAMARINCustomAction
[DesignTimeVisible(false)] [DesignTimeVisible(false)]
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
public Label text, counter; public static Label text, counter;
public MainPage() public MainPage()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment