2017년 6월 9일 금요일

Visual Studio for mac으로 작성된 계산기 앱 소스 입니다.

자마린 스튜디오가 비주얼 스튜디오로 흡수되었습니다.
얼마전 정식 버전이 출시되었죠...
수업용 예제로 사용할 계산기 전체 소스입니다.
C# 코드 + XAML 태그로 구성되어 있습니다.
Xamarin Forms로 만들면 원소스를 아이폰, 안드로이드폰, 윈도우폰 등에서 사용할 수 있습니다.







MainPage.xaml 의 태그들

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="Calculator.MainPage">

    <Grid Padding="5,0" RowSpacing="1"
        ColumnSpacing="1" BackgroundColor="Black">
        <Grid.RowDefinitions>
            <Grid.RowDefinition Height="2*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Label FontAttributes="Bold" 
                FontSize="48" 
                BackgroundColor="Black" Text="0"
                TextColor="White" 
                HorizontalTextAlignment="End" 
                VerticalTextAlignment="Center"
            LineBreakMode="NoWrap" Grid.ColumnSpan="4" />
        <Button Text="7" Grid.Row="1" Grid.Column="0"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="8" Grid.Row="1" Grid.Column="1"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="9" Grid.Row="1" Grid.Column="2"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />

        <Button Text="4" Grid.Row="2" Grid.Column="0"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="5" Grid.Row="2" Grid.Column="1"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="6" Grid.Row="2" Grid.Column="2"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />

        <Button Text="1" Grid.Row="3" Grid.Column="0"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="2" Grid.Row="3" Grid.Column="1"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="3" Grid.Row="3" Grid.Column="2"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />
        <Button Text="0" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" />

        <Button Text="/" Grid.Row="1" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" />
        <Button Text="X" Grid.Row="2" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" />
        <Button Text="-" Grid.Row="3" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" />
        <Button Text="+" Grid.Row="4" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" />

        <Button Text="C" Grid.Row="5" Grid.Column="0"
                BackgroundColor="#808080" TextColor="White"
                FontSize="36" BorderRadius="0" />

        <Button Text="=" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" />
    </Grid>

</ContentPage>


(이벤트를 모두 연결한 MainPage.xaml 코드)
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="Calculator.MainPage">

    <Grid Padding="5,0" RowSpacing="1"
        ColumnSpacing="1" BackgroundColor="Black">
        <Grid.RowDefinitions>
          <RowDefinition Height="2*" />
          <RowDefinition Height="*" />
          <RowDefinition Height="*" />
          <RowDefinition Height="*" />
          <RowDefinition Height="*" />
          <RowDefinition Height="*" />
       </Grid.RowDefinitions>

       <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
       </Grid.ColumnDefinitions>
        
        <Label x:Name="resultText" 
                FontAttributes="Bold" 
                FontSize="48" 
                BackgroundColor="Black" Text="0"
                TextColor="White" 
                HorizontalTextAlignment="End" 
                VerticalTextAlignment="Center"
            LineBreakMode="NoWrap" Grid.ColumnSpan="4" />
        <Button Text="7" Grid.Row="1" Grid.Column="0"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
               Clicked="OnSelectNumber" />
        <Button Text="8" Grid.Row="1" Grid.Column="1"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
               Clicked="OnSelectNumber" /> 
        <Button Text="9" Grid.Row="1" Grid.Column="2"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
               Clicked="OnSelectNumber" />

        <Button Text="4" Grid.Row="2" Grid.Column="0"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
                Clicked="OnSelectNumber" />
        <Button Text="5" Grid.Row="2" Grid.Column="1"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
               Clicked="OnSelectNumber" />
        <Button Text="6" Grid.Row="2" Grid.Column="2"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
               Clicked="OnSelectNumber" />

        <Button Text="1" Grid.Row="3" Grid.Column="0"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0"
               Clicked="OnSelectNumber" /> 
        <Button Text="2" Grid.Row="3" Grid.Column="1"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" 
               Clicked="OnSelectNumber" /> 
        <Button Text="3" Grid.Row="3" Grid.Column="2"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" 
               Clicked="OnSelectNumber" /> 
        <Button Text="0" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3"
               BackgroundColor="White" TextColor="Black"
               FontSize="36" BorderRadius="0" 
               Clicked="OnSelectNumber" /> 

        <Button Text="/" Grid.Row="1" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" 
                Clicked="OnSelectOperator" />
        <Button Text="X" Grid.Row="2" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" 
                Clicked="OnSelectOperator" />
        <Button Text="-" Grid.Row="3" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" 
                Clicked="OnSelectOperator" />
        <Button Text="+" Grid.Row="4" Grid.Column="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0" 
                Clicked="OnSelectOperator" />

        <Button Text="C" Grid.Row="5" Grid.Column="0"
                BackgroundColor="#808080" TextColor="White"
                FontSize="36" BorderRadius="0" 
                Clicked="OnClear" />

        <Button Text="=" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="3"
                BackgroundColor="#FFA500" TextColor="White"
                FontSize="36" BorderRadius="0"
                Clicked="OnCalculate" />
    </Grid>

</ContentPage>

(로직이 모두 추가된 MainPage.xaml.cs파일)
using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace Calculator
{
    public partial class MainPage : ContentPage
    {
int currentState = 1;
string mathOperator;
double firstNumber, secondNumber;

        public MainPage()
        {
            InitializeComponent();
            //reset하는 코드추가 
            OnClear(this, null); 
        }
void OnSelectNumber(object sender, EventArgs e)
{
Button button = (Button)sender;
string pressed = button.Text;

if (this.resultText.Text == "0" || currentState < 0)
{
this.resultText.Text = "";
if (currentState < 0)
currentState *= -1;
}

this.resultText.Text += pressed;

double number;
if (double.TryParse(this.resultText.Text, out number))
{
this.resultText.Text = number.ToString("N0");
if (currentState == 1)
{
firstNumber = number;
}
else
{
secondNumber = number;
}
}
}

void OnSelectOperator(object sender, EventArgs e)
{
currentState = -2;
Button button = (Button)sender;
string pressed = button.Text;
mathOperator = pressed;
}

void OnClear(object sender, EventArgs e)
{
firstNumber = 0;
secondNumber = 0;
currentState = 1;
this.resultText.Text = "0";
}

void OnCalculate(object sender, EventArgs e)
{
if (currentState == 2)
{
var result = SimpleCalculator.Calculate(firstNumber, secondNumber, mathOperator);

this.resultText.Text = result.ToString("N0");
firstNumber = result;
currentState = -1;
}
}

    }
}

(SharedResources.cs파일)
using System;
using Xamarin.Forms; 

namespace Calculator
{
    public static class SharedResources
    {
        public static Color OpButtonBkColor
        {
            get { return Color.FromRgb(0xff, 0xa5, 0);  }
        }
    }
}



2017년 6월 8일 목요일

8월에 오픈할 자마린 프로그래밍 과정을 준비하고 있습니다.

작년부터 자료를 수집하고 조금씩 준비하고 있던 자마린 프로그래밍 과정입니다.
한국 마이크로소프트에 모여서 몇달간 같이 스터디도 하고 발표도 했습니다. 조금씩 정리도 되고 틀이 잡혀가네요.

azure에 ASP.NET MVC  기반의  Web API를 사용해서 GET/PUT/POST/DELETE메서드를 구현해서 json으로 통신하도록 준비한 웹사이트 입니다.


매우 저렴하게 구할 수 있는 중국산 안드로이드 타블렛입니다. 50에서 60불 수준입니다. ZTE Trek2 입니다. C#으로 짠 안드로이드 앱을 배포했습니다. 


C#으로 짠 아이폰앱을 6S plus에 배포했습니다. 


2017년 5월 24일 수요일

2017년 4월 11일 화요일

2017년 4월 6일 목요일

AR/VR 과정이 오픈되었습니다. HTC의 VIVE와 갤럭시 기어 .VR로 강의장이 셋팅되었네요.

기술이 이렇게 발전하는군요. ㅋㅋㅋㅋ
멀캠 강의장 중에 하나가 오늘 셋팅되었습니다. HTC에서 나온 VIVE라는 기기입니다. 별도의 피씨가 필요합니다. 약 100만원정도에 셋팅할 수 있는 사양입니다. 여기에 바이브를 연결하면 됩니다. 유저의 모션을 트랙킹할 수 있는 장비가 2개 있고 양손에 컨트롤러를 들고 스팀 게임을 하면 됩니다. 
바이브의 가격은 125만원입니다. 1년전보다 1/10의 가격으로 떨어진 상태라고 합니다. 



안경을 쓴 상태에서 착용해 보니 많이 불편합니다. ㅠㅠ 


양손에 들고 공을 잡거나(아래쪽에 버튼이 있습니다), 아니면 활을 쏘거나 하는 다양한 액션이 가능하고 바로 바로 진동으로 피드백이 옵니다. 



유저의 위치와 모션을 트랙킹하는 레이저를 쏩니다. 잠시 시연을 해 보았는데 무척 신기합니다. 갤럭시 기어 VR하고는 차원이 다르네요. ㅋㅋㅋ 


2017년 4월 5일 수요일

파이썬 기반의 장고(django) web framework와 jqGrid를 같이 사용하기

파이썬 기반의 장고(django) web framework와 jqGrid를 같이 사용하기

https://github.com/gerry/django-jqgrid


2017년 4월 4일 화요일

파이썬 Flask 학습에 관련된 자료들입니다.

파이썬 Flask 학습에 관련된 자료들입니다.

http://carpedm20.blogspot.kr/2013/07/python-web-framework-flask.html

아래와 같이 모듈을 설치하면 됩니다.
$ flask\Scripts\pip install flask
$ flask\Scripts\pip install flask-login
$ flask\Scripts\pip install flask-openid
$ flask\Scripts\pip install flask-mail
$ flask\Scripts\pip install flask-sqlalchemy
$ flask\Scripts\pip install sqlalchemy-migrate
$ flask\Scripts\pip install flask-whooshalchemy
$ flask\Scripts\pip install flask-wtf
$ flask\Scripts\pip install flask-babel
$ flask\Scripts\pip install guess_language
$ flask\Scripts\pip install flipflop
$ flask\Scripts\pip install coverage

제 AI는 스스로 생각하고 학습한다.. 난리난 AI 에이전트 직접 확인해보니 - 영상정리해 봅니다.

  ChatGPT가 나온지 3년이 넘었습니다. ㅎㅎ 처음에는 생성형AI에서 LLM으로 시장이 변화되었습니다. 작년말부터는 에이전트의 시대라고 하고 있습니다. 저도 관련 강의를 하고 일을 하고 있지만 따라가기가 벅찰정도로 매주 새로운 소식들이 올라옵니다...