public void CreateCrop(int currX, int currY) { // Disapprove the slot m_cropperForm.m_slotsPanel.DisapproveSlot(); HideArrow(); // EAST if (currX >= m_prevMouse.X) { // SOUTH if (currY >= m_prevMouse.Y) { m_scaleDir = Direction.SE; } // NORTH else { m_scaleDir = Direction.NE; } } // WEST else { // SOUTH if (currY >= m_prevMouse.Y) { m_scaleDir = Direction.SW; } // NORTH else { m_scaleDir = Direction.NW; } } m_cropRect.X = m_prevMouse.X; m_cropRect.Y = m_prevMouse.Y; m_cropRect.Width = currX - m_prevMouse.X; m_cropRect.Height = currY - m_prevMouse.Y; m_cropAction = CropAction.SCALE; }
public CropPanelClass(CropperForm cropperForm) { m_cropperForm = cropperForm; m_slotRatio = m_cropperForm.SlotRatio; // Initialize the crop panel m_cropPanel = new Panel(); m_cropPanel.Width = m_cropperForm.ClientSize.Width - m_cropperForm.m_imagesLibrary.Width; m_cropPanel.Height = m_cropperForm.ClientSize.Height - m_cropperForm.m_menuStrip.Height - m_cropperForm.m_slotsPanel.Height; m_cropPanel.Location = new Point(m_cropperForm.m_imagesLibrary.Width, m_cropperForm.m_menuStrip.Height); m_cropPanel.BackgroundImageLayout = ImageLayout.Center; m_cropPanel.BackgroundImageChanged += new EventHandler(m_cropPanel_BackgroundImageChanged); m_cropPanel.Paint += new PaintEventHandler(m_cropPanel_Paint); m_cropperForm.Controls.Add(m_cropPanel); // Create the arrow bitmap m_arrowBmp = new Bitmap( Image.FromFile(Application.StartupPath + "//Data//Images//Arrow.png"), m_cropperForm.m_slotsPanel.SlotWidth, m_cropperForm.m_slotsPanel.SlotWidth); // Initialize the arrow position m_arrowPos = new Point(0, 0); // Create the arrow picture box m_arrowPb = new PictureBox(); m_arrowPb.Size = new Size( m_arrowBmp.Width, (int)(m_arrowBmp.Width * 1.2f)); m_arrowPb.Location = new Point( ((m_cropperForm.m_slotsPanel.SlotCount + 1) * m_cropperForm.m_slotsPanel.SlotGap) + (m_cropperForm.m_slotsPanel.SlotCount * m_cropperForm.m_slotsPanel.SlotWidth), m_cropPanel.Height - m_arrowPb.Height); m_arrowPb.Image = m_arrowBmp; m_arrowPb.Tag = true; // Means the arrow goes down at first m_arrowPb.BackColor = Color.Transparent; m_arrowPb.Visible = false; m_cropPanel.Controls.Add(m_arrowPb); // Create the delete button m_deleteBut = new Button(); m_deleteBut.BackgroundImageLayout = ImageLayout.Stretch; m_deleteBut.BackColor = Color.Black; m_deleteBut.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//X.png"); m_deleteBut.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_deleteBut.Cursor = Cursors.Hand; m_deleteBut.Visible = false; m_deleteBut.Click += new EventHandler(m_deleteBut_Click); m_cropPanel.Controls.Add(m_deleteBut); // Create the color palette button m_CCWButt = new Button();; m_CCWButt.Name = "CCW"; m_CCWButt.BackgroundImageLayout = ImageLayout.Stretch; m_CCWButt.BackColor = Color.Black; m_CCWButt.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//CW.png"); m_CCWButt.BackgroundImage.RotateFlip(RotateFlipType.RotateNoneFlipX); m_CCWButt.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_CCWButt.Location = new Point(m_deleteBut.Width, 0); m_CCWButt.Cursor = Cursors.Hand; m_CCWButt.Visible = false; m_CCWButt.Click += new EventHandler(rotateButt_Click); m_cropPanel.Controls.Add(m_CCWButt); // Create the color palette button m_CWButt = new Button();; m_CWButt.Name = "CW"; m_CWButt.BackgroundImageLayout = ImageLayout.Stretch; m_CWButt.BackColor = Color.Black; m_CWButt.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//CW.png"); m_CWButt.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_CWButt.Location = new Point(2 * m_deleteBut.Width, 0); m_CWButt.Cursor = Cursors.Hand; m_CWButt.Visible = false; m_CWButt.Click += new EventHandler(rotateButt_Click); m_cropPanel.Controls.Add(m_CWButt); // Create the color dialog button m_colorBut = new Button(); m_colorBut.BackColor = Color.Red; m_colorBut.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_colorBut.Location = new Point(3 * m_deleteBut.Width, 0); m_colorBut.Cursor = Cursors.Hand; m_colorBut.Visible = false; m_colorBut.Click += new EventHandler(m_colorBut_Click); m_cropPanel.Controls.Add(m_colorBut); // Create the color aprove crop button m_approveCrop = new Button(); m_approveCrop.BackgroundImageLayout = ImageLayout.Stretch; m_approveCrop.BackColor = Color.Black; m_approveCrop.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//V.png"); m_approveCrop.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_approveCrop.Location = new Point(4 * m_deleteBut.Width, 0); m_approveCrop.Cursor = Cursors.Hand; m_approveCrop.Visible = false; m_approveCrop.Click += new EventHandler(m_approveCrop_Click); m_cropPanel.Controls.Add(m_approveCrop); // Crop rectangle variables m_cropAction = CropAction.NONE; m_newLocation = new Point(); m_prevMouse = new Point(); m_scaleRadius = 6; m_scaleDir = Direction.CENTER; // Crop rectangle m_cropRect = new Rectangle(); // Main picture box m_cropPb = new PictureBox(); m_cropPb.Visible = false; m_cropPb.MouseMove += new MouseEventHandler(m_cropPb_MouseMove); m_cropPb.MouseDown += new MouseEventHandler(m_cropPb_MouseDown); m_cropPb.MouseUp += new MouseEventHandler(m_cropPb_MouseUp); m_cropPb.Paint += new PaintEventHandler(m_cropPb_Paint); m_cropPanel.Controls.Add(m_cropPb); // Initialize the logo bitmap Image logoImage = Image.FromFile(Application.StartupPath + "//Data//Images//Subli-art logo.png"); float logoWidth = m_cropPanel.Width * 0.3f; float logoHeight = logoWidth / (logoImage.Width / (float)logoImage.Height); m_logoSize = new Size((int)logoWidth, (int)logoHeight); m_logo = new Bitmap(logoImage, m_logoSize); // Initialize the arrow timer m_arrowTimer = new Timer(); m_arrowTimer.Interval = 1; m_arrowTimer.Tick += new EventHandler(m_arrowTimer_Tick); }
private void m_cropPb_MouseUp(object sender, MouseEventArgs e) { m_cropAction = CropAction.NONE; }
private void InCropRect(int currX, int currY, string state) { // If the mouse is in crop rectangle area if ( (currX > m_cropRect.X - m_scaleRadius && currX < m_cropRect.X + m_cropRect.Width + m_scaleRadius) && (currY > m_cropRect.Y - m_scaleRadius && currY < m_cropRect.Y + m_cropRect.Height + m_scaleRadius)) { // Get the place of the mouse on the crop rectangle m_scaleDir = GetDirection(currX, currY); // If the mouse is down if (state.Equals("down")) { m_prevMouse.X = currX; m_prevMouse.Y = currY; if (m_scaleDir == Direction.CENTER) { m_cropAction = CropAction.DRAG; } else { m_cropAction = CropAction.SCALE; } } else { if (m_scaleDir == Direction.N || m_scaleDir == Direction.S) { m_cropPb.Cursor = Cursors.SizeNS; } else if (m_scaleDir == Direction.W || m_scaleDir == Direction.E) { m_cropPb.Cursor = Cursors.SizeWE; } else if (m_scaleDir == Direction.NW || m_scaleDir == Direction.SE) { m_cropPb.Cursor = Cursors.SizeNWSE; } else if (m_scaleDir == Direction.NE || m_scaleDir == Direction.SW) { m_cropPb.Cursor = Cursors.SizeNESW; } else { m_cropPb.Cursor = Cursors.SizeAll; } } } else { // If the mouse is down if (state.Equals("down")) { m_prevMouse.X = currX; m_prevMouse.Y = currY; m_cropAction = CropAction.CREATE; } else { m_cropAction = CropAction.NONE; } m_cropPb.Cursor = Cursors.Cross; } }
public CropPanelClass(CropperForm cropperForm, float slotRatio, PanelType type) { m_type = type; m_cropperForm = cropperForm; m_slotRatio = slotRatio; // CROP PANEL m_cropPanel = new Panel(); m_cropPanel.Width = m_cropperForm.ClientSize.Width - m_cropperForm.m_imagesLibrary.Width; m_cropPanel.Height = m_cropperForm.ClientSize.Height - m_cropperForm.m_menuStrip.Height - m_cropperForm.CurrSlotsPanel.Height; m_cropPanel.Location = new Point(m_cropperForm.m_imagesLibrary.Width, m_cropperForm.m_menuStrip.Height); m_cropPanel.BackgroundImageLayout = ImageLayout.Center; m_cropPanel.BackgroundImageChanged += new EventHandler(m_cropPanel_BackgroundImageChanged); m_cropPanel.Paint += new PaintEventHandler(m_cropPanel_Paint); m_cropperForm.Controls.Add(m_cropPanel); // ARROW BITMAP m_arrowBmp = new Bitmap( Image.FromFile(Application.StartupPath + "//Data//Images//Arrow.png"), m_cropperForm.CurrSlotsPanel.SlotWidth, m_cropperForm.CurrSlotsPanel.SlotWidth); // ARROW POSITION m_arrowPos = new Point(0, 0); // ARROW PICTURE BOX m_arrowPb = new PictureBox(); m_arrowPb.Name = m_cropperForm.m_langDictionary["Arrow Text Create"]; m_arrowPb.Size = new Size( m_arrowBmp.Width, (int)(m_arrowBmp.Width * 1.2f)); if (m_type != PanelType.Last) { m_arrowPb.Location = new Point( ((m_cropperForm.CurrSlotsPanel.SlotCount + 1) * m_cropperForm.CurrSlotsPanel.SlotGap) + (m_cropperForm.CurrSlotsPanel.SlotCount * m_cropperForm.CurrSlotsPanel.SlotWidth), m_cropPanel.Height - m_arrowPb.Height); } else { m_arrowPb.Location = new Point( ((m_cropperForm.CurrSlotsPanel.SlotCount + 2) * m_cropperForm.CurrSlotsPanel.SlotGap) + ((m_cropperForm.CurrSlotsPanel.SlotCount + 1) * m_cropperForm.CurrSlotsPanel.SlotWidth), m_cropPanel.Height - m_arrowPb.Height); } m_arrowPb.Image = m_arrowBmp; m_arrowPb.Tag = true; // Means the arrow goes down at first m_arrowPb.BackColor = Color.Transparent; m_arrowPb.Visible = false; m_cropPanel.Controls.Add(m_arrowPb); // DELETE BUTTON m_deleteBut = new Button(); m_deleteBut.BackgroundImageLayout = ImageLayout.Stretch; m_deleteBut.BackColor = Color.Black; m_deleteBut.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//X.png"); m_deleteBut.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_deleteBut.Cursor = Cursors.Hand; m_deleteBut.Visible = false; m_deleteBut.Click += new EventHandler(m_deleteBut_Click); m_cropPanel.Controls.Add(m_deleteBut); // CCW BUTTON m_CCWButt = new Button();; m_CCWButt.Name = "CCW"; m_CCWButt.BackgroundImageLayout = ImageLayout.Stretch; m_CCWButt.BackColor = Color.Black; m_CCWButt.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//CW.png"); m_CCWButt.BackgroundImage.RotateFlip(RotateFlipType.RotateNoneFlipX); m_CCWButt.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_CCWButt.Location = new Point(m_deleteBut.Width, 0); m_CCWButt.Cursor = Cursors.Hand; m_CCWButt.Visible = false; m_CCWButt.Click += new EventHandler(rotateButt_Click); m_cropPanel.Controls.Add(m_CCWButt); // CW BUTTON m_CWButt = new Button();; m_CWButt.Name = "CW"; m_CWButt.BackgroundImageLayout = ImageLayout.Stretch; m_CWButt.BackColor = Color.Black; m_CWButt.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//CW.png"); m_CWButt.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_CWButt.Location = new Point(2 * m_deleteBut.Width, 0); m_CWButt.Cursor = Cursors.Hand; m_CWButt.Visible = false; m_CWButt.Click += new EventHandler(rotateButt_Click); m_cropPanel.Controls.Add(m_CWButt); // COLOR BUTTON m_colorBut = new Button(); m_colorBut.BackColor = Color.Red; m_colorBut.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_colorBut.Location = new Point(3 * m_deleteBut.Width, 0); m_colorBut.Cursor = Cursors.Hand; m_colorBut.Visible = false; m_colorBut.Click += new EventHandler(m_colorBut_Click); m_cropPanel.Controls.Add(m_colorBut); // APPROVE CROP m_approveCrop = new Button(); m_approveCrop.BackgroundImageLayout = ImageLayout.Stretch; m_approveCrop.BackColor = Color.Black; m_approveCrop.BackgroundImage = new Bitmap(Application.StartupPath + "//Data//Images//V.png"); m_approveCrop.Size = new Size((int)(m_cropPanel.Width * 0.03f), (int)(m_cropPanel.Width * 0.03f)); m_approveCrop.Location = new Point(4 * m_deleteBut.Width, 0); m_approveCrop.Cursor = Cursors.Hand; m_approveCrop.Visible = false; m_approveCrop.Click += new EventHandler(m_approveCrop_Click); m_cropPanel.Controls.Add(m_approveCrop); // CROP RECTANGLE VARIABLES m_cropAction = CropAction.NONE; m_newLocation = new Point(); m_prevMouse = new Point(); m_scaleRadius = 6; m_scaleDir = Direction.CENTER; // CROP RECTANGLE m_cropRect = new Rectangle(); // MAIN PICTURE BOX m_cropPb = new PictureBox(); m_cropPb.Visible = false; m_cropPb.MouseMove += new MouseEventHandler(m_cropPb_MouseMove); m_cropPb.MouseDown += new MouseEventHandler(m_cropPb_MouseDown); m_cropPb.MouseUp += new MouseEventHandler(m_cropPb_MouseUp); m_cropPb.Paint += new PaintEventHandler(m_cropPb_Paint); m_cropPanel.Controls.Add(m_cropPb); // LOGO BITMAP Image logoImage = Image.FromFile(Application.StartupPath + "//Data//Images//Subli-art logo.png"); float logoWidth = m_cropPanel.Width * 0.3f; float logoHeight = logoWidth / (logoImage.Width / (float)logoImage.Height); m_logoSize = new Size((int)logoWidth, (int)logoHeight); m_logo = new Bitmap(logoImage, m_logoSize); // ARROW TIMER m_arrowTimer = new Timer(); m_arrowTimer.Interval = 1; m_arrowTimer.Tick += new EventHandler(m_arrowTimer_Tick); }