2013年8月27日 星期二

如何取消訂閱行事曆

有網友問已訂閱的行事曆如何取消,所以就多了這一篇。和訂閱行事曆一樣必需透過瀏覽器進入SkyDrive的行事曆設定。進入SkyDrive的行事曆後,點選右邊的小齒輪,進入選項頁
選擇想要取消訂閱的行事曆
 刪除

相關文章
整合Windows 8與google行事曆

2013年8月22日 星期四

[W8App] XAML/C# Hex string

XAML的Hex string表示是以&#x開頭,如:

   1: <Button Content="&#xE114;" FontFamily="Segoe UI Symbol"/>

但C#的Hex string是以\x開頭,如:



   1: btn.Content = "\xE114";

2013年8月19日 星期一

[W8App] Custom Control – Access template component

Step 1. XAML,給予要存取元件名稱

   1: <Style TargetType="local:WaitReadyButton">
   2:     <Setter Property="Template">
   3:         <Setter.Value>
   4:             <ControlTemplate TargetType="local:WaitReadyButton">
   5:                 <Grid>
   6:                     <TextBlock x:Name="txtSymbol" Text=""/>
   7:                 </Grid>
   8:             </ControlTemplate>
   9:         </Setter.Value>
  10:     </Setter>
  11: </Style>

Step 2. C#,宣告存取元件



   1: public sealed class WaitReadyButton : Control
   2: {
   3:     private TextBlock _txtSymbol;

Step 3. C#,在OnApplyTemplate()中取得元件



   1: protected override void OnApplyTemplate()
   2: {
   3:     base.OnApplyTemplate();
   4:  
   5:     _txtSymbol = GetTemplateChild(@"txtSymbol") as TextBlock;
   6: }

成功取得元件後即可在程式碼中使用該元件。


Reference


1. Creating a WPF Custom Control

2013年8月9日 星期五

VS2012 extension - Image Watch

我在開發中的影像程式大部份都是在計算影像的某些特徵值,因此最終輸出的結果不是影像而是一些數值。不過在開發的過程中難免都會遇到問題,當輸出的結果與預期有落差時,確認是計算的過程出現的問題還是載入影像本身的發生問題是除錯過程中必。MS提供VS2012一個方便的擴充套件Image Watch,方便讓我們直接在Debug的過程中觀察記憶體中的影像資料。

我們可以透過VS2012的擴充工具直接搜尋「Image Watch」來安裝。

ImageWatch

ImageWath預設只支援OpenCV的cvMat與Intel的IPLImage。我很少利用這些工具來開發,因此必需新增.nativs。

ImageWath會在VS2012開啟後,從[User]\Documents\Visual Studio 2012\Visualizers目錄下自動搜尋.nativs檔。我們可以把自行定義的影像格式寫成檔案放在Visualizers目錄中,讓ImageWath可以解讀。下面是我常用的影像格式參考Image Watch Help後所完成的.nativs檔案内容:

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
   3:   <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1"
   4:                 MenuName="Add to Image Watch"/>
   5:   <Type Name="ImgWGenericImage&lt;*&gt;">
   6:     <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
   7:   </Type>
   8:   <Type Name="ImgWGenericImage&lt;*&gt;">
   9:     <Expand>
  10:       <Synthetic Name="[type]" Condition='strcmp("unsigned char", "$T1") == 0'>
  11:         <DisplayString>UINT8</DisplayString>
  12:       </Synthetic>
  13:       <Synthetic Name="[type]" Condition='strcmp("float", "$T1") == 0'>
  14:         <DisplayString>FLOAT32</DisplayString>
  15:       </Synthetic>
  16:       <Item Name="[channels]">nchannels</Item>
  17:       <Item Name="[width]">ncols</Item>
  18:       <Item Name="[height]">nrows</Item>
  19:       <Item Name="[data]">data</Item>
  20:       <Item Name="[stride]">ncols*nchannels*sizeof($T1)</Item>
  21:     </Expand>
  22:   </Type>
  23: </AutoVisualizer>

在我們的程式碼中要有對應的C++定義:



   1: #ifdef _DEBUG
   2: template <typename T>
   3: struct ImgWGenericImage
   4: {
   5:     unsigned int ncols;
   6:     unsigned int nrows;
   7:     unsigned int nchannels;
   8:     T* data;
   9: };
  10: #endif // _DEBUG

當我們在Debug模式下單步執行時,透過選單[View]→[Other Windows]→[Image Watch]叫出Image Watch視窗後,可以在Image Watch的視窗中直接看到影像的結果:


result


還可輸出成檔案


dumpresult


Image Watch有提供一些簡單的指令方便我們觀察影像。詳細的用法就直接參考Help吧!


Reference
1. Image Watch Help
2. Image Watch Extension

2013年8月7日 星期三

[W8App] VS2012 Unit Test - Prepare environment (2)

我的Unit Test主要是測試與驗証Portable Library的功能,其中又與影像相關的程式有關。在測試時必需從檔案中讀取大量的數據進行分析處理,處理的結果再回存回硬碟比對結果。

但是,即使只是Unit Test專案,也必需遵守W8App的檔案權限限制。因此在測試之前必需先設定Unit Test專案的權限。

我通常會指定Unit Test專案有存取Documents Library、Pictures Library、Videos Library這三個檔案庫的能力。這樣就能使Unit Test能「讀」這三個檔案庫中的檔案。

Capabilities

如果Unit Test專案還需要有輸出結果到硬碟中,則必需讓專案還有「寫」的能力。必需指定File Type Associations支援的副檔名,以下範例為指定Unit Test可以輸出jpg檔案。

Declarations

由於我的影像檔案庫非常的大,使用了好幾顆硬碟,可依下面步驟把不同硬碟的路徑都指定到Documents Library (或Pictures / Videos)中。

1. 開啟檔案管理員,對著Documents點滑鼠右鍵。選擇「Properties」

Documents_Properties_1

2. 點選「Add …」選擇指定的目錄

Documents_Properties_2