Exemplo n.º 1
0
        //////////////////////////////
        //pnlResource events handlers
        //////////////////////////////

        private void pnlResources_DragEnter(object sender, DragEventArgs e)
        {
            Resource r = new Resource();

            if ((e.Data.GetDataPresent(r.GetType())))
            {
                Resource res = (Resource)e.Data.GetData(r.GetType());
                if (tutorialMode && tutorialStep == 5)
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else if (!resourceCoordinates.ContainsKey(res.ID))
                {
                    e.Effect = DragDropEffects.None;
                }
                else
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Exemplo n.º 2
0
        ///////////////////////
        //pnlMap event handlers
        ///////////////////////

        private void pnlMap_DragEnter(object sender, DragEventArgs e)
        {
            Resource r = new Resource();

            if ((e.Data.GetDataPresent(r.GetType())))
            {
                if (tutorialMode && tutorialStep > 3)
                {
                    return;
                }
                Resource res = (Resource)e.Data.GetData(r.GetType());

                ResourceIcon resIcon = new ResourceIcon(res);

                Point p = pnlMap.PointToClient(new Point(e.X, e.Y));

                Rectangle rect = new Rectangle(
                    p.X - resIcon.Width / 2, p.Y - resIcon.Height / 2,
                    resIcon.Width + 15, resIcon.Height + 15);
                lblCoordinates.Text = p.X + ", " + p.Y;

                bool boom = false;

                foreach (Control ctrl in pnlMap.Controls)
                {
                    if (ctrl.GetType().Equals(resIcon.GetType()))
                    {
                        if (((Resource)ctrl.Tag).ID == res.ID)
                        {
                            continue;
                        }
                        if (rect.IntersectsWith(ctrl.Bounds))
                        {
                            boom = true;
                            break;
                        }
                    }
                }

                lblMessage.Text = "";
                if (boom)
                {
                    lblMessage.Text = "Nemoguće je preklapanje ikonica";
                    e.Effect        = DragDropEffects.None;
                }
                else
                {
                    e.Effect = DragDropEffects.Copy;
                }

                lblCoordinates.Text = p.X + ", " + p.Y;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Exemplo n.º 3
0
        private void pnlResources_DragDrop(object sender, DragEventArgs e)
        {
            Resource r = new Resource();

            if (e.Data.GetDataPresent(r.GetType()))
            {
                Resource res = (Resource)e.Data.GetData(r.GetType());

                Control deleted = null;

                foreach (Control ctrl in pnlMap.Controls)
                {
                    if (ctrl.Tag != null && ctrl.Tag.Equals(res))
                    {
                        deleted = ctrl;
                        break;
                    }
                }

                if (tutorialMode)
                {
                    lblTutorial.Text = "Tutorijal je uspesno završen! klikni Završi tutorijal.";
                    pbxRight.Hide();
                }

                if (deleted != null)
                {
                    pnlMap.Controls.Remove(deleted);
                    resourceCoordinates.Remove(res.ID);
                    if (tutorialMode)
                    {
                        pnlResources.Controls.Add(new ResourceControl(res, pnlResources.Controls.Count * 80 + 10));
                    }
                    else
                    {
                        pnlResources.Controls.Add(new ResourceControl(resources[res.ID], pnlResources.Controls.Count * 80 + 10));
                    }
                }
                lblUnmappedResources.Text = "Nemapirani resursi(" + pnlResources.Controls.Count + ")";
            }
        }
Exemplo n.º 4
0
        ///////////////////////////
        //pnlDelete event handlers
        //////////////////////////

        private void pnlDelete_DragEnter(object sender, DragEventArgs e)
        {
            Resource r = new Resource();

            if ((e.Data.GetDataPresent(r.GetType())))
            {
                if (tutorialMode && tutorialStep != 4)
                {
                    return;
                }
                e.Effect        = DragDropEffects.Copy;
                lblMessage.Text = "Spusti za brisanje resursa iz evidencije";
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Exemplo n.º 5
0
        private void pnlDelete_DragDrop(object sender, DragEventArgs e)
        {
            Resource r = new Resource();

            if (e.Data.GetDataPresent(r.GetType()))
            {
                Resource res = (Resource)e.Data.GetData(r.GetType());

                Control deleted = null;

                foreach (Control ctrl in pnlMap.Controls)
                {
                    if (ctrl.Tag != null && ctrl.Tag.Equals(res))
                    {
                        deleted = ctrl;
                        break;
                    }
                }



                if (deleted != null)
                {
                    removeResource(deleted as ResourceIcon);
                    if (tutorialMode)
                    {
                        tutorialStep++;
                        pnlMap.Controls[3].BackColor = tutorialColor;
                        lblTutorial.Text             = "Prevuci crvenu ikonicu na listu nemapiranih resursa";
                        pbxDown.Hide();
                        pbxRight.Show();
                    }
                }
                else
                {
                    Control sub    = null;
                    int     maxTop = 0;

                    foreach (Control ctrl in pnlResources.Controls)
                    {
                        if (ctrl.Tag.Equals(res))
                        {
                            deleted = ctrl;
                            //break;
                        }
                        if (ctrl.Top > maxTop)
                        {
                            sub    = ctrl;
                            maxTop = ctrl.Top;
                        }
                    }

                    if (deleted != null)
                    {
                        ///////////////////////
                        sub.Top = deleted.Top;
                        pnlResources.Controls.Remove(deleted);
                        lblUnmappedResources.Text = "Nemapirani resursi(" + pnlResources.Controls.Count + ")";
                        ////////////////////////
                        //resources.Remove(res.ID);
                        //MainForm_Load(this, null);
                    }
                }
            }
            lblMessage.Text = "";
        }
Exemplo n.º 6
0
        private void pnlMap_DragDrop(object sender, DragEventArgs e)
        {
            Resource r = new Resource();

            if (e.Data.GetDataPresent(r.GetType()))
            {
                Resource res = (Resource)e.Data.GetData(r.GetType());

                ResourceIcon resIcon = new ResourceIcon(res);
                resIcon.Name = res.ID;

                Point p = pnlMap.PointToClient(new Point(e.X, e.Y));

                foreach (Control ctrl in pnlMap.Controls)
                {
                    if (ctrl.GetType().Equals(resIcon.GetType()))
                    {
                        if (((Resource)resIcon.Tag).ID == ((Resource)((ResourceIcon)ctrl).Tag).ID)
                        {
                            pnlMap.Controls.Remove(ctrl);
                            break;
                        }
                    }
                }

                pnlMap.Controls.Add(resIcon);

                resIcon.Left = p.X - 20;
                resIcon.Top  = p.Y - 20;

                pnlMap.Refresh();

                if (tutorialMode)
                {
                    tutorialStep++;

                    if (tutorialStep == 1)
                    {
                        pbxLeft.SendToBack();
                        resIcon.BackColor = tutorialColor;
                        lblTutorial.Text  = "Pomeri crvenu ikonicu na mapi";
                        pnlResources.Controls.RemoveAt(0);
                        foreach (Control ctrl in pnlResources.Controls)
                        {
                            if (!((Resource)ctrl.Tag).ID.Equals((((Resource)resIcon.Tag).ID)))
                            {
                                ctrl.Top -= 108;
                            }
                        }
                        pbxLeft.Hide();
                    }
                    else if (tutorialStep == 2)
                    {
                        resIcon.BackColor = Color.White;
                        lblTutorial.Text  = "Prevuci crvenu stavku na mapu";
                        pnlResources.Controls[0].BackColor = tutorialColor;
                        pbxLeft.Show();
                    }
                    else if (tutorialStep == 3)
                    {
                        resIcon.BackColor = tutorialColor;
                        lblTutorial.Text  = "Pomeri crvenu ikonicu na mapi";
                        pnlResources.Controls.RemoveAt(0);
                        foreach (Control ctrl in pnlResources.Controls)
                        {
                            if (!((Resource)ctrl.Tag).ID.Equals((((Resource)resIcon.Tag).ID)))
                            {
                                ctrl.Top -= 108;
                            }
                        }
                        pbxLeft.Hide();
                    }
                    else if (tutorialStep == 4)
                    {
                        foreach (Control ctrl in pnlMap.Controls)
                        {
                            if (ctrl.Tag != null && !((Resource)ctrl.Tag).ID.Equals(((Resource)resIcon.Tag).ID))
                            {
                                resIcon = (ResourceIcon)ctrl;
                                break;
                            }
                        }
                        resIcon.BackColor = tutorialColor;
                        lblTutorial.Text  = "Prevuci crvenu ikonicu u kantu";
                        pbxDown.Show();
                    }
                    else if (tutorialStep == 5)
                    {
                        pnlMap.Controls[3].BackColor = tutorialColor;
                        lblTutorial.Text             = "Prevuci crvenu ikonicu na listu nemapiranih resursa";
                        pbxRight.Show();
                    }


                    return;
                }

                if (!resourceCoordinates.ContainsKey(res.ID))
                {
                    resourceCoordinates.Add(res.ID, new ResourcePosition(res, resIcon.Left, resIcon.Top));
                    ////////////////
                    Control sub = null, deleted = null;
                    int     maxTop = 0;

                    foreach (Control ctrl in pnlResources.Controls)
                    {
                        if (ctrl.Tag.Equals(res))
                        {
                            deleted = ctrl;
                            //break;
                        }
                        if (ctrl.Top > maxTop)
                        {
                            sub    = ctrl;
                            maxTop = ctrl.Top;
                        }
                    }

                    if (deleted != null)
                    {
                        //ResourceControl resControl = deleted as ResourceControl;
                        sub.Top = deleted.Top;
                        pnlResources.Controls.Remove(deleted);
                        lblUnmappedResources.Text = "Nemapirani resursi(" + pnlResources.Controls.Count + ")";
                    }
                    /////////////
                    //MainForm_Load(this, null);
                }
                else
                {
                    resourceCoordinates[res.ID].X = resIcon.Left;
                    resourceCoordinates[res.ID].Y = resIcon.Top;
                }
            }
        }