/// <summary> /// ファイルリストの作成 /// </summary> static private void CreateFileList(BindableObject bindable, object oldValue, object newValue) { FilesControl control = bindable as FilesControl; // 既存の情報を一旦クリア control.Children.Clear(); foreach (File file in (newValue as List <File>)) { // ファイルの種類によってアイコンを設定 string icon = ""; switch (file.Name.Split('.')[1]) { case "pptx": case "ppt": icon = "QuickAppointment.Assets.PowerPoint.png"; break; case "doc": case "docx": icon = "QuickAppointment.Assets.Word.png"; break; case "xls": case "xlsx": icon = "QuickAppointment.Assets.Excel.png"; break; default: icon = "QuickAppointment.Assets.Document.png"; break; } // ActionLabel を利用して詳細は表示 ActionLabel label = new ActionLabel(); label.Icon = icon; label.IconSize = 30; label.Text = file.Name; label.Type = "File"; label.Data = file; control.Children.Add(label); } }
/// <summary> /// ラベルの作成 /// </summary> static private void CreateLabel(BindableObject bindable, object oldValue, object newValue) { // ActionLabel インスタンスを取得し、必要な情報がそろっていることを確認 ActionLabel control = bindable as ActionLabel; if (string.IsNullOrEmpty(control.Text) || string.IsNullOrEmpty(control.Type) || string.IsNullOrEmpty(control.Icon)) { return; } // アイコンの作成 Image icon = new Image(); icon.WidthRequest = icon.HeightRequest = control.IconSize; icon.Source = ImageSource.FromResource(control.Icon); control.Children.Add(icon); // 文字列の作成 Label label = new Label(); label.Text = control.Text.TrimStart(' '); control.Children.Add(label); }