
ActiveX로 개발하는게 생산성도 좋고 편하다고?
그럼 매번 IE로 업그레이드 될때마다 수정해줘야 하는게 생산성이 매우 뛰어나는구나꼭 Linux도아닌 MAC도 아닌 MS Windows의 IE6, IE7 에서만 사용해주시기 바랍니다.
Posted by reiKop


Posted by reiKop

Posted by reiKop
전에 소개했던 이벤트 송출 방식에는 이벤트의 발생만 나타낼수만 있다.
하지만 지금 포스팅하는 문서에는 값을 포함햇 이벤트를 발생할수 있는법을 제시한다.
[code c#]
public event RoutedPropertyChangedEventHandler<double> VolumnChanged;
protected virtual void OnVolumnChanged(double oldValue, double newValue)
{
RoutedPropertyChangedEventHandler<double> handler = VolumnChanged;
if (handler != null)
{
handler(this, new RoutedPropertyChangedEventArgs<double>(oldValue, newValue));
}
}
[/code]
[code c#]
OnVolumnChanged( 0.9 , 1.0 );
[/code]
Posted by reiKop
플래시에서는 브라우져가 크기가 변경될시에 발생하는 이벤트가 있다.
[code java]
addEventListener("resize",resizeEvent);
function resizeEvent(e:Event):void
{
trace( this.width, this.height );
}
[/code]
실버라이트에서는 이것을 찾는게 어려웠다.
Resize 라는 이벤트도 없고 난감했는데 구글링을 통해 쉽게 답을 얻었다.
[code c#]
public Page(){
InitializeComponent();
App.Current.Host.Content.Resized += new EventHandler(Content_Resized);
}
[/code]
이벤트를 받아온 함수에서는 값을 받아오면 된다!
[code c#]
void Content_Resized(object sender, EventArgs e){
double height = App.Current.Host.Content.ActualHeight;
double width = App.Current.Host.Content.ActualWidth;
}
[/code]
참고한 사이트
http://silverlight.net/blogs/msnow/archive/2008/06/06/browser-resize-how-to-determine-your-browser-size.aspx
Posted by reiKop

Posted by reiKop
동영상 플레이어나 특이한상황에서 풀스크린 지정이 필요할 때가 있다.
이때는 이렇게 해주면 된다.
[code c#]
void FullScreen()
{
System.Windows.Interop.SilverlightHost host = Application.Current.Host;
System.Windows.Interop.Content content = host.Content;
content.IsFullScreen = true;
}
[/code]
원래 화면으로 돌아오려면
Windows 는 Alt+F4, ESC 키
MAC 은 ESC키면 돌아온다.
그리고 전체화면으로 됐을때 사이즈를 알고 싶으면 이벤트를 등록하면 된다.
[code c#]
content.FullScreenChanged += new EventHandler(content_FullScreenChanged);
void content_FullScreenChanged(object sender, EventArgs e)
{
content.ActualHeight;
content.ActualWidth;
}
[/code]
참 쉽죠잉
Posted by reiKop
일단 delegate를 선언을 하게 되면 그 delegate는 함수를 참조하게 된다.
[code c#]
using System;
namespace ex_10_delegate
{
class Program
{
public delegate void PrintOut(string s); // delegate declare
public static void WriteToConsole(string s)
{
Console.WriteLine(s);
}
static void Main(string[] args)
{
PrintOut printout = new PrintOut(WriteToConsole);
printout(" PrintOut을 호출한다");
printout("PrintOut은 다시 WriteToConsole을 호출한다");
}
}
}
[/code]
특이한 점은 delete에 함수를 "+" 연산자를 써서 연속적으로 함수 호출이 가능하다는 것이다.
[code c#]
using System;
namespace delegate_coffee
{
class Program
{
public delegate void Stuff(); // delegate declare
public static void Sugar()
{
Console.WriteLine("Sugar");
}
public static void Cream()
{
Console.WriteLine("Cream");
}
public static void Milk()
{
Console.WriteLine("Milk");
}
public static void Coffee()
{
Console.WriteLine("Coffee");
}
static void Main(string[] args)
{
Stuff S = new Stuff(Sugar);
Stuff C = new Stuff(Cream);
Stuff M = new Stuff(Milk);
Stuff Cafe = new Stuff(Coffee);
Console.WriteLine("비엔나 커피 만들기: ");
Stuff Vienna = S + C + Cafe;
Vienna();
Console.WriteLine("블랙 커피 만들기: ");
Stuff BlackCoffee = S + Cafe;
BlackCoffee();
}
}
}
/*
*델리게이트 객체는 메모리에서 할당될 때 생성자에 매개 변수로 메쏘드를 넘겨 받는다. 이 메쏘드를 Named Method라 한다.
*/
[/code]
그리고 deleate는 익명함수를 만들수 있다.
[code c#]
using System;
namespace delegate_Annonymouse
{
class Program
{
public delegate void PrintOut(string s);
static void Main(string[] args)
{
//익명 메쏘드 정의
PrintOut printout = delegate(string s)
{
Console.WriteLine(s);
};
printout("익명 메쏘드");
printout("쉬윈가 쉽지 않은가?");
}
}
}
/*
* 익명 메쏘드는 재사용되지 않는 코드를 가진 메쏘드를 델리게이트가 호출하게 될 경우에 유용하게 사용될 수 있다.
*/
[/code]
마지막으로 이벤트를 응용한다.
[code c#]
using System;
namespace delegate_event
{
class Client
{
private int ID;
public delegate void ClientService(object sender, EventArgs args);
public event ClientService Service;
public Client(int ID)
{
this.ID = ID;
}
public int ClientID
{
get { return this.ID; }
}
public void FireEvent()
{
if (Service != null)
{
EventArgs args = new EventArgs();
Service(this, args);
}
}
}
class Program
{
public static void OnEvent(object sender, EventArgs args)
{
Client client = (Client)sender;
Console.WriteLine("{0} , event fire", client.ClientID);
}
static void Main(string[] args)
{
Client clientA = new Client(1);
clientA.Service += new Client.ClientService(OnEvent);
clientA.FireEvent();
}
}
}
[/code]
Posted by reiKop
Posted by reiKop

Posted by reiKop
전에 한번 소개한적이 있는 데이터서비스를 쉽게 해주는 클래스를 성능향상을 업데이트 해서 제작 했다.
OpenZet 프로젝트를 참여 하면서 전에 만들 클래스들을 리팩토링도 하고 Interface를 추가해서 넣었다.
XML등을 로드 하기 위해서 이렇게 해주면 된다.
XML이 EUC-KR인코딩일 경우 간혹 데이터를 제대로 못 읽어오는 문제를 해결했다.
[code]var hl:HTTPLoader = new HTTPLoader();
hl.addEventListener("complete",resultHandler);
hl.load(new URLRequest("http://testXMLAnithing.xml","EUC-KR"));
function resultHandler(e:RPCEvent):void
{
var xml:XMLList = new XML(e.data).children();
Alert.show(xml.toXMLString());
}
[/code]
그리고 BlazeDS의 등장으로 플래시 시절 많이 사용하던 openAmf, AMFPHP 등을 편하게 연결해주는 클래스도 제작되었다.
[code]var ac:AMFCaller = AMFCaller.getInstance();
ac.URL = "http://YourAMFGatewayAdress";
ac.addEventListener(RPCEvent.COMPLETE,completeEvent);
ac.call("test.TestClass.getTest");
function completeEvent(e:RPCEvent):void
{
Alert.show(e.data);
}
[/code]
마지막으로 BlazeDS, FDS등 RemoteObejct를 사용하는 데이터 통신을 마찬가지로 쉽게 가지고 오게 했다.
[code]var param:Object = {};
param.id = "reikop";
var ro:RemoteObjectCaller = RemoteObjectCaller.getInstance();
ro.addEventListener("complete",resultHandler);
ro.call("test.getTest",param);
function resultHandler(e:ResultEvent):void
{
Alert.show(e.data as String);
}[/code]자세한 도움말을 보고 싶다면 다음 위키를 참조하면 된다.
그리고 오픈젯 프로젝트에 대해서 알고 싶다면 여기를 클릭하면 된다.
Posted by reiKop