Webサイトの内容をGoogle等に効率よく知らせる為の仕組み、
それが構造化マークアップ。
具体的には、タグ内の文字列に意味を持たせたり、情報をまとめて定義したりする。
構造化マークアップでSEO対策を
Nexus 5にAndroid 9(Pie)を入れてみた
Nexus 5 – Wikipedia
Nexus 5のOTAアップデートが、2016年の6.0.1を持って終了している為、
久々にCFWに手を出してみることにした。
基本的には、下記参考サイトに記載されていることを行っただけなのだが、
一部想定外のトラブルが発生した為、記載する。
参考サイト
Nexus5 Android9 のセットアップ – Radi開別館
Nexus5にAndroid9をいれました – Qiita
ディレクトリ・ファイル名 使用禁止文字の置換
/// <summary>
/// 使用禁止文字の置換
/// </summary>
/// <param name="strData"></param>
/// <returns></returns>
private static string ReplaceInvalidChar(string strData)
{
string strResult = strData;
foreach (char invalidChar in Path.GetInvalidFileNameChars())
{
while (strResult.IndexOf(invalidChar) >= 0)
{
strResult = strResult.Remove(strResult.IndexOf(invalidChar), 1);
}
}
List<string> arrayReplaceChar = new List<string> { "*", "/", "&", """, "\", "
", "
", " ", "<", ">", "[", "]", "{", "}", "|", ":", ";", "?", "!", ",", ".", "=", "~", "$", "%" };
foreach (string strReplaceChar in arrayReplaceChar)
{
strResult = strResult.Replace(strReplaceChar, "");
strResult = strResult.Replace(Strings.StrConv(strReplaceChar, VbStrConv.Wide), "");
}
strResult = strResult.Trim(' ');
return strResult;
}
ScrollViewerのアンカーへスクロールする
MainView.xaml
<Window x:Class="WpfApp27.View.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:l="http://schemas.livet-mvvm.net/2011/wpf"
xmlns:local="clr-namespace:WpfApp27.View"
xmlns:vm="clr-namespace:WpfApp27.ViewModel"
mc:Ignorable="d"
Title="MainView" Height="250" Width="400">
<Window.DataContext>
<vm:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Button Content="Page1へ">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="ScrollToObject" MethodParameter="{Binding ElementName=page1}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Content="Page2へ">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="ScrollToObject" MethodParameter="{Binding ElementName=page2}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Content="Page3へ">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="ScrollToObject" MethodParameter="{Binding ElementName=page3}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
<ScrollViewer Grid.Column="1">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="0,0,0,300"/>
</Style>
</StackPanel.Resources>
<TextBlock x:Name="page1" Text="Page1"/>
<TextBlock x:Name="page2" Text="Page2"/>
<TextBlock x:Name="page3" Text="Page3"/>
</StackPanel>
</ScrollViewer>
</Grid>
</Window>
リソース内の文字列をXAMLに表示する
Resources.resx
アクセス修飾子をPublicにし、文字列を格納する。
ラムダ式を用いたイベントハンドラの削除
EventHandler handler = null;
handler = (object sender, EventArgs e) =>
{
objWindow.Closed -= handler;
};
objWindow.Closed += handler;
naudioを用いた音楽再生
MainWindow.xaml
<Window x:Class="WpfApp25.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp25"
mc:Ignorable="d"
Title="MainWindow" Height="142" Width="404">
<Grid>
<TextBox x:Name="txtFilePath" Margin="40,10,46,73"/>
<Button Content="再生" Margin="100,60,96,21" Click="Button_Click"/>
</Grid>
</Window>
ToastNotificationsを用いた通知表示
なお、ToastNotificationsには、MessageOptions内にNotificationClickActionというクリック通知用アクションが用意されているが、
うまく動作しなかったため、代替処理を行っている。
Windowの子要素を再帰検索する
MainWindow.xaml
<Window x:Class="WpfApp24.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp24"
mc:Ignorable="d"
Title="MainWindow" Height="242" Width="409">
<Grid>
<TextBox HorizontalAlignment="Left" Height="30" Margin="65,10,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="90"/>
<Grid HorizontalAlignment="Left" Height="125" Margin="10,60,0,0" VerticalAlignment="Top" Width="365" Background="#FF66EC49">
<Grid HorizontalAlignment="Left" Height="60" Margin="10,55,0,0" VerticalAlignment="Top" Width="150" Background="#FFEA7878">
<TextBox HorizontalAlignment="Left" Height="35" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="105"/>
</Grid>
<TextBox HorizontalAlignment="Left" Height="35" Margin="55,15,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="105"/>
<Grid HorizontalAlignment="Left" Height="60" Margin="190,55,0,0" VerticalAlignment="Top" Width="150" Background="#FF7670F7">
<TextBox HorizontalAlignment="Left" Height="35" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="105"/>
</Grid>
</Grid>
</Grid>
</Window>