using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace FCC_Uber_MDX_Configurator { public partial class GraphicLayoutEditorForm : Form { public int CurrentPage = -1; public Bitmap RulerBitmap = new Bitmap(1, 1); public Bitmap MAIN_PANEL_Bitmap; public bool showGridLines = true; public bool isDeleteEnabled = false; public int mouse_x = 0, mouse_y = 0; public MouseStatus _MouseStatus = MouseStatus.NOTHING; public RenderLevel _RenderStatus = RenderLevel.TEXTURED; public static Pen Pen_OutlineMode = new Pen(Color.FromArgb(122, Color.Black), 1.0f); public Color Color_OutlineModeFill = Color.FromArgb(50, 0, 0, 255); public GlobalStaticClass.FusionImage CurrentImage = null; public Point ImageOffset = new Point(0, 0); public enum MouseStatus { NOTHING = -1, PRELOCK = 1, LOCKED = 2}; public enum RenderLevel { OUTLINE = 0, TEXTURED = 2 }; public enum GradientLevel { NORMALBLUE, PRELOCK_YELLOW }; #region Initialization public GraphicLayoutEditorForm(int input_page) { InitializeComponent(); CurrentPage = input_page; this.Size = new Size(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth + global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Width + 20 + 25, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight + TS_GraphicsToolBar.Height + global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Height + 40 + 25); MAIN_PANEL.Location = new Point(0 + global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Width, TS_GraphicsToolBar.Height + global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Height); MAIN_PANEL.Size = new Size(GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight); MAIN_PANEL_Bitmap = new Bitmap(MAIN_PANEL.Width, MAIN_PANEL.Height); RedrawPixelRulers(); this.Shown += new EventHandler(GraphicLayoutEditorForm_Shown); } void GraphicLayoutEditorForm_Shown(object sender, EventArgs e) { Graphics m_g = MAIN_PANEL.CreateGraphics(); UpdateGraphics(); m_g.DrawImage(MAIN_PANEL_Bitmap, 0, 0); this.Shown += new EventHandler(GraphicLayoutEditorForm_Shown); } #endregion #region Form Size Changed private void GraphicLayoutEditorForm_SizeChanged(object sender, EventArgs e) { RedrawPixelRulers(); } #endregion #region Draw Pixel Ruler Guides private void RedrawPixelRulers() { RulerBitmap = new Bitmap(this.Size.Width, this.Size.Height); Graphics g = Graphics.FromImage(RulerBitmap); g.Clear(Color.LightGray); g.DrawImage(global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft, new Rectangle(new Point(0, TS_GraphicsToolBar.Height + 0), global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Size)); int currentX = 0; int currentY = 0; SolidBrush b = new SolidBrush(Color.Black); Font f = new Font("Arial", 7); StringFormat dF = new StringFormat(StringFormatFlags.DirectionVertical); for (int x = global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Width; x < this.Size.Width; x += global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankHorizontal.Width) { g.DrawImage(global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankHorizontal, new Rectangle(new Point(x, TS_GraphicsToolBar.Height), global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankHorizontal.Size)); g.DrawString(currentX.ToString(), f, b, new PointF(x + 2, TS_GraphicsToolBar.Height + 1)); currentX += global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankHorizontal.Width; } for (int y = global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_TopLeft.Height + TS_GraphicsToolBar.Height; y < this.Size.Height; y += global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankVertical.Height) { g.DrawImage(global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankVertical, new Rectangle(new Point(0, y), global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankVertical.Size)); g.DrawString(currentY.ToString(), f, b, new RectangleF(new PointF(0 + 1, y + 2), new SizeF(global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankVertical.Width - 5 - 1, global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankVertical.Height - 2))); currentY += global::FCC_Uber_MDX_Configurator.Properties.Resources.Ruler_BlankVertical.Height; } g.Dispose(); this.BackgroundImage = RulerBitmap; this.BackgroundImageLayout = ImageLayout.None; } #endregion #region Mouse Move Event private void MAIN_PANEL_MouseMove(object sender, MouseEventArgs e) { if (new Rectangle(MAIN_PANEL.Location, MAIN_PANEL.Size).Contains(new Point(e.Location.X + MAIN_PANEL.Location.X, e.Location.Y + MAIN_PANEL.Location.Y))) { TSL_CURRENTMOUSE.Text = "[" + e.X.ToString() + "," + e.Y.ToString() + "]"; mouse_x = e.X; mouse_y = e.Y; if (_MouseStatus == MouseStatus.LOCKED) { if (CurrentImage != null) { CurrentImage._x = mouse_x - ImageOffset.X; CurrentImage._y = mouse_y - ImageOffset.Y; if (CurrentImage._x < 0) { CurrentImage._x = 0; } else if (CurrentImage._x + CurrentImage._width > MAIN_PANEL.Width) { CurrentImage._x = MAIN_PANEL.Width - CurrentImage._width; } if (CurrentImage._y < 0) { CurrentImage._y = 0; } else if (CurrentImage._y + CurrentImage._height > MAIN_PANEL.Height) { CurrentImage._y = MAIN_PANEL.Height - CurrentImage._height; } } else { } } UpdateGraphics(e.X, e.Y); } else { TSL_CURRENTMOUSE.Text = "[*,*]"; _MouseStatus = MouseStatus.NOTHING; CurrentImage = null; ChangeDeleteStatus(false); UpdateGraphics(); } } #endregion #region Change Delete Status public void ChangeDeleteStatus(bool _status) { isDeleteEnabled = _status; foreach (ToolStripItem _t in TS_GraphicsToolBar.Items) { if (_t != TSB_Delete && _t != TSL_CURRENTMOUSE && _t != TSB_MOUSESTATUS && _t != TSB_RotateImage) { _t.Enabled = !isDeleteEnabled; } } } #endregion #region Update Graphics because of Mouse Moving public void UpdateGraphics(int x, int y) { UpdateGraphics(); //m_g.DrawImage(MAIN_PANEL_Bitmap, 0, 0); if (showGridLines) { Graphics m_g = MAIN_PANEL.CreateGraphics(); //Graphics g = MAIN_PANEL.CreateGraphics(); //Graphics g = Graphics.FromImage(MAIN_PANEL_Bitmap); //g.Clear(Color.White); //g.DrawImage(MAIN_PANEL_Bitmap, new Point(0, 0)); Pen p = new Pen(Color.LightBlue, 1.0f); //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; m_g.DrawLine(p, x, 0.0f, x, MAIN_PANEL.Size.Height); m_g.DrawLine(p, 0, y, MAIN_PANEL.Size.Width, y); m_g.Dispose(); } } #endregion #region Update Graphics - All GUI Objects Drawing public void UpdateGraphics() { switch (_MouseStatus) { case MouseStatus.NOTHING: TSB_MOUSESTATUS.Image = global::FCC_Uber_MDX_Configurator.Properties.Resources.NothingIcon; break; case MouseStatus.PRELOCK: TSB_MOUSESTATUS.Image = global::FCC_Uber_MDX_Configurator.Properties.Resources.UnlockIcon; break; case MouseStatus.LOCKED: TSB_MOUSESTATUS.Image = global::FCC_Uber_MDX_Configurator.Properties.Resources.LockIcon; break; default: break; } UpdateGraphics_DrawToBitmap(_RenderStatus, _MouseStatus, MAIN_PANEL_Bitmap, CurrentPage, CurrentImage); Graphics m_g = MAIN_PANEL.CreateGraphics(); m_g.DrawImage(MAIN_PANEL_Bitmap, 0, 0); m_g.Dispose(); } public static Bitmap UpdateGraphics_DrawToBitmap(RenderLevel _level, MouseStatus _input_MouseStatus, Bitmap _draw2, int CurrentPage, GlobalStaticClass.FusionImage CurrentImage) { Graphics g = Graphics.FromImage(_draw2); g.Clear(Color.White); if (_level == RenderLevel.TEXTURED) { foreach (GlobalStaticClass.FusionImage_BackgroundImage _back in GlobalStaticClass._Global_List_Graphics_BackgroundImage) { if (_back._page == CurrentPage) { switch (_back._imageLayout.ToLower()) { case "centre": { int c_x = (GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth / 2) - (_back._image.Width / 2); int c_y = (GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight / 2) - (_back._image.Height / 2); g.DrawImage(_back._image, new Rectangle(c_x, c_y, _back._image.Width, _back._image.Height)); } break; case "tile": { for (int i = 0; i < GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth / _back._image.Width; i++) { for (int j = 0; j < GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight / _back._image.Height; j++) { g.DrawImage(_back._image, new Point(_back._image.Width * i, _back._image.Height * j)); } } } break; case "stretch": { g.DrawImage(_back._image, new Rectangle(0, 0, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight)); } break; case "zoom": { double _scale = 1.0; double _scalex = (double)GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth / (double)_back._image.Width; double _scaley = (double)GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight / (double)_back._image.Height; if (_scalex < _scaley) { g.DrawImage(_back._image, new Rectangle(0, (GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight / 2) - (int)((_back._image.Height * _scalex) / 2), GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth, (int)(_back._image.Height * _scalex))); } else { g.DrawImage(_back._image, new Rectangle((GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth / 2) - (int)((_back._image.Width * _scaley) / 2), 0, (int)(_back._image.Width * _scaley), GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight)); } } break; default: break; } break; } } } for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images.Count; i++) { switch (GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._ListReferenceType) { case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_STATICIMAGES: { if (!GlobalStaticClass._Global_List_Graphics_StaticImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } bool isTheSame = (GlobalStaticClass._Global_List_Graphics_StaticImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList] == CurrentImage); UpdateGraphics_DrawImageAtRenderLevel(g, _level, _input_MouseStatus, (GlobalStaticClass.FusionImage)GlobalStaticClass._Global_List_Graphics_StaticImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList], isTheSame); } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_DISPLAYBUTTONS: { if (!GlobalStaticClass._Global_List_Graphics_DisplayButton[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } bool isTheSame = (GlobalStaticClass._Global_List_Graphics_DisplayButton[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList] == CurrentImage); UpdateGraphics_DrawImageAtRenderLevel(g, _level, _input_MouseStatus, (GlobalStaticClass.FusionImage)GlobalStaticClass._Global_List_Graphics_DisplayButton[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList], isTheSame); } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_MULTIIMAGES: { if (!GlobalStaticClass._Global_List_Graphics_MultiImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } bool isTheSame = (GlobalStaticClass._Global_List_Graphics_MultiImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList] == CurrentImage); UpdateGraphics_DrawImageAtRenderLevel(g, _level, _input_MouseStatus, (GlobalStaticClass.FusionImage)GlobalStaticClass._Global_List_Graphics_MultiImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList], isTheSame); } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_VARIABLELOCATION: { if (!GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } bool isTheSame = (GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList] == CurrentImage); int _tempX = GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._x, _tempY = GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._y; if (GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._translateAround == GlobalStaticClass.Axis.HORIZONTAL) { GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._x += GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._location_minimum; } else { GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._y += GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._location_minimum; } UpdateGraphics_DrawImageAtRenderLevel(g, _level, _input_MouseStatus, (GlobalStaticClass.FusionImage)GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList], isTheSame); GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._x = _tempX; GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._y = _tempY; } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_GRAPH: { if (!GlobalStaticClass._Global_List_Graphics_Graphs[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } bool isTheSame = (GlobalStaticClass._Global_List_Graphics_Graphs[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList] == CurrentImage); UpdateGraphics_DrawImageAtRenderLevel(g, _level, _input_MouseStatus, (GlobalStaticClass.FusionImage)GlobalStaticClass._Global_List_Graphics_Graphs[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList], isTheSame); } break; default: break; } } for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_TextLabels.Count; i++) { if (!GlobalStaticClass._Global_List_Graphics_TextLabels[i]._pages.Contains(CurrentPage)) { continue; } bool isTheSame = (GlobalStaticClass._Global_List_Graphics_TextLabels[i] == CurrentImage); UpdateGraphics_DrawImageAtRenderLevel(g, _level, _input_MouseStatus, (GlobalStaticClass.FusionImage)GlobalStaticClass._Global_List_Graphics_TextLabels[i], isTheSame); } g.Dispose(); return _draw2; } #endregion #region Draw Individual Image private static void UpdateGraphics_DrawImageAtRenderLevel(Graphics input_graphic, RenderLevel input_level, MouseStatus _MouseStatus, GlobalStaticClass.FusionImage input_image, bool isCurrentModule) { if (input_image._image == null) { return; } switch (input_level) { case RenderLevel.OUTLINE: if (_MouseStatus == MouseStatus.NOTHING) { UpdateGraphics_DrawImageAsOutline(input_graphic, input_image, GradientLevel.NORMALBLUE); } else { if (isCurrentModule) { UpdateGraphics_DrawImageAsOutline(input_graphic, input_image, GradientLevel.NORMALBLUE); } else { UpdateGraphics_DrawImageAsOutline(input_graphic, input_image, GradientLevel.PRELOCK_YELLOW); } } break; case RenderLevel.TEXTURED: if (_MouseStatus == MouseStatus.NOTHING) { UpdateGraphics_DrawImageAsTexture(input_graphic, input_image); } else { if (isCurrentModule) { UpdateGraphics_DrawImageAsTexture(input_graphic, input_image); } else { UpdateGraphics_DrawImageAsOutline(input_graphic, input_image, GradientLevel.PRELOCK_YELLOW); } } break; default: break; } } #endregion #region Draw Individual Image - As Outline private static void UpdateGraphics_DrawImageAsOutline(Graphics input_graphic, GlobalStaticClass.FusionImage input_image, GradientLevel input_level) { Point _topLeft = new Point(input_image._x, input_image._y); Point _topRight = new Point(input_image._x + input_image._width, input_image._y); Point _bottomLeft = new Point(input_image._x, input_image._y + input_image._height); Point _bottomRight = new Point(input_image._x + input_image._width, input_image._y + input_image._height); input_graphic.DrawRectangle(Pen_OutlineMode, input_image._x, input_image._y, input_image._width, input_image._height); System.Drawing.Drawing2D.LinearGradientBrush Brush_OutlineMode = Brush_OutlineMode = new System.Drawing.Drawing2D.LinearGradientBrush(_bottomRight, _topLeft, Color.FromArgb(50, 50, 50, 255), Color.FromArgb(50, 255, 255, 255)); if(input_level == GradientLevel.PRELOCK_YELLOW) { Brush_OutlineMode = new System.Drawing.Drawing2D.LinearGradientBrush(_bottomRight, _topLeft, Color.FromArgb(50, 255, 0, 0), Color.FromArgb(50, 255, 255, 255)); } input_graphic.FillRectangle(Brush_OutlineMode, input_image._x, input_image._y, input_image._width, input_image._height); } #endregion #region Draw Individual Image - As Texture private static void UpdateGraphics_DrawImageAsTexture(Graphics input_graphic, GlobalStaticClass.FusionImage input_image) { if (input_image._rotation != 0.0) { Bitmap _blah = new Bitmap(input_image._width, input_image._height); Graphics _blahG = Graphics.FromImage(_blah); _blahG.Clear(Color.Transparent); _blahG.TranslateTransform((float)input_image._image.Width / 2, (float)input_image._image.Height / 2); _blahG.RotateTransform(input_image._rotation); _blahG.TranslateTransform(-(float)input_image._image.Width / 2, -(float)input_image._image.Height / 2); _blahG.DrawImage(input_image._image, new Rectangle(new Point(0, 0), new Size(input_image._width, input_image._height))); _blahG.Dispose(); input_graphic.DrawImage(_blah, new Rectangle(input_image._x, input_image._y, input_image._width, input_image._height)); } else { input_graphic.DrawImage(input_image._image, new Rectangle(input_image._x, input_image._y, input_image._width, input_image._height)); } } #endregion #region Mouse Leave Event private void MAIN_PANEL_MouseLeave(object sender, EventArgs e) { TSL_CURRENTMOUSE.Text = "[*,*]"; _MouseStatus = MouseStatus.NOTHING; CurrentImage = null; ChangeDeleteStatus(false); UpdateGraphics(); } #endregion #region Mouse Enter Event private void MAIN_PANEL_MouseEnter(object sender, EventArgs e) { } #endregion #region Keyboard Shortcuts private void GraphicLayoutEditorForm_KeyPress(object sender, KeyPressEventArgs e) { if ((int)e.KeyChar == (int)Keys.Space) { showGridLines = !showGridLines; UpdateGraphics(mouse_x, mouse_y); } } #endregion #region Add Static Image private void TSB_StaticImage_Click(object sender, EventArgs e) { AddStaticImageForm _tempSIF = new AddStaticImageForm(); if (_tempSIF.ShowDialog() == DialogResult.OK) { if (_tempSIF.CurrentStaticImage != null) { GlobalStaticClass._Global_List_Graphics_StaticImage.Add(_tempSIF.CurrentStaticImage); GlobalStaticClass.GraphicsSort(); } } this.DialogResult = DialogResult.None; UpdateGraphics(); } #endregion #region Mouse Click Event private void MAIN_PANEL_MouseClick(object sender, MouseEventArgs e) { //Point actualMousePoint = new Point(e.Location.X + MAIN_PANEL.Location.X, e.Location.Y + MAIN_PANEL.Location.Y); Point actualMousePoint = new Point(e.Location.X, e.Location.Y); switch (_MouseStatus) { case MouseStatus.NOTHING: { GlobalStaticClass.FusionImage _tempReturn = CheckForModuleBounds(actualMousePoint); if (_tempReturn != null) { CurrentImage = _tempReturn; _MouseStatus = MouseStatus.PRELOCK; } else { if (isDeleteEnabled) { //Could have been the background... if ((new ConfirmDialogForm("Null Click", "Delete Background?", "Are you trying to delete this pages background image?")).ShowDialog() == DialogResult.OK) { ChangeDeleteStatus(false); _MouseStatus = MouseStatus.NOTHING; foreach (GlobalStaticClass.FusionImage_BackgroundImage _back in GlobalStaticClass._Global_List_Graphics_BackgroundImage) { if (_back._page == CurrentPage) { GlobalStaticClass._Global_List_Graphics_BackgroundImage.Remove(_back); break; } } } } } } break; case MouseStatus.PRELOCK: { GlobalStaticClass.FusionImage _tempReturn = CheckForModuleBounds(actualMousePoint); if (CurrentImage == _tempReturn) { if (e.Button == MouseButtons.Left) { ChangeDeleteStatus(false); ImageOffset = new Point(actualMousePoint.X - _tempReturn._x, actualMousePoint.Y - _tempReturn._y); _MouseStatus = MouseStatus.LOCKED; } else if (e.Button == MouseButtons.Right) { _MouseStatus = MouseStatus.NOTHING; if (isDeleteEnabled) { ChangeDeleteStatus(false); foreach (GlobalStaticClass.FusionImage_StaticImage _testStatic in GlobalStaticClass._Global_List_Graphics_StaticImage) { if (_testStatic == _tempReturn) { if ((new ConfirmDialogForm("Confirm Delete", "Delete Graphics Object?", "Are you sure you want to delete this static image at [" + _tempReturn._x + ", " + _tempReturn._y + "]? There is no undo.")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_StaticImage.Remove(_testStatic); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_DisplayButton _testDisplayButton in GlobalStaticClass._Global_List_Graphics_DisplayButton) { if (_testDisplayButton == _tempReturn) { if ((new ConfirmDialogForm("Confirm Delete", "Delete Graphics Object?", "Are you sure you want to delete this display button at [" + _tempReturn._x + ", " + _tempReturn._y + "]? There is no undo.")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_DisplayButton.Remove(_testDisplayButton); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_MultiImage _testMultiImage in GlobalStaticClass._Global_List_Graphics_MultiImage) { if (_testMultiImage == _tempReturn) { if ((new ConfirmDialogForm("Confirm Delete", "Delete Graphics Object?", "Are you sure you want to delete this multi-image at [" + _tempReturn._x + ", " + _tempReturn._y + "]? There is no undo.")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_MultiImage.Remove(_testMultiImage); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_VariableLocationImage _testVariableLocation in GlobalStaticClass._Global_List_Graphics_VariableLocationImage) { if (_testVariableLocation == _tempReturn) { if ((new ConfirmDialogForm("Confirm Delete", "Delete Graphics Object?", "Are you sure you want to delete this variable location image at [" + _tempReturn._x + ", " + _tempReturn._y + "]? There is no undo.")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_VariableLocationImage.Remove(_testVariableLocation); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionFont_TextLabel _testTextImage in GlobalStaticClass._Global_List_Graphics_TextLabels) { if (_testTextImage == _tempReturn) { if ((new ConfirmDialogForm("Confirm Delete", "Delete Graphics Object?", "Are you sure you want to delete this text-label at [" + _tempReturn._x + ", " + _tempReturn._y + "]? There is no undo.")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_TextLabels.Remove(_testTextImage); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_Graph _testGraph in GlobalStaticClass._Global_List_Graphics_Graphs) { if (_testGraph == _tempReturn) { if ((new ConfirmDialogForm("Confirm Delete", "Delete Graphics Object?", "Are you sure you want to delete this graph instance at [" + _testGraph._x + ", " + _testGraph._y + "]? There is no undo.")).ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_Graphs.Remove(_testGraph); } this.DialogResult = DialogResult.None; break; } } } else { foreach (GlobalStaticClass.FusionImage_StaticImage _testStatic in GlobalStaticClass._Global_List_Graphics_StaticImage) { if (_testStatic == _tempReturn) { AddStaticImageForm _tempStaticForm = new AddStaticImageForm(_testStatic); if (_tempStaticForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_StaticImage.Remove(_testStatic); GlobalStaticClass._Global_List_Graphics_StaticImage.Add(_tempStaticForm.CurrentStaticImage); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_DisplayButton _testDisplayButton in GlobalStaticClass._Global_List_Graphics_DisplayButton) { if (_testDisplayButton == _tempReturn) { AddDisplayButtonForm _tempDisplayButtonForm = new AddDisplayButtonForm(_testDisplayButton); if (_tempDisplayButtonForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_DisplayButton.Remove(_testDisplayButton); GlobalStaticClass._Global_List_Graphics_DisplayButton.Add(_tempDisplayButtonForm.CurrentDisplayButton); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_MultiImage _testMultiImage in GlobalStaticClass._Global_List_Graphics_MultiImage) { if (_testMultiImage == _tempReturn) { AddMultiImageForm _tempMultiImageForm = new AddMultiImageForm(_testMultiImage); if (_tempMultiImageForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_MultiImage.Remove(_testMultiImage); GlobalStaticClass._Global_List_Graphics_MultiImage.Add(_tempMultiImageForm.CurrentMultiImage); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_VariableLocationImage _testVariableLocation in GlobalStaticClass._Global_List_Graphics_VariableLocationImage) { if (_testVariableLocation == _tempReturn) { AddVariableLocationImageForm _tempVarLocationImageForm = new AddVariableLocationImageForm(_testVariableLocation); if (_tempVarLocationImageForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_VariableLocationImage.Remove(_testVariableLocation); GlobalStaticClass._Global_List_Graphics_VariableLocationImage.Add(_tempVarLocationImageForm.CurrentVariableLocationImage); GlobalStaticClass.GraphicsSort(); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionFont_TextLabel _testTextImage in GlobalStaticClass._Global_List_Graphics_TextLabels) { if (_testTextImage == _tempReturn) { AddTextLabelForm _tempTextLabelForm = new AddTextLabelForm(_testTextImage); if (_tempTextLabelForm.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_TextLabels.Remove(_testTextImage); GlobalStaticClass._Global_List_Graphics_TextLabels.Add(_tempTextLabelForm.CurrentTextLabel); } this.DialogResult = DialogResult.None; break; } } foreach (GlobalStaticClass.FusionImage_Graph _testGraph in GlobalStaticClass._Global_List_Graphics_Graphs) { if (_testGraph == _tempReturn) { AddGraphForm _tempAGF = new AddGraphForm(_testGraph); if (_tempAGF.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_Graphs.Remove(_testGraph); GlobalStaticClass._Global_List_Graphics_Graphs.Add(_tempAGF.CurrentGraph); } this.DialogResult = DialogResult.None; break; } } } } } else { _MouseStatus = MouseStatus.NOTHING; } } break; case MouseStatus.LOCKED: { CurrentImage = null; ChangeDeleteStatus(false); _MouseStatus = MouseStatus.NOTHING; } break; default: break; } UpdateGraphics(); } #endregion #region Check Module Bounds public GlobalStaticClass.FusionImage CheckForModuleBounds(Point mouseLocation) { for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_TextLabels.Count; i++) { if (!GlobalStaticClass._Global_List_Graphics_TextLabels[i]._pages.Contains(CurrentPage)) { continue; } GlobalStaticClass.FusionFont_TextLabel _textLabel = GlobalStaticClass._Global_List_Graphics_TextLabels[i]; if (new Rectangle(_textLabel._x, _textLabel._y, _textLabel._width, _textLabel._height).Contains(mouseLocation)) { return (GlobalStaticClass.FusionImage)_textLabel; } } for (int i = GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images.Count - 1; i >= 0; i--) { switch (GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._ListReferenceType) { case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_STATICIMAGES: { if (!GlobalStaticClass._Global_List_Graphics_StaticImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } GlobalStaticClass.FusionImage_StaticImage _static = GlobalStaticClass._Global_List_Graphics_StaticImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]; if (new Rectangle(_static._x, _static._y, _static._width, _static._height).Contains(mouseLocation)) { return (GlobalStaticClass.FusionImage)_static; } } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_DISPLAYBUTTONS: { if (!GlobalStaticClass._Global_List_Graphics_DisplayButton[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } GlobalStaticClass.FusionImage_DisplayButton _disp = GlobalStaticClass._Global_List_Graphics_DisplayButton[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]; if (new Rectangle(_disp._x, _disp._y, _disp._width, _disp._height).Contains(mouseLocation)) { return (GlobalStaticClass.FusionImage)_disp; } } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_MULTIIMAGES: { if (!GlobalStaticClass._Global_List_Graphics_MultiImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } GlobalStaticClass.FusionImage_MultiImage _multi = GlobalStaticClass._Global_List_Graphics_MultiImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]; if (new Rectangle(_multi._x, _multi._y, _multi._width, _multi._height).Contains(mouseLocation)) { return (GlobalStaticClass.FusionImage)_multi; } } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_VARIABLELOCATION: { if (!GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } GlobalStaticClass.FusionImage_VariableLocationImage _vLSI = GlobalStaticClass._Global_List_Graphics_VariableLocationImage[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]; if (new Rectangle(_vLSI._x, _vLSI._y, _vLSI._width, _vLSI._height).Contains(mouseLocation)) { return (GlobalStaticClass.FusionImage)_vLSI; } } break; case GlobalStaticClass.ZOrderListIndexMatrix.ENUM_GRAPH: { if (!GlobalStaticClass._Global_List_Graphics_Graphs[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]._pages.Contains(CurrentPage)) { continue; } GlobalStaticClass.FusionImage_Graph _vLSI = GlobalStaticClass._Global_List_Graphics_Graphs[GlobalStaticClass._Global_List_Graphics_Generic_Sorted_Images[i]._IndexInList]; if (new Rectangle(_vLSI._x, _vLSI._y, _vLSI._width, _vLSI._height).Contains(mouseLocation)) { return (GlobalStaticClass.FusionImage)_vLSI; } } break; default: break; } } return null; } #endregion #region Change Render Level private void TSB_RENDER_OUTLINE_Click(object sender, EventArgs e) { _RenderStatus = RenderLevel.OUTLINE; UpdateGraphics(); } private void TSB_RENDER_FULL_Click(object sender, EventArgs e) { _RenderStatus = RenderLevel.TEXTURED; UpdateGraphics(); } #endregion #region Add Background Image private void TSB_BackgroundImage_Click(object sender, EventArgs e) { AddBackgroundImageForm _tempBackForm = null; int back_index = -1; for (int i = 0; i < GlobalStaticClass._Global_List_Graphics_BackgroundImage.Count; i++) { if (GlobalStaticClass._Global_List_Graphics_BackgroundImage[i]._page == CurrentPage) { back_index = i; break; } } if (back_index == -1) { _tempBackForm = new AddBackgroundImageForm(CurrentPage); } else { _tempBackForm = new AddBackgroundImageForm(GlobalStaticClass._Global_List_Graphics_BackgroundImage[back_index]); } if (_tempBackForm.ShowDialog() == DialogResult.OK) { if (back_index >= 0) { GlobalStaticClass._Global_List_Graphics_BackgroundImage.RemoveAt(back_index); } GlobalStaticClass._Global_List_Graphics_BackgroundImage.Add(_tempBackForm.CurrentBackgroundImage); } UpdateGraphics(); } #endregion #region Save Button private void TSB_SAVE_Click(object sender, EventArgs e) { UpdateGraphics(); this.DialogResult = DialogResult.OK; } #endregion #region Toggle Crossshairs private void TSB_TOGGLECROSSHAIRS_Click(object sender, EventArgs e) { showGridLines = !showGridLines; UpdateGraphics(mouse_x, mouse_y); } #endregion #region Add Display Button private void TSB_DisplayButton_Click(object sender, EventArgs e) { AddDisplayButtonForm _tempSDBew = new AddDisplayButtonForm(); if (_tempSDBew.ShowDialog() == DialogResult.OK) { if (_tempSDBew.CurrentDisplayButton != null) { GlobalStaticClass._Global_List_Graphics_DisplayButton.Add(_tempSDBew.CurrentDisplayButton); GlobalStaticClass.GraphicsSort(); } } this.DialogResult = DialogResult.None; UpdateGraphics(); } #endregion #region Render Region Main Button Click private void TSSB_RENDER_ButtonClick(object sender, EventArgs e) { if (_RenderStatus == RenderLevel.TEXTURED) { _RenderStatus = RenderLevel.OUTLINE; } else if (_RenderStatus == RenderLevel.OUTLINE) { _RenderStatus = RenderLevel.TEXTURED; } UpdateGraphics(); } #endregion private void TSB_MultiImage_Click(object sender, EventArgs e) { AddMultiImageForm _tempMIF = new AddMultiImageForm(); if (_tempMIF.ShowDialog() == DialogResult.OK) { if (_tempMIF.CurrentMultiImage != null) { GlobalStaticClass._Global_List_Graphics_MultiImage.Add(_tempMIF.CurrentMultiImage); GlobalStaticClass.GraphicsSort(); } } this.DialogResult = DialogResult.None; UpdateGraphics(); } private void TSB_Delete_Click(object sender, EventArgs e) { ChangeDeleteStatus(!isDeleteEnabled); } private void TSB_TEXT_LABEL_Click(object sender, EventArgs e) { AddTextLabelForm _tempTLF = new AddTextLabelForm(); if (_tempTLF.ShowDialog() == DialogResult.OK) { GlobalStaticClass._Global_List_Graphics_TextLabels.Add(_tempTLF.CurrentTextLabel); this.DialogResult = DialogResult.None; UpdateGraphics(); } } private void TSB_VARIABLELOCATION_Click(object sender, EventArgs e) { AddVariableLocationImageForm _tempVLIF = new AddVariableLocationImageForm(); if (_tempVLIF.ShowDialog() == DialogResult.OK) { if (_tempVLIF.CurrentVariableLocationImage != null) { GlobalStaticClass._Global_List_Graphics_VariableLocationImage.Add(_tempVLIF.CurrentVariableLocationImage); GlobalStaticClass.GraphicsSort(); } } this.DialogResult = DialogResult.None; UpdateGraphics(); } private void TSB_GRAPH_Click(object sender, EventArgs e) { AddGraphForm _tempGF = new AddGraphForm(); if (_tempGF.ShowDialog() == DialogResult.OK) { if (_tempGF.CurrentGraph != null) { GlobalStaticClass._Global_List_Graphics_Graphs.Add(_tempGF.CurrentGraph); GlobalStaticClass.GraphicsSort(); } } this.DialogResult = DialogResult.None; UpdateGraphics(); } } }