예제 #1
0
        public void ShowOriginal()
        {
            isChanged = true;
            BoardImageItem item = GetSelectItem();

            if (item != null)
            {
                item.ShowOriginal();
            }
        }
예제 #2
0
        public void ShowFitFull(bool isAdd)
        {
            isChanged = true;
            BoardImageItem item = GetSelectItem();

            if (item != null)
            {
                item.ShowFitFull(isAdd);
            }
        }
예제 #3
0
        /// <summary>
        /// 添加图片
        /// </summary>
        /// <param name="url"></param>
        public BoardImageItem Add(string fileName)
        {
            isChanged = true;
            Border border = new Border();

            ImageBrush imageBrush = new ImageBrush();

            FileStream img = new FileStream(fileName, FileMode.Open);

            byte[] imgbyte = new byte[img.Length];
            img.Read(imgbyte, 0, imgbyte.Length);
            img.Close();
            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.CacheOption  = BitmapCacheOption.OnLoad;
            bitmap.StreamSource = new MemoryStream(imgbyte);
            bitmap.EndInit();

            imageBrush.ImageSource = bitmap;
            imageBrush.Stretch     = Stretch.UniformToFill;

            border.Background            = imageBrush;
            border.Width                 = bitmap.Width;
            border.Height                = bitmap.Height;
            border.IsManipulationEnabled = true;

            //动态事件
            border.MouseDown  += new MouseButtonEventHandler(border_MouseDown);
            border.MouseMove  += new MouseEventHandler(border_MouseMove);
            border.MouseUp    += new MouseButtonEventHandler(border_MouseUp);
            border.MouseWheel += new MouseWheelEventHandler(border_MouseWheel);

            //返回值
            BoardImageItem item = new BoardImageItem();

            item.BitmapImage      = bitmap;
            item.FrameworkElement = border;

            this.BoardImageList.Add(item);
            this.touchPad.Children.Add(border);
            this.Select(item);

            item.ShowFit();

            if (BoardImageList.Count == 1)
            {
                item.ShowCenter();
            }

            return(item);
        }
예제 #4
0
        /// <summary>
        /// 设置选中项
        /// </summary>
        /// <param name="item"></param>
        /// <param name="isSelect"></param>
        public void Select(BoardImageItem item)
        {
            UnSelect();

            if (item != null)
            {
                Border border2 = item.FrameworkElement as Border;
                border2.BorderBrush     = new SolidColorBrush(this.SelectColor);
                border2.BorderThickness = new Thickness(this.DefaultThickness);
                item.IsSelect           = true;

                Canvas.SetZIndex(border2, this.zIndex++);
            }

            this.OnSelectChanged();
        }
예제 #5
0
        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="item"></param>
        public void Remove(BoardImageItem item)
        {
            if (item == null)
            {
                return;
            }

            this.BoardImageList.Remove(item);
            this.touchPad.Children.Remove(item.FrameworkElement);

            if (IsAutoSelect && (BoardImageList.Count > 0))
            {
                this.Select(BoardImageList.Last());
            }

            this.OnSelectChanged();
            isChanged = true;
        }
예제 #6
0
        void border_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            isChanged = true;
            BoardImageItem boardImageItem = GetSelectItem();

            if (boardImageItem == null)
            {
                return;
            }

            if (e.Delta > 0)
            {
                boardImageItem.ShowMoreBig();
            }
            else
            {
                boardImageItem.ShowMoreSmall();
            }
        }