GSI

Posted by gsi
:

본 자료는 해당 책의 부록 내용을 따라 하면서 작성해 본것입니다.
자세한 DB 자료 및 기타 다른 내용은 따로 요청 하시거나..
관련책 홈페이지를 통해서 찾으실 수 있습니다.

관련책 이름 : 비주얼 웹 디벨로퍼 2005 익스프레스로 배우는 ASP.NET 2.0

Posted by gsi
:

[DB 테이블 내용]

NoteDB
   > 테이블
      >note(dbo.note)
         nid : int : No null
         name : varchar(20) : null
         content : text : null
         email : varchar(32) : null
         date : datetime : null

[저장 프로시저 내용]

USE [NoteDB]
GO
/****** 개체:  StoredProcedure [dbo].[sp_AddNote]    스크립트 날짜: 09/27/2007 01:57:39 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER Procedure [dbo].[sp_AddNote]
(
    @Name   varchar(50),
    @Content  varchar(400),
    @Email      varchar(50)
)
AS

INSERT INTO Note
(
    name, content, email, date
)
VALUES
(
    @Name, @Content, @Email, getdate()
)

[코드 내용]

//커텍션 스트링 지정
string source = @"Data Source=GSI;Initial Catalog=NoteDB;Persist Security Info=True;User ID=sa;Password=****";
//커넥션 개체 생성
SqlConnection conn;
conn = new SqlConnection(source);
//커넥션 오픈
conn.Open();

//저장 프로시저 오픈 및 값 저장
SqlCommand cmd = new SqlCommand("sp_AddNote", conn);
cmd.CommandType = CommandType.StoredProcedure;

SqlParameter param1 = new SqlParameter("@Name", SqlDbType.VarChar, 50);
param1.Value = name; //컨트롤로 부터 이름 저장
cmd.Parameters.Add(param1);

SqlParameter param2 = new SqlParameter("@Content", SqlDbType.VarChar, 400);
param2.Value = content; //컨트롤로 부터 컨텐트 저장
cmd.Parameters.Add(param2);

SqlParameter param3 = new SqlParameter("@Email", SqlDbType.VarChar, 50);
param3.Value = email; //컨트롤로 부터 이메일 저장
cmd.Parameters.Add(param3);

//
cmd.ExecuteNonQuery();

//기타 내용 추가 하기

//커넥션 닫기
conn.Close();

Posted by gsi
:

SqlDataReader 사용법

DB&XML 2007. 9. 27. 01:36 |

DB 테이블 내용
NoteDB
   > 테이블
      >note(dbo.note)
         nid : int : No null
         name : varchar(20) : null
         content : text : null
         email : varchar(32) : null
         date : datetime : null

위의 내용은 SQL DB 내용을 요약한 것입니다.
한줄 짜리 메모용으로 사용되어질 테이블 내역입니다.

위의 내용을 SqlDataReader를 사용해서 접근하고 데이터를 가져 오는 방법을 기술하였습니다.

//커넥션 스트링을 지정합니다.
string source = @"Data Source=GSI;Initial Catalog=NoteDB;Persist Security Info=True;User ID=sa;Password=****";

//커텍션 스트링을 사용해서 SqlConnection을 생성합니다.
SqlConnection conn;
conn = new SqlConnection(source);

//커텍션을 오픈합니다.
conn.Open();

//SqlDataReader 용 객체를 가져 옵니다.
//이때 쿼리문을 커넥션에 적용해서 값을 가져 오게 됩니다.
SqlDataReader reader = conn.ExecuteReader("SELECT * FROM note");

//아래의 코드는 웹에서 Response를 사용해서 값을 가져 오는 방법입니다.
Response.Write("<td>" + reader["nid"] + "</td>");
Response.Write("<td>" + reader["name"] + "</td>");
Response.Write("<td>" + reader["content"] + "</td>");
Response.Write("<td>" + reader["email"] + "</td>");
Response.Write("<td>" + reader["date"] + "</td>");

>>위와 같이 reader["컬럼이름"]를 사용해서 값을 가져 올 수 있습니다.

//커넥션을 닫습니다.
conn.Close();

Posted by gsi
:

ASP.NET 2.0 개발을 처음 하다 보면 가끔 나오는 오류인듯..
IIS 의 asp 버젼을 1.0 으로 초기 설정 되어 있다면 아래의 PostBack 코딩 부분에서
오류가 나게 되는거 같습니다.

 [오류내용]

'/aspx' 응용 프로그램에 서버 오류가 있습니다.

파서 오류

설명: 이 요청을 제공하는 데 필요한 리소스를 구문 분석하는 동안 오류가 발생했습니다. 아래의 구문 분석 오류 정보를 확인한 다음 소스 파일을 적절하게 수정하십시오.

파서 오류 메시지: 'PostBack' 형식을 로드할 수 없습니다.

소스 오류:

줄 1:  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PostBack.aspx.cs" Inherits="PostBack" %>
줄 2:  
줄 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

소스 파일: C:\Inetpub\wwwroot\Project\ch05\ObjectEx\PostBack.aspx    줄: 1


버전 정보: Microsoft .NET Framework 버전:1.0.3705.0; ASP.NET 버전:1.0.3705.0

[해결방법]
IIS의 해당 가상 디렉토리의 등록 정보에 들어가서 "ASP.NET" 탭을 선택합니다.
ASP.NET 버전 : 2.0.***** 를 선택 합니다.

이후에 실행하면 에러가 나지 않네요.
버젼 차이만 있는건지 혹시 아시는분 답변 주세요 ^^
Posted by gsi
:

음.. 디자인이란.. 어렵다..
Window Media Player 에 있는 디자인과 비슷한 느낌을 주기 위해서
포토샵으로 몇개 만들어서 적용해 봤다.

UX가 중요시 되고 있는 시점에서 디자인이란 더욱더 사용자로 하여금
요구되어 지고 있는거 같다.

웹 프로그램을 잘 짜지 못하니.. 요즘 Asp.NET 를 배우고 있는데
내년 쯤이면 나만의 웹 페이지를 만들수 있을거 같은데..

나 자신을 위해서 화이팅!!!..
Posted by gsi
:

[C++] Cast에 대해서... (펌)

C++ 2007. 9. 20. 17:14 |

관련 주소 : http://blog.naver.com/process3?Redirect=Log&logNo=20017834722
본 글은 cast 쪽을 보면서 자료로 참고 하기 위해서 퍼 왔습니다.

캐스트 연산은 주어진 식이 가지고 있는 형을 다른 형으로 강제로 바꾸는것입니다.

C++에는 (C 시절부터 존재하는 C 스타일 캐스트를 제외하고) 다음 네 가지 종류의 캐스트 연산이 있습니다.

* dynamic_cast
* static_cast
* reinterpret_cast
* const_cast

---------------
1. dynamic_cast
---------------

dynamic_cast(e)는 부모 클래스와 자식 클래스의 관계에 있는 포인터 형 사이의 변환 또는 레퍼런스 형 사이의 변환을 수행하는데,

- 같은 형 사이의 변환
- 널 포인터의 변환
- 자식 클래스로부터 부모 클래스로의 변환
과 같은 '뻔한' 경우가 아니라면 e는 다형적 형(polymorphic type; 가상 함수가 포함된 클래스 형)의 좌변값이나 포인터여야 하며, 컴파일시에 변환이 이루어지는 다른 종류의 캐스트 연산과는 달리 실행시에 동적 형(dynamic type)에 근거한 변환이 시도되고, 변환의 성공 여부를 검사하는 의미도 함께 가지고 있습니다.

포인터의 경우 변환이 실패하면 결과값은 널 포인터가 되는데, 이를 if 등의 조건 검사에 활용할 수 있습니다.

struct animal { virtual void ~animal(); };
struct dog : animal { void bark(); };
struct cat : animal { void mew(); };

void test(animal* a)
{
if (dog* d = dynamic_cast(a)) d->bark(); else
if (cat* c = dynamic_cast(a)) c->mew();
}

레퍼런스의 경우 변환이 실패하면 헤더에 정의되어 있는 std::bad_cast 예외가 발생합니다. 즉 이는 주어진 변환이 성공할 것을 알고 있을 때 주로 사용합니다.

void test(animal& a)
{
dog& d = dynamic_cast(a);
d.bark();
}

dog d; test(d); // 성공
cat c; test(c); // 실패 - std::bad_cast 예외 발생

dynamic_cast와 비슷한 성질을 가지고 있으면서 변환 대신 형 검사만 하는 typeid 연산자도 있는데, 피연산자는 식이나 형이 되고, 연산의 결과값은 헤더에 정의되어 있는 std::type_info 형의 좌변값입니다.

void test_equal(animal& x, animal& y)
{
if (typeid(x) == typeid(y)) { /* 같은 종류 */ }
else { /* 다른 종류 */ }
}

void test_dog(animal& x)
{
if (typeid(x) == typeid(dog)) { /* x is a dog */ }
}

dynamic_cast와 typeid는 C++에서 제공하는 실행시의 형 정보(RTTI; run-time type information)의 일환인데, 이를 남발하면 클래스 체계를 확장하고 관리하기가 어려워지므로 꼭 필요한 경우에만 사용하고 되도록 가상 함수를 통한 다형성을 이용하는 것이 바람직합니다.

--------------
2. static_cast
--------------

static_cast(e)는 가장 일반적인 형태의 캐스트 연산으로, 어떤 임시 변수 t를 T t(e);와 같이 선언하고 초기화하여 그 임시 변수 t의 값을 사용하는 것과 같은 암시적인 변환을 비롯하여, 산술형(char, int, double 등) 및 열거형(enum) 사이의 변환, 부모 클래스와 자식 클래스의 관계가 관련된 변환, void 형으로의 변환 등을 수행할 수 있습니다. 다만 부모 클래스와 자식 클래스 사이의 변환은 주어진 식의 동적 자료형(dynamic type)이 아닌 정적 자료형(static type)에 전적으로 의존합니다.

inline int integer_quotient(double a, double b)
{ return static_cast(a / b); }

animal* a = new dog;
dog* d = static_cast(a); // 올바른 캐스트 연산

animal* a = new cat;
dog* d = static_cast(a); // 잘못된 캐스트 연산

animal* a = new animal;
dog* d = static_cast(a); // 잘못된 캐스트 연산

-------------------
3. reinterpret_cast
-------------------

reinterpret_cast(e)는 서로 다른 형의 포인터 사이의 변환이나, 정수와 포인터 사이의 변환 등 서로 관계가 없는 형 사이의 변환을, 구현체가 정의하는 방법에 따라 수행합니다. 정수와 포인터 사이의 변환의 결과값은 주로 e를 표현하는 비트열을 그대로 정수 및 포인터로 해석한 값이 됩니다.

reinterpret_cast는 그 변환 방법이 대부분 구현체가 정의하도록 맡겨져 있어서 이식성을 떨어뜨리며, 요구된 변환이 올바른 변환인지의 여부를 검사하지 않으므로 신중하게 사용해야 합니다.

unsigned char* const video_base =
reinterpret_cast(0x80000000);

unsigned int ui = 0x01234567;
*reinterpret_cast(&ui) = 0xFF;

-------------
4. const_cast
-------------

const_cast(e)는 const 또는 volatile으로 한정된 형에서 이들을 떼어내는 변환을 수행할 수 있습니다. 이는 C++ 형 체계를 무너뜨릴 수 있으므로 신중하게 사용해야 합니다.

void lie(const int* pci)
{
int* pi = const_cast(pci);
*pi = 0;
}

int i = 1;
lie(&i); // OK

const int ci = 1;
lie(&ci); // Ouch!!


위 네 가지 중에서 dynamic_cast를 제외한 셋은 C에서 (type)expression 의 형태로 사용할 수 있었던 것인데, C++에서도 "C 스타일 캐스트 연산" 이라고 불리며 남아 있기는 합니다만, 새로 작성하는 C++ 코드에서는 C++ 스타일의 캐스트 연산을 사용하는 것이 좋습니다. 이는 어떤 종류의
변환을 프로그래머가 의도하는지 명확하게 나타내 주며, 위험할 수 있는 캐스트 연산이 코드에서 좀 더 두드러져 보이도록 하고 찾기도 쉽게 만들어주기 때문입니다.

위의 내용은 캐스트 연산에 대한 일반적인 설명인데, 좀 더 구체적인 상황에서의 적용 예를 보고 연습을 해 보시려면 GotW #17을 참조해 보시기 바랍니다.



출처 : http://funspace.org/
Posted by gsi
:

Where does a Binding find its data?

If you’ve look at much WPF Xaml you’ve probably seen bindings like this:

 

<TextBlock Text="{Binding Name" />

 

… which binds the Text property of the TextBlock to the Name property of some data object.

 

The question that begets is:  where does the data come from?  The rest of this post looks at the answer.

 

 

Properties on Binding

 

The Binding class has a few properties that provide ways to let you set the source of the data onto the Binding, depending on what works best for your situation.   Binding looks like this:

 

public class Binding : BindingBase

{

    ...

    public object Source { get; set; }

    public string ElementName { get; set; }

    public RelativeSource RelativeSource { get; set; }

    ...

}

 

 

The Source Property

 

The most straightforward way to set the source of the Binding is to use the Source property.  One of the more common ways to do that is to reference the data out of a resource dictionary:

 

<Grid>

  <Grid.Resources>

    <Int32Collection x:Key='DataSource1'>1,2,3</Int32Collection>

  </Grid.Resources>

 

  <ListBox ItemsSource='{Binding Source={StaticResource DataSource1}}' />

</Grid>

 

(This example creates a ListBox with 3 entries in it, labeled “1”, “2”, and “3”.)

 

You can be even more explicit by setting the Source directly, specifying the Binding in full Xml syntax (rather than the above markup extension syntax):

 

<Grid>

  <ListBox>

    <ListBox.ItemsSource>

      <Binding>

        <Binding.Source>

          <Int32Collection>1,2,3</Int32Collection>

        </Binding.Source>

      </Binding>

    </ListBox.ItemsSource>

  </ListBox>

</Grid>

 

You can also set the Binding.Source by referencing a static member:

 

namespace MyNamespace

{

    class MyClass

    {

        public static List<int> MyData;

        static MyClass()

        {

            MyData = new List<int>();

            MyData.Add(1);

            MyData.Add(2);

            MyData.Add(3);

        }

 

    }

}

 

 

<Page

    xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'

    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'

    xmlns:my="clr-namespace:MyNamespace" >

 

  <ListBox ItemsSource='{Binding Source={x:Static my:MyClass.MyData}}' />

 

</Page>

 

 

The ElementName Property

 

Aside from the Binding.Source property, you can also reference your data by name, using Binding.ElementName, such as:

 

<StackPanel>

  <TextBox Name='TextBox1' />

  <Button Content='{Binding Text, ElementName=TextBox1}' />

</StackPanel>

 

(This example causes the button label to be whatever you type into the text box.)

 

 

The RelativeSource Property

 

The RelativeSource property provides a way to tell the Binding to look around where it’s used to find its source.  For example, the ‘Self’ RelativeSource binds to the object on which the Binding is placed, such as in the following (which creates a TextBlock that says “Hi”):

 

<TextBlock Tag='Hi' Text='{Binding Tag, RelativeSource={RelativeSource Self}}' />

 

As another example, the following binds the TextBlock.Text property to the Grid in its ancestry (again displaying “Hi” in this case):

 

<Grid Tag='Hi'>

 

  <Border Background='LightGray'>

    <TextBlock

         Text='{Binding Tag, RelativeSource={RelativeSource FindAncestor, AncestorType=Grid}}' />

  </Border>

 

</Grid>

 

The other two modes of a RelativeSource are TemplatedParent and PreviousData.

 

Explicit DataContext Property

 

A common way the Binding can get its source is via a DataContext property set on an element (on the element itself, not on the Binding).  For (a rather boring) example, this creates a Button that says “Click”:

 

<Button Content='{Binding}'>

  <Button.DataContext>

    <sys:String>Click</sys:String>

  </Button.DataContext>

</Button>

 

This gets more interesting and typical if you set the DataContext somewhere else, usually on the root of the page/window.  That works because the DataContext property inherits.  The following example shows that by setting the DataContext onto the root.  In this case, it is set to be an XmlDataProvider which is querying a Yahoo web service for the weather in Barrow, Alaska.  Since the DataContext inherits, Bindings throughout the page have access to it automatically.  Note also in this case that since we’re binding to XML, the Bindings are using XPath syntax.

 

<Page   

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 

    >

 

  <Page.DataContext>

    <XmlDataProvider

            Source="http://xml.weather.yahoo.com/forecastrss?p=99723" 

            XPath="/rss/channel"/>

  </Page.DataContext>

 

  <Border BorderBrush="Black"

          BorderThickness="1" Width="370" Height="170" CornerRadius="6">

    <StackPanel>

 

      <!-- Image for "Yahoo! News" -->

      <Image Margin="15,15,0,0"

                   Stretch="None" 

                   HorizontalAlignment="Left"

                   Source="{Binding XPath=image/url}" />

 

      <!-- Text to say e.g. "Yahoo! Weather - Bellevue, WA", with a hyperlink to a

           detailed weather page -->

      <TextBlock Margin="15,15,0,0">

        <Hyperlink NavigateUri="{Binding XPath=item[1]/link}">

          <TextBlock Text="{Binding XPath=title}"/>

        </Hyperlink>

      </TextBlock>

 

      <!-- Text to say e.g. "Conditions for Belleveue, WA at 9:53am ..." -->

      <TextBlock FontWeight="Bold"    Margin="15,15,0,0"

                 Text="{Binding XPath=item[1]/title}"/>

 

      <!-- Weather details  -->

      <TextBlock Margin="15,0,0,0">

 

        <!-- Text to say current condition and temp -->

        <TextBlock>

          <TextBlock.Text>

            <Binding >

              <Binding.XPath>

                item[1]/*[local-name()="condition" and

                namespace-uri()="http://xml.weather.yahoo.com/ns/rss/1.0"]/@text

              </Binding.XPath>

            </Binding>

          </TextBlock.Text>

        </TextBlock>,

        <TextBlock>

          <TextBlock.Text>

            <Binding >

              <Binding.XPath>

                item[1]/*[local-name()="condition" and

                namespace-uri()="http://xml.weather.yahoo.com/ns/rss/1.0"]/@temp

              </Binding.XPath>

            </Binding>

          </TextBlock.Text>

        </TextBlock>°

        <TextBlock>

          <TextBlock.Text>

            <Binding >

              <Binding.XPath>

                *[local-name()="units" and

                namespace-uri()="http://xml.weather.yahoo.com/ns/rss/1.0"]/@temperature

              </Binding.XPath>

            </Binding>

          </TextBlock.Text>

        </TextBlock>

        <LineBreak/>

 

        <!-- Text to say sunrise/sunset times -->

        Sunrise:

        <TextBlock>

          <TextBlock.Text>

            <Binding >

              <Binding.XPath>

                *[local-name()="astronomy" and

                namespace-uri()="http://xml.weather.yahoo.com/ns/rss/1.0"]/@sunrise

              </Binding.XPath>

            </Binding>

          </TextBlock.Text>

        </TextBlock>, sunset:

 

        <TextBlock>

          <TextBlock.Text>

            <Binding >

              <Binding.XPath>

                *[local-name()="astronomy" and

                namespace-uri()="http://xml.weather.yahoo.com/ns/rss/1.0"]/@sunset

              </Binding.XPath>

            </Binding>

          </TextBlock.Text>

        </TextBlock>

      </TextBlock>

    </StackPanel>

 

  </Border>

</Page>

 

… Sunrise at midnight, sunset at noon:

 

Attachment: barrow.jpg (11494 bytes)

 

 

Implicit DataContext

 

Finally, there are a couple of places where the DataContext gets set automatically for you.  That usually happens with ContentControl (e.g. Button) and ItemsControl (e.g. ListBox). 

 

Here’s a ContentControl example.  In this markup we have a DataTemplate set up in a ResourceDictionary so that it will be used for any ContentControl that has a String as its content.  So it’s automatically picked up in the subsequent Button.  In that DataTemplate, we have a binding to the data item, which in this case is the ContentControl.Content.  Therefore what we get here is a Button that says “Click” in bold italic.

 

<Page   

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 

    xmlns:sys="clr-namespace:System;assembly=mscorlib" >

 

  <Page.Resources>

    <DataTemplate DataType="{x:Type sys:String}">

      <!-- The Text property is bound to the Content property of

           whatever ContentControl with which this DataTemplate is used -->

      <TextBlock Text='{Binding}' FontStyle='Italic' FontWeight='Bold' />

    </DataTemplate>

  </Page.Resources>

 

  <Button>Click</Button>

 

</Page>

 

 

And here’s an ItemsControl example.  In this markup, we have a ListBox bound to an integer collection again (using the inherited DataContext as the source), but this time we have an item template, which is a  template to use when displaying the items in the ListBox.  And within that item template, the DataContext is again automatically set to be the item

 

<Page   

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml >

 

  <Page.DataContext>

    <Int32Collection>1,2,3</Int32Collection>

  </Page.DataContext>

 

  <!-- ItemsSource is bound to the DataContext (Int32Collection) -->

  <ListBox ItemsSource='{Binding}' >

    <ListBox.ItemTemplate>

      <DataTemplate>

 

        <DataTemplate.Triggers>

          <!-- Within the DataTemplate, the DataContext is set to be the data item.

               So this DataTrigger.Binding property's DataContext is going to be

               the item (1, 2, or 3) -->

          <DataTrigger Binding='{Binding}' Value='2'>

            <Setter Property='TextBlock.FontStyle' Value='Italic' />

            <Setter Property='TextBlock.FontWeight' Value='Bold' />

          </DataTrigger>

        </DataTemplate.Triggers>

 

        <Border Padding='10'>

          <!-- Similarly this Text property is bound to the item (1, 2, or 3) -->

          <TextBlock Text='{Binding}' />

        </Border>

      </DataTemplate>

    </ListBox.ItemTemplate>

  </ListBox>

</Page>

Posted by gsi
:

RectAnimation anima = new RectAnimation();
anima .From =
new Rect(100, 100, 200, 200);
anima .To =
new Rect(0, 0, 400, 400);
anima .Duration =
new Duration(TimeSpan.FromSeconds(1));
anima .AutoReverse =
true;
anima .RepeatBehavior =
RepeatBehavior.Forever;
AnimationClock clock = anima .CreateClock();
dc.DrawRectangle(
Brushes.Blue, null, new Rect(0, 0, 0, 0), clock);

Posted by gsi
:

xaml 코드에서 Completed="OnCompleted" 를 사용해서 에니메이션이 완료 되었을때 처리코드를 추가 할 수 있다.

<
Window.Resources>
  <
Storyboard x:Key="sb1" Completed="OnCompleted"
>
     <
DoubleAnimation  Storyboard.TargetName="deactiveAnimationRectangle" Storyboard.TargetProperty="Width" From="20" To="400" Duration="0:0:5"
/>
     <
DoubleAnimation Storyboard.TargetName="holdEndAnimationRectangle" Storyboard.TargetProperty="Width" From="10" To="400" Duration="0:0:1.5" BeginTime="0:0:0.5"
/>
</
Storyboard
>
</
Window.Resources
>

Being able, when animation ended, to set rectangle Width using: holdEndAnimationRectangle.Width = 250;

Also tried:

void OnCompleted (object sender, EventArgs e)
{
  Storyboard sb = (Storyboard)this.FindResource("sb1"
);
  sb.FillBehavior = FillBehavior
.Stop;
  holdEndAnimationRectangle.Width = 250;
}

Posted by gsi
:

<Window x:Class="WpfApplication.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow">

    <Canvas>

        <Button x:Name="MyButton" Loaded="MyButton_Loaded">Button</Button>

    </Canvas>

</Window>

 

        private void MyButton_Loaded(object sender, RoutedEventArgs e)

        {

            const string TranslateTransformName = "MyAnimatedTranslateTransform";

 

            TranslateTransform tt = new TranslateTransform(50, 50);

            NameScope.SetNameScope(tt, new NameScope());

            this.RegisterName(TranslateTransformName, tt);

            this.MyButton.RenderTransform = tt;

 

            Storyboard sb = new Storyboard();

 

            DoubleAnimation daX = new DoubleAnimation(50, 200, new Duration(new TimeSpan(0, 0, 5)));

            daX.AutoReverse = true;

            daX.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard.SetTargetName(daX, TranslateTransformName);

            Storyboard.SetTargetProperty(daX, new PropertyPath(TranslateTransform.XProperty));

            sb.Children.Add(daX);

 

            DoubleAnimation daY = new DoubleAnimation(50, 200, new Duration(new TimeSpan(0, 0, 5)));

            daY.AutoReverse = true;

            daY.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard.SetTargetName(daY, TranslateTransformName);

            Storyboard.SetTargetProperty(daY, new PropertyPath(TranslateTransform.YProperty));

            sb.Children.Add(daY);

 

            DoubleAnimation daW = new DoubleAnimation(50, 200, new Duration(new TimeSpan(0, 0, 5)));

            daW.AutoReverse = true;

            daW.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard.SetTargetName(daW, "MyButton");

            Storyboard.SetTargetProperty(daW, new PropertyPath(Button.WidthProperty));

            sb.Children.Add(daW);

 

            DoubleAnimation daH = new DoubleAnimation(50, 200, new Duration(new TimeSpan(0, 0, 5)));

            daH.AutoReverse = true;

            daH.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard.SetTargetName(daH, "MyButton");

            Storyboard.SetTargetProperty(daH, new PropertyPath(Button.HeightProperty));

            sb.Children.Add(daH);

 

            sb.Begin(this.MyButton);

        }

Posted by gsi
:

세삼 느끼는 거지만 msdn의 예제는 너무 xaml 중심으로 되어 있다.
이런 코드의 예제가 절실하게 필요한 때인거 같다.

-- XAML CODE—

 

<Storyboard x:Key="OnCalendarLoaded">

 <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"

Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(SkewTransform.AngleX)"

Storyboard.TargetName="TargetShape">

                        <SplineDoubleKeyFrame   KeySpline="0.5,0.5,0.5,0.5" Value="0" KeyTime="00:00:00"/>

                        <SplineDoubleKeyFrame   KeySpline="0.5,0.5,0.5,0.5" Value="15" KeyTime="00:00:01"/>

            </DoubleAnimationUsingKeyFrames>

      </Storyboard>

….

          <Rectangle Stroke="White" Margin="0,20,0,0"

            Width="120" Height="100"

            x:Name="TargetShape"

            Fill="sc#0.400752217, 0.3677801, 0.3677801, 0.3677801">

              <Rectangle.RenderTransform>

                <TransformGroup>

                  <TranslateTransform X="0" Y="0"/>

                  <ScaleTransform ScaleX="0" ScaleY="0"/>

                  <SkewTransform AngleX="15" AngleY="0"/>

                  <RotateTransform Angle="0"/>

                  <TranslateTransform X="0" Y="0"/>

                  <TranslateTransform X="0" Y="0"/>

                </TransformGroup>

              </Rectangle.RenderTransform>

            </Rectangle>

 

Void StartAnimationsFunction()

{

      Storyboard story = (Storyboard)this.FindResource("OnCalendarLoaded");

      BeginStoryboard(story); // IT WORKS!

}

 


 

-- C# CODE --

 

<Storyboard x:Key="OnCalendarLoaded">

      </Storyboard>

 

 

Void StartAnimationsFunction ()

{

      Storyboard story = (Storyboard)this.FindResource("OnCalendarLoaded");

story.Children.Add(getAnimation1("TargetShape"));

      BeginStoryboard(story); // NOTHING HAPPENS!

}

       

        private DoubleAnimationUsingKeyFrames getAnimation1(string name)

        {

            DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();

            anim.BeginTime = new TimeSpan(0, 0, 0);

 

            Storyboard.SetTargetName(anim, name);

            Storyboard.SetTargetProperty(anim,

                new PropertyPath("0.1[2].2", new DependencyProperty[] {

                    UIElement.RenderTransformProperty,

                    TransformGroup.ChildrenProperty,

                    SkewTransform.AngleXProperty}));

 

            anim.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0)), new KeySpline(.5, .5, .5, .5)));

            anim.KeyFrames.Add(new SplineDoubleKeyFrame(15, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 1)), new KeySpline(.5, .5, .5, .5)));

 

            return anim;

        }

Posted by gsi
:

XmlDataProvider 를 Blend에서 선언할때는 특정 경로를 통해서 입력 하게 되어 있다.
그것을 xaml 파일에서 바꾸는 방법은 잘 모르겠고,

템플릿 디자인 할때는 Blend에서 바로 적용해서 해보는게 편하니 그렇게 해야 할거 같다.

해당 주소에 대한 xml 파일 정보를 읽어 오기 위해서 아래와 같이 작성하였다.

[xaml]
<XmlDataProvider x:Key="memberDS" d:IsDataSource="True" Source="http://localhost/azit/tazit/member.xml"/>

[cs]
private void OnClick(object sender, System.Windows.RoutedEventArgs e)
{
 XmlDataProvider provider = this.Resources["memberDS"] as XmlDataProvider;
 if(provider != null) provider.Source = new Uri(UrlText.Text);
}

1. xaml 파일의 Source 부분은 당장 없어도 이상은 없다.
2. UrlText.Text 부분은 텍스트 에디터를 입력 받는 컨트롤이다.
3. 버튼 이벤트를 통해서 Url 경로를 넘겨 주고 자동으로 로딩되게 처리해봤다.
Posted by gsi
:

가끔은....

내 일상 2007. 9. 19. 02:09 |

내가 힘들게 한 사람이 몇명이나 될까..
문득 그 생각이 들었다.

하지만 그 책임은 내가 져야 하는것도 안다.
언제일까?..
아마도 한참 좋아 지고 있을때.. 안좋은 일이 생기는 거니까.
난 지금이 좋다. 뭐든지 할 수 있고, 내가 좋아 하는 사람과 살고 있고..

지금일까?..

하지만 내가 나이가 먹은 만큼 내가 받아 들이고 가야 할 것도 많은거 같다.

언제까지 지금 마음 변치 말고 앞을 향해서 가보자..

그게 인생인듯 하다..

나이가 들면서 삶의 무게를 조금씩 짊어지고 가면서
그 짐들을 조금씩 해결해 가는것..

사는 의미는 어떻게 보면 허무하면서도..
그걸 해결하고 조금더 나은 삶을 살고 싶어 하는 욕망이 있기 때문에
살수 있는거 아닐까?..

Posted by gsi
:

몇주동안 풀리지 않던 문제가 오늘 풀렸다.

HTTP를 사용한 XML 데이터 접근 쪽에서 해결하였다.
IIS 설정 부터 해서 템플릿 까지 여러가지 설정이 있었지만.
결과적으로 Blend(wpf) 쪽에서 원하는 데이터를 접근해서 사용하는 것은 가능해졌다.

이제 그 결과를 화면에 어떻게 뿌려 볼지 및 기타 동작들에 대해서 조금씩 더 추가해보자.

iamgsi 화이팅!!!
Posted by gsi
: