Пример #1
0
        private void FastGridUserHitCell(object sender, MouseEventArgs e, int rowIndex, FastColumn col)
        {
            if (e.Button != MouseButtons.Left || rowIndex < 0)
            {
                return;
            }

            var description = fastGrid.rows[rowIndex].ValueObject as TemplateDescription;

            if (col.PropertyName == description.Property(p => p.Close))
            {
                var templateDescription = fastGrid.GetRowValues <TemplateDescription>(false).ToList();
                if (description != null)
                {
                    ChartTemplate.DellChartTemplate(description.Name);
                    templateDescription.Remove(description);
                    fastGrid.DataBind(templateDescription);
                    fastGrid.Invalidate();
                }
            }
            else if (col.PropertyName == description.Property(p => p.Name))
            {
                var dropDownDialog = new DropDownDialog("Введите название",
                                                        fastGrid.GetRowValues <TemplateDescription>(false)
                                                        .Select(x => x.Name)
                                                        .Cast <object>()
                                                        .ToList(), false);
                dropDownDialog.SelectedText = description.Name;
                var dialogResult = dropDownDialog.ShowDialog();
                var newName      = dropDownDialog.SelectedText;
                if (dialogResult == DialogResult.Cancel || newName == description.Name)
                {
                    return;
                }
                if (!ChartTemplate.UpdateChartTemplateName(description.Name, newName))
                {
                    description.Name = newName;
                    fastGrid.UpdateRow(rowIndex, description);
                    fastGrid.InvalidateRow(rowIndex);
                }
                else
                {
                    Rebind();
                }
            }
            else if (col.PropertyName == description.Property(p => p.IndicatorsCount))
            {
                if (description != null)
                {
                    ShowTooltip(string.Format("Шаблон \"{0}\" содержит индикаторы", description.Name),
                                string.Join(Environment.NewLine, description.IndicatorNames), e.X, e.Y);
                }
            }
        }