Esempio n. 1
0
        public ModifyControler(View.ResEditor resed)
        {
            re  = resed;
            res = makeRes();
            if (res != null)
            {
                for (int i = 0; i < GlowingEarth.getInstance().getMaster().getResources().Count; i++)
                {
                    if (res.getMark().Equals(GlowingEarth.getInstance().getMaster().getResources()[i].getMark()))
                    {
                        GlowingEarth.getInstance().getMaster().getResources()[i] = res;
                        break;
                    }
                }
            }
            else
            {
                success = false;
                return;
            }

            foreach (Model.MapItem mi in GlowingEarth.getInstance().getMaster().getMapItems())
            {
                if (mi.getID().Equals(res.getMark()))
                {
                    mi.setName(res.getName());
                    mi.setPath(res.getIco());
                }
            }
            success = true;
            GlowingEarth.getInstance().getMaster().notifyChange();
        }
Esempio n. 2
0
 private bool chckRes()
 {
     foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources())
     {
         if (res.getMark().Equals(r.getMark()))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 3
0
        public DeleteControler(Model.Resource r)
        {
            foreach (Model.Resource d in GlowingEarth.getInstance().getMaster().getResources())
            {
                if (d.getMark().Equals(r.getMark()))
                {
                    GlowingEarth.getInstance().getMaster().getResources().Remove(d);
                    break;
                }
            }
            ObservableCollection <Model.MapItem> mati = new ObservableCollection <Model.MapItem>();

            foreach (Model.MapItem mi in GlowingEarth.getInstance().getMaster().getMapItems())
            {
                if (!mi.getID().Equals(r.getMark()))
                {
                    mati.Add(mi);
                }
            }
            GlowingEarth.getInstance().getMaster().setMapItems(mati);
            success = true;
        }
Esempio n. 4
0
        public ModifyControler(View.TypeEditor resed)
        {
            te = resed;

            if ((type = makeType()) != null)
            {
                for (int i = 0; i < GlowingEarth.getInstance().getMaster().getTypes().Count; i++)
                {
                    if (type.getMark().Equals(GlowingEarth.getInstance().getMaster().getTypes()[i].getMark()))
                    {
                        GlowingEarth.getInstance().getMaster().getTypes()[i] = type;
                        break;
                    }
                }
            }
            else
            {
                success = false;
                return;
            }

            GlowingEarth.getInstance().itemList.Items.Refresh();

            ObservableCollection <Model.Resource> temp = GlowingEarth.getInstance().getMaster().getResources();

            for (int i = 0; i < temp.Count; i++)
            {
                if (GlowingEarth.getInstance().getMaster().getResources()[i].getType().getMark().Equals(type.getMark()))
                {
                    Model.Resource r = temp[i];
                    r.setType(type);
                    if (r.getHasTypeImg())
                    {
                        r.setIcon(type.getImg());
                    }
                    ObservableCollection <Model.MapItem> mapitems = GlowingEarth.getInstance().getMaster().getMapItems();
                    for (int j = 0; j < mapitems.Count; j++)
                    {
                        if (mapitems[j].getID().Equals(r.getMark()))
                        {
                            mapitems[j].setPath(r.getIco());
                        }
                    }
                    GlowingEarth.getInstance().getMaster().setMapItems(mapitems);
                }
            }
            GlowingEarth.getInstance().getMaster().setResources(temp);
            success = true;
            GlowingEarth.getInstance().map.Items.Refresh();
            GlowingEarth.getInstance().getMaster().notifyChange();
        }
Esempio n. 5
0
        public DeleteControler(Model.Type e)
        {
            foreach (Model.Type d in GlowingEarth.getInstance().getMaster().getTypes())
            {
                if (d.getMark().Equals(e.getMark()))
                {
                    GlowingEarth.getInstance().getMaster().getTypes().Remove(d);
                    break;
                }
            }
            ObservableCollection <Model.Resource> temp = new ObservableCollection <Model.Resource>();

            foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().resources)
            {
                temp.Add(r);
            }
            for (int i = 0; i < temp.Count; i++)
            {
                if (e.getMark().Equals(temp[i].getType().getMark()))
                {
                    Model.Resource rz = temp[i];
                    ObservableCollection <Model.MapItem> mati = new ObservableCollection <Model.MapItem>();

                    foreach (Model.MapItem mi in GlowingEarth.getInstance().getMaster().getMapItems())
                    {
                        if (!mi.getID().Equals(rz.getMark()))
                        {
                            mati.Add(mi);
                        }
                    }
                    GlowingEarth.getInstance().getMaster().setMapItems(mati);
                    GlowingEarth.getInstance().getMaster().getResources().Remove(temp[i]);
                }
            }

            success = true;
        }