-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewController.cs
More file actions
131 lines (112 loc) · 4.71 KB
/
MainViewController.cs
File metadata and controls
131 lines (112 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using Foundation;
using UIKit;
using CoreGraphics;
/// <summary>
///
/// Copyright 2015 Markus Fischer
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// </summary>
namespace SortingVisualisation
{
public partial class MainViewController : UIViewController, IUIPopoverPresentationControllerDelegate
{
public MainViewController () : base ("MainViewController", null)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
slider.Value = 30;
glView.MainViewController = this;
glView.AnimationInterval = 1.0 / 60.0;
glView.StartAnimation();
this.Slider.Value = 30f / 255f;
this.AnzahlIterationenLabel.Text = "";
}
public void SetSortName(string name)
{
sortNameLabel.Text = name;
}
public UIKit.UISwitch ColorSwitch { get { return this.colorSwitch; } }
public UIKit.UISlider Slider { get { return this.slider; } }
public UIKit.UISegmentedControl SegmentedControl { get { return this.segmentedControl; } }
public UIKit.UILabel AnzahlIterationenLabel { get { return this.anzahlIterationenLabel; } }
public SortingVisualisation.EAGLView GlView { get { return this.glView; } }
partial void switchChanged (Foundation.NSObject sender)
{
this.glView.Reset();
}
partial void termsOfUseClicked (Foundation.NSObject sender)
{
UIButton tappedButton = (UIButton)sender;
TermsOfUse popupViewController = new TermsOfUse();
popupViewController.Init();
// popupViewController.View.Frame = new CGRect(0,0,320,200);
popupViewController.ModalPresentationStyle = UIModalPresentationStyle.Popover;
// popupViewController.ContentSizeForViewInPopover = new CGSize(150, 160);
popupViewController.PreferredContentSize = new CGSize(320, 200);
// Present the popover from the button that was tapped in the detail view.
this.PresentViewController(popupViewController,true, null);
UIPopoverPresentationController popover = popupViewController.PopoverPresentationController;
popover.Delegate = new MyPopoverDelegate();
popover.PermittedArrowDirections = UIPopoverArrowDirection.Right;
popover.SourceView = tappedButton;
popover.SourceRect = tappedButton.Frame;
popover.PopoverLayoutMargins = new UIEdgeInsets (10,10,10,10);
}
partial void infoClicked (Foundation.NSObject sender)
{
UIButton tappedButton = (UIButton)sender;
InfoPopupOverViewController popupViewController = new InfoPopupOverViewController();
popupViewController.Sort = sortNameLabel.Text;
popupViewController.Init();
// popupViewController.View.Frame = new CGRect(0,0,320,200);
popupViewController.ModalPresentationStyle = UIModalPresentationStyle.Popover;
// popupViewController.ContentSizeForViewInPopover = new CGSize(150, 160);
popupViewController.PreferredContentSize = new CGSize(320, 200);
// Present the popover from the button that was tapped in the detail view.
this.PresentViewController(popupViewController,true, null);
UIPopoverPresentationController popover = popupViewController.PopoverPresentationController;
popover.Delegate = new MyPopoverDelegate();
popover.PermittedArrowDirections = UIPopoverArrowDirection.Right;
popover.SourceView = tappedButton;
popover.SourceRect = tappedButton.Frame;
popover.PopoverLayoutMargins = new UIEdgeInsets (10,10,10,10);
}
public class MyPopoverDelegate : UIPopoverPresentationControllerDelegate
{
public override UIModalPresentationStyle GetAdaptivePresentationStyle (UIPresentationController forPresentationController)
{
return UIModalPresentationStyle.None;
}
public override UIModalPresentationStyle GetAdaptivePresentationStyle (UIPresentationController controller, UITraitCollection traitCollection)
{
return UIModalPresentationStyle.None;
}
/*
public override void PrepareForPopoverPresentation (UIPopoverPresentationController popoverPresentationController)
{
popoverPresentationController.AdaptivePresentationStyle = () -> { return UIModalPresentationStyle.None };
}
*/
}
}
}