Exemplo n.º 1
0
        ///////////////
        // tutorial
        ///////////////////


        private void tutorijalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tutorialMode = true;

            helpProvider.SetHelpKeyword(this, "Tutorijal");

            Tutorial t = new Tutorial(this);

            btnEndTutorial.Show();


            menuStrip1.Enabled = false;

            pnlMap.Controls.Clear();
            pnlResources.Controls.Clear();
            Resource[] dummyResources = t.GenerateDummyResources();

            ResourceControl firstControl = new ResourceControl(dummyResources[0], 10);

            firstControl.SetBackgroundColor(tutorialColor);
            pnlResources.Controls.Add(firstControl);
            for (int i = 1; i < dummyResources.Length; i++)
            {
                pnlResources.Controls.Add(new ResourceControl(dummyResources[i], pnlResources.Controls.Count * 80 + 10));
            }

            lblTutorial.Text = "Prevuci crvenu stavku na mapu";

            pnlMap.Controls.Add(pbxLeft);
            pnlMap.Controls.Add(pbxDown);
            pnlMap.Controls.Add(pbxRight);
            pbxLeft.Show();
        }
Exemplo n.º 2
0
        internal void moveToPnlResources(ResourceIcon resourceIcon)
        {
            Resource res = resourceIcon.Tag as Resource;

            pnlMap.Controls.Remove(resourceIcon);
            resourceCoordinates.Remove(res.ID);

            Control ctrl = new ResourceControl(resources[res.ID], pnlResources.Controls.Count * 80 + 10);

            pnlResources.Controls.Add(ctrl);
            lblUnmappedResources.Text = "Nemapirani resursi(" + pnlResources.Controls.Count + ")";
        }
Exemplo n.º 3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            off = 10;
            int cnt = 0;

            pnlResources.Controls.Clear();
            foreach (Resource res in resources.Values)
            {
                if (!resourceCoordinates.ContainsKey(res.ID))
                {
                    ResourceControl resControl = new ResourceControl(res, off);
                    pnlResources.Controls.Add(resControl);

                    off += 80;
                    cnt++;
                }
            }
            pnlResources.Refresh();
            lblUnmappedResources.Text = "Nemapirani resursi(" + cnt + ")";

            if (e == null)
            {
                return;
            }

            pnlMap.Controls.Clear();
            foreach (ResourcePosition rpos in resourceCoordinates.Values)
            {
                if (resources.ContainsKey(rpos.ID))
                {
                    ResourceIcon resIcon = new ResourceIcon(resources[rpos.ID]);
                    pnlMap.Controls.Add(resIcon);
                    resIcon.Left = rpos.X;
                    resIcon.Top  = rpos.Y;
                }
                else
                {
                    resourceCoordinates.Remove(rpos.ID);
                }
            }
        }
Exemplo n.º 4
0
        private void updateMap()
        {
            List <Control>  deletedControls = new List <Control>();
            ResourceIcon    dummyIcon       = new ResourceIcon();
            ResourceControl dummyResCtrl    = new ResourceControl();

            foreach (Control ctrl in pnlMap.Controls)
            {
                if (ctrl.GetType().Equals(dummyIcon.GetType()))
                {
                    ResourceIcon resIcon = (ResourceIcon)ctrl;
                    if (!resources.ContainsKey(((Resource)resIcon.Tag).ID))
                    {
                        deletedControls.Add(ctrl);
                        resourceCoordinates.Remove(((Resource)resIcon.Tag).ID);
                    }
                    else
                    {
                        Resource res = MainForm.resources[((Resource)resIcon.Tag).ID];
                        resIcon.Tag = res;
                        resIcon.UpdateControl();
                    }
                }
            }

            foreach (Control ctrl in deletedControls)
            {
                pnlMap.Controls.Remove(ctrl);
            }

            foreach (string id in addedResources)
            {
                Control ctrl = new ResourceControl(resources[id], pnlResources.Controls.Count * 80 + 10);
                pnlResources.Controls.Add(ctrl);
            }
            addedResources.Clear();
            lblUnmappedResources.Text = "Nemapirani resursi(" + pnlResources.Controls.Count + ")";

            deletedControls.Clear();

            foreach (Control ctrl in pnlResources.Controls)
            {
                if (ctrl.GetType().Equals(dummyResCtrl.GetType()))
                {
                    ResourceControl resCtrl = (ResourceControl)ctrl;
                    if (!resources.ContainsKey(((Resource)resCtrl.Tag).ID))
                    {
                        deletedControls.Add(ctrl);
                    }
                    else
                    {
                        Resource res = MainForm.resources[((Resource)resCtrl.Tag).ID];
                        resCtrl.Tag = res;
                        resCtrl.UpdateControl();
                    }
                }
            }

            if (deletedControls.Count > 0)
            {
                MainForm_Load(this, null);
            }
        }