本文整理汇总了C#中Xamarin.Forms.ContentPage.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ContentPage.GetType方法的具体用法?C# ContentPage.GetType怎么用?C# ContentPage.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.ContentPage
的用法示例。
在下文中一共展示了ContentPage.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyllableBackCard
public SyllableBackCard (string kana,StudyCard root,ContentPage drillMode)
{
NavigationPage.SetHasBackButton (this, false);
if(drillMode.GetType () == typeof(SyllableRCard))
Title = Character.getCategory(kana)+" Writing";
else if(drillMode.GetType () == typeof(SyllableCard))
Title = Character.getCategory(kana)+" Reading";
string mode = Character.cData [Character.kana_lookup (kana.Split('\n')[0].Split('/')[0])];
string pronun = Character.kana_to_romaji (kana);
pronun = pronun.Replace (" ", "_");
if(Settings.voice)
DependencyService.Get<IAudio>().PlayMp3File("Audio/SC/sc_"+pronun+".mp3");
Label left = new Label {
Text = "x",
BackgroundColor = Color.Red,
YAlign = TextAlignment.Center,
XAlign = TextAlignment.Center,
FontSize = 20
};
Label right = new Label {
Text = "✓",
BackgroundColor = Color.Green,
YAlign = TextAlignment.Center,
XAlign = TextAlignment.Center,
FontSize = 20
};
Grid grid = new Grid {
VerticalOptions = LayoutOptions.Fill,
HorizontalOptions = LayoutOptions.Fill,
RowDefinitions = {
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
},
ColumnDefinitions = {
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (6, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
}
};
if (mode.Length > 0) {
string[] strArray = mode.Split ('/');
string header = strArray [0].Split ('\n')[0];
//Big letter
grid.Children.Add (new Label {
Text = strArray [0],
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
FontSize = 100-header.Length*20,
}, 1, 0);
grid.Children.Add (new Label {
Text = strArray [1],
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
FontSize = 40,
TextColor = Color.Maroon
}, 1, 2);
if (drillMode.GetType () == typeof(SyllableRCard)) {
Image writingImg = new Image ();
writingImg.Source=ImageSource.FromFile(DependencyService.Get<IPicture> ().GetPictureFromDisk ("Writing"));
grid.Children.Add (writingImg, 1, 1);
}
grid.Children.Add (left, 0, 1, 0, 3);
grid.Children.Add (right, 2, 3, 0, 3);
}
// grid.Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 10);
Content = grid;
var leftTapRecognizer = new TapGestureRecognizer ();
left.GestureRecognizers.Add (leftTapRecognizer);
leftTapRecognizer.Tapped += (s, e) => {
if (root.GetType () == typeof(TestPage)) {
((TestPage)root).wrongCount++;
}
root.drillList.Add (drillMode);
root.testProgress++;
if(root.drillList[root.testProgress].GetType()==typeof(SyllableCard))
{
SyllableCard orgCard=(SyllableCard)root.drillList[root.testProgress];
SyllableCard nextCard = new SyllableCard(orgCard.mCharacter,orgCard.mRoot, StudyCard.drillRightCount);
Navigation.InsertPageBefore(nextCard,this);
}
else if(root.drillList[root.testProgress].GetType()==typeof(SyllableRCard))
{
SyllableRCard orgCard=(SyllableRCard)root.drillList[root.testProgress];
SyllableRCard nextCard = new SyllableRCard (orgCard.mKana, orgCard.mRoot, StudyCard.drillRightCount);
Navigation.InsertPageBefore(nextCard,this);
}
Navigation.PopAsync ();
DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing");
//.........这里部分代码省略.........
示例2: BackCard
public BackCard (string kana,StudyCard root,ContentPage drillMode)
{
NavigationPage.SetHasBackButton (this, false);
this.Title = kana;
string mode = Character.cData [Character.kana_lookup (kana.Split('\n')[0])];
string pronun = Character.kana_to_romaji (kana.Split('\n')[0]);
pronun=pronun.Replace (" ", "_");
if(Settings.voice)
DependencyService.Get<IAudio>().PlayMp3File("Audio/SC/sc_"+pronun+".mp3");
Label left = new Label{Text="x", BackgroundColor = Color.Red,YAlign=TextAlignment.Center,XAlign=TextAlignment.Center,FontSize=20};
Label right = new Label{Text="✓",BackgroundColor = Color.Green,YAlign=TextAlignment.Center,XAlign=TextAlignment.Center,FontSize=20 };
Grid grid = new Grid {
VerticalOptions = LayoutOptions.Fill,
HorizontalOptions=LayoutOptions.Fill,
RowDefinitions = {
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
},
ColumnDefinitions = {
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (6, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
}
};
if (mode.Length > 0) {
string[] strArray = mode.Split ('/');
string header = strArray [0].Split ('\n')[0];
//Big letter
grid.Children.Add (new Label {
Text = strArray [0],
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
FontSize = 100-header.Length*20,
}, 1, 0);
if (drillMode.GetType () == typeof(Cardfront)) {
Image writingImg = new Image ();
writingImg.Source=ImageSource.FromFile(DependencyService.Get<IPicture> ().GetPictureFromDisk ("Writing"));
grid.Children.Add (writingImg, 1, 1);
}
grid.Children.Add (new Label {
Text = strArray [1],
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
FontSize = 40,
TextColor = Color.Maroon
}, 1, 2);
grid.Children.Add (left, 0, 1, 0, 3);
grid.Children.Add (right, 2, 3, 0, 3);
// handwriting
var leftTapRecognizer = new TapGestureRecognizer ();
left.GestureRecognizers.Add (leftTapRecognizer);
leftTapRecognizer.Tapped += (s, e) => {
DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing");
int index=root.drillList.LastIndexOf(drillMode);
if(drillMode.GetType()==typeof(Cardfront))
{
drillMode=new Cardfront(((Cardfront)drillMode).mCharacter,root);
}
root.drillList.Add(drillMode);
index++;
Navigation.InsertPageBefore(root.drillList[index],this);
Navigation.PopAsync();
};
var rightTapRecognizer = new TapGestureRecognizer ();
right.GestureRecognizers.Add (rightTapRecognizer);
rightTapRecognizer.Tapped += async (s, e) => {
DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing");
int index=root.drillList.LastIndexOf(drillMode);
if(index==root.drillList.Count-1)
{
root.addDrill();
if(root.drillList.Count==0)
{
// Navigation.PopAsync();
root.addDrill();
}
else
{
index=0;
Navigation.InsertPageBefore(root.drillList[0],this);
await Navigation.PopAsync();
}
}
else
{
index++;
Navigation.InsertPageBefore(root.drillList[index],this);
await Navigation.PopAsync();
//.........这里部分代码省略.........
示例3: ExBackCard
public ExBackCard (string key,string value,StudyCard root,ContentPage drillMode,string kanaMode)
{
NavigationPage.SetHasBackButton (this, false);
this.Title = key.Split(' ')[0];
if (kanaMode.Length > 0) { //changes the title on test mode
if (drillMode.GetType () == typeof(ExCardfront))
this.Title = kanaMode.Split (' ') [1] + " Writing";
else if (drillMode.GetType () == typeof(ExampleCard))
this.Title = kanaMode.Split (' ') [1] + " Reading";
}
int fontSize1 = 40,fontSize2=20;
if (Device.Idiom == TargetIdiom.Tablet) {
fontSize1 = 80;
fontSize2 = 30;
}
Label left = new Label{Text="x", BackgroundColor = Color.Red,YAlign=TextAlignment.Center,XAlign=TextAlignment.Center,FontSize=20};
Label right = new Label{Text="✓",BackgroundColor = Color.Green,YAlign=TextAlignment.Center,XAlign=TextAlignment.Center,FontSize=20 };
Grid grid = new Grid {
VerticalOptions = LayoutOptions.Fill,
RowDefinitions = {
new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
new RowDefinition {Height = new GridLength (1, GridUnitType.Star)},
},
ColumnDefinitions = {
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (6, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
}
};
grid.Children.Add (left, 0, 1, 0, 4);
grid.Children.Add (right, 2, 3, 0, 4);
if (drillMode.GetType () == typeof(ExCardfront)) {
Image writingImg = new Image ();
writingImg.Source=ImageSource.FromFile(DependencyService.Get<IPicture> ().GetPictureFromDisk ("Writing"));
grid.Children.Add (writingImg, 1, 1);
}
string kanaStr = key.Split (' ') [0];
string romStr = key.Substring (kanaStr.Length+1);
if(Settings.voice)
DependencyService.Get<IAudio>().PlayMp3File("Audio/Examples/"+kanaStr+".mp3");
grid.Children.Add(new Label{Text=kanaStr,XAlign=TextAlignment.Center,YAlign=TextAlignment.Center,FontSize=fontSize1-kanaStr.Length*2},1,0);
grid.Children.Add(new Label{Text=romStr,XAlign=TextAlignment.Center,YAlign=TextAlignment.Center,FontSize=fontSize1-romStr.Length-2,TextColor=Color.Maroon},1,2);
string english, english1, english2;
if (value == "giga- (109)") {
english = "giga- (10";
english1 = "9";
english2 = ")";
} else if (value == "hecto- (102)") {
english = "hecto- (10";
english1 = "2";
english2 = ")";
} else if (value == "mega- (106)") {
english = "mega- (10";
english1 = "6";
english2 = ")";
} else {
english = value;
english1 = "";
english2 = "";
}
Label englishLabel = new Label (){Text=english,FontSize=fontSize2,XAlign=TextAlignment.Center,YAlign=TextAlignment.Center};
StackLayout sublayout;
if (english1.Length > 0) {
Label englishLabel1 = new Label () {
Text = english1,
XAlign = TextAlignment.Center,
FontSize = (int)fontSize2 * 0.4,
YAlign=TextAlignment.Start
};
Label englishLabel2 = new Label (){ FontSize = fontSize2, Text = english2, XAlign = TextAlignment.Center};
sublayout = new StackLayout () {
Children = { englishLabel, englishLabel1, englishLabel2 },
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
grid.Children.Add (sublayout, 1, 3);
} else {
grid.Children.Add(englishLabel,1,3);
}
Content = grid;
var leftTapRecognizer = new TapGestureRecognizer ();
left.GestureRecognizers.Add (leftTapRecognizer);
leftTapRecognizer.Tapped += (s, e) => {
DependencyService.Get<IPicture> ().DeletePictureFromDisk ("Writing");
if(root.GetType()==typeof(CompMenu))
{
((CompMenu)root).wrongCount++;
if(drillMode.GetType()==typeof(ExCardfront))
//.........这里部分代码省略.........