March
4th,
2014
起因:
主要是因為在Windows Store 上面,需要產生兩個相同的內容的產品
但是版號與產品名稱卻不能相同.
做法:
原本做法
複製一個相同的目錄 (原本稱為ㄓ ProjA 複製出來為 ProjB)
修改 csproj 把每個檔案的鏈結改到原本的 檔案
在搬移的過程中,會出現以下的錯誤
Could not find **.xbf in target folder
查詢過後發現,XAML 的檔案無法去link具有上一層目錄的檔案架構 ( ….XXX)
但是卻可以去link “XXX “
解決方法:
僅僅複製把ProjB 的需要的檔案到ProjA的目錄下
AssemblyInfo.cs (注意要改名)
XXX.csproj
XXX_StoreKey.pfx
XXX_TemporaryKey.pfx
Package_StoreAssociation.xml (注意要改名)
Package.appxmanifest(注意要改名)
這樣下來是有點醜,因為 bin/obj 會共用~這個之後會再仔細觀察是否有任何問題
此外需要改兩個東西
在 csproj 裡面
在 Package.appxmanifest與Package_StoreAssociation.xml 內
這樣就可以產生兩個一樣內容的app 在你的桌面
參考:
http://stackoverflow.com/questions/8162179/how-do-i-install-two-versions-of-my-metro-app
繼續閱讀
February
27th,
2014
這一些主要是為了想學習架設 Jenkins,不過還沒整理完~先把這部分的整理出來….
[問題] 利用command line 的 MSBuild.exe 會發生錯誤 “error MSB8020: The builds tools for v120 (Platform Toolset = ‘v120’) cannot be found.”
我也發現~就算你裝了 VS2013只要你有裝 VS2012 tool set你有可能會按倒 VS2012 command line tool,這時候的版本會出現
msbuild.exe /version
4.0.30319…
解法: 首先要確認你執行是VS2013 command line tool或是執行 msbuild.exe 在 c:Program Fies(X86)MSBuild12.0Bin
參考: http://public.kitware.com/Bug/view.php?id=14369
[問題]MSBuild去開始跑 *.sln 會出現 error MSB3779: The processor architecture of project being build “Any CPU” is not supported by referenced SDK ….
這個問題主要是因為在sln 裡面的設定 有加入當初建立project (專案)的時候的設定 Any CPU, Mixed Platform … etc.
所以解法有以下的方式:
解法: [Build]->[Configuration Manager…] 去把沒需要build的platform 關閉,記得 “Build” 跟 “Deploy” 都要關閉.當然你真的都用不到~其實可以刪除…
參考:
http://stackoverflow.com/questions/1074654/how-do-i-force-msbuild-to-compile-for-32-bit-mode
http://stackoverflow.com/questions/3155492/how-to-specify-platform-for-msbuild
繼續閱讀
February
25th,
2014
這裡整理了一些關於在Android寫相機App會產生的一些疑問,並且把自己寫好的程式整理出來放在Github上面. 這裡產生的相機功能主要如下: 利用 Camera class產生相機的控制部分 預覽的視窗 拍照後可以讓Android系統預設的相簿觀看 讓相機產生preview 1.將需要授權的相關部分放在”AndroidManifest.xml” <uses-permissionandroid:name=”android.permission.CAMERA”/> <uses-featureandroid:name=”android.hardware.camera.autofocus”/> <uses-featureandroid:name=”android.hardware.camera”android:required=”false”/> <uses-permissionandroid:name=”android.permission.WRITE_EXTERNAL_STORAGE”/> 把需要的元件畫出來,需要一個SurfaceView跟一個Button,修改reslayoutactivity_main.xml <SurfaceView android:id=”@+id/surfaceView1” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:layout_alignParentBottom=”true” android:layout_alignParentLeft=”true” android:layout_alignParentRight=”true”> </SurfaceView> <Button android:id=”@+id/btn_capture” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignRight=”@+id/surfaceView1” android:layout_below=”@+id/textView1” android:layout_marginRight=”18dp” android:layout_marginTop=”144dp” android:text=”Capture”/> 讓preview可以動作,這裡的code比較多,儘量寫清楚點 3.1 建立 相關原件 //Camera object Camera mCamera; //Preview surface SurfaceView surfaceView; //Preview surface handle for callback SurfaceHolder surfaceHolder; //Camera button Button btnCapture; //Note if preview windows is on. booleanpreviewing; 3.2 連接原件修改原來的 OnCreate @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnCapture = (Button) findViewById(R.id.btn_capture); surfaceView = (SurfaceView) findViewById(R.id.surfaceView1); ...
繼續閱讀
February
19th,
2014
其實應該是不難,只是一直很難找到正確的解答.可能是WPF,Windows Phone與Store App會有不同的結果,稍微記錄一下.
需求:
在Windows Store App中,有些圖片,希望可以用程式的方式來決定讀取的方式.
解法:
找了半天,不論是
<code style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;" class="pln">img1</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;" class="pun">.</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#2b91af;background-position:initial initial;background-repeat:initial initial;" class="typ">Source</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;" class="pun">=</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#00008b;background-position:initial initial;background-repeat:initial initial;" class="kwd">new</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#2b91af;background-position:initial initial;background-repeat:initial initial;" class="typ">BitmapImage</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;" class="pun">(</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#00008b;background-position:initial initial;background-repeat:initial initial;" class="kwd">new</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#2b91af;background-position:initial initial;background-repeat:initial initial;" class="typ">Uri</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;" class="pun">(</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#800000;background-position:initial initial;background-repeat:initial initial;" class="str">"ms-appx:///Assets/Common_Pic/image2.png"</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;" class="pun">,</span><span style="margin:0;padding:0;border:0;font-size:13.63636302948px;vertical-align:baseline;background-color:transparent;color:#2b91af;background-position:initial initial;background-repeat:initial initial;" class="typ">UriKi</span></code>
甚至也把URI 換成 System.Uri也是不行.
後來找到這篇文章才終於搞定Load Image Dynamically From Application Uri in Windows Store Apps
步驟寫一下:
首先千萬記得把你要變動的圖片記得讀進project 中,內容可以設定為 content. 檔案方式可以用成copy if newer
之前主要失敗的原因是,檔案在那個時候其實還沒有完全讀完畢,所以需要用 StorageFile 來讀取
記得讀取檔案是 async 的動作,所以得用 await 強制它讀完繼續執行
最後再把檔案用BitmpImage包起來並且傳給 image.Source
完整程式碼可參考底下~或是去看鏈結
參考:
主要解法: http://www.c-sharpcorner.com/UploadFile/99bb20/load-image-dynamically-from-application-uri-in-windows-store/
其他問相關問題~當做參考吧
http://stackoverflow.com/questions/21283400/how-to-change-images-source-windows-store-app-with-code/21881311#21881311
http://stackoverflow.com/questions/12450906/metro-windows-store-app-relative-image-source-binding-does-not-work
http://stackoverflow.com/questions/11836032/setting-image-source-programatically-in-metro-app-image-doesnt-appear/21881098#21881098
繼續閱讀
February
15th,
2014
繼續不斷地學習,不斷的回復自己的記憶
#define 在compiler階段就會展開,所以要確認清楚他的展開方式,比如
#define M1(x) X5+3
M1(5)5 ==> 55+35 => (55)+(35) = 40
他可以不止一行~對於只有一行的if 判斷要小心 if(a) staement Macro(b) , Macro(b) b++; b—; 在此~ b–將會跑不到. 怕失誤要加上 {} 或是改成 inline function
參數有 # 會加上 escape character,也就是 “ —> ”
#define值並不會有值~也就是
#define FOO1
#ifdef FOO1
.. statement1
#endif
跟 if (FOO1 == 0) 是不同 (其實這樣會compiler error)
如果要#define 一個數字~要換成常數 (constant) exam: #define FOO 5.3
如果只有一個檔案要用,改成 static const FOO = 5.3;
多個檔案 extern const FOO= 5.3;
CPP裡面 const FOO=5.3;
當專案大的時候,由於 .h 會被很多的檔案載入~所以define macro 不建議放在 .h 容易被其他人用到(或是override)
http://qualitycoding.org/precompiled-headers/
建議寫在.c 或是 .cpp 並且在用完之後馬上 #undef 避免被蓋掉(override)
詳細code整理我放這裡: https://gist.github.com/kkdai/9014911
參考資料:
http://bbs.nsysu.edu.tw/txtVersion/treasure/program/M.855729774.C/M.948127113.E.html
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Preprocessor_Macros#Preprocessor_Macros
http://openhome.cc/Gossip/CppGossip/inlineFunction.html
http://web2.fg.tp.edu.tw/~cc/blog/wp-content/uploads/2010/06/20100715advanceC.pdf
http://anna-zr.iteye.com/blog/510368
Include guard about define http://en.wikipedia.org/wiki/Include_guard
http://qualitycoding.org/precompiled-headers/
9 Code Smells of Preprocessor Use http://qualitycoding.org/preprocessor/
繼續閱讀
February
13th,
2014
主要注意到這個是因為meetup上面的活動
開始去查一下關於Docker的內容,但是由於它能做的事情太多了.我也只貼出一些我所了解的部分
Docker可以將PAAS裡面的OS或是App拆解成container並且快速讀取或是執行
整個速度大概是一秒就載入完成
Docker 也可以run某一種單一app的結果~比如ping或是 bash
Docker的 image在寫回去前都會保持原樣~所以可以快速地使用並且安全得保存
如同下面影片,你可以載入bash大膽的把 /etc /bin 都刪除~然後離開~馬上再載入..
甚至可以把整個PAAS載入後加上你的修改來看結果.
這裡可以去官方網站玩demo
相關資料:
官方網站: https://www.docker.io
Present 影片 http://www.youtube.com/watch?v=Q5POuMHxW-0
中文介紹: http://tiewei.github.io/cloud/Docker-Getting-Start/
繼續閱讀