Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeUdpSocket();

            this.DrawingCanvas.Gesture += new RecongnitionGestrueHandler(DrawingCanvas_Gesture);

            _pathGenerator = new PathGenerator(this.DrawingCanvas);
            _pathGenerator.PathGenerated += new Action <PathGeometry>(_pathGenerator_PathGenerated);

            _freeCropHelper = new ImageFreeCropHelper(this.DrawingCanvas);
            _freeCropHelper.ImageCropped += new EventHandler <ImageCropEventArgs>(_freeCropHelper_ImageCropped);

            _recognier              = new TouchRecognizeAutomata(this.DrawingCanvas);
            _recognier.ModeChanged += new Action <TouchRecognizeAutomata.InputMode>(_recognier_ModeChanged);

            if (Directory.Exists(".\\Saved") == false)
            {
                Directory.CreateDirectory(".\\Saved");
            }

            // Liner 등록
            AddLiner();

            // Line 모드의 이벤트 등록
            _recognier.OnLineStarted += new TouchRecognizeAutomata.EventHandler(_recognier_OnLineStarted);
            _recognier.OnLineMove    += new TouchRecognizeAutomata.EventHandler(_recognier_OnLineMove);
            _recognier.OnLineEnded   += new TouchRecognizeAutomata.EventHandler(_recognier_OnLineEnded);

            this.DrawingCanvas.PreviewTouchDown += new EventHandler <TouchEventArgs>(DrawingCanvas_PreviewTouchDown);
            this.DrawingCanvas.PreviewTouchMove += new EventHandler <TouchEventArgs>(DrawingCanvas_PreviewTouchMove);
            this.DrawingCanvas.PreviewTouchUp   += new EventHandler <TouchEventArgs>(DrawingCanvas_PreviewTouchUp);

            _isCutStarted = false;

            //<control:Liner x:Name="ui_lineRuler" Visibility="Collapsed">
            //    <control:Liner.Triggers>
            //        <EventTrigger RoutedEvent="TouchUp">
            //            <BeginStoryboard Storyboard="{StaticResource linerHideAnimation}"/>
            //        </EventTrigger>
            //    </control:Liner.Triggers>
            //</control:Liner>
        }
        public MainWindow()
        {
            InitializeComponent();
            InitializeUdpSocket();

            this.DrawingCanvas.Gesture += new RecongnitionGestrueHandler(DrawingCanvas_Gesture);

            _pathGenerator = new PathGenerator(this.DrawingCanvas);
            _pathGenerator.PathGenerated += new Action<PathGeometry>(_pathGenerator_PathGenerated);

            _freeCropHelper = new ImageFreeCropHelper(this.DrawingCanvas);
            _freeCropHelper.ImageCropped += new EventHandler<ImageCropEventArgs>(_freeCropHelper_ImageCropped);

            _recognier = new TouchRecognizeAutomata(this.DrawingCanvas);
            _recognier.ModeChanged += new Action<TouchRecognizeAutomata.InputMode>(_recognier_ModeChanged);

            if (Directory.Exists(".\\Saved") == false)
                Directory.CreateDirectory(".\\Saved");

            // Liner 등록
            AddLiner();

            // Line 모드의 이벤트 등록
            _recognier.OnLineStarted += new TouchRecognizeAutomata.EventHandler(_recognier_OnLineStarted);
            _recognier.OnLineMove += new TouchRecognizeAutomata.EventHandler(_recognier_OnLineMove);
            _recognier.OnLineEnded += new TouchRecognizeAutomata.EventHandler(_recognier_OnLineEnded);

            this.DrawingCanvas.PreviewTouchDown += new EventHandler<TouchEventArgs>(DrawingCanvas_PreviewTouchDown);
            this.DrawingCanvas.PreviewTouchMove += new EventHandler<TouchEventArgs>(DrawingCanvas_PreviewTouchMove);
            this.DrawingCanvas.PreviewTouchUp +=new EventHandler<TouchEventArgs>(DrawingCanvas_PreviewTouchUp);

            _isCutStarted = false;

            //<control:Liner x:Name="ui_lineRuler" Visibility="Collapsed">
            //    <control:Liner.Triggers>
            //        <EventTrigger RoutedEvent="TouchUp">
            //            <BeginStoryboard Storyboard="{StaticResource linerHideAnimation}"/>
            //        </EventTrigger>
            //    </control:Liner.Triggers>
            //</control:Liner>
        }
        void _recognier_ModeChanged(TouchRecognizeAutomata.InputMode obj)
        {
            this.CurrentMode = obj;

            switch (obj)
            {
                case TouchRecognizeAutomata.InputMode.None:
                    this.SelectedIndex(0);
                    break;
                case TouchRecognizeAutomata.InputMode.Pen:
                    this.SelectedIndex(1);
                    break;
                case TouchRecognizeAutomata.InputMode.Erase:
                    this.SelectedIndex(6);
                    break;
                case TouchRecognizeAutomata.InputMode.SelMovImg:
                    this.SelectedIndex(0);
                    break;
                case TouchRecognizeAutomata.InputMode.TransImg:
                    this.SelectedIndex(0);
                    break;
                case TouchRecognizeAutomata.InputMode.Cut:
                    this.SelectedIndex(3);

                    break;
                case TouchRecognizeAutomata.InputMode.Ruler:
                    Debug.WriteLine("Ruler selected");
                    this.llbToolHeaders.SelectedIndex = 3;      // line ruler
                    break;
                case TouchRecognizeAutomata.InputMode.Line:
                    Polyline line = new Polyline();
                    // TODO
                    double angle = _liner.rotation.Angle + 90;
                    //Point linerFirstPoint = TouchDevice;
                    break;
                default:
                    break;
            }

            System.Diagnostics.Debug.WriteLine(string.Format("현재 툴 모드: {0}", this.DrawingCanvas.EditingMode));
        }