VB C# .NET Freamworkの備忘録

C#, VB.NET Freamworkの備忘録を掲載しています。 コントロール、WPF、スレッド、共通関数と実用的なコードを掲載してきます。

WPFで画像等ファイルをリソースやコンテンツとして利用する際の概念が
以下に示す。
http://msdn.microsoft.com/ja-jp/library/aa970069%28v=vs.80%29.aspx

ローカル アセンブリのプロジェクト フォルダのサブフォルダにある XAML リソース ファイルのパッケージ URI の例を次に示します。
pack://application:,,,/Subfolder/ResourceFile.xaml

実行可能アセンブリが起動される場所のサブフォルダに格納されている、XAML 起点サイト ファイルのパッケージ URI の例を次に示します。

pack://siteoforigin:,,,/Subfolder/SiteOfOriginFile.xaml




以下にコンテンツファイルの読み込み方法を示す。
Uri pageUri = new Uri("pack://siteoforigin:,,,/SiteOfOriginFile.xaml", UriKind.Absolute);
this.pageFrame.Source = pageUri;

同様にXAMLで書くと
<Frame Name="pageFrame" Source="pack://siteoforigin:,,,/SiteOfOriginFile.xaml" />



または、以下の読み込み方もある。

// Navigate to xaml page Uri uri = new Uri("/SiteOfOriginFile.xaml", UriKind.Relative); StreamResourceInfo info = Application.GetRemoteStream(uri); System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader(); Page page = (Page)reader.LoadAsync(info.Stream); this.pageFrame.Content = page;

XAMLの読み込み
http://morio2.blogspot.jp/2012/12/xaml.html



WPF Imageの読み込みを行います。


        Dim imageFilePath As String = "みかん.jpg"
            If Not IO.File.Exists(imageFilePath) Then
                Dim folderPath As String = System.IO.Path.Combine("C:\フルーツ", "冬")
                imageFilePath = IO.Path.Combine(folderPath, imageData.ImageFilePath)
            End If
  
  
            ' 表示する場合
            If IO.File.Exists(imageFilePath) Then
                ' 画像が存在する場合
                Dim bi As New BitmapImage()
                bi.BeginInit()
                bi.CacheOption = BitmapCacheOption.OnLoad
                bi.UriSource = New System.Uri(imageFilePath, UriKind.Absolute)
                bi.EndInit()
  
                _image.Source = bi
  
             End If 

----------------------------------------------------------
VB C# .NET Freamworkの備忘録
http://ari-it.doorblog.jp/
javascriptの備忘録
http://ari-java.doorblog.jp/
--------------------------------------------------------- 

TodoAttributeの作成

開発の際に、Attributeを作成することで、開発状況の確認等に役立ちます。

Namespace Attributes
    Public NotInheritable Class TODOAttribute
        Inherits Attribute
‌ 
        Private _name As String
        Private _content As String
‌ 
        ''' <summary>
        ''' TODO未定義のAttributeを記載します。
        ''' </summary>
        ''' <param name="name">名前</param>
        ''' <param name="content">未定義内容(追加した日付記載お願いします。)</param>
        ''' <remarks></remarks>
        Sub New(ByVal name As StringByVal content As String)
            ' TODO: Complete member initialization 
            _name = name
            _content = content
        End Sub
‌ 
    End Class
End Namespace
‌ 

  ''' <summary>
    ''' コマンドの実行を行います。(非同期)
    ''' </summary>
    ''' <returns>成功時:0/失敗時:-3</returns >
    ''' <remarks ></remarks >]
    <TOD("arimura","2013/6/3 作成中")> _
    Public Shared Function CreatProcess(ByVal exeName As StringByVal param As StringAs Diagnostics.Process
‌ 
        Dim newProc As Diagnostics.Process = Nothing
        newProc = New Diagnostics.Process()
        newProc.StartInfo.FileName = exeName
        newProc.StartInfo.Arguments = param
‌ 
‌ 
        Return newProc
‌ 
    End Function 
‌ 
End Function 

----------------------------------------------------------
VB C# .NET Freamworkの備忘録
http://ari-it.doorblog.jp/
javascriptの備忘録
http://ari-java.doorblog.jp/
--------------------------------------------------------- 

↑このページのトップヘ