퇴근5분전

 버튼 -> 누르고 있으면 이벤트 발생 ~

 

클릭과는 다른 동작을 함.

 

 

# 차이는 다음과 같음.

 

  void jsfW_Button1_MouseUp(object sender, MouseEventArgs e)
        {
            jsfW_Button1.ForeColor = Color.Black;
        }

  

// 버튼을 누른체 1초후 발생 -> Click Event 는 건너뜀.

  void jsfW_Button1_MousePressing(object sender, EventArgs e)
        {     

             jsfW_Button1.ForeColor = Color.Red;
             label1.Text += "Press" + Environment.NewLine;       
        }

   void jsfW_Button1_MouseDown(object sender, MouseEventArgs e)
        {
            jsfW_Button1.ForeColor = Color.Black;
        }

  

  void jsfW_Button1_Click(object sender, EventArgs e)
        {
            label1.Text += "클릭"+ Environment.NewLine;
        }

 

 

#  소스

 

  public class JSFW_Button : Button
    {
        bool isMDown = false;
        TimeSpan PressingTimeSpan = TimeSpan.MinValue;
        bool IsPressed = false;

        protected override void OnMouseDown(MouseEventArgs mevent)
        {
            base.OnMouseDown(mevent);
            if (mevent.Button == System.Windows.Forms.MouseButtons.Left)
            {
                isMDown = true;
                PressingTimeSpan = new TimeSpan(DateTime.Now.Ticks);
                Action pressingAction = PressChecking;
                pressingAction.BeginInvoke(ir => pressingAction.EndInvoke(ir), pressingAction);
            }
        }

        void PressChecking()
        {
            IsPressed = false;
            while (isMDown)
            {
                Debug.Write(DateTime.Now.Subtract(PressingTimeSpan).Millisecond + Environment.NewLine);
                if( TimeSpan.FromTicks(  DateTime.Now.Ticks ).Subtract(PressingTimeSpan).TotalMilliseconds > 1000 )
                {
                    Invoke( new Action<EventArgs>( OnMousePressing), EventArgs.Empty);
                    break; // Thread 종료!
                }
                System.Threading.Thread.Sleep(200);
            }
        }

        protected override void OnClick(EventArgs e)
        {
            if (IsPressed == false)
            {
                base.OnClick(e);
            }
            IsPressed = false;
        }

        protected override void OnMouseUp(MouseEventArgs mevent)
        {
            isMDown = false;
            base.OnMouseUp(mevent);
        }
        
        public event EventHandler MousePressing = null;

        protected void OnMousePressing(EventArgs e)
        {
            if (MousePressing != null)
            {
                IsPressed = true;
                MousePressing(this, e);
            }
        }
    }

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

GDI+] 이미지 회전!  (0) 2012.08.13
2010 WinForm ] 컨트롤 리사이징 예제...  (0) 2012.07.20
.NET ] 멀티 랭귀지 지원 ...  (0) 2012.03.06
ArrayList.Sort 하기...  (4) 2011.07.29
[IPC] Event 추가 ~~  (0) 2011.05.14


  멀티 랭귀지 지원에 대해 글을 한번 싸질러본다.

몇가지 글을 찾아보았는데... 영문에 장수도 만만치 않다.

따라해도 뭐가 빠졌는지 잘 안된다...

 따라하기를 포기하고 그냥 내방식대로 코드 노가다와 감으로 짜보니 되더라...


1. 새 프로젝트를 생성한다. ( 응용프로그램 : Form )
2. 프로젝트내에 기본으로 있는 Resources.resx 에  [이름)Name / 값)Name] 을 추가해준다. ( 영문명 )
3. 새 항목 추가로 리소스를 추가한다. 이때 이름은 Resources.ko-kr.resx 이다. ( 한글명 )
동일한 Key로 써야 하니까 [이름)Name / 값) 이름] 이라고 추가한다.
4. 폼에 버튼 하나를 놓아둔다.
5. Form 소스에서 버튼.Text 에 Name을 할당해보자.
---- 소스 --------------------------------------------------------------------------------------

 button1.Text = Demo_MultiLanguage.Properties.Resources.Name;

요렇게.... 넣으면 기본 리소스 이용으로 영문으로 "Name" 이  나온다.
Name으로 나오게 된다.

한글로 안나오는 이유를 보면..
Demo_MultiLanguage.Properties.Resources.Culture  요 값이 null 값으로

null이면 기본 리소스 값을 가져오는 듯 하다.

6. 이제 한글이 되도록 바꿔보자.
---- 소스 --------------------------------------------------------------------------------------

 Demo_MultiLanguage.Properties.Resources.Culture = new System.Globalization.CultureInfo("ko-kr");
 button1.Text = Demo_MultiLanguage.Properties.Resources.Name;

요러면... 버튼에 "이름" 이라고 표시된다.


## 중요 참고 사항 ###############################################################################

1. 새로 만든 리소스 파일명에 주의 한다.
Resources.resx
Resources.ko-kr.resx

2. 파일 위치를 잘 맞춘다.


끝!!!


--- 추가 내용 (잘못된 정보다)----------------------------------
{  // 또 실수할까봐... 남겨둔다.
all in one code framework 의 샘플들을 훑어보던 중 쇼킹..

Form아래 resx파일을 추가해두고
해당 resx에서  [이름)컨트롤명.프로퍼티 / 값) 값]  요거 하나로 끝나는걸 봤다.

코드를 넣을필요도 없네??? 멋지다.
}
>> 잘못된 정보다!!! 위!!


잘못된 정보대로 하니 안된다... 저걸로 하는게 아니고

의외로 간단하게 된다.

Form에 localizable 프로퍼티를 디자이너 에서 true 시켜놓고 디자인 작업을 하면 
자동으로 생성이 되네? -> resx에...
다음 그냥 디자이너에서 속성창에서 Text수정하면 자동으로 resx를 만들어 저장한다.

정리하면

그냥 로컬라이즈 = true 걸어놓고
언어 선택 후
디자이너에서 컨트롤 프로퍼티를 조정하면 알아서 저장된다 ㅡ.,ㅡ;;






'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

2010 WinForm ] 컨트롤 리사이징 예제...  (0) 2012.07.20
.Net] 버튼 Pressed Event!!  (0) 2012.05.09
ArrayList.Sort 하기...  (4) 2011.07.29
[IPC] Event 추가 ~~  (0) 2011.05.14
LINQ] 로또 구하기?  (1) 2011.04.25


ArrayList 에 담아 있는 데이타를 순서에 맞춰 정렬하는 부분에 대해 구현한 것임.

간단하다... 아래처럼 하면

 간단히 담는놈(ArrayList)에 담겨질놈(SortunitClass)을 담아서,
정렬할 방법을 가지고 있는 놈( SortunitClassCompare )에게 넘겨준다.



// 훈스에 올라온 질문글에 대한 답글로 단 소스임.
  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            ArrayList ar = new ArrayList();

            ar.Add(new SortunitClass() { Index = 9, Data = "아홉" });
            ar.Add(new SortunitClass() { Index = 3, Data = "셋" });
            ar.Add(new SortunitClass() { Index = 5, Data = "다섯" });
            ar.Add(new SortunitClass() { Index = 11, Data = "열하나" });
            ar.Add(new SortunitClass() { Index = 1, Data = "하나" });

            ar.Sort(new SortunitClassCompare());
        }
    }

    public class SortunitClassCompare : IComparer, IComparer<SortunitClass>
    {
        public int Compare(SortunitClass x, SortunitClass y)
        {
            return x.Index.CompareTo(y.Index);
        }

        public int Compare(object x, object y)
        {
            return Compare((SortunitClass)x, (SortunitClass)y);
        }
    }


    public struct SortunitClass 
    {
        public int Index { get; set; }
        public string Data { get; set; }
    }

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

.Net] 버튼 Pressed Event!!  (0) 2012.05.09
.NET ] 멀티 랭귀지 지원 ...  (0) 2012.03.06
[IPC] Event 추가 ~~  (0) 2011.05.14
LINQ] 로또 구하기?  (1) 2011.04.25
[C#]Box 그리기...  (0) 2010.11.29

회사에서의 서버 모니터링 프로그램을 만들면서

프로그램 or 서비스 등에서의 상태이벤트를 감시하는 프로그램을 만드는데 있어서...

IPC를 적용하였다. 초기 ipc를 사용하게 된 배경은 pc내에서 타 프로세스에서 모니터링 Agent로 상태를

전달하기 위해 공유객체를 이용하면 좋겠다 싶어서 였는데...

IPC 공유객체 관련해서 이벤트를 추가하는 부분은 없었다.

곧 한쪽에서 데이타를 넣었을때 -> 다른 쪽에서 이벤트를 발생시키는 로직에 대한 MSDN 은 찾을 수 가 없다.

찾다 찾다... TCPIP로 구현된것이 몇가지 있길래 분석하여 삽질을 통해 알아내고 만들었다. 

 서버 모니터링!!!  2주라...  어차피 등급은 초급이라 돈을 올려줄 순 없다면서 왜 일은 그런걸 시킬까...

어차피 만들고 있지만... 에효... 왠지 공개하기는 싫으넹..


'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

.NET ] 멀티 랭귀지 지원 ...  (0) 2012.03.06
ArrayList.Sort 하기...  (4) 2011.07.29
LINQ] 로또 구하기?  (1) 2011.04.25
[C#]Box 그리기...  (0) 2010.11.29
[C#]TabControl에서 특정 TabPage를 안보이게 감추기..  (0) 2010.11.26

한줄로 로또번호 구하기가 가능하네... Linq 역시 멋지넹... 

LINQ 역시 재미있엉...

 public partial class Form1 : Form
    {
        bool[] numbers = new bool[45];
        Random rd = new Random();
        public Form1()
        {
            InitializeComponent();
        
            var results = numbers.Select( (t, i ) => rd.Next(45) + 1 ).GroupBy( k => k ).TakeWhile((val , idx) => idx < 6 ).OrderBy( g => g.Key );
            listBox1.DataSource = results.ToArray();
            listBox1.DisplayMember = "Key";
        }
    }

'# 4) .Net ( Vs 2010 ) > C#' 카테고리의 다른 글

ArrayList.Sort 하기...  (4) 2011.07.29
[IPC] Event 추가 ~~  (0) 2011.05.14
[C#]Box 그리기...  (0) 2010.11.29
[C#]TabControl에서 특정 TabPage를 안보이게 감추기..  (0) 2010.11.26
[LINQ] 콤마 구분자 넣기?  (0) 2010.11.24


오늘도 pdf를 !!!

 SupportedOrientations="PortraitOrLandscape"  요것은  기기를 눕혔을때 또는 세웠을때 동적으로 레이아웃을 바꾸어준다.
 
Orientation  기기가 어떤방향으로 놓여져 있는지 확인가능한 프로퍼티이다.

+ OnOrientationChanged 가 존재함.


실버라이트로는 소개에 나온곳까지 ... 했넹...

기본 Xaml 소개정도는 건너 띠었고...

XNA GAME 프로젝트를 했더니.. 맨바탕이 뜨네 ...

음.. 다 하나씩 해볼끄낭..


ㅡ.,ㅡ;; 웁쓰 폰트... 없다.. 포비님 블로그 가니 생성도 하드만... 난 목록이 안보이네...

영어공부나 하자 ㅠㅠ...










레이아웃 이용하는 방법을 확인하였다.

_파일명.cshtml   _ 는 참조페이지라는 의미란다. 직접 호출할수 없다고 한다.( 해볼까낭? )

@RenderPage( "_호출페이지")  현재 페이지 호출페이지를 Include 한다. 

위 결과물은 다음과 같다.

 화살표는 읽히는 방향으로 그려두었다. 자세한건 pdf 참조.
 실행페이지는 Content.cshtml 이다.




장난 삼아 10분만에 뚝딱 뽑았다..

디자인 참 단순... 무식하군..


로또 소스  : 짧다..
 public class LottoClass
    {
        public static IEnumerable  Play(int gameCount = 1)
        {
            bool[] boxs = new bool[45];
            List<int> Item = new List<int>();
            Random rd = new Random();
            try
            {
                do
                {
                    int idx = rd.Next() % 45;
                    if (!boxs[idx])
                    {
                        boxs[idx] = true;
                        Item.Add(idx);
                    }
                }
                while (boxs.Count((a) => a == true) < 6);
                Item.Sort();
            }
            catch
            {
            }
            finally
            {
                rd = null;
                Array.Clear(boxs, 0, boxs.Length);
                boxs = null;
            }
            return from o in Item
                   select o+1;                  
        }
    }


메인.xaml ( 데모 소스에서 수정 )
<phone:PhoneApplicationPage
    x:Class="WindowsPhoneApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="당첨기원~♥" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="로또추첨번호" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>          
        </StackPanel>
       
        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="120"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Button Click="Button_Click" Grid.Row="0" Content="뽑기" Margin="2,0,-2,0"></Button>
            <ListBox Name="LottoContents"  Grid.Row="1" ItemsSource="{Binding}">
                    <TextBlock Text="{Binding Path=Name}"></TextBlock>
            </ListBox>
        </Grid>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>

메인.xaml.cs
  public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            LottoContents.DataContext = LottoClass.Play(1);
        }
    }


 재부팅 후 설치 완료하고, 띠웠더니 ... 멍!! 에러가?? 이건 뭐지?

에러 내용 : Connection failed because of invalid command-line arguments.  
해결방법 :   http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/fde4c415-44c5-4837-b1cd-e09727a75b92/
I too am experiencing this issue.  It is definitely an issue associated with the Emulator loading/running  a WP7 bin image.  Can create in standalone mode outside of VS2010 (express) connection.

Step 1:

Open Cmd.exe window (doesn't matter if done as Run-As-Admin, or not)

Step 2:

Change to Emulator directory:
C:\Program Files\Microsoft XDE\1.0


Step 3:

Run WP7 Emulator:
xde.exe C:\Program Files\Microsoft SDKs\WindowsPhone\v7.0\Emulation\Images\WM70C1.bin

 

I glad to provide log files, video, or laptop (live near Redmond) if it will help.

 

Any insight much appreciated,

Thanks,

--Brian

----------------------------------------------------------------------------------------------

실행화면을 보자!! 
 
여리~~ 버튼에 MessageBox를 걸었더니 아래 처럼 메세지 박스가 뜬다.. 소리도.. 띠리링..은 아녔던
것 같고~~~

Button.Text  안되나보다 Content 로 해야 되네...

 오 기대되네... 집에서 할일이 생기다뉘...





http://msdn.microsoft.com/ko-kr/library/ff402531(v=VS.92).aspx

구글 번역기로 개요의 내용을 추려본다.

개발에 필요한 프레임웍 2가지를 제공한다.
  1. 실버라이트 프레임워크   : 이벤트기반, XMAL 기반
  2. XNA 프레임워크 : 루프기반
  ? 클라우드,  Azure, XBOX, WCF, REST, 위치기반 알림서비스 등... 지원한다.

아키텍쳐 
실행화면 :  실버라이트와 XNA로 보안/ 그래픽을 제공한다.
도구 : 비쥬얼스튜디오로 신속하게 만들수 있다.
클라우드서비스 : XBox, Azure, 알림서비스, 위치서비스등... 데이타를 공유할 수 있다? 인가?
포탈서비스 : 개발자 등록을 통해 시장을 제공한다.


실행
실버라이트 : UI
XNA : 게임 활성화.. XBOX, 게임 개발 API를 지원함.
센서 : 멀티터치, 가속도계, 마이크센서등을 API를 이용할수 있다.
미디어 : 실버라이트와 XNA를 통해 미디어관련 API를 이용할수 있다.
데이타 : 데이타를 안전하게 관리할 수 있다.  ( 어떻게 해석하면 이렇게 될까... 망할영어.. )
위치 : 위치API를 통해 사용자의 위치를 알아낼수 있다. 위치가 변경될때 계산을 통해 알수 있고,
API는 클라우드와 연계가 가능하다???

.. 이하 생략..

도구 설치하고 개발가능하고
개발자 등록을 통해 다른 사용자들이 사용할수 있다고 씌여있는 듯 하다.


이런글 남겨두면 영어 못하는거 동네방네 소문내는건데... 쩝...


이론... 영어공부해야되네...

설치중에 실패 ㅠㅠ... 30분깔다 멈추냥 ㅠㅠ.