블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Category

Recent Post

Recent Comment

Archive

'.Net Project'에 해당되는 글 538

  1. 2009.12.01 46장 InkPresenter 컨트롤
  2. 2009.12.01 45장) Drag&Drop 컨트롤
  3. 2009.12.01 42장) ScrollViewer 컨트롤
  4. 2009.12.01 41장) ToolTip 컨트롤
2009. 12. 1. 16:00 .Net Project/SilverLight 3.0
반응형
  InkPresenter  Control
 -
  InkPresenter.Xaml
  

<UserControl x:Class="RiaInkPresenter.MainPage"

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

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

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel>

            <Button x:Name="btnCleare"

                        Background="Blue"

                       Width="400" Height="25"

                       Content="íe|" FontSize="15"></Button>

           

            <InkPresenter x:Name="ipPen"

                          Background="Silver"

                          Width="400"

                          Height="300">           

            </InkPresenter>

        </StackPanel>      

    </Grid>

</UserControl>


 InkPresenter.CS 실행화면..)


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using System.Windows.Ink;

 

namespace RiaInkPresenter

{

    public partial class MainPage : UserControl

    {

        //Stroke Shape Type : Pen Shape

        private Stroke stroke;

        private Brush brush = new SolidColorBrush(Colors.Red); //[A] Pen Save

 

        public MainPage()

        {

            InitializeComponent();

           

            ////Click Event

            this.ipPen.MouseLeftButtonDown += new MouseButtonEventHandler
                                                  (ipPen_MouseLeftButtonDown);

            this.ipPen.MouseMove += new MouseEventHandler(ipPen_MouseMove);

            this.ipPen.MouseLeftButtonUp += new MouseButtonEventHandler
                                                  (ipPen_MouseLeftButtonUp);

            this.ipPen.MouseLeave += new MouseEventHandler(ipPen_MouseLeave);

 

            this.ipPen.LostMouseCapture += new MouseEventHandler
                                           (ipPen_LostMouseCapture);

 

            this.btnCleare.Click += new RoutedEventHandler(btnCleare_Click);

 

            this.ipPen.KeyDown += new KeyEventHandler(ipPen_KeyDown);

            this.LayoutRoot.KeyDown += new KeyEventHandler
                            (LayoutRoot_KeyDown);
//[D] Pen Color Changed

         }

       
        
void LayoutRoot_KeyDown(object sender, KeyEventArgs e)

        {

            //RGB Color

            if (e.Key == Key.R)

            {

                brush = new SolidColorBrush(Colors.Red); //[B] Pen Color Red

            }

 

            else if (e.Key == Key.G)

            {

                brush = new SolidColorBrush(Colors.Green);

            }

            else if (e.Key == Key.B)

            {

                brush = new SolidColorBrush(Colors.Blue);

            }

 

            else

            {

                brush = new SolidColorBrush(Colors.Black);

            }

        }


       
//KeyDown Event

        void ipPen_KeyDown(object sender, KeyEventArgs e)

        {

            //RGB Color

            if (e.Key == Key.R){

                brush = new SolidColorBrush(Colors.Red); //[B] Pen Color Red

            }

 

            else if (e.Key == Key.G){

                brush = new SolidColorBrush(Colors.Green);

            }

            else if (e.Key == Key.B){

                brush = new SolidColorBrush(Colors.Blue);

            }

 

            else{

                brush = new SolidColorBrush(Colors.Black);

            }

        }

        //Click 버튼 클릭시 클리어
        void btnCleare_Click(object sender, RoutedEventArgs e)

        {

            ipPen.Strokes.Clear();

        }

        //마우스 캡쳐를 잃었을 때...

        void ipPen_LostMouseCapture(object sender, MouseEventArgs e)

        {

            stroke = null;

        }

       

        private void InitializePen()

        {

            this.stroke.DrawingAttributes.Color = 
                 ((
SolidColorBrush)brush).Color; //[C] Pen Color

            this.stroke.DrawingAttributes.OutlineColor = Colors.Black;

        }

        //영역 벗어 날때 처리..

        void ipPen_MouseLeave(object sender, MouseEventArgs e)

        {

            ipPen_MouseLeftButtonUp(null, null); //메서드 호출
        }

 

        void ipPen_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)

        {

            ipPen.ReleaseMouseCapture();//Mouse Capture

            stroke = null;

        }

 

        void ipPen_MouseMove(object sender, MouseEventArgs e)

        {

            if (stroke != null)

            {

                //stroke = new Stroke(e.StylusDevice.GetStylusPoints(ipPen));   

                this.stroke.StylusPoints.Add
                                     (e.StylusDevice.GetStylusPoints(ipPen));

            }           

            //ipPen.Strokes.Add(stroke);

        }

 

        void ipPen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

        {

            ipPen.CaptureMouse(); //마우스 위치 캡쳐

            ////현재 잉크 영역에서 마우스 캡쳐

            this.stroke = new Stroke(e.StylusDevice.GetStylusPoints(ipPen));

            ////First Loading...

            InitializePen(); //펜 색상 초기화

            ////모양 출력

            ipPen.Strokes.Add(stroke);              

        }

    }

} 




반응형

'.Net Project > SilverLight 3.0' 카테고리의 다른 글

48장 ComboBox 컨트롤  (0) 2009.12.02
47장 RoutedEventArgs 컨트롤  (0) 2009.12.01
45장) Drag&Drop 컨트롤  (0) 2009.12.01
42장) ScrollViewer 컨트롤  (0) 2009.12.01
41장) ToolTip 컨트롤  (0) 2009.12.01
posted by Magic_kit
2009. 12. 1. 12:22 .Net Project/SilverLight 3.0
반응형
  Drag&Drop 컨트롤
  Drag&Drop 컨트롤 사용 방법)


<
UserControl x:Class="RiaDragDrop.MainPage"

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

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

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Canvas x:Name="lblName" Width="400" Height="300" Background="Silver">

        <TextBlock Name="txtDrag" Text="DrageDrop" FontSize="30"></TextBlock>

       

    </Canvas>   

</UserControl> 


 Drag&Drop. Cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaDragDrop

{

    public partial class MainPage : UserControl

    {

        private bool isMouseDown = false; //마우스 클릭 중인지 확인

        private Point lastPoint = new Point(); //마지막 커서 위치

        private Point offset = new Point(); //왼쪽 상단과 개체의 간격 여백

 

        public MainPage()

        {

            InitializeComponent();

           

            //[1]Left Button

            this.txtDrag.MouseLeftButtonDown += new MouseButtonEventHandler
                                                (txtDrag_MouseLeftButtonDown);

 

            //[2]mouse Move

            this.txtDrag.MouseMove += new MouseEventHandler(txtDrag_MouseMove);

 

            ////left over

            this.txtDrag.MouseLeftButtonUp += new MouseButtonEventHandler
                                                  (txtDrag_MouseLeftButtonUp);  

        }

 

        //Mouse Over

        void txtDrag_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)

        {

            isMouseDown = false; //클릭되지 않은 상태            
                   this
.txtDrag.ReleaseMouseCapture(); //
캡쳐된 마우스 정보 해제

        }

 

        //Mouse Move

        void txtDrag_MouseMove(object sender, MouseEventArgs e)

        {

            if (isMouseDown) // 마우스 클릭상태에서만 드래그
            {

                lastPoint = e.GetPosition(null); //재 설정                

                //TextBlockC Left 속성 재지정

                txtDrag.SetValue(Canvas.LeftProperty, lastPoint.X - offset.X);

                txtDrag.SetValue(Canvas.TopProperty, lastPoint.Y - offset.Y);

            }

        }

 

        //Mouse Down

        void txtDrag_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

        {

            isMouseDown = true; //클릭된 상태
            this.txtDrag.CaptureMouse(); //현재 요소의 마우스
                                                                            클릭시 마우스에 대한 정보 저장  

            lastPoint = e.GetPosition(null);
            //
마우스 위치 반환
            //MessageBox.Show(lastPoint.X.ToString());

            offset.X = lastPoint.X - Convert.ToDouble
                        (txtDrag.GetValue(Canvas.LeftProperty));

            offset.Y = lastPoint.Y - Convert.ToDouble
                        (txtDrag.GetValue(Canvas.TopProperty));

        }

    }

}




반응형

'.Net Project > SilverLight 3.0' 카테고리의 다른 글

47장 RoutedEventArgs 컨트롤  (0) 2009.12.01
46장 InkPresenter 컨트롤  (0) 2009.12.01
42장) ScrollViewer 컨트롤  (0) 2009.12.01
41장) ToolTip 컨트롤  (0) 2009.12.01
40장) 다시 보는 Canvas 예제 (복습)  (0) 2009.12.01
posted by Magic_kit
2009. 12. 1. 10:58 .Net Project/SilverLight 3.0
반응형
 ScrollViewer Control 
 - Content 프로퍼터에 설정된 자식 요소가 모두 포함 될 수 있는 스크롤 영역을 만드는 컨트롤 방식
 - 프로퍼티 설정하여 세로, 가로 스크롤바가 보이는 조건을 설정 가능 하도록 하고 있다. 
 ScrollViewer Control 사용 방법)


<UserControl x:Class="RiaScrollView.MainPage"

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

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

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Canvas>

        <ScrollViewer Canvas.Left="10" Canvas.Top="10"

                      Height="100" Width="100"

                      HorizontalScrollBarVisibility="Auto"

                      VerticalScrollBarVisibility="Auto">

            <TextBlock Width="400" TextWrapping="Wrap" Text="ScrollView Control

                       This video demonstrates how to utilize a user's
                       web camera and

                       microphone attached to their computer via the browser.

                       This demonstrates the basics of the core

                       API for capturing the audio/video." >               

            </TextBlock>           

        </ScrollViewer>

    </Canvas>

</UserControl> 




반응형

'.Net Project > SilverLight 3.0' 카테고리의 다른 글

46장 InkPresenter 컨트롤  (0) 2009.12.01
45장) Drag&Drop 컨트롤  (0) 2009.12.01
41장) ToolTip 컨트롤  (0) 2009.12.01
40장) 다시 보는 Canvas 예제 (복습)  (0) 2009.12.01
39장) RadioButton 컨트롤  (0) 2009.11.27
posted by Magic_kit
2009. 12. 1. 10:14 .Net Project/SilverLight 3.0
반응형
  ToolTip 컨트롤
 - 풍선 도움말 같은 정보를사용자에게 전달하고자 할 때 유용하게 사용 가능 
 - 문자열 뿐만 아니라 Grid, Canvas, StackPanel 같은 컨테이너 컨트롤을 이용하여 좀 더 다양하고 
    화려 하게 표시 가능 

  ToolTip 컨트롤 사용 방법)

<UserControl x:Class="RiaToolTip.MainPage"

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

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

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Canvas>

        <Button Canvas.Left="5" Canvas.Top="10"
              
 Content="Sample Button1" Width="100" Height="30">

            <ToolTipService.ToolTip>

                <ToolTip Content="Sample Button"></ToolTip>

            </ToolTipService.ToolTip>

        </Button>

       

        <Button Canvas.Left="5" Canvas.Top="50"
               
 Content="Sample Button2" Width="100" Height="30">

            <ToolTipService.ToolTip>

                <ToolTip>

                    <ToolTip.Content>

                        <Grid>

                            <Rectangle Width="130" Height="50" Fill="Orange"
                                       RadiusX
="15" RadiusY="15"></Rectangle>

                            <TextBlock Text="Sample Button1"
                                       TextAlignment
="Center"></TextBlock> 

                        </Grid>

                    </ToolTip.Content>

                </ToolTip>                

            </ToolTipService.ToolTip>

        </Button>

        <Button Canvas.Left="5" Canvas.Top="90" Content="Sample Button3"
                Width
="100" Height="30">

            <ToolTipService.ToolTip>

                <ToolTip>

                    <ToolTip.Content>

                        <StackPanel Orientation="Vertical">

                            <TextBlock Text="Description Image" 
                                       Foreground
="Blue"></TextBlock>

                        </StackPanel>

                    </ToolTip.Content>

                </ToolTip>

            </ToolTipService.ToolTip>           

        </Button>

    </Canvas>   

</UserControl> 




반응형
posted by Magic_kit