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(); }
public override void Execute() { // make sure only one image is visible if (models.NumEnabled != 1) { models.Window.ShowErrorDialog("Exactly one image equation should be visible for conversion."); return; } var pipeId = models.GetFirstEnabledPipeline(); var srcTex = models.Pipelines[pipeId].Image; if (srcTex == null) { return; // not yet computed? } var firstImage = models.Images.Images[models.Pipelines[pipeId].Color.FirstImageId]; var texName = firstImage.Filename; var origFormat = firstImage.OriginalFormat; var texAlias = firstImage.Alias; var vm = new ResolutionViewModel(2); var dia = new ResolutionDialog { DataContext = vm }; if (models.Window.ShowDialog(dia) != true) { return; } var tex = models.ConvertToLatLong((TextureArray2D)srcTex, vm.Width); // clear all images models.Reset(); models.Images.AddImage(tex, false, texName, origFormat, texAlias); }
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(); }
protected override void CreateChildren() { base.CreateChildren(); _chkInspect = new CheckBox { Text = "Inspector", StyleName = "checkbox", Right = 10, Top = 10, //Padding = 0, ResizeWithContent = true, ToggleMode = true, FocusEnabled = false, // true Selected = OptionsModel.Instance.InspectorActive }; _chkInspect.Click += delegate { OptionsModel.Instance.InspectorActive = _chkInspect.Selected; }; AddContentChild(_chkInspect); _chkDetails = new CheckBox { Text = "Details", StyleName = "checkbox", Right = 10, Top = 10, //Padding = 0, ResizeWithContent = true, ToggleMode = true, FocusEnabled = false, //Selected = OptionsModel.Instance.DetailsActive }; _chkDetails.Change += new EventHandler(delegate { //OptionsModel.Instance.DetailsActive = _chkDetails.Selected; }); AddContentChild(_chkDetails); _chkRunInBackground = new CheckBox { Text = "Run in the background", StyleName = "checkbox", Right = 10, Top = 10, //Padding = 0, ResizeWithContent = true, ToggleMode = true, FocusEnabled = false, Selected = OptionsModel.Instance.RunInBackground }; _chkRunInBackground.Change += delegate { //Application.runInBackground = _chkRunInBackground.Selected; OptionsModel.Instance.RunInBackground = _chkRunInBackground.Selected; Logger.Log("Application.runInBackground changed to: " + OptionsModel.Instance.RunInBackground); }; AddContentChild(_chkRunInBackground); AddChild(new Label { Text = "Volume: ", StyleName = "checkbox" }); _sliderVolume = new HSlider { Value = OptionsModel.Instance.Volume, Minimum = 0, Maximum = 1, PercentWidth = 100, Tooltip = "Volume", StyleName = "slider_volume" }; _sliderVolume.Change += new EventHandler(delegate //(Core.Events.Event e) { //ValueChangedEvent vce = (ValueChangedEvent) e; var tt = Math.Round(_sliderVolume.Value * 100) + " %"; _sliderVolume.Tooltip = tt; TooltipManagerStage.Instance.UpdateTooltip(tt); OptionsModel.Instance.Volume = _sliderVolume.Value; }); AddChild(_sliderVolume); Button button = new Button { Text = "Set resolution", FocusEnabled = false }; button.Click += delegate { ResolutionDialog dialog = new ResolutionDialog(); PopupManager.Instance.AddPopup(dialog); }; AddChild(button); }