Exemplo n.º 1
0
 /// <summary>
 /// Initialize component of main window
 /// </summary>
 public MainWindow()
 {
     try
     {
         this.DataContext = this;
         InitializeComponent();
         MainCanvas.Focus();
         MainCanvas.MouseUp             += OnMouseUp;
         MainCanvas.MouseMove           += PolygonDrag;
         MainCanvas.MouseLeftButtonDown += MyMouseDownHandler;
         SaveButton.Command              = new SaveCommand();
         polygonesList.Command           = new ShapesCommand();
         this.Title = "Untitled.xml";
         polygonesList.ItemsSource = polygons;
         MainCanvas.KeyUp         += KeyboardDragging;
         Closing += new System.ComponentModel.CancelEventHandler((object sender, System.ComponentModel.CancelEventArgs e) =>
         {
             Save();
             if (!close)
             {
                 e.Cancel = true;
             }
         });
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.ToString());
     }
 }
Exemplo n.º 2
0
 public MainWindow()
 {
     InitializeComponent();
     MainCanvas.Focus();
     //this.Content = img;
     //Content = img; //same as the above. you don't need to write "this".
 }
Exemplo n.º 3
0
 private void canvas_MouseEnter(object sender, MouseEventArgs e)
 {
     if (Utils.Tool != Utils.Tools.Arrow)
     {
         Mouse.OverrideCursor = Cursors.Cross;
     }
     MainCanvas.Focus();
     //Info_panel.Position = Utils.ComposePositionLabelContent(e.GetPosition(MainCanvas));
 }
Exemplo n.º 4
0
        private void SaveButton_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // MainCanvas.UpdateLayout();
            MainCanvas.Focus();
            var rtb = new RenderTargetBitmap((int)MainCanvas.ActualWidth, (int)MainCanvas.ActualHeight, 92, 92,
                                             PixelFormats.Default);

            rtb.Render(MainCanvas);
            // var cropped = new CroppedBitmap(rtb, new Int32Rect(50, 50,
            // (int) MainCanvas.RenderSize.Width,
            // (int) MainCanvas.RenderSize.Height));
            var pathToSave = GetPathToSave();
            var encoder    = GetEncoder(new FileInfo(pathToSave).Extension);

            // Add image
            encoder.Frames.Add(BitmapFrame.Create(rtb));
            SaveImage(pathToSave, encoder);
            MessageBox.Show("Мем создан успешно!");
        }
Exemplo n.º 5
0
        public void EndInput()
        {
            if (EndInputAction != null)
            {
                EndInputAction();
            }
            else
            {
                return;
            }

            EndInputAction = null;

            Font oldFont = txtInput.Font;

            txtInput.Font    = Settings.inputFont;
            txtInput.Visible = false;

            oldFont.Dispose(); // throw away the zoomed font
            Refresh();
            MainCanvas.Focus();
        }