2013-08-28

Update DataTime in SQLite

When operating DateTime type in SQLite, need to convert the date time string into specific format
yyyy-MM-dd HH:mm:ss

2013-08-18

Certificate & Provision

從MAC的KeyChain中,  鑰匙圈存取->憑証輔助程式->從憑証授權要求憑証
email : 不知有何影響, 非AppleID
一般名稱 : 在KeyChain中會顯示的名稱
要求之後
1. 產生CertificateSigningRequest.certSigningRequest 這個檔案, 這是要上傳到Apple Developer去產生cetificate的
2. 在KeyChain中會自動產生兩把Key(公用密鑰, 專用密鑰)

接著到Apple Developer, 登入後到Certificates去新增憑証
Development類型的憑証好像不能重覆?
選好憑証類型之後, 順著流程將CSR檔案上傳, 上傳完畢後即會產生.cer檔供下載
下載後double click這個檔, 即會灌入KeyChain中並與專用密鑰自動連結

接著處理Provision
一個Provision跟一個App ID對應
這裏的App ID是指在Apple Developer裏設定, 準備要開發的app
一個Provision可以包含多個憑証(每個憑証相當於對應一台開發機器)
一個Provision可以包含多台iDevice
Provision是用來安裝在iDevice上,
所以整個Certificates跟Provision的作用,
是Apple為了控制哪個開發者帳號(by Apple ID)
用了哪台機器(by Certificate)
要開發什麼app(by App IDs of Provision)
要在哪些iDevice(by Devices of Provision)上測試

生成Provision並下載之後, double-click即會安裝進XCode Origanizer裏供專案使用, 視必要會自動安裝到iDevice上去

2013-05-30

XCODE設定部份程式碼不使用ARC

1. 選擇專案,此時會出現專案設定畫面。
2. 選擇你的 Target,並切換到 Build Phases 畫面。
3. 找到 Compile Sources 這個畫面,然後選擇你要設定不使用 ARC 的程式碼
4. 按下 Enter 鍵後,會跳出一個視窗要你輸入東西,在裏面輸入 -fno-objc-arc 就可以了。

2012-06-08

Dispatcher.Invoke

Dim folderName As String = Dispatcher.Invoke(DispatcherPriority.Normal, New Func(Of String)(Function() txtFolderName.Text))
Dispatcher.Invoke(DispatcherPriority.Normal, New Action(Sub() lblProgress.Content = i & " / " & BackupPhotos.Count))

Remove pdb files when compile

There is an option in the “Project Properties", “Build", “Advanced…".
Change “Debug Info:" to None.

2011-07-27

DataGrid – Committing changes cell-by-cell

Private isManualEditCommit As Boolean = False
    Private Sub DG_CellEditEnding(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridCellEditEndingEventArgs) Handles DG.CellEditEnding
        If Not isManualEditCommit Then
            isManualEditCommit = True
            DG.CommitEdit(DataGridEditingUnit.Row, True)
            isManualEditCommit = False
        End If
    End Sub

2011-07-26

Get DataGrid row and cell

There are no simple built-in methods for accessing individual rows or columns in WPF DataGrid. The following code samples will provide simple methods for accessing these items.
First of all we need a helper function for selecting a visual child:
public static T GetVisualChild<T>(Visual parent) where T : Visual
{
    T child = default(T);
    int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
    for (int i = 0; i < numVisuals; i++)
    {
        Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
        child = v as T;
        if (child == null)
        {
            child = GetVisualChild<T>(v);
        }
       if (child != null)
       {
           break;
       }
   }
       return child;
}
There is a simple method for getting the current (selected) row of the DataGrid:
public static DataGridRow GetSelectedRow(this DataGrid grid)
{
    return (DataGridRow)grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem);
}
We can also get a row by its indices:
public static DataGridRow GetRow(this DataGrid grid, int index)
{
    DataGridRow row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
    if (row == null)
    {
        // May be virtualized, bring into view and try again.
        grid.UpdateLayout();
        grid.ScrollIntoView(grid.Items[index]);
        row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
    }
    return row;
}
Now we can get a cell of a DataGrid by an existing row:
public static DataGridCell GetCell(this DataGrid grid, DataGridRow row, int column)
{
    if (row != null)
    {
        DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(row);

        if (presenter == null)
        {
            grid.ScrollIntoView(row, grid.Columns[column]);
            presenter = GetVisualChild<DataGridCellsPresenter>(row);
        }

        DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
        return cell;
    }
    return null;
}
Or we can simply select a row by its indices:
public static DataGridCell GetCell(this DataGrid grid, int row, int column)
{
    DataGridRow rowContainer = grid.GetRow(row);
    return grid.GetCell(rowContainer, column);
}
The functions above are extension methods. Their use is simple:
var selectedRow = grid.GetSelectedRow();
var columnCell = grid.GetCell(selectedRow, 0);