コード例 #1
0
        /// <summary>
        ///     按原图比例展示图像
        /// </summary>
        //--------------------------------------------------------------------------
        //修改历史:
        //日期      修改人     修改
        //2010-8-27 zhanggang  创建代码
        //--------------------------------------------------------------------------
        public void OriginalView()
        {
            BitmapSource img = (BitmapSource)(ViewedPhoto.Source);

            ViewedPhoto.Width  = curCoef * img.Width;
            ViewedPhoto.Height = curCoef * img.Height;
            ViewScroll.UpdateLayout();
        }
コード例 #2
0
        /// <summary>
        ///     顺时针旋转图片
        ///     <param name="sender">调用对象</param>
        ///     <param name="e">参数信息</param>
        /// </summary>
        //--------------------------------------------------------------------------
        //修改历史:
        //日期      修改人     修改
        //2010-8-3  zhanggang  创建代码
        //--------------------------------------------------------------------------
        private void Rotate_Click(object sender, RoutedEventArgs e)
        {
            logger.Debug("旋转图片处理开始。");

            //1:判断命令来源
            Button button = e.Source as Button;
            string cmd    = button.Content.ToString();

            //2:根据按钮进行放大系数修改
            switch (cmd)
            {
            case "旋转(顺)":
                rotateDegree += 90;
                break;

            case "旋转(逆)":
                rotateDegree -= 90;
                break;

            default:
                break;
            }

            //3:旋转图像
            using (FileStream mse = new FileStream(SelectedImageName, FileMode.Open, FileAccess.Read))
            {
                BitmapImage bitImage = new BitmapImage();
                bitImage.BeginInit();
                bitImage.StreamSource = mse;
                bitImage.CacheOption  = BitmapCacheOption.OnLoad;
                bitImage.Rotation     = InnerUtility.GetRotation(rotateDegree);
                bitImage.EndInit();
                bitImage.Freeze();

                ViewedPhoto.Source = bitImage;
                ViewedPhoto.Width  = bitImage.Width * curCoef;
                ViewedPhoto.Height = bitImage.Height * curCoef;

                ViewScroll.UpdateLayout();
            }

            logger.Debug("旋转图片处理结束。");
        }
コード例 #3
0
        /// <summary>
        ///
        ///     <param name="sender">调用对象</param>
        ///     <param name="e">参数信息</param>
        /// </summary>
        //--------------------------------------------------------------------------
        //修改历史:
        //日期      修改人     修改
        //2010-8-5  zhanggang  创建代码
        //--------------------------------------------------------------------------
        private void Zoom_Click(object sender, RoutedEventArgs e)
        {
            logger.Debug("更新图像大小处理开始。");

            orginalViewButtonPressed = false;

            //1:判断命令来源
            Button button = e.Source as Button;
            string cmd    = button.Content.ToString();

            //2:根据按钮进行放大系数修改
            switch (cmd)
            {
            case "放大":
                curCoef *= 1.5;
                SingleImageSizeChanged();
                break;

            case "缩小":
                curCoef *= (double)2.0 / 3;
                SingleImageSizeChanged();
                break;

            case "原图":
                curCoef = 1.0;
                orginalViewButtonPressed = true;
                OriginalView();
                break;

            default:
                break;
            }

            ViewScroll.UpdateLayout();
            SetScrollViewerVisible(ViewScroll, ScrollBarVisibility.Auto);

            logger.Debug("更新图像大小处理结束。");
        }