public string ShowOptionsDialog(IntPtr hParentWnd, string parameters) { ISettingsOriginator originator = RestoreFromParameters(parameters); //Show the options dialog FormOptions frm = _kernel.Get <FormOptions>(new ConstructorArgument("originator", originator)); NativeWindow nativeWindow = new NativeWindow(); try { nativeWindow.AssignHandle(hParentWnd); } catch { nativeWindow = null; } if (nativeWindow != null) { frm.ShowDialog(nativeWindow); } else { frm.ShowDialog(); } //Save our memento return(originator.GetMemento().ToString()); }
public FormBugListView(IBugService svc, ISingleBugViewPresenter sbPres, [Named("ViewSettings")]ISettingsOriginator viewSettings) { InitializeComponent(); _presenter = new BugListViewPresenter(this, svc); _singleBugPresenter = sbPres; _viewSettings = viewSettings; SelectedBugs = new ObservableCollection<IBug>(); Projects = new List<IProject>(); CommandToApply = new YouTrackCommand() { DisableNotifications = false }; comboBoxProject.DataSource = bindingSourceProjects; //Set up grid dataGridViewBugs.Columns.Add(new DataGridViewCheckBoxColumn() { ReadOnly = false, AutoSizeMode = DataGridViewAutoSizeColumnMode.None, Resizable = DataGridViewTriState.False, Width = 20 }); dataGridViewBugs.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "ID", ReadOnly = true, Resizable = DataGridViewTriState.True }); dataGridViewBugs.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Summary", ReadOnly = true, Resizable = DataGridViewTriState.True }); dataGridViewBugs.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Description", ReadOnly = true, Resizable = DataGridViewTriState.True, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill }); _linkCol = new DataGridViewLinkColumn() { LinkBehavior = LinkBehavior.NeverUnderline, UseColumnTextForLinkValue = true, Text = "view", ReadOnly = true, Resizable = DataGridViewTriState.False, Width = 50, DefaultCellStyle = new DataGridViewCellStyle(dataGridViewBugs.DefaultCellStyle) { Alignment = DataGridViewContentAlignment.MiddleCenter } }; dataGridViewBugs.Columns.Add(_linkCol); dataGridViewBugs.CellContentClick += new DataGridViewCellEventHandler(dataGridViewBugs_CellContentClick); bindingSourceProjects.CurrentChanged += (s, ea) => { if (!bindingSourceProjects.IsBindingSuspended) SelectedProject = bindingSourceProjects.Current as IProject; }; comboBoxPage.SelectedIndexChanged += (s, ea) => UpdatePage(); comboBoxPage.KeyUp += (s, ea) => { if (ea.KeyCode == Keys.Enter) UpdatePage(); }; bindingSourceBugs.DataSourceChanged += new EventHandler(bindingSourceBugs_DataSourceChanged); SelectedBugs.CollectionChanged += (s, ea) => labelSelected.Text = String.Format("Selected: {0}", SelectedBugs.Count); checkBoxApplyCommand.CheckStateChanged += (s, ea) => { _applyCommand = checkBoxApplyCommand.Checked; }; textBoxCommand.TextChanged += (s, ea) => { _commandToApply.Command = textBoxCommand.Text; }; }
public FormBugListView(IBugService svc, ISingleBugViewPresenter sbPres, [Named("ViewSettings")] ISettingsOriginator viewSettings) { InitializeComponent(); _presenter = new BugListViewPresenter(this, svc); _singleBugPresenter = sbPres; _viewSettings = viewSettings; SelectedBugs = new ObservableCollection <IBug>(); Projects = new List <IProject>(); CommandToApply = new YouTrackCommand() { DisableNotifications = false }; comboBoxProject.DataSource = bindingSourceProjects; //Set up grid dataGridViewBugs.Columns.Add(new DataGridViewCheckBoxColumn() { ReadOnly = false, AutoSizeMode = DataGridViewAutoSizeColumnMode.None, Resizable = DataGridViewTriState.False, Width = 20 }); dataGridViewBugs.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "ID", ReadOnly = true, Resizable = DataGridViewTriState.True }); dataGridViewBugs.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Summary", ReadOnly = true, Resizable = DataGridViewTriState.True }); dataGridViewBugs.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = "Description", ReadOnly = true, Resizable = DataGridViewTriState.True, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill }); _linkCol = new DataGridViewLinkColumn() { LinkBehavior = LinkBehavior.NeverUnderline, UseColumnTextForLinkValue = true, Text = "view", ReadOnly = true, Resizable = DataGridViewTriState.False, Width = 50, DefaultCellStyle = new DataGridViewCellStyle(dataGridViewBugs.DefaultCellStyle) { Alignment = DataGridViewContentAlignment.MiddleCenter } }; dataGridViewBugs.Columns.Add(_linkCol); dataGridViewBugs.CellContentClick += new DataGridViewCellEventHandler(dataGridViewBugs_CellContentClick); bindingSourceProjects.CurrentChanged += (s, ea) => { if (!bindingSourceProjects.IsBindingSuspended) { SelectedProject = bindingSourceProjects.Current as IProject; } }; comboBoxPage.SelectedIndexChanged += (s, ea) => UpdatePage(); comboBoxPage.KeyUp += (s, ea) => { if (ea.KeyCode == Keys.Enter) { UpdatePage(); } }; bindingSourceBugs.DataSourceChanged += new EventHandler(bindingSourceBugs_DataSourceChanged); SelectedBugs.CollectionChanged += (s, ea) => labelSelected.Text = String.Format("Selected: {0}", SelectedBugs.Count); checkBoxApplyCommand.CheckStateChanged += (s, ea) => { _applyCommand = checkBoxApplyCommand.Checked; }; textBoxCommand.TextChanged += (s, ea) => { _commandToApply.Command = textBoxCommand.Text; }; }
private void SaveCurrentUserSettings(ISettingsOriginator orig) { //Grab settings as string ISettingsService svc = _kernel.Get <ISettingsService>(); foreach (ISetting sett in orig.GetMemento().Settings) { svc.Set(sett); } }
private ISettingsOriginator RestoreFromParameters(string parameters) { //Restore our saved memento ISettingsMemento memento = _kernel.Get <ISettingsMemento>(new ConstructorArgument("settingsAsString", parameters)); //Restore originator from memento ISettingsOriginator originator = SettingsOriginatorFactory.Instance.CreateOriginator(); originator.RestoreFromMemento(memento); return(originator); }
private ISettingsOriginator RestoreFromCurrentUserSettings() { //Grab settings as string ISettingsService svc = _kernel.Get <ISettingsService>(); //Restore our saved memento ISettingsMemento memento = _kernel.Get <ISettingsMemento>(new ConstructorArgument("settingsAsString", svc.GetAllSettingsAsXML())); //Restore originator from memento ISettingsOriginator originator = SettingsOriginatorFactory.Instance.CreateOriginator(); originator.RestoreFromMemento(memento); return(originator); }
public void Initalize_Sets_URL_On_View() { MockRepository repo = new MockRepository(); IOptionsView mockOptionsView = repo.StrictMock <IOptionsView>(); ISettingsOriginator mockSettingsOriginator = repo.StrictMock <ISettingsOriginator>(); ISettingsMemento mockSettingsMemento = repo.StrictMock <ISettingsMemento>(); ISetting urlSetting = repo.StrictMock <ISetting>(); ISetting userNameSetting = repo.StrictMock <ISetting>(); ISetting passwordSetting = repo.StrictMock <ISetting>(); string url = "http://www.google.com"; string userName = "******"; string password = "******"; urlSetting.Expect(set => set.Value).Return(url); userNameSetting.Expect(set => set.Value).Return(userName); passwordSetting.Expect(set => set.Value).Return(password); mockSettingsOriginator.Expect(org => org.Get("TrackerURL")).Return(urlSetting); mockSettingsOriginator.Expect(org => org.Get("UserName")).Return(userNameSetting); mockSettingsOriginator.Expect(org => org.Get("Password")).Return(passwordSetting); mockSettingsOriginator.Expect(org => org.GetMemento()).Return(mockSettingsMemento); mockOptionsView.Expect(view => view.URL).SetPropertyWithArgument(url); mockOptionsView.Expect(view => view.UserName).SetPropertyWithArgument(userName); mockOptionsView.Expect(view => view.Password).SetPropertyWithArgument(password); repo.ReplayAll(); IOptionsPresenter pres = new OptionsPresenter(mockOptionsView, mockSettingsOriginator); pres.Initalize(); mockOptionsView.VerifyAllExpectations(); mockSettingsOriginator.VerifyAllExpectations(); urlSetting.VerifyAllExpectations(); }
public OptionsPresenter(IOptionsView view, [Named("Parameters")] ISettingsOriginator settings) { _view = view; _settings = settings; }
public string GetCommitMessage2(IntPtr hParentWnd, string parameters, string commonURL, string commonRoot, string[] pathList, string originalMessage, string bugID, out string bugIDOut, out string[] revPropNames, out string[] revPropValues) { try { Cursor.Current = Cursors.AppStarting; revPropNames = new string[0]; revPropValues = new string[0]; bugIDOut = string.Empty; _selectedBugs = new List <IBug>(); ISettingsOriginator originator = RestoreFromParameters(parameters); _kernel.Rebind <IBugService>().ToConstructor <YouTrackBugService>(svc => new YouTrackBugService(svc.Inject <IHttpWebRequestFactory>(), originator.Get(YurtleTrackPlugin.URLOPTIONNAME).Value, originator.Get(YurtleTrackPlugin.USEROPTIONNAME).Value, originator.Get(YurtleTrackPlugin.PASSWORDOPTIONNAME).Value)); _kernel.Rebind <ISettingsOriginator>().ToConstant(originator).Named("Parameters"); ISettingsOriginator viewSettingsOriginator = RestoreFromCurrentUserSettings(); FormBugListView vw = _kernel.Get <FormBugListView>(new ConstructorArgument("viewSettings", viewSettingsOriginator)); _kernel.Rebind <ISettingsOriginator>().ToConstant(viewSettingsOriginator).Named("ViewSettings"); DialogResult ret = vw.ShowDialog(); //Save view settings SaveCurrentUserSettings(viewSettingsOriginator); if (ret != DialogResult.OK) { return(originalMessage); } StringBuilder sb = new StringBuilder(originalMessage); if (!String.IsNullOrEmpty(originalMessage) && !originalMessage.EndsWith("\n")) { sb.AppendLine(); } if (vw.SelectedBugs != null && vw.SelectedBugs.Count > 0) { foreach (IBug bug in vw.SelectedBugs) { sb.AppendFormat("Fixed #{0} : {1}", bug.ID, bug.Summary); sb.AppendLine(); } //end foreach _selectedBugs.AddRange(vw.SelectedBugs); if (vw.ApplyCommand) { _commandsToProcess.Add(vw.CommandToApply); } } //end if return(sb.ToString()); } catch // (Exception ex) { //MessageBox.Show(ex.ToString()); throw; } finally { Cursor.Current = Cursors.Default; } }
public OptionsPresenter(IOptionsView view, [Named("Parameters")]ISettingsOriginator settings) { _view = view; _settings = settings; }
public FormOptions([Named("Parameters")] ISettingsOriginator originator) : this() { _presenter = new OptionsPresenter(this, originator); }
private void SaveCurrentUserSettings(ISettingsOriginator orig) { //Grab settings as string ISettingsService svc = _kernel.Get<ISettingsService>(); foreach (ISetting sett in orig.GetMemento().Settings) svc.Set(sett); }
public YouTrackWebSingleBugView([Named("Parameters")] ISettingsOriginator settings) { _settings = settings; }
public YouTrackWebSingleBugView([Named("Parameters")]ISettingsOriginator settings) { _settings = settings; }