Пример #1
0
        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; };
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            _settingsLoaded = false;

            try
            {
                _presenter.Initialize();

                //Load some view settings
                ISetting locationX  = _viewSettings.Get("LocationX");
                ISetting locationY  = _viewSettings.Get("LocationY");
                ISetting sizeWidth  = _viewSettings.Get("SizeWidth");
                ISetting sizeHeight = _viewSettings.Get("SizeHeight");
                ISetting projectID  = _viewSettings.Get("LastProjectID");
                ISetting command    = _viewSettings.Get("LastCommandText");
                ISetting useCommand = _viewSettings.Get("LastUseCommand");

                if (locationX != null && locationY != null)
                {
                    this.DesktopLocation = new Point(Convert.ToInt32(locationX.Value), Convert.ToInt32(locationY.Value));
                }
                else
                {
                    this.StartPosition = FormStartPosition.CenterParent;
                }

                if (sizeWidth != null && sizeHeight != null)
                {
                    this.Size = new Size(Convert.ToInt32(sizeWidth.Value), Convert.ToInt32(sizeHeight.Value));
                }

                if (projectID != null)
                {
                    IProject proj = Projects.FirstOrDefault(p => p.ID == projectID.Value);
                    if (proj != null)
                    {
                        bindingSourceProjects.Position = bindingSourceProjects.IndexOf(proj);
                    }
                }                //end if

                if (command != null)
                {
                    CommandToApply = new YouTrackCommand()
                    {
                        Command = command.Value, DisableNotifications = false
                    }
                }
                ;
                if (useCommand != null)
                {
                    try
                    {
                        ApplyCommand = bool.Parse(useCommand.Value);
                    }
                    catch { ApplyCommand = false; }
                }                //end if

                //Successfully loaded settings
                _settingsLoaded = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }            //end try

            base.OnLoad(e);
        }