private void menuSave_Click(object sender, RoutedEventArgs e) { DrawArea.SaveMeg(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.MainForm = ((MegaPaint.MainWindow)(target)); #line 15 "..\..\MainWindow.xaml" this.MainForm.Loaded += new System.Windows.RoutedEventHandler(this.MainForm_Loaded); #line default #line hidden return; case 2: this.menuFile = ((System.Windows.Controls.MenuItem)(target)); return; case 3: this.menuNew = ((System.Windows.Controls.MenuItem)(target)); #line 47 "..\..\MainWindow.xaml" this.menuNew.Click += new System.Windows.RoutedEventHandler(this.menuNew_Click); #line default #line hidden return; case 4: this.menuOpen = ((System.Windows.Controls.MenuItem)(target)); #line 48 "..\..\MainWindow.xaml" this.menuOpen.Click += new System.Windows.RoutedEventHandler(this.menuOpen_Click); #line default #line hidden return; case 5: this.menuSave = ((System.Windows.Controls.MenuItem)(target)); #line 49 "..\..\MainWindow.xaml" this.menuSave.Click += new System.Windows.RoutedEventHandler(this.menuSave_Click); #line default #line hidden return; case 6: this.menuSaveAs = ((System.Windows.Controls.MenuItem)(target)); #line 50 "..\..\MainWindow.xaml" this.menuSaveAs.Click += new System.Windows.RoutedEventHandler(this.menuSaveAs_Click); #line default #line hidden return; case 7: this.menuAbout = ((System.Windows.Controls.MenuItem)(target)); return; case 8: this.menuExit = ((System.Windows.Controls.MenuItem)(target)); #line 52 "..\..\MainWindow.xaml" this.menuExit.Click += new System.Windows.RoutedEventHandler(this.menuExit_Click); #line default #line hidden return; case 9: this.menuEdit = ((System.Windows.Controls.MenuItem)(target)); return; case 10: this.menuSelectAll = ((System.Windows.Controls.MenuItem)(target)); #line 55 "..\..\MainWindow.xaml" this.menuSelectAll.Click += new System.Windows.RoutedEventHandler(this.menuSelectAll_Click); #line default #line hidden return; case 11: this.menuDeleteAll = ((System.Windows.Controls.MenuItem)(target)); #line 56 "..\..\MainWindow.xaml" this.menuDeleteAll.Click += new System.Windows.RoutedEventHandler(this.menuDeleteAll_Click); #line default #line hidden return; case 12: this.menuResetRotate = ((System.Windows.Controls.MenuItem)(target)); #line 57 "..\..\MainWindow.xaml" this.menuResetRotate.Click += new System.Windows.RoutedEventHandler(this.menuResetRotate_Click); #line default #line hidden return; case 13: this.Grid_1 = ((System.Windows.Controls.Grid)(target)); return; case 14: this.btnCut = ((System.Windows.Controls.Button)(target)); #line 69 "..\..\MainWindow.xaml" this.btnCut.Click += new System.Windows.RoutedEventHandler(this.btnCut_Click); #line default #line hidden return; case 15: this.btnCopy = ((System.Windows.Controls.Button)(target)); #line 70 "..\..\MainWindow.xaml" this.btnCopy.Click += new System.Windows.RoutedEventHandler(this.btnCopy_Click); #line default #line hidden #line 70 "..\..\MainWindow.xaml" this.btnCopy.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.btnCopy_IsEnabledChanged); #line default #line hidden return; case 16: this.btnPaste = ((System.Windows.Controls.Button)(target)); #line 71 "..\..\MainWindow.xaml" this.btnPaste.Click += new System.Windows.RoutedEventHandler(this.btnPaste_Click); #line default #line hidden #line 71 "..\..\MainWindow.xaml" this.btnPaste.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.btnPaste_IsEnabledChanged); #line default #line hidden return; case 17: this.btnUndo = ((System.Windows.Controls.Button)(target)); #line 72 "..\..\MainWindow.xaml" this.btnUndo.Click += new System.Windows.RoutedEventHandler(this.btnUndo_Click); #line default #line hidden #line 72 "..\..\MainWindow.xaml" this.btnUndo.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.btnUndo_IsEnabledChanged); #line default #line hidden return; case 18: this.btnRedo = ((System.Windows.Controls.Button)(target)); #line 73 "..\..\MainWindow.xaml" this.btnRedo.Click += new System.Windows.RoutedEventHandler(this.btnRedo_Click); #line default #line hidden #line 73 "..\..\MainWindow.xaml" this.btnRedo.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.btnRedo_IsEnabledChanged); #line default #line hidden return; case 19: this.btnLine = ((System.Windows.Controls.Button)(target)); #line 79 "..\..\MainWindow.xaml" this.btnLine.Click += new System.Windows.RoutedEventHandler(this.btnLine_Click); #line default #line hidden return; case 20: this.btnRectangle = ((System.Windows.Controls.Button)(target)); #line 80 "..\..\MainWindow.xaml" this.btnRectangle.Click += new System.Windows.RoutedEventHandler(this.btnRectangle_Click); #line default #line hidden return; case 21: this.btnFilledRectangle = ((System.Windows.Controls.Button)(target)); #line 81 "..\..\MainWindow.xaml" this.btnFilledRectangle.Click += new System.Windows.RoutedEventHandler(this.btnFilledRectangle_Click); #line default #line hidden #line 81 "..\..\MainWindow.xaml" this.btnFilledRectangle.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.btnFilledRectangle_MouseDown); #line default #line hidden return; case 22: this.btnEllipse = ((System.Windows.Controls.Button)(target)); #line 82 "..\..\MainWindow.xaml" this.btnEllipse.Click += new System.Windows.RoutedEventHandler(this.btnEllipse_Click); #line default #line hidden return; case 23: this.btnFilledEllipse = ((System.Windows.Controls.Button)(target)); #line 83 "..\..\MainWindow.xaml" this.btnFilledEllipse.Click += new System.Windows.RoutedEventHandler(this.btnFilledEllipse_Click); #line default #line hidden #line 83 "..\..\MainWindow.xaml" this.btnFilledEllipse.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.btnFilledEllipse_MouseDown); #line default #line hidden return; case 24: this.lblForeground = ((System.Windows.Controls.Label)(target)); return; case 25: this.lblBackground = ((System.Windows.Controls.Label)(target)); return; case 26: this.lsbForeground = ((Xceed.Wpf.Toolkit.ColorPicker)(target)); #line 99 "..\..\MainWindow.xaml" this.lsbForeground.SelectedColorChanged += new System.Windows.RoutedPropertyChangedEventHandler <System.Nullable <System.Windows.Media.Color> >(this.lsbForeground_SelectedColorChanged); #line default #line hidden return; case 27: this.lsbBackground = ((Xceed.Wpf.Toolkit.ColorPicker)(target)); #line 100 "..\..\MainWindow.xaml" this.lsbBackground.SelectedColorChanged += new System.Windows.RoutedPropertyChangedEventHandler <System.Nullable <System.Windows.Media.Color> >(this.lsbBackground_SelectedColorChanged); #line default #line hidden return; case 28: this.Grid_2 = ((System.Windows.Controls.Grid)(target)); return; case 29: this.btnSelect = ((System.Windows.Controls.Button)(target)); #line 125 "..\..\MainWindow.xaml" this.btnSelect.Click += new System.Windows.RoutedEventHandler(this.btnSelect_Click); #line default #line hidden return; case 30: this.btnPencil = ((System.Windows.Controls.Button)(target)); #line 126 "..\..\MainWindow.xaml" this.btnPencil.Click += new System.Windows.RoutedEventHandler(this.btnPencil_Click); #line default #line hidden return; case 31: this.btnText = ((System.Windows.Controls.Button)(target)); #line 127 "..\..\MainWindow.xaml" this.btnText.Click += new System.Windows.RoutedEventHandler(this.btnText_Click); #line default #line hidden return; case 32: this.btnImage = ((System.Windows.Controls.Button)(target)); #line 128 "..\..\MainWindow.xaml" this.btnImage.Click += new System.Windows.RoutedEventHandler(this.btnImage_Click); #line default #line hidden return; case 33: this.btnRotateLeft = ((System.Windows.Controls.Button)(target)); #line 138 "..\..\MainWindow.xaml" this.btnRotateLeft.Click += new System.Windows.RoutedEventHandler(this.btnRotateLeft_Click); #line default #line hidden #line 138 "..\..\MainWindow.xaml" this.btnRotateLeft.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.btnRotateLeft_IsEnabledChanged); #line default #line hidden return; case 34: this.btnRotateRight = ((System.Windows.Controls.Button)(target)); #line 139 "..\..\MainWindow.xaml" this.btnRotateRight.Click += new System.Windows.RoutedEventHandler(this.btnRotateRight_Click); #line default #line hidden #line 139 "..\..\MainWindow.xaml" this.btnRotateRight.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.btnRotateRight_IsEnabledChanged); #line default #line hidden return; case 35: this.txtRotate = ((Xceed.Wpf.Toolkit.MaskedTextBox)(target)); return; case 36: this.sliderSize = ((System.Windows.Controls.Slider)(target)); #line 153 "..\..\MainWindow.xaml" this.sliderSize.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderSize_ValueChanged); #line default #line hidden return; case 37: this.cbxNormal = ((System.Windows.Controls.RadioButton)(target)); #line 163 "..\..\MainWindow.xaml" this.cbxNormal.Checked += new System.Windows.RoutedEventHandler(this.cbxNormal_Checked); #line default #line hidden return; case 38: this.cbxDot = ((System.Windows.Controls.RadioButton)(target)); #line 164 "..\..\MainWindow.xaml" this.cbxDot.Checked += new System.Windows.RoutedEventHandler(this.cbxDot_Checked); #line default #line hidden return; case 39: this.cbxDash = ((System.Windows.Controls.RadioButton)(target)); #line 165 "..\..\MainWindow.xaml" this.cbxDash.Checked += new System.Windows.RoutedEventHandler(this.cbxDash_Checked); #line default #line hidden return; case 40: this.cbxDoubleLine = ((System.Windows.Controls.RadioButton)(target)); #line 166 "..\..\MainWindow.xaml" this.cbxDoubleLine.Checked += new System.Windows.RoutedEventHandler(this.cbxDoubleLine_Checked); #line default #line hidden return; case 41: this.cbxDashArrow = ((System.Windows.Controls.RadioButton)(target)); #line 167 "..\..\MainWindow.xaml" this.cbxDashArrow.Checked += new System.Windows.RoutedEventHandler(this.cbxDashArrow_Checked); #line default #line hidden return; case 42: this.ExpFilledCustom = ((System.Windows.Controls.Expander)(target)); return; case 43: this.btnFilledSolid = ((System.Windows.Controls.Button)(target)); #line 175 "..\..\MainWindow.xaml" this.btnFilledSolid.Click += new System.Windows.RoutedEventHandler(this.btnFilledSolid_Click); #line default #line hidden return; case 44: this.btnFilledGradient = ((System.Windows.Controls.Button)(target)); #line 180 "..\..\MainWindow.xaml" this.btnFilledGradient.Click += new System.Windows.RoutedEventHandler(this.btnFilledGradient_Click); #line default #line hidden return; case 45: this.btnFilledHatch = ((System.Windows.Controls.Button)(target)); #line 190 "..\..\MainWindow.xaml" this.btnFilledHatch.Click += new System.Windows.RoutedEventHandler(this.btnFilledHatch_Click); #line default #line hidden return; case 46: this.btnFilledTexture = ((System.Windows.Controls.Button)(target)); #line 191 "..\..\MainWindow.xaml" this.btnFilledTexture.Click += new System.Windows.RoutedEventHandler(this.btnFilledTexture_Click); #line default #line hidden return; case 47: this.btnTheme = ((System.Windows.Controls.Primitives.ToggleButton)(target)); #line 203 "..\..\MainWindow.xaml" this.btnTheme.Click += new System.Windows.RoutedEventHandler(this.btnTheme_Click); #line default #line hidden return; case 48: this.DrawArea = ((MegaPaint.DrawArea)(target)); return; } this._contentLoaded = true; }
private void menuSaveAs_Click(object sender, RoutedEventArgs e) { DrawArea.SaveAsImage(); }
private void menuOpen_Click(object sender, RoutedEventArgs e) { DrawArea.OpenMeg(); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); AddNewObject(drawArea, new DrawImage(p.X, p.Y)); }
private void menuLayer_Click(object sender, RoutedEventArgs e) { frmLayerForm ld = new frmLayerForm(DrawArea.TheLayers); ld.ShowDialog(); bool Visible = false; for (int i = 0; i < ld.layerList.Count; i++) { if (ld.layerList[i].LayerNew) { Layer layer = new Layer(); layer.LayerName = ld.layerList[i].LayerName; layer.Graphics = new GraphicsList(); DrawArea.TheLayers.Add(layer); } } DrawArea.TheLayers.InactivateAllLayers(); string ActiveLayerName = ""; for (int i = 0; i < ld.layerList.Count; i++) { if (ld.layerList[i].LayerActive) { DrawArea.TheLayers.SetActiveLayer(i); ActiveLayerName = ld.layerList[i].LayerName; if (ld.layerList[i].LayerVisible) { Visible = true; } else { Visible = false; } } if (ld.layerList[i].LayerVisible) { DrawArea.TheLayers.MakeLayerVisible(i); } else { DrawArea.TheLayers.MakeLayerInvisible(i); } DrawArea.TheLayers[i].LayerName = ld.layerList[i].LayerName; } for (int i = 0; i < ld.layerList.Count; i++) { if (ld.layerList[i].LayerDelete) { DrawArea.TheLayers.RemoveLayer(i); } } DrawArea.Invalidate(); menuLayer.Header = ActiveLayerName; if (Visible) { menuLayer.Icon = new System.Windows.Controls.Image { Source = new BitmapImage(new Uri("../../Resources/Images/Visible.png", UriKind.Relative)) }; } else { menuLayer.Icon = new System.Windows.Controls.Image { Source = new BitmapImage(new Uri("../../Resources/Images/InVisible.png", UriKind.Relative)) }; } }
/* --- Phương thức --- */ public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); // Kiểm tra có phải là đang resize int al = drawArea.TheLayers.ActiveLayerIndex; int n = drawArea.TheLayers[al].Graphics.SelectionCount; for (int i = 0; i < n; i++) { DrawObject o = drawArea.TheLayers[al].Graphics.GetSelectedObject(i); int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // Giữ đối tượng cần resize resizedObject = o; resizedObjectHandle = handleNumber; // Khi resize một đối tượng phải unselect các đối tượng khác drawArea.TheLayers[al].Graphics.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.TheLayers); break; } } // Kiểm tra có phải là đang move if (selectMode == SelectionMode.None) { int n1 = drawArea.TheLayers[al].Graphics.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.TheLayers[al].Graphics[i].HitTest(point) == 0) { o = drawArea.TheLayers[al].Graphics[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; // Unselect tất cả nếu Ctrl chưa nhấn và một đối tượng chưa được chọn if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.TheLayers[al].Graphics.UnselectAll(); } o.Selected = true; commandChangeState = new CommandChangeState(drawArea.TheLayers); drawArea.Cursor = Cursors.SizeAll; } } // Kiểm tra có phải là đang group selection if (selectMode == SelectionMode.None) { if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.TheLayers[al].Graphics.UnselectAll(); } selectMode = SelectionMode.NetSelection; drawArea.DrawNetRectangle = true; } lastPoint.X = point.X; lastPoint.Y = point.Y; startPoint.X = point.X; startPoint.Y = point.Y; drawArea.Capture = true; drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); int al = drawArea.TheLayers.ActiveLayerIndex; wasMove = true; // Set con trỏ khi chưa nhấn chuột if (e.Button == MouseButtons.None) { Cursor cursor = null; if (drawArea.TheLayers[al].Graphics != null) { for (int i = 0; i < drawArea.TheLayers[al].Graphics.Count; i++) { int n = drawArea.TheLayers[al].Graphics[i].HitTest(point); if (n > 0) { cursor = drawArea.TheLayers[al].Graphics[i].GetHandleCursor(n); break; } } } if (cursor == null) { cursor = Cursors.Default; } drawArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } // Khi nhấn trái chuột // Tìm khoảng cách giữa hai điểm trước và sau int dx = point.X - lastPoint.X; int dy = point.Y - lastPoint.Y; lastPoint.X = point.X; lastPoint.Y = point.Y; // Resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); drawArea.Refresh(); } } // Move if (selectMode == SelectionMode.Move) { int n = drawArea.TheLayers[al].Graphics.SelectionCount; for (int i = 0; i < n; i++) { drawArea.TheLayers[al].Graphics.GetSelectedObject(i).Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.Refresh(); } // Group selection if (selectMode == SelectionMode.NetSelection) { drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); return; } }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); AddNewObject(drawArea, new DrawSpecialShape(p.X, p.Y, 1, 1, drawArea.LineColor, drawArea.LineWidth, drawArea.PenType, drawArea.FillColor, drawArea.FillImage, drawArea.DrawFilled, drawArea.DrawGradient, drawArea.DrawHatch, drawArea.DrawTexture, drawArea.ShapeName)); }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { newPolygon = null; base.OnMouseUp(drawArea, e); }
// 3 event phổ biến để vẽ public virtual void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { }