Esempio n. 1
0
 public BoxOptionsForm(xBox box)
 {
     InitializeComponent();
     Text = Options.LangCur.lEOTitle + " " + Options.LangCur.lEETitleBox;
     // Share
     lblReference.Text = Options.LangCur.lEOReference;
     lblName.Text      = Options.LangCur.lEOName;
     toolTip.SetToolTip(btnGetReference, Options.LangCur.hEOGetReference);
     // Own
     lblText.Text = Options.LangCur.lBOText;
     lblSize.Text = Options.LangCur.lBOSize;
     // Store
     Box = box;
     if (Box == null)
     {
         btnOk.Enabled = false;
         return;
     }
     // Fill
     tbReference.Text    = Box.Reference;
     tbName.Text         = Box.Name;
     tbDescription.Text  = Box.Description;
     tbText.Text         = Box.Text;
     nudSizeWidth.Value  = Box.Width;
     nudSizeHeight.Value = Box.Height;
 }
Esempio n. 2
0
 private void UpdateBoxNode(ListViewItem lvItem, xBox Box)//Ok
 {
     lvItem.SubItems[0].Text = '"' + Box.Name + '"';
     lvItem.SubItems[1].Text = Box.Left + ", " + Box.Top + " : " + Box.Width + ", " + Box.Height;
     lvItem.SubItems[2].Text = '"' + Box.Prototype.Name + '"';
     lvItem.SubItems[3].Text = '"' + Box.Reference + '"';
     lvItem.SubItems[4].Text = '"' + Box.Text + '"';
 }
Esempio n. 3
0
        private void btnBoxEdit_Click(object sender, EventArgs e)//Ok
        {
            if (lvBoxes.SelectedItems.Count < 1)
            {
                return;
            }
            xBox box = (lvBoxes.SelectedItems[0].Tag as xBox);

            if (box == null)
            {
                return;
            }
            if (new BoxOptionsForm(box).ShowDialog() == DialogResult.OK)
            {
                Map.Draw();
                Options.mainForm.Invalidate();
            }
            UpdateBoxNode(lvBoxes.SelectedItems[0], box);
        }
Esempio n. 4
0
        private void MainForm_MouseMove(object sender, MouseEventArgs e)//
        {
            #region Cursor selection
            if (e.Button == MouseButtons.None)
            {
                if (MoverB.Visible &&
                    MoverB.X <= e.X && e.X < MoverB.X + MoverB.W &&
                    MoverB.Y <= e.Y && e.Y < MoverB.Y + MoverB.H)
                {
                    Cursor = MoverB.Cursor;
                }
                else if (MoverA.Visible &&
                         MoverA.X <= e.X && e.X < MoverA.X + MoverA.W &&
                         MoverA.Y <= e.Y && e.Y < MoverA.Y + MoverA.H)
                {
                    Cursor = MoverA.Cursor;
                }
                else if (Selection.Visible &&
                         Selection.X <= e.X && e.X < Selection.X + Selection.W &&
                         Selection.Y <= e.Y && e.Y < Selection.Y + Selection.H)
                {
                    Cursor = Cursors.Hand;
                }
                else
                {
                    Cursor = (Map.AnythingAt(Map.ScrollX + e.X, Map.ScrollY + e.Y) == null) ? Cursors.Default : Cursors.Hand;
                }
            }
            #endregion

            #region Moving/Sizing
            else
            {
                bool redraw = true;
                int  msXn   = e.X,
                     msYn   = e.Y;
                Map.SnapXY(ref msXn, ref msYn);
                int dX = msXn - msXnLast,
                    dY = msYn - msYnLast;

                #region Move B point of line / Resize box
                if (MoverB.Active)
                {
                    // Resize
                    if (Map.Selected.IsLink)
                    {
                        if (dX != 0 || dY != 0)
                        {
                            var Link = (Map.Selected as xLink);
                            Link.XB += dX;
                            Link.YB += dY;
                            TryToBindToObject(Map,
                                              Map.ScrollX + e.X, Map.ScrollY + e.Y,
                                              ref Link.ObjectB, ref Link.ObjectBID,
                                              ref Link.DotB, ref Link.DotBID,
                                              ref Link.XB, ref Link.YB);
                        }
                        else
                        {
                            redraw = false;
                        }
                    }
                    // Move
                    else if (Map.Selected.IsBox)
                    {
                        if (dX != 0 || dY != 0)
                        {
                            xBox Box = (Map.Selected as xBox);
                            Box.Width  += dX;
                            Box.Height += dY;
                            if (Box.Width < 1)
                            {
                                Box.Width = 1;
                            }
                            if (Box.Height < 1)
                            {
                                Box.Height = 1;
                            }
                        }
                        else
                        {
                            redraw = false;
                        }
                    }
                }
                #endregion

                #region Move A point of line
                else if (MoverA.Active)
                {
                    if (dX != 0 || dY != 0)
                    {
                        var Link = (Map.Selected as xLink);
                        Link.XA += dX;
                        Link.YA += dY;
                        TryToBindToObject(Map,
                                          Map.ScrollX + e.X, Map.ScrollY + e.Y,
                                          ref Link.ObjectA, ref Link.ObjectAID,
                                          ref Link.DotA, ref Link.DotAID,
                                          ref Link.XA, ref Link.YA);
                    }
                    else
                    {
                        redraw = false;
                    }
                }
                #endregion

                #region Move element
                else if (Selection.Active)
                {
                    if (dX != 0 || dY != 0)
                    {
                        if (Map.Selected.IsObject)
                        {
                            (Map.Selected as xObject).X += dX;
                            (Map.Selected as xObject).Y += dY;
                        }
                        else if (Map.Selected.IsBox)
                        {
                            (Map.Selected as xBox).Left += dX;
                            (Map.Selected as xBox).Top  += dY;
                        }
                        else
                        {
                            //...
                        }
                    }
                    else
                    {
                        redraw = false;
                    }
                }
                #endregion

                #region Map scrolling
                else
                {
                    Map.ScrollX += msXLast - e.X;
                    Map.ScrollY += msYLast - e.Y;
                    CheckScrollers();
                    redraw = false;
                }
                #endregion

                if (redraw)
                {
                    Map.Changed = true;
                    Map.UpdateTabName();
                    Map.Selected.Check();
                    if (Map.Selected.IsObject)
                    {
                        Map.CheckLinksToObject(Map.Selected.ID);
                    }
                    Map.Draw(Map.ScrollX, Map.ScrollY, Options.PortW, Options.PortH);
                }

                CheckFrames();
                Invalidate();

                msXLast  = e.X;
                msYLast  = e.Y;
                msXnLast = msXn;
                msYnLast = msYn;
            }
            #endregion
        }
Esempio n. 5
0
        private void MainForm_MouseDown(object sender, MouseEventArgs e)//
        {
            // Save action start point
            msXnLast = msXLast = e.X;
            msYnLast = msYLast = e.Y;
            Map.SnapXY(ref msXnLast, ref msYnLast);

            // Prevent senseless action
            if (rbObject.Checked && rbObject.Tag == null)
            {
                rbDefault.Checked = true;
            }
            else if (rbLink.Checked && rbLink.Tag == null)
            {
                rbDefault.Checked = true;
            }
            else if (rbBox.Checked && rbBox.Tag == null)
            {
                rbDefault.Checked = true;
            }

            #region Default tool
            if (rbDefault.Checked)
            {
                ContextMenuStrip = cmsElement;
                if (MoverB.Visible &&
                    MoverB.X <= msXLast && msXLast < MoverB.X + MoverB.W &&
                    MoverB.Y <= msYLast && msYLast < MoverB.Y + MoverB.H)
                {
                    MoverB.Active = true;
                }
                else if (MoverA.Visible &&
                         MoverA.X <= msXLast && msXLast < MoverA.X + MoverA.W &&
                         MoverA.Y <= msYLast && msYLast < MoverA.Y + MoverA.H)
                {
                    MoverA.Active = true;
                }
                else if (Selection.Visible &&
                         Selection.X <= msXLast && msXLast < Selection.X + Selection.W &&
                         Selection.Y <= msYLast && msYLast < Selection.Y + Selection.H)
                {
                    Selection.Active = true;
                    Cursor           = Selection.Cursor;
                }
                else
                {
                    if (Map.SelectAt(msXLast + Map.ScrollX, msYLast + Map.ScrollY) == null)
                    {
                        if (hScrollBar.LargeChange < hScrollBar.Maximum)
                        {
                            if (vScrollBar.LargeChange < vScrollBar.Maximum)
                            {
                                Cursor = Cursors.NoMove2D;
                            }
                            else
                            {
                                Cursor = Cursors.NoMoveHoriz;
                            }
                        }
                        else
                        if (vScrollBar.LargeChange < vScrollBar.Maximum)
                        {
                            Cursor = Cursors.NoMoveVert;
                        }
                        else
                        {
                            Cursor = Cursors.No;
                        }
                        ContextMenuStrip = cmsMap;
                    }
                    else
                    {
                        Selection.Active = true;
                    }
                    CheckFrames(true);
                }
            }
            #endregion

            #region Element tool
            else
            {
                MoverA.Visible     =
                    MoverB.Visible = false;
                ContextMenuStrip   = cmsElement;
                //
                if (rbObject.Checked)
                {
                    var Object = new xObject(Map);
                    Object.Prototype         = Map.AddPObject(rbObject.Tag as xPrototype);
                    Object.PrototypeID       = Object.Prototype.ID;
                    Object.PrototypeRevision = Object.Prototype.Revision;
                    Map.Objects.Add(Object);
                    // Set data
                    Object.X = msXLast + Map.ScrollX;
                    Object.Y = msYLast + Map.ScrollY;
                    Map.SnapXY(ref Object.X, ref Object.Y);
                    //
                    Map.Selected     = Object;
                    Selection.Active = true;
                }
                else if (rbLink.Checked)
                {
                    var Link = new xLink(Map);
                    Link.Prototype         = Map.AddPLink(rbLink.Tag as xPrototype);
                    Link.PrototypeID       = Link.Prototype.ID;
                    Link.PrototypeRevision = Link.Prototype.Revision;
                    Map.Links.Add(Link);
                    // Set data
                    Link.XA = Link.XB = msXLast + Map.ScrollX;
                    Link.YA = Link.YB = msYLast + Map.ScrollY;
                    Map.SnapXY(ref Link.XA, ref Link.YA);
                    Map.SnapXY(ref Link.XB, ref Link.YB);
                    // Try to bind to object
                    Map.Selected = Map.ObjectAt(msXLast + Map.ScrollX, msYLast + Map.ScrollY);
                    if (Map.Selected != null)
                    {
                        Link.ObjectA   = Map.Selected as xObject;
                        Link.ObjectAID = Link.ObjectA.ID;
                        Link.DotA      = Link.ObjectA.GetNearestDot(msXLast + Map.ScrollX, msYLast + Map.ScrollY);
                        Link.DotAID    = Link.DotA.ID;
                        Link.XA        = Link.ObjectA.Left + Link.DotA.X;
                        Link.YA        = Link.ObjectA.Top + Link.DotA.Y;
                    }
                    //
                    Map.Selected  = Link;
                    MoverB.Cursor = Cursors.SizeAll;
                    MoverB.Active = true;
                }
                else
                {
                    var Box = new xBox(Map);
                    Box.Prototype         = Map.AddPBox(rbBox.Tag as xPrototype);
                    Box.PrototypeID       = Box.Prototype.ID;
                    Box.PrototypeRevision = Box.Prototype.Revision;
                    Map.Boxes.Add(Box);
                    // Set data
                    Box.Left   = msXLast + Map.ScrollX;
                    Box.Top    = msYLast + Map.ScrollY;
                    Box.Width  = 1;
                    Box.Height = 1;
                    Box.Text   = (Box.Prototype as xPBox).Text;
                    Map.SnapXY(ref Box.Left, ref Box.Top);
                    //
                    Map.Selected  = Box;
                    MoverB.Cursor = Cursors.SizeNWSE;
                    MoverB.Active = true;
                }
                // Update
                Map.Selected.Check();
                Map.Draw(Map.Selected.Left - 8, Map.Selected.Top - 8, Map.Selected.Width + 16, Map.Selected.Height + 16);
                CheckFrames(true);
            }
            #endregion

            Invalidate();
        }