public ResEditor(GlowingEarth ge) { refer = ge; InitializeComponent(); res = new ObservableCollection <Model.Resource>(); types = ge.getMaster().types; tags = ge.getMaster().tags; filter.Items.Add(null); if (types.Count > 0) { foreach (Model.Type t in types) { typeBox.Items.Add(t); filter.Items.Add(t); } } copy = new ObservableCollection <Model.Resource>(); foreach (Model.Resource r in ge.getMaster().resources) { copy.Add(r); res.Add(r); } ShowDialog(); }
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 AddEtiqControler(View.NewTag w) { wind = w; if (contAdd()) { e = new Etiquette(wind.IDbox.Text, wind.colorp.SelectedColor.ToString(), wind.descBox.Text); } else { success = false; return; } if (chckTag()) { addTag(); success = true; GlowingEarth.getInstance().getMaster().notifyChange(); return; } else { wind.Errl.Content = "Tag with this ID already exists"; success = false; return; } }
public DeleteControler(Model.Etiquette e) { foreach (Model.Etiquette d in GlowingEarth.getInstance().getMaster().getTags()) { if (d.getID().Equals(e.getID())) { GlowingEarth.getInstance().getMaster().getTags().Remove(d); break; } } foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources()) { foreach (Model.Etiquette et in r.getTags()) { if (et.getID().Equals(e.getID())) { r.getTags().Remove(et); break; } } r.setTags(r.getTags()); //Cudna greska bez ovoga -.- } success = true; }
public NewType(GlowingEarth ge) { this.ge = ge; InitializeComponent(); this.DataContext = this; pc = new Controler.PicChanger(); }
private void IDbox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { String curText = IDbox.Text; bool found = false; foreach (Model.Etiquette r in GlowingEarth.getInstance().getMaster().tags) { if (r.getID().Equals(curText)) { found = true; Error.Content = "Tag with this ID already exists"; IDbox.BorderBrush = System.Windows.Media.Brushes.Red; break; } } if (!found || curText.Equals("")) { BrushConverter bc = new BrushConverter(); IDbox.BorderBrush = (System.Windows.Media.Brush)bc.ConvertFrom("#C7DFFC"); if (Error.Content.Equals("Tag with this ID already exists") || Error.Content.Equals("Invalid ID character")) { Error.Content = ""; } } }
public AddTypeControler(View.NewType w) { wind = w; if (contAdd()) { string img = wind.icoPath.Text; e = new Model.Type(wind.IDbox.Text, wind.nameBox.Text.Trim(' '), wind.descBox.Text, img); } else { success = false; return; } if (chckTag()) { addTag(); success = true; GlowingEarth.getInstance().getMaster().notifyChange(); return; } else { wind.Error.Content = "Type with this ID already exists"; success = false; return; } }
public DeleteProjectControler() { GlowingEarth.getInstance().getMaster().getResources().Clear(); GlowingEarth.getInstance().getMaster().getTypes().Clear(); GlowingEarth.getInstance().getMaster().getTags().Clear(); GlowingEarth.getInstance().getMaster().getMapItems().Clear(); GlowingEarth.getInstance().getMaster().setTitle(GlowingEarth.getInstance().getMaster().getTitle().Replace("*", string.Empty)); }
private void delete_Click(object sender, RoutedEventArgs e) { MessageBoxResult mbr = System.Windows.MessageBox.Show("Are you sure?", "Confirm Deletion", MessageBoxButton.YesNo); if (mbr == MessageBoxResult.Yes) { Controler.DeleteControler dc = new Controler.DeleteControler(_selectedTag); GlowingEarth.getInstance().getMaster().notifyChange(); } }
private void ok_Click(object sender, RoutedEventArgs e) { resC = new Controler.AddRessControler(this); if (resC.getSuccess()) { System.Windows.MessageBox.Show("Resource added successfully!", "Success!", MessageBoxButton.OK); resetWindow(); GlowingEarth.getInstance().getMaster().notifyChange(); } }
public LoadProjectControler() { if (GlowingEarth.getInstance().getMaster().getTitle().Contains("*")) { DialogResult dr = MessageBox.Show("Do you want to save changes?", "Save changes", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { OpenFileDialog fid = new OpenFileDialog(); fid.DefaultExt = ".gemap"; fid.Filter = "Glowing Earth Map (*.gemap)|*.gemap"; DialogResult diir = fid.ShowDialog(); if (diir == System.Windows.Forms.DialogResult.OK) { SaveProjectControler spc = new SaveProjectControler(); } } } OpenFileDialog fd = new OpenFileDialog(); fd.DefaultExt = ".gemap"; fd.Filter = "Glowing Earth Map (*.gemap)|*.gemap"; DialogResult dir = fd.ShowDialog(); if (dir == System.Windows.Forms.DialogResult.OK) { path = fd.FileName; BinaryFormatter fm = new BinaryFormatter(); FileStream sm = null; try { sm = File.OpenRead(path); Model.MasterClass x = (Model.MasterClass)fm.Deserialize(sm); GlowingEarth.getInstance().getMaster().setTags(x.getTags()); GlowingEarth.getInstance().getMaster().setTypes(x.getTypes()); GlowingEarth.getInstance().getMaster().setResources(x.getResources()); GlowingEarth.getInstance().getMaster().setTitle(x.getTitle()); GlowingEarth.getInstance().getMaster().setSerPath(x.getSerPath()); GlowingEarth.getInstance().getMaster().setMapItems(x.getMapItems()); ThisWasLastController tc = new ThisWasLastController("save"); } catch (Exception e) { MessageBox.Show("Loading went wrong. Please, try again. If the problem persists, contact your administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (sm != null) { sm.Dispose(); sm.Close(); } } } }
private bool chckRes() { foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources()) { if (res.getMark().Equals(r.getMark())) { return(false); } } return(true); }
private void delete_Click(object sender, RoutedEventArgs e) { Error.Content = ""; MessageBoxResult mbr = System.Windows.MessageBox.Show("Are you sure you want to delete this type? This could lead to deletion of resources that contain this type.", "Confirm Deletion", MessageBoxButton.YesNo); if (mbr == MessageBoxResult.Yes) { Controler.DeleteControler dec = new Controler.DeleteControler(_selType); GlowingEarth.getInstance().getMaster().notifyChange(); } }
public bool chckTag() { foreach (Etiquette t in GlowingEarth.getInstance().getMaster().getTags()) { if (t.getID().Equals(e.getID())) { success = false; return(false); } } return(true); }
public bool chckTag() { foreach (Model.Type t in GlowingEarth.getInstance().getMaster().getTypes()) { if (t.getMark().Equals(e.getMark())) { success = false; return(false); } } return(true); }
public TypeEditor(GlowingEarth ge) { refer = ge; copy = new ObservableCollection <Model.Type>(); foreach (Model.Type t in refer.getMaster().types) { copy.Add(t); } InitializeComponent(); tyx = ge.getMaster().types; ShowDialog(); }
public TagEditor(GlowingEarth ge) { refer = ge; InitializeComponent(); tags = ge.getMaster().tags; copy = new ObservableCollection <Model.Etiquette>(); foreach (Model.Etiquette e in refer.getMaster().tags) { copy.Add(e); } ShowDialog(); }
private void modify_Click(object sender, RoutedEventArgs e) { Controler.ModifyControler mc = new Controler.ModifyControler(this); if (mc.getSucc()) { System.Windows.MessageBox.Show("Resource modified successfully!", "Success!", MessageBoxButton.OK); GlowingEarth.getInstance().getMaster().notifyChange(); } else { Error.Content = "Something went wrong :("; } }
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 ok_Click(object sender, RoutedEventArgs e) { if (cont()) { ec = new Controler.AddEtiqControler(this); if (ec.getSuccess()) { System.Windows.MessageBox.Show("Tag added successfully!", "Success!", MessageBoxButton.OK); IDbox.Text = ""; descBox.Text = ""; Errl.Content = ""; GlowingEarth.getInstance().getMaster().notifyChange(); } } }
public SaveProjectAsControler() { SaveFileDialog fd = new SaveFileDialog(); fd.DefaultExt = ".gemap"; fd.Filter = "Glowing Earth Map (*.gemap)|*.gemap"; DialogResult dr = fd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { GlowingEarth.getInstance().getMaster().setSerPath(fd.FileName); saveProject(fd.FileName); } }
private void modify_Click(object sender, RoutedEventArgs e) { Controler.ModifyControler mc = new Controler.ModifyControler(this); if (mc.getSucc()) { for (int i = 0; i < copy.Count; i++) { if (copy[i].getMark().Equals(mc.getRes().getMark())) { copy[i] = mc.getRes(); res[i] = mc.getRes(); break; } } System.Windows.MessageBox.Show("Resource modified successfully!", "Success!", MessageBoxButton.OK); Error.Content = ""; } GlowingEarth.getInstance().getMaster().notifyChange(); }
/*KRAJ VALIDACIJE PRICEBOXA*/ private void typeBox_Copy_SelectionChanged(object sender, SelectionChangedEventArgs e) { ObservableCollection <Model.Resource> resez = new ObservableCollection <Model.Resource>(); _selectedResource = null; picpath = ""; filt = (Model.Type)filter.SelectedItem; if (filt != null && (searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources..."))) { foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources()) { if (r.getType().getMark().Equals(filt.getMark())) { resez.Add(r); } } res.Clear(); foreach (Model.Resource r in resez) { res.Add(r); } } else if (filt != null && !(searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources..."))) { foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources()) { if (r.getType().getMark().Equals(filt.getMark()) && r.getMark().Equals(searchBox.Text)) { resez.Add(r); } } res.Clear(); foreach (Model.Resource r in resez) { res.Add(r); } } else { restartResez(); } }
public NewRes(GlowingEarth g) { pc = new PicChanger(); InitializeComponent(); ge = g; typeBox.DataContext = ge.getMaster().types; DataContext = this; tagovi = ge.getMaster().tags; if (ge.getMaster().types.Count > 0) { foreach (Model.Type t in ge.getMaster().types) { typeBox.Items.Add(t); } } foreach (Model.Etiquette b in tagovi) { b.isPartOfRes = false; } }
public NewProjectControler(string name) { if (GlowingEarth.getInstance().getMaster().getTitle().Contains("*")) { if (MessageBox.Show("You have some unsaved changes on current map. Do you want to save those changes?", "Save changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { SaveFileDialog fd = new SaveFileDialog(); fd.DefaultExt = ".gemap"; fd.Filter = "Glowing Earth Map (*.gemap)|*.gemap"; DialogResult dr = fd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { GlowingEarth.getInstance().getMaster().setSerPath(fd.FileName); saveProject(fd.FileName); } } } projName = "Glowing Earth - " + name; GlowingEarth.getInstance().getMaster().getResources().Clear(); GlowingEarth.getInstance().getMaster().getTypes().Clear(); GlowingEarth.getInstance().getMaster().getTags().Clear(); GlowingEarth.getInstance().getMaster().getMapItems().Clear(); GlowingEarth.getInstance().getMaster().setTitle(projName); if (MessageBox.Show("To see this project next time you open Glowing Earth, you should save this project.\nDo you want to save this project?", "Save new project", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveFileDialog fd = new SaveFileDialog(); fd.DefaultExt = ".gemap"; fd.Filter = "Glowing Earth Map (*.gemap)|*.gemap"; DialogResult dr = fd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { GlowingEarth.getInstance().getMaster().setSerPath(fd.FileName); saveProject(fd.FileName); ThisWasLastController tc = new ThisWasLastController("save"); } } }
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; }
public bool saveProject(string path) { BinaryFormatter fm = new BinaryFormatter(); FileStream sm = null; try { sm = File.OpenWrite(path); fm.Serialize(sm, GlowingEarth.getInstance().getMaster()); GlowingEarth.getInstance().getMaster().setTitle(GlowingEarth.getInstance().getMaster().getTitle().Replace("*", string.Empty)); sm.Dispose(); sm.Close(); return(true); } catch (Exception e) { MessageBox.Show("Saving went wrong. Please, try again. If the problem persists, contact your administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(e.StackTrace); sm.Dispose(); sm.Close(); return(false); } }
public void save() { BinaryFormatter fm = new BinaryFormatter(); FileStream sm = null; try { sm = File.OpenWrite(path); fm.Serialize(sm, GlowingEarth.getInstance().getMaster().getSerPath()); } catch (Exception e) { Console.WriteLine(e.StackTrace); } finally { if (sm != null) { sm.Dispose(); sm.Close(); } } }
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; }
public ModifyControler(View.TagEditor resed) { tage = resed; if ((tag = makeTag()) != null) { for (int i = 0; i < GlowingEarth.getInstance().getMaster().getTags().Count; i++) { if (tag.getID().Equals(GlowingEarth.getInstance().getMaster().getTags()[i].getID())) { GlowingEarth.getInstance().getMaster().getTags()[i] = tag; break; } } } else { success = false; return; } foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources()) { List <Model.Etiquette> temp = r.getTags(); int j = 0; foreach (Model.Etiquette et in temp) { if (et.getID().Equals(tag.getID())) { temp[j] = tag; break; } j++; } r.setTags(temp); } success = true; GlowingEarth.getInstance().getMaster().notifyChange(); }