コード例 #1
0
        private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            if (tcMain.Items.Count == 0 || (tcMain.Items[0] as BaseUserControl).filePath.Equals(String.Empty))
            {
                if ((userControls[3] as BaseUserControl).filePath.Equals(String.Empty))
                {
                    return;
                }
                mLightList = (userControls[3] as BaseMakerLightUserControl).GetData();
            }
            else
            {
                if (userControls[userControls.IndexOf((BaseUserControl)tcMain.Items[0])].IsMakerLightUserControl())
                {
                    BaseMakerLightUserControl baseMakerLightUserControl = tcMain.Items[0] as BaseMakerLightUserControl;
                    mLightList = baseMakerLightUserControl.GetData();
                }
            }
            mLightList = Business.LightBusiness.Copy(mLightList);
            UserControl userControl = null;

            if (sender == iPlayer)
            {
                //DeviceModel deviceModel =  FileBusiness.CreateInstance().LoadDeviceModel(AppDomain.CurrentDomain.BaseDirectory + @"Device\" + playerDefault);
                //bToolChild.Width = deviceModel.DeviceSize;
                //bToolChild.Height = deviceModel.DeviceSize + 31;
                //bToolChild.Visibility = Visibility.Visible;
                //加入播放器页面
                userControl = new PlayerUserControl(mw, mLightList);
            }
            else if (sender == iPaved)
            {
                //加入平铺页面
                userControl = new ShowPavedUserControl(mw, mLightList);
            }
            else if (sender == iExport)
            {
                userControl = new ExportUserControl(mw, mLightList);
            }
            else if (sender == iPianoRoll)
            {
                userControl = new ShowPianoRollUserControl(mw, mLightList);
            }
            else if (sender == iData)
            {
                userControl = new DataGridUserControl(mw, mLightList);
            }
            else if (sender == iMy3D)
            {
                userControl = new My3DUserControl(mw, mLightList);
            }
            gTool.Children.Clear();
            gTool.Children.Add(userControl);
            gToolBackGround.Visibility = Visibility.Visible;
            DoubleAnimation daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5)));

            userControl.BeginAnimation(OpacityProperty, daV);
        }
コード例 #2
0
        private void DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            Thumb thumb    = sender as Thumb;
            int   position = -1;

            if (thumb == thumb_player)
            {
                position = 0;
            }
            else if (thumb == thumb_paved)
            {
                position = 1;
            }
            if (position == -1)
            {
                return;
            }
            double left = Canvas.GetLeft(thumb);

            if (left > gd.ActualWidth / 3 * 2 || (gMain.Children[0] as BaseUserControl).filePath.Equals(String.Empty))
            {
                thumb.RenderTransformOrigin = new Point(0.5, 0.5);
                if (position == 0)
                {
                    thumb.RenderTransform = MatrixTransform_01;
                }
                else if (position == 1)
                {
                    thumb.RenderTransform = MatrixTransform_02;
                }
                double top = Canvas.GetTop(thumb);

                QuadraticBezierSegment quadraticBezierSegment = new QuadraticBezierSegment();
                quadraticBezierSegment.Point1 = new Point((startPoints[position].X - left) / 2, (top - startPoints[position].Y) / 2);
                quadraticBezierSegment.Point2 = new Point(startPoints[position].X - left, startPoints[position].Y - top);
                PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();
                pathSegmentCollection.Add(quadraticBezierSegment);

                PathFigure pathFigure = new PathFigure();
                pathFigure.StartPoint = new Point(0, 0);
                pathFigure.Segments   = pathSegmentCollection;

                PathFigureCollection pathFigureCollection = new PathFigureCollection();
                pathFigureCollection.Add(pathFigure);

                PathGeometry pathGeometry = new PathGeometry();
                pathGeometry.Figures = pathFigureCollection;

                MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
                matrixAnimation.PathGeometry = pathGeometry;
                //动画的路径
                matrixAnimation.Duration   = TimeSpan.FromSeconds(0.5);
                matrixAnimation.Completed += MatrixAnimation_Completed;
                //matrixAnimation.FillBehavior = FillBehavior.Stop;
                //matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
                //matrixAnimation.DoesRotateWithTangent = true;
                //Storyboard.SetTarget(matrixAnimation, thumb);
                if (position == 0)
                {
                    Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_01");//动画的对象
                }
                else if (position == 1)
                {
                    Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_02");//动画的对象
                }
                Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));

                Storyboard pathAnimationStoryboard = new Storyboard();
                pathAnimationStoryboard.Children.Add(matrixAnimation);
                pathAnimationStoryboard.Begin(this);
            }
            else
            {
                BaseMakerLightUserControl baseMakerLightUserControl = gMain.Children[0] as BaseMakerLightUserControl;
                UserControl userControl = null;
                if (position == 0)
                {
                    //加入播放器页面
                    PlayerUserControl playerUserControl = new PlayerUserControl(mw);
                    playerUserControl.SetData(baseMakerLightUserControl.GetData());
                    userControl = playerUserControl;
                }
                else if (position == 1)
                {
                    //加入平铺页面
                    //PavedUserControl pavedUserControl = new PavedUserControl(this,baseMakerLightUserControl.GetData());
                    //userControl = pavedUserControl;
                }
                gMost.Children.Add(userControl);
                DoubleAnimation daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5)));
                userControl.BeginAnimation(OpacityProperty, daV);
                //回原位
                ToolBackToOld(thumb, position);
            }
        }