コード例 #1
0
        private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (rect.Width.ToString() == "NaN" || rect.Height.ToString() == "NaN" || rect.Width == 0 || rect.Height == 0)
            {
                return;
            }
            e.Handled = true;
            ConfirmDialog congfirm = new ConfirmDialog();
            var           position = e.GetPosition(this);

            congfirm.Top  = position.Y;
            congfirm.Left = position.X;
            // if ((bool)congfirm.ShowDialog())
            {
                Bitmap   image = new Bitmap((int)rect.Width, (int)rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
                Graphics g     = Graphics.FromImage(image);
                g.CopyFromScreen((int)startPoint.X, (int)startPoint.Y, 0, 0, image.Size);
                //image.Save(@"c:\image.bmp");
                System.Windows.Clipboard.SetImage(Convert(image));
                //WindowState = WindowState.Minimized;
                VisibilityOfSplash = Visibility.Hidden;
                //Canvas.SetTop(splashRect, startPoint.X);
                //Canvas.SetLeft(splashRect, startPoint.Y);
                //Canvas.SetRight(splashRect, position.X);
                //Canvas.SetBottom(splashRect, position.Y);


                this.Dispatcher.BeginInvoke((Action) delegate()
                {
                    txtMouseLocation.Visibility = Visibility.Hidden;
                    canvas.Children.Remove(rect);
                    canvas.UpdateLayout();
                    startPoint.X = 0;
                    startPoint.Y = 0;
                    Canvas.SetBottom(rect, 0);
                    Canvas.SetRight(rect, 0);
                    Canvas.SetLeft(rect, 0);
                    Canvas.SetTop(rect, 0);
                    rect.UpdateLayout();
                    canvas.UpdateLayout();
                    path.UpdateLayout();
                    UpdateLayout();
                }, System.Windows.Threading.DispatcherPriority.Send, null);
                //rect = null;
                this.Hide();
            }
            //canvas.Children.OfType<System.Windows.Shapes.Rectangle>().ToList().ForEach(x=>canvas.Children.Remove(x));
        }
コード例 #2
0
        private void UpdateWritineLineIndicator()
        {
            if (writingLineRectangle != null)
                imageGrid.Children.Remove(writingLineRectangle);

            writingLineRectangle = new Rectangle();
            writingLineRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            writingLineRectangle.VerticalAlignment = VerticalAlignment.Top;
            writingLineRectangle.Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 0));
            writingLineRectangle.StrokeThickness = 2;

            imageGrid.Children.Add(writingLineRectangle);

            image1.UpdateLayout();

            if (image1.Source == null)
            {
                writingLineRectangle.Visibility = Visibility.Hidden;
                return;
            }

            writingLineRectangle.Visibility = Visibility.Visible;

            writingLineRectangle.Width = image1.ActualWidth + 50;
            double heightPixelSize = image1.ActualHeight/image1.Source.Height;

            int writingLinePosition = viewModel.SelectedCharacterData.WritingLinePosition;

            double pos = (writingLinePosition+1)*heightPixelSize-2;

            writingLineRectangle.Margin = new Thickness(-25, pos, 0, 0);
            writingLineRectangle.UpdateLayout();
        }