1.安裝PAServer
將 \Program Files\Embarcadero\RAD Studio\10.0\PAServer中的setup_paserver.zip 複製到 Mac OSX系统
2.將setup_paserver.zip解壓縮進行安裝。
3.安裝完後,進行環境配置
\user\XXXX\Applications\Embarcadero\RADPAServer\10.0\,執行paserver
4.執行後,paserver會請您設定密碼,設定完後就配置ok!
5.利用文字編輯程式打開目錄下的 paserver.command,在第二行後面加上-password=xxxx,xxxx是你在上一步驟設定的密碼。儲存後關閉!
6.幫 paserver.command建立捷徑(替身),或是利用「系統偏好設定」→「帳號」→「登入項目」讓它隨系統啟動。
[PHP]計算二點間距離
[php]
#lat1,lon1是第一個點的經緯度
#lat2,lon2是第二個點的經緯度
#unit的話就用"K" (這樣的話傳回值就會是公尺)
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
global $source;
$theta = $lon1 – $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
$meters = intval($miles * 1.609344 * 1000);
if($meters > 10000){
return intval($meters/1000).msg(‘公里’,’km’);
}else{
return $meters.msg(‘公尺’,’m’);
}
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
[/php]
台灣鐵路通Taiwan Railway – 考驗對車站的熟悉度
您是鐵道迷嗎?自認對台灣鐵路瞭若指掌嗎?那您可以來玩玩這款「台灣鐵路通Taiwan Railway」遊戲。
設計師魏巍 一手包辦了遊戲中的圖片、程式及音效,連宣傳影片都是自己拍攝的,可見對於APP的用心程度。
遊戲的玩法也相當簡單,在畫面中會出現現在地及目的地二個提示。然後以手指拖拉列車往正確的方向即可!
所以遊戲的前提是,您要自認熟悉各個站名的先後順序,或是在遊戲中有相關的資訊供參考。
下載網址:
iOS: https://itunes.apple.com/tw/app/id624473652?mt=8
Android: https://play.google.com/store/apps/details?id=com.appsgaga.game.taiwanrailway
[Delphi XE3]輕鬆更改程式外觀
以前在撰寫程式時,最討厭的就是醜醜的外觀,如果不是自己畫,就是得找第三方元件(像BusinessSkinForm)來解決。
自從Delphi XE2就開始有的功能,跟大家分享一下如何讓程式看起來不再這麼醜。
1.靜態更改
.Project→Options開啟Project Options選項,在Application→Appearance的Custom Styles就是可以更改介面的選項
.如果不清楚長什麼樣子時,可以點選任一名稱反白後,再點旁邊的Preview就可以預覽
.勾選要變成的Style後,再到Default Style下拉你要的Style按OK即可。
2.動態程式更改
.依照靜態更改方式,勾選你想要呈現的STYLE。
.增加 uses Vcl.Themes
[delphi]
uses Vcl.Themes;
[/delphi]
.讀入風格檔
[delphi]
procedure TForm1.Button1Click(Sender: TObject);
Var
StyleName : string;
begin
ListBox1.Items.Clear;
for StyleName in TStyleManager.StyleNames do
if ListBox1.Items.IndexOf(Name)=-1 then
ListBox1.Items.Add(StyleName);
end;
[/delphi]
.設定風格檔
[delphi]
procedure TForm1.Button2Click(Sender: TObject);
begin
if ListBox1.ItemIndex>=0 then
TStyleManager.SetStyle(ListBox1.Items[ListBox1.ItemIndex]);;
end;
[/delphi]
範例程式下載 GitHub https://github.com/superlevin/DelphiXE3_SetStyle
3.自製風格.Tools→Bitmap Style Designer
預設的Style檔案位置在:C:\Users\Public\Documents\RAD Studio\10.0\Styles
[Delphi XE3] 取得螢幕解析度
[delphi]
uses Winapi.Windows;
procedure TMainForm.Button1Click(Sender: TObject);
var
ScreenHorizontal :integer;
ScreenVertical:integer;
begin
ScreenPixelX:= GetDeviceCaps(GetDC(Application.Handle),HORZRES); // Horizontal width in pixels
ScreenPixelY:= GetDeviceCaps(GetDC(Application.Handle),VERTRES); // Vertical height in pixels
// 取得螢幕解析度
ShowMessage(IntToStr(ScreenHorizontal)+’ X ‘+ IntToStr(ScreenVertical));
end;
[/delphi]
[Delphi XE3]ESC/POS範例
找遍了台灣的資料,對於POS收銀系統硬體相關的程式非常的少。
只好自己Try & Error一番,順便也將結果告訴一下大家囉~希望大家不要再為了它而浪費了不少時間。
很簡單的示範如何利用Delphi XE3及SPComm 元件來印出收據、切紙並打開錢櫃。
[sourcecode language=”delphi”]
procedure TForm2.Button1Click(Sender: TObject);
var
s:Ansistring;
begin
Comm1.CommName := ComboBox1.Text;
Try
Comm1.StartComm;
//初始化
s:= chr(27) + chr(64);
Comm1.WriteCommData(PAnsiChar(s),Length(s));
// 印出目前日期、時間並換行
s:= DateToStr(now)+’ ‘+TimeToStr(now)+ chr(10)+ chr(13) ;
Comm1.WriteCommData(PAnsiChar(s),Length(s));
s:= chr(27) + chr(100) + chr(2);
Comm1.WriteCommData(PAnsiChar(s),Length(s));
s:= chr(29) + chr(33) + chr(17) ;
Comm1.WriteCommData(PAnsiChar(s),Length(s));
s:= ‘Printer – Testing Success’+ chr(10);
Comm1.WriteCommData(PAnsiChar(s),Length(s));
s:= chr(29) + chr(33) + chr(0) ;
Comm1.WriteCommData(PAnsiChar(s),Length(s));
s:= chr(27) + chr(100) + chr(5);
Comm1.WriteCommData(PAnsiChar(s),Length(s));
// 切紙
s := Chr(29) + Chr(86) + Chr(0) ;
Comm1.WriteCommData(PAnsiChar(s),Length(s));
//打開錢櫃
s := chr(27) + chr(112) + chr(0) + chr(50) + chr(200) ;
Comm1.WriteCommData(PAnsiChar(s),Length(s));
Except
on E: Exception do Begin
ShowMessage(‘Open ComPort Error!’+#10#13+’Error MSG:’+E.Message);
End;
End;
end;
[/sourcecode]
[Delphi XE3]如何清除Welcome Page中的Recently Opened Projects
Delphi 有記住打開過的專案的功能,在下一次開啟IDE時會顯示在Welcome Page中,那要如何清除呢?
1.File→Reopen→Properties
可以設定~
.Number of Projects →記住幾個開過的專案(預設10個)
.Number of files→記住幾個開過的檔案(預設15個)
.Reopen Items就是顯示在Welcome Page的內容,可以點選後用Delete或直接Clear
2.進入登錄編輯程式刪除
HKEY_CURRENT_USER\Software\Embarcadero\BDS\10.0\Closed Projects
3.寫程式刪除
uses 加入 System.Win.Registry;
[delphi]
procedure TForm1.Button1Click(Sender: TObject);
var
iCount : Integer;
Reg : TRegistry;
sList : TStrings;
begin
sList := TStringList.Create;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(‘\Software\Embarcadero\BDS\10.0\Closed Projects’, True) then
Reg.GetValueNames(sList);
if sList.Count > 0 then begin
for iCount := 0 to Pred(sList.Count) do
Reg.DeleteValue(sList[icount]);
end else
MessageDlg(‘No registry items to be cleaned at this time.’,
mtInformation, [mbOk], 0);
finally
sList.Free;
Reg.Free;
end;
end;
[/delphi]
前端攻城師不可錯過的網站-前端工程開發實務
擁有非常深厚功力的啊嗚(蔣定宇),將他一系列「Web前端程式開發實務」的講議及資料無私的分享出來,目的是為了讓F2E(Front -End Engineer)的產業能更加成長。這真的是佛心來的,因為Joseph在Yahoo!期間就擔任多年的前端工程師,後期更是YDN的傳教士,協助推廣YUI。目前也是miiicasa的前端工程部門主管,所以對前端工程真的是有相當的專業在。推薦給各位!
網站: http://f2eclass.com/
投影片: http://www.slideshare.net/josephj/presentations
原始碼 : https://github.com/josephj/f2e-class/tree/master/slide
verlet-js蠻炫的JS物理引擎
verlet-js是一套開放原始碼的JavaScript物理引擎,擁有粒子系統以及碰撞、關連、拖拉、模擬等特性。
透過Verlet也可以做出 box2d 效果的遊戲唷!在官方網站上,提供了幾個範例程式可以更瞭解物理引擎的用法。
[Delphi]Splash-Screen的寫法
Delphi的資源似乎變得很少了!不過自從看到XE3似乎有些長進後,或許大家可以嘗試回鍋來做開發也不錯,畢竟Delphi在開發商用軟體的速度真的蠻快速的 :)。後續除了一些行動裝置開發、網頁開發的分享,也來做一下Delphi開發的分享好了!
Splash Screen是什麼?就是打開程式時,會先顯示個幾秒的圖片,大多是產品名稱、公司Logo這類的東西。在Delphi做法也很簡單:
1. File → New → VCL Form – Delphi 新增一個 Form
2. 開啟 Project → View Source 就可以看到 Project Source。
[delphi]
program Project1;
uses
Vcl.Forms,
Unit1 in ‘Unit1.pas’ {Form1},
Unit2 in ‘Unit2.pas’ {Form2};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
[/delphi]
3. 改成如下就可以!
[delphi]
program Project1;
uses
Vcl.Forms,
Unit1 in ‘Unit1.pas’ {Form1},
Unit2 in ‘Unit2.pas’ {Form2};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
try
Form2:=TForm2.create(application);
Form2.show;
Form2.Update;
Application.CreateForm(TForm1, Form1);
finally
Form2.Free;
end;
Application.Run;
end.
[/delphi]
4. 如此一來,如果專案變大後,一方面在程式初始化時,可以Show出產品畫面外,避免看起來好像是程式當掉的冏境。也可以讓程式看起來更專業些XD