Exemple #1
0
        public override Rectangle PositionEditingPanel(Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
        {
            if (_ownerCell == null && _columnSpan == 1 && _rowSpan == 1)
            {
                return(base.PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded, singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow));
            }

            int rowIndex = RowIndex;
            ExDataGridViewTextBoxCell ownerCell = this;

            if (_ownerCell != null)
            {
                rowIndex  = _ownerCell.RowIndex;
                cellStyle = _ownerCell.GetInheritedStyle(null, rowIndex, true);
                _ownerCell.GetFormattedValue(_ownerCell.Value, rowIndex, ref cellStyle, null, null, DataGridViewDataErrorContexts.Formatting);
                IDataGridViewEditingControl editingControl = this.DataGridView.EditingControl as IDataGridViewEditingControl;
                if (editingControl != null)
                {
                    editingControl.ApplyCellStyleToEditingControl(cellStyle);
                    Control editingPanel = this.DataGridView.EditingControl.Parent;
                    if (editingPanel != null)
                    {
                        editingPanel.BackColor = cellStyle.BackColor;
                    }
                }
                ownerCell = _ownerCell;
            }
            cellBounds = GetSpannedCellBoundsFromChildCellBounds(this, cellBounds);
            cellClip   = GetSpannedCellClipBounds(ownerCell, cellBounds);
            return(base.PositionEditingPanel(cellBounds, cellClip, cellStyle, singleVerticalBorderAdded, singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow));
        }
Exemple #2
0
        private void SetCurrentCellValue(DataGridView grid, object value)
        {
            IDataGridViewEditingControl editingControl = null;
            DataGridViewEditingControlShowingEventHandler onEditingControlShowing =
                (sender, args) =>
            {
                Assume.IsNull(editingControl);
                editingControl = args.Control as IDataGridViewEditingControl;
            };

            try
            {
                grid.EditingControlShowing += onEditingControlShowing;
                grid.BeginEdit(true);
                if (null != editingControl)
                {
                    editingControl.EditingControlFormattedValue = value;
                }
                else
                {
                    grid.CurrentCell.Value = value;
                }
            }
            finally
            {
                grid.EditingControlShowing -= onEditingControlShowing;
            }
        }
        private bool TrySetValue(DataGridViewCell cell, string strValue)
        {
            IDataGridViewEditingControl editingControl = null;
            DataGridViewEditingControlShowingEventHandler onEditingControlShowing =
                (sender, args) =>
            {
                Assume.IsNull(editingControl);
                editingControl = args.Control as IDataGridViewEditingControl;
            };

            try
            {
                DataGridView.EditingControlShowing += onEditingControlShowing;
                DataGridView.CurrentCell            = cell;
                DataGridView.BeginEdit(true);
                if (null != editingControl)
                {
                    object convertedValue;
                    if (!TryConvertValue(strValue, DataGridView.CurrentCell.FormattedValueType, out convertedValue))
                    {
                        return(false);
                    }
                    editingControl.EditingControlFormattedValue = convertedValue;
                }
                else
                {
                    object convertedValue;
                    if (!TryConvertValue(strValue, DataGridView.CurrentCell.ValueType, out convertedValue))
                    {
                        return(false);
                    }
                    DataGridView.CurrentCell.Value = convertedValue;
                }
                if (!DataGridView.EndEdit())
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception e)
            {
                Program.ReportException(e);
                return(false);
            }
            finally
            {
                DataGridView.EditingControlShowing -= onEditingControlShowing;
            }
        }
        //=====================================================================

        /// <summary>
        /// This is used to determine whether or not the given row owns the editing textbox control
        /// </summary>
        /// <param name="rowIndex">The index of the row to check</param>
        /// <returns>True if it owns the control, false if it does not</returns>
        protected bool OwnsEditingTextBox(int rowIndex)
        {
            IDataGridViewEditingControl editControl = editingTextBox as IDataGridViewEditingControl;

            return(rowIndex != -1 && editControl != null && rowIndex == editControl.EditingControlRowIndex);
        }
Exemple #5
0
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("p180test_calibration_DukeApril2016.sky")));
            var surrogateStandards = new Dictionary <string, string>
            {
                { "Leu", "Ile" },
                { "Lys", "Orn" },
                { "Ac-Orn", "Orn" },
                { "SDMA", "ADMA" },
                { "alpha-AAA", "Orn" },
                { "Carnosine", "His" },
                { "Histamine", "His" },
                { "Kynurenine", "Tyr" },
                { "Met-SO", "Met" },
                { "Nitro-Tyr", "Tyr" },
                { "c4-OH-Pro", "Pro" },
                { "t4-OH-Pro", "Pro" },
            };

            // Set the standard type of the surrogate standards to StandardType.SURROGATE_STANDARD
            RunUI(() =>
            {
                List <IdentityPath> pathsToSelect = SkylineWindow.SequenceTree.Nodes.OfType <PeptideGroupTreeNode>()
                                                    .SelectMany(peptideGroup => peptideGroup.Nodes.OfType <PeptideTreeNode>())
                                                    .Where(peptideTreeNode => surrogateStandards.Values.Contains(peptideTreeNode.DocNode.RawTextId))
                                                    .Select(treeNode => treeNode.Path)
                                                    .ToList();
                SkylineWindow.SequenceTree.SelectedPaths = pathsToSelect;
                SkylineWindow.SetStandardType(StandardType.SURROGATE_STANDARD);
            });

            // Use the document grid to set the Normalization Method of the molecules that have surrogate standards
            var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            RunUI(() => documentGrid.ChooseView(Resources.Resources_ReportSpecList_GetDefaults_Peptide_Quantification));
            IDataGridViewEditingControl editingControl = null;
            DataGridViewEditingControlShowingEventHandler onEditingControlShowing =
                (sender, args) => editingControl = args.Control as IDataGridViewEditingControl;

            documentGrid.DataGridView.EditingControlShowing += onEditingControlShowing;

            // ReSharper disable AccessToForEachVariableInClosure
            foreach (var entry in surrogateStandards)
            {
                WaitForConditionUI(() => documentGrid.IsComplete);
                RunUI(() =>
                {
                    var colPeptide = documentGrid.FindColumn(PropertyPath.Root);
                    for (int iRow = 0; iRow < documentGrid.RowCount; iRow++)
                    {
                        var row = documentGrid.DataGridView.Rows[iRow];
                        if (!entry.Key.Equals(row.Cells[colPeptide.Index].FormattedValue))
                        {
                            continue;
                        }
                        var colNormalizationMethod            = documentGrid.FindColumn(PropertyPath.Root.Property("NormalizationMethod"));
                        documentGrid.DataGridView.CurrentCell = row.Cells[colNormalizationMethod.Index];
                        documentGrid.DataGridView.BeginEdit(false);
                        editingControl.EditingControlFormattedValue =
                            string.Format(Resources.RatioToSurrogate_ToString_Ratio_to_surrogate__0____1__, entry.Value,
                                          "Heavy");
                        documentGrid.DataGridView.EndEdit();
                    }
                });
            }

            // Make sure that the Y-Axis on the CalibrationForm reflects the normalization method of the selected molecule
            var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm());

            foreach (var peptideGroupTreeNode in SkylineWindow.SequenceTree.Nodes.OfType <PeptideGroupTreeNode>())
            {
                foreach (var peptideTreeNode in peptideGroupTreeNode.Nodes.OfType <PeptideTreeNode>())
                {
                    RunUI(() => SkylineWindow.SequenceTree.SelectedPath = peptideTreeNode.Path);
                    WaitForGraphs();
                    string yAxisText = calibrationForm.ZedGraphControl.GraphPane.YAxis.Title.Text;
                    if (null != peptideTreeNode.DocNode.NormalizationMethod)
                    {
                        Assert.IsInstanceOfType(peptideTreeNode.DocNode.NormalizationMethod, typeof(NormalizationMethod.RatioToSurrogate));
                        Assert.AreEqual(QuantificationStrings.CalibrationCurveFitter_GetYAxisTitle_Normalized_Peak_Area,
                                        yAxisText);
                    }
                    else
                    {
                        Assert.IsInstanceOfType(SkylineWindow.Document.Settings.PeptideSettings.Quantification.NormalizationMethod, typeof(NormalizationMethod.RatioToLabel));
                        string expectedTitle = CalibrationCurveFitter.PeakAreaRatioText(IsotopeLabelType.light,
                                                                                        IsotopeLabelType.heavy);
                        Assert.AreEqual(expectedTitle, yAxisText);
                    }
                }
            }
        }