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(); }
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(); }
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { Error.Content = ""; if (_selectedResource != null) { this.modify.IsEnabled = true; this.delete.IsEnabled = true; if (_selectedResource.getFreq() == Model.Resource.FreqType.RARE) { radioRare.IsChecked = true; radioUniv.IsChecked = false; radioFreq.IsChecked = false; } else if (_selectedResource.getFreq() == Model.Resource.FreqType.FREQUENT) { radioRare.IsChecked = false; radioUniv.IsChecked = false; radioFreq.IsChecked = true; } else if (_selectedResource.getFreq() == Model.Resource.FreqType.UNIVERSAL) { radioRare.IsChecked = false; radioUniv.IsChecked = true; radioFreq.IsChecked = false; } if (_selectedResource.getUnit() == Model.Resource.Units.BAREL) { radioBarrel.IsChecked = true; radioKG.IsChecked = false; radioScoop.IsChecked = false; radioT.IsChecked = false; } if (_selectedResource.getUnit() == Model.Resource.Units.KG) { radioBarrel.IsChecked = false; radioKG.IsChecked = true; radioScoop.IsChecked = false; radioT.IsChecked = false; } else if (_selectedResource.getUnit() == Model.Resource.Units.SCOOP) { radioBarrel.IsChecked = false; radioKG.IsChecked = false; radioScoop.IsChecked = true; radioT.IsChecked = false; } else if (_selectedResource.getUnit() == Model.Resource.Units.T) { radioBarrel.IsChecked = false; radioKG.IsChecked = false; radioScoop.IsChecked = false; radioT.IsChecked = true; } typeBox.SelectedItem = _selectedResource.getType(); picpath = _selectedResource.getIco(); } else { this.modify.IsEnabled = false; this.delete.IsEnabled = false; } }