protected void OnBtnAddRulesClicked(object sender, System.EventArgs e) { ResolutionDialog ed = new ResolutionDialog(parentWindow); int result = ed.Run(); if (result == (int)ResponseType.Ok){ Rule res = ed.Resolution; if (res!= null ){ Rule cdFind = MainClass.Settings.Resolution.Rules.Find(x=>x.Name.ToUpper() ==res.Name.ToUpper()); if (cdFind != null){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("resolution_is_exist", cdFind.Name), "", Gtk.MessageType.Error,parentWindow); md.ShowDialog(); ed.Destroy(); return; } maxCond ++; res.Id = maxCond; resolStore.AppendValues(res.Id,res.Name,res.Specific,res); MainClass.Settings.Resolution.Rules.Add(res); if(ed.CreateFile){ try{ string newFile = System.IO.Path.Combine(MainClass.Paths.DisplayDir, res.Name + ".ini"); EmulatorDisplay.Create(newFile,res.Width,res.Height); }catch(Exception ex){ Tool.Logger.Error(ex.Message,null); MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error,parentWindow); ms.ShowDialog(); return; } } } } ed.Destroy(); }
private void EditRule() { TreeSelection ts = tvResolution.Selection; TreeIter ti = new TreeIter(); ts.GetSelected(out ti); TreePath[] tp = ts.GetSelectedRows(); if (tp.Length < 1) return ; Rule cd = (Rule)tvResolution.Model.GetValue(ti, 3); if (cd == null) return; if(cd.Id ==-1){ MessageDialogs mdError = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("edit_resolution_system"), "", Gtk.MessageType.Error,parentWindow); mdError.ShowDialog(); return; } int width= cd.Width; int height =cd.Height; ResolutionDialog ed = new ResolutionDialog(cd,parentWindow); int result = ed.Run(); if (result == (int)ResponseType.Ok){ Rule res = ed.Resolution; if (res!= null ){ Rule cdFind = MainClass.Settings.Resolution.Rules.Find(x=>x.Id ==res.Id); if (cdFind == null){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("resolution_is_exist", cdFind.Name), "", Gtk.MessageType.Error,parentWindow); md.ShowDialog(); ed.Destroy(); return; } cdFind = res; resolStore.SetValues(ti,cdFind.Id,cdFind.Name,cdFind.Specific,cdFind); try{ string[] listFi = Directory.GetFiles(MainClass.Paths.DisplayDir, "*.ini"); foreach (string fi in listFi){ EmulatorDisplay dd = new EmulatorDisplay(fi); if (dd.Load()){ if (dd.Height == height && dd.Width == width){ dd.Height = res.Height; dd.Width = res.Width; dd.Save(); } } } }catch(Exception ex){ Tool.Logger.Error(ex.Message,null); MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error,parentWindow); ms.ShowDialog(); return; } } } ed.Destroy(); }