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

Finished Xamarin Custom Action

parent 54b2e11e
......@@ -3,16 +3,14 @@
<Files>
<File FileName="XAMARINCustomAction/MainPage.xaml.cs" Line="23" Column="50" />
<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" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="XAMARINCustomAction" expanded="True">
<Node name="XAMARINCustomAction" expanded="True">
<Node name="MainPage.xaml" expanded="True" />
</Node>
<Node name="XAMARINCustomAction" expanded="True" />
<Node name="XAMARINCustomAction.iOS" expanded="True">
<Node name="CustomActionIos.cs" selected="True" />
</Node>
......@@ -21,12 +19,12 @@
</Pad>
</Pads>
</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.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<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>
\ No newline at end of file
......@@ -19,28 +19,53 @@ namespace XAMARINCustomAction.iOS
mainpage = page;
var iospage = page.GetRenderer().ViewController;
UIAccessibilityCustomAction up = new UIAccessibilityCustomAction(name: "Increment", target: iospage, selector: new Selector("Increment:"));
UIAccessibilityCustomAction down = new UIAccessibilityCustomAction(name: "Decrement", target: iospage, selector: new Selector("Decrement:"));
UIAccessibilityCustomAction up = new UIAccessibilityCustomAction("Increment", actionHandler: Increment);
UIAccessibilityCustomAction down = new UIAccessibilityCustomAction("Decrement", actionHandler: Decrement);
iospage.AccessibilityCustomActions = new UIAccessibilityCustomAction[2] { up, down };
Debug.WriteLine($"PIPPO: DS, counter = {MainPage.counter.Text}");
}
[Export("Increment:")]
private void Increment()
private bool Increment(UIAccessibilityCustomAction customAction)
{
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);
Console.WriteLine($"PIPPO: clicked on increment {n}");
Console.WriteLine("PIPPO: clicked on increment");
Debug.WriteLine($"PIPPO: clicked on increment {n}");
mainpage.counter.Text = "" + (n++);
}
[Export("Decrement:")]
}*/
/*[Export("Decrement:")]
private void Decrement()
{
Console.WriteLine("PIPPO: clicked on decrement");
int n = Int32.Parse(mainpage.counter.Text);
mainpage.counter.Text = "" + (n--);
}
}*/
}
}
......@@ -14,7 +14,7 @@ namespace XAMARINCustomAction
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
public Label text, counter;
public static Label text, counter;
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