Ejemplo n.º 1
0
        public DataGridCell GetCell(int row, int column)

        {
            DataGridRow rowContainer = GetRow(row);

            if (rowContainer != null)

            {
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);

                if (presenter == null)

                {
                    g1.ScrollIntoView(rowContainer, g1.Columns[column]);

                    presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                }

                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);

                return(cell);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public DataGridCell GetCell(int row, int column)
        {
            try
            {
                DataGridRow rowContainer = GetRow(row);

                if (rowContainer != null)
                {
                    DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                    if (presenter == null)
                    {
                        return(null);
                    }
                    DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                    if (cell == null)
                    {
                        grdMachinesGroups.ScrollIntoView(rowContainer, grdMachinesGroups.Columns[column]);
                        cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                    }
                    return(cell);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(null);
        }
Ejemplo n.º 3
0
        //show gridview for staff consultation and teaching time
        public static void showGridView(string fName, string gName, ref DataGrid dg)
        {
            //clear the previous background color
            clearDataGridBackgroundColor(ref dg);


            //retrieve consultation time and teaching time from database
            Database        db   = new Database();
            List <string[]> time = db.retrieveTime(fName, gName, "");
            int             row;
            int             col;

            foreach (var t in time)
            {
                col = Array.IndexOf(dataWeek, t[2]);
                row = Array.IndexOf(dayHour, t[0]);
                int startT = int.Parse(t[0].Substring(0, 2));
                int endT   = int.Parse(t[1].Substring(0, 2));
                for (int i = 0; i < endT - startT; i++)
                {
                    DataGridRow            dr        = (DataGridRow)dg.ItemContainerGenerator.ContainerFromIndex(row);
                    DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(dr);
                    DataGridCell           dc        = presenter.ItemContainerGenerator.ContainerFromIndex(col) as DataGridCell;

                    //dc.Focus();
                    dc.Background = new SolidColorBrush(Colors.Red);
                    // dg.Rows[row].Cells[col].Selected = true;
                    row++;
                }
                row = 0;
            }
        }
Ejemplo n.º 4
0
        private void AddButton(int i, int j)
        {
            if (i < this.DataDG.Items.Count)
            {
                DataRowView            drv       = DataDG.Items[i] as DataRowView;
                DataGridRow            row       = GetRow(DataDG, i);
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row);
                DataGridCell           cell      = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(j);

                DGObjectDef     objectDef = standard.GetDGObjectDefByName(dataTable.TableName);
                DataFileService dfs       = new DataFileService(objectDef.Code, IDindex[i]);

                StackPanel _stackpanel = new StackPanel();
                _stackpanel.Orientation = Orientation.Horizontal;

                MyButton _button1 = new MyButton();
                _button1.Content = "下载附件";
                _button1._dfs    = dfs;
                _button1.Click  += _button1._dfs.Downloadfile;

                MyButton _button2 = new MyButton();
                _button2.Content = "上传附件";
                _button2._dfs    = dfs;
                _button2.Click  += _button2._dfs.Uploadfile;

                _stackpanel.Children.Add(_button2);
                _stackpanel.Children.Add(_button1);
                cell.Content = _stackpanel;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取可见DataGridRow的单元格
        /// </summary>
        /// <param name="dataRow">可见DataGridRow</param>
        /// <param name="columnIndex">单元格所在的列号</param>
        /// <returns>指定的单元格</returns>
        public static DataGridCell GetCell(this DataGridRow dataRow, int columnIndex)
        {
            DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(dataRow);
            DataGridCell           cell      = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);

            return(cell);
        }
        // Get TextBlock from cell presenter for just edited cell
        private TextBlock GetCell(int rowNumber, string columnName)
        {
            DataGridRow row = this.ItemContainerGenerator.ContainerFromIndex(rowNumber) as DataGridRow; // it might be null if row is not loaded yet

            if (row != null)
            {
                int column = -1;
                // need column index, but only have column name
                for (int i = 0; i < Columns.Count; i++)
                {
                    // todo: check whether it is possible to make this in more safe way
                    if (Columns[i] is DataGridBoundColumn && ((Binding)((DataGridBoundColumn)Columns[i]).Binding).Path.Path == columnName)
                    {
                        column = i;
                    }
                }
                if (column >= 0)
                {
                    DataGridCellsPresenter presenter = C1.WPF.VTreeHelper.GetChildOfType(row, typeof(DataGridCellsPresenter)) as DataGridCellsPresenter;
                    if (presenter != null)
                    {
                        DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                        if (cell != null)
                        {
                            return(C1.WPF.VTreeHelper.GetChildOfType(cell, typeof(TextBlock)) as TextBlock);
                        }
                    }
                }
            }
            return(null);
        }
        // Token: 0x06002604 RID: 9732 RVA: 0x000B5F50 File Offset: 0x000B4150
        protected override List <AutomationPeer> GetChildrenCore()
        {
            DataGridCellsPresenter cellsPresenter = this.OwningDataGridRow.CellsPresenter;

            if (cellsPresenter != null && cellsPresenter.ItemsHost != null)
            {
                List <AutomationPeer> list = new List <AutomationPeer>(3);
                AutomationPeer        rowHeaderAutomationPeer = this.RowHeaderAutomationPeer;
                if (rowHeaderAutomationPeer != null)
                {
                    list.Add(rowHeaderAutomationPeer);
                }
                DataGridItemAutomationPeer dataGridItemAutomationPeer = base.EventsSource as DataGridItemAutomationPeer;
                if (dataGridItemAutomationPeer != null)
                {
                    list.AddRange(dataGridItemAutomationPeer.GetCellItemPeers());
                }
                AutomationPeer detailsPresenterAutomationPeer = this.DetailsPresenterAutomationPeer;
                if (detailsPresenterAutomationPeer != null)
                {
                    list.Add(detailsPresenterAutomationPeer);
                }
                return(list);
            }
            return(base.GetChildrenCore());
        }
Ejemplo n.º 8
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         DataGridRow rowContainer = (DataGridRow)this.ItemContainerGenerator.ContainerFromItem(this.CurrentItem);
         if (rowContainer != null)
         {
             int columnIndex = this.Columns.IndexOf(this.CurrentColumn);
             DataGridCellsPresenter presenter = Helper.FindVisualChild <DataGridCellsPresenter>(rowContainer);
             if (columnIndex == Columns.Count() - 1)
             {
                 DataGridCell     cell    = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                 TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
                 request.Wrapped = true;
                 cell.MoveFocus(request);
                 //BeginEdit();
                 PressKey(Key.Down);
             }
             else
             {
                 CommitEdit();
                 DataGridCell     cell    = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                 TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
                 request.Wrapped = true;
                 cell.MoveFocus(request);
             }
             SelectedItem = CurrentItem;
             e.Handled    = true;
             //UpdateLayout();
         }
     }
 }
Ejemplo n.º 9
0
        private void OnDataGridPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is VsDataGrid dataGrid))
            {
                return;
            }

            if (!(dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.CurrentCell.Item) is DataGridRow row))
            {
                return;
            }

            DataGridCellsPresenter presenter = row.Descendents().OfType <DataGridCellsPresenter>().FirstOrDefault();

            if (presenter == null)
            {
                return;
            }

            int index = dataGrid.Columns.IndexOf(dataGrid.CurrentColumn);

            if (index < 0)
            {
                return;
            }

            if (!(presenter.ItemContainerGenerator.ContainerFromIndex(index) is DataGridCell cell) || cell.IsEditing)
            {
                return;
            }

            dataGrid.BeginEdit(e);
        }
Ejemplo n.º 10
0
        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
            {
                e.Handled = true;
                TextBox tb = sender as TextBox;

                DataGridRow dgr = (DataGridRow)grdUnSelJudge.ItemContainerGenerator.ContainerFromIndex(0);
                if (dgr == null)
                {
                    return;
                }
                grdUnSelJudge.SelectedIndex = 0;
                grdUnSelJudge.Focus();
                DataGridCellsPresenter presenter = AthleticsCommon.GetVisualChild <DataGridCellsPresenter>(dgr);

                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(1);
                if (cell != null)
                {
                    cell.Focus();
                }


                //dgr.Focus();
            }
        }
Ejemplo n.º 11
0
 private DataGridCell GetCell(DataGridRow rowContainer, int column)
 {
     if (rowContainer != null)
     {
         DataGridCellsPresenter presenter = FindVisualChild <DataGridCellsPresenter>(rowContainer);
         if (presenter == null)
         {
             /* if the row has been virtualized away, call its ApplyTemplate() method
              * to build its visual tree in order for the DataGridCellsPresenter
              * and the DataGridCells to be created */
             rowContainer.ApplyTemplate();
             presenter = FindVisualChild <DataGridCellsPresenter>(rowContainer);
         }
         if (presenter != null)
         {
             DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell;
             if (cell == null)
             {
                 /* bring the column into view
                  * in case it has been virtualized away */
                 ScrollIntoView(rowContainer, Columns[column]);
                 cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell;
             }
             return(cell);
         }
     }
     return(null);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Get the cell and its data for decision making
        /// </summary>
        public static DataGridCell GetCell(DataGrid dataGrid, DataGridRow rowContainer, int column)
        {
            if (rowContainer != null)
            {
                //get the childern of the visual presenter
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                if (presenter == null)
                {
                    rowContainer.ApplyTemplate();
                    presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                }
                if (presenter != null)
                {
                    //get the findal cell object
                    DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell;
                    //if the cell object is null refresh grid and get the current cell object
                    if (cell == null)
                    {
                        dataGrid.ScrollIntoView(rowContainer, dataGrid.Columns[column]);
                        dataGrid.UpdateLayout();
                        cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell;
                    }

                    return(cell);
                }
            }
            return(null);
        }
Ejemplo n.º 13
0
        private void UpdateSourceValidation(MappingDataGridCtrl mappingDataGridCtrl, ObservableCollection <ConfiguredMeasurementData> configuredMeasurements)
        {
            // In case multiple rules are bound then it would come like "Required|Numeric
            var validationRules = mappingDataGridCtrl.ValidationRule.Split(new[] { "|", }, StringSplitOptions.RemoveEmptyEntries);

            for (int rowindex = 0; rowindex < mappingDataGridCtrl.MappingDataGrid.Items.Count; rowindex++)
            {
                DataGridRow            rowContainer = (DataGridRow)mappingDataGridCtrl.MappingDataGrid.ItemContainerGenerator.ContainerFromIndex(rowindex);
                DataGridCellsPresenter presenter    = GetVisualChild <DataGridCellsPresenter>(rowContainer);

                for (int i = 1; i < 3; i++)
                {
                    DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(i);

                    if (cell != null)
                    {
                        TextBox textBox = GetVisualChild <TextBox>(cell);
                        if (textBox != null)
                        {
                            var bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);

                            if (bindingExpression != null)
                            {
                                bindingExpression.UpdateSource();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 获取DataGrid控件单元格
        /// </summary>
        /// <param name="dataGrid">DataGrid控件</param>
        /// <param name="rowIndex">单元格所在的行号</param>
        /// <param name="columnIndex">单元格所在的列号</param>
        /// <returns>指定的单元格</returns>
        public static DataGridCell GetCell(this DataGrid dataGrid, int rowIndex, int columnIndex)
        {
            DataGridRow rowContainer = dataGrid.GetRow(rowIndex);

            if (rowContainer != null)
            {
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                if (presenter == null)
                {
                    dataGrid.ScrollIntoView(rowContainer, dataGrid.Columns[columnIndex]);
                    presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                }
                if (presenter == null)
                {
                    return(null);
                }

                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                if (cell == null)
                {
                    dataGrid.ScrollIntoView(rowContainer, dataGrid.Columns[columnIndex]);
                    cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
                }
                return(cell);
            }
            return(null);
        }
Ejemplo n.º 15
0
        public static TextBlock GetTextBlock(DataGridRow rowContainer, int column)
        {
            DataGridCellsPresenter presenter    = FindControl.FindChild <DataGridCellsPresenter>(rowContainer, string.Empty);
            DataGridCell           datagridCell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);

            return(GetTextBlock(datagridCell));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Clears the validation rules.
        /// </summary>
        private void ClearValidationRules()
        {
            for (int rowindex = 0; rowindex < this.MappingDataGrid.Items.Count; rowindex++)
            {
                DataGridRow            rowContainer = (DataGridRow)this.MappingDataGrid.ItemContainerGenerator.ContainerFromIndex(rowindex);
                DataGridCellsPresenter presenter    = GetVisualChild <DataGridCellsPresenter>(rowContainer);

                for (int i = 1; i < 3; i++)
                {
                    DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(i);

                    if (cell != null)
                    {
                        TextBox textBox = GetVisualChild <TextBox>(cell);
                        if (textBox != null)
                        {
                            Binding binding = BindingOperations.GetBinding(textBox, TextBox.TextProperty);

                            if (binding != null)
                            {
                                binding.ValidationRules.Clear();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void accountListDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid dataGrid = sender as DataGrid;

            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                // find row for the first selected item
                DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]);
                if (row != null)
                {
                    DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row);
                    // find grid cell object for the cell with index 0
                    DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(0) as DataGridCell;
                    if (cell != null)
                    {
                        currentusername = (((TextBlock)cell.Content).Text);
                    }

                    DataGridCellsPresenter presenter2 = GetVisualChild <DataGridCellsPresenter>(row);
                    // find grid cell object for the cell with index 0
                    DataGridCell cell2 = presenter2.ItemContainerGenerator.ContainerFromIndex(1) as DataGridCell;
                    if (cell != null)
                    {
                        currentpassword = (((TextBlock)cell2.Content).Text);
                    }
                }
            }


            Trace.WriteLine("Selection changed to: " + currentusername);

            userNameTb.Text = currentusername;
            passwordTb.Text = currentpassword;
        }
Ejemplo n.º 18
0
        public void ClickOnCheckBox(string checkboxHeaderValue, string fieldToSearchOnHeader, string fieldValueToSearch)
        {
            foreach (var item in mGrid.DataSourceList)
            {
                string actualFieldName = item.GetType().GetProperty(fieldToSearchOnHeader).GetValue(item).ToString();
                if (actualFieldName == fieldValueToSearch)
                {
                    DataGridCellsPresenter presenter = null;
                    CheckBox checkbox = null;


                    Execute(() =>
                    {
                        mGrid.Grid.SelectedItem = item;
                        mGrid.ScrollToViewCurrentItem();
                    });

                    SleepWithDoEvents(1000);
                    DataGridRow row = mGrid.Grid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow;
                    Execute(() =>
                    {
                        presenter = General.GetVisualChild <DataGridCellsPresenter>(row);
                        object a  = presenter.ItemContainerGenerator.Items[0].GetType().GetProperty(checkboxHeaderValue).GetValue(presenter.ItemContainerGenerator.Items[0]);
                        if (a != null)
                        {
                            DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(0);
                            checkbox          = General.GetVisualChild <CheckBox>(cell);
                        }

                        checkbox.IsChecked = !checkbox.IsChecked;
                    });
                }
            }
        }
Ejemplo n.º 19
0
        public static void SetFocusOnNewCreatedColumn(DataGrid DataGrid, int rowIndex)
        {
            DataGrid.Focus();

            DataGridRow rowContainer = DataGrid.ItemContainerGenerator.ContainerFromIndex(rowIndex) as DataGridRow;

            if (rowContainer == null)
            {
                DataGrid.SelectedIndex = rowIndex;
                DataGrid.ScrollIntoView(DataGrid.SelectedItem);
                rowContainer = DataGrid.ItemContainerGenerator.ContainerFromIndex(rowIndex) as DataGridRow;
            }
            if (rowContainer != null)
            {
                rowContainer.ApplyTemplate();
                DataGridCellsPresenter presenter = WpfTools.FindVisualChild <DataGridCellsPresenter>(rowContainer);
                DataGridCell           cell      = presenter.ItemContainerGenerator.ContainerFromIndex(0) as DataGridCell;
                if (cell == null)
                {
                    /* bring the column into view in case it has been virtualized away */
                    DataGrid.ScrollIntoView(rowContainer, DataGrid.Columns[0]);
                    cell = presenter.ItemContainerGenerator.ContainerFromIndex(0) as DataGridCell;
                }
                if (cell != null)
                {
                    cell.Focus();
                }
            }
        }
Ejemplo n.º 20
0
        public static DataGridCell GetCell(this DataGrid source, int row, int column)
        {
            DataGridRow rowContainer = GetRow(source, row);

            if (rowContainer != null)
            {
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                if (presenter == null)
                {
                    rowContainer.ApplyTemplate();
                    presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                }

                if (presenter == null)
                {
                    return(null);
                }

                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                if (cell == null)
                {
                    source.ScrollIntoView(rowContainer, source.Columns[column]);
                    cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                }
                return(cell);
            }
            return(null);
        }
        static DataGridCell GetCell(DataGrid dataGrid, DataGridRow row, int column)
        {
            if (dataGrid == null)
            {
                throw new ArgumentNullException(nameof(dataGrid));
            }
            if (row == null)
            {
                throw new ArgumentNullException(nameof(row));
            }
            if (column < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(column));
            }

            DataGridCellsPresenter presenter = FindVisualChild <DataGridCellsPresenter>(row);

            if (presenter == null)
            {
                row.ApplyTemplate();
                presenter = FindVisualChild <DataGridCellsPresenter>(row);
            }
            if (presenter != null)
            {
                var cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell;
                if (cell == null)
                {
                    dataGrid.ScrollIntoView(row, dataGrid.Columns[column]);
                    cell = presenter.ItemContainerGenerator.ContainerFromIndex(column) as DataGridCell;
                }
                return(cell);
            }
            return(null);
        }
        public DataGridCell GetCell(int rowIndex, int columnIndex, DataGrid dg)
        {
            DataGridRow            row  = dg.ItemContainerGenerator.ContainerFromIndex(rowIndex) as DataGridRow;
            DataGridCellsPresenter p    = GetVisualChild <DataGridCellsPresenter>(row);
            DataGridCell           cell = p.ItemContainerGenerator.ContainerFromIndex(columnIndex) as DataGridCell;

            return(cell);
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Notification from the DataGrid that the columns collection has changed.
        /// </summary>
        /// <param name="columns">The columns collection.</param>
        /// <param name="e">The event arguments from the collection's change event.</param>
        protected internal virtual void OnColumnsChanged(ObservableCollection <DataGridColumn> columns, NotifyCollectionChangedEventArgs e)
        {
            DataGridCellsPresenter cellsPresenter = CellsPresenter;

            if (cellsPresenter != null)
            {
                cellsPresenter.OnColumnsChanged(columns, e);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        ///     Method which tries to scroll a cell for given index into the scroll view
        /// </summary>
        /// <param name="index"></param>
        internal void ScrollCellIntoView(int index)
        {
            DataGridCellsPresenter cellsPresenter = CellsPresenter;

            if (cellsPresenter != null)
            {
                cellsPresenter.ScrollCellIntoView(index);
            }
        }
        private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            if (RowToColor != null)
            {
                try
                {
                    DataGridRow dgr = e.Row;
                    DataRowView drv = (DataRowView)dgr.Item;

                    e.Row.Background = defaultBackGroundBrush;
                    e.Row.Foreground = defaultForeGroundBrush;

                    bool bStrikeRow = false;

                    //Go through each of the columns and look for a match
                    for (int i = 0; i < this.Columns.Count; i++)
                    {
                        //For the coloring, go through the RowToColor property
                        for (int j = 0; j < RowToColor.Count; j++)
                        {
                            if (this.Columns[i].Header.ToString() == RowToColor[j].ColumnHeader)
                            {
                                if (drv[i].ToString() == RowToColor[j].ColumnValue)
                                {
                                    e.Row.Background = RowToColor[j].RowBackGroundBrushColor;
                                    e.Row.Foreground = RowToColor[j].RowForeGroundBrushColor;
                                }
                            }
                        }
                    }

                    if (bStrikeRow == true)
                    {
                        DataGridCellsPresenter presenter = DataGridHelper.GetVisualChild <DataGridCellsPresenter>(dgr);
                        if (presenter != null)
                        {
                            for (int i = 0; i < this.Columns.Count; i++)
                            {
                                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(i);
                                if (cell == null)
                                {
                                    this.ScrollIntoView(dgr, this.Columns[i]);
                                    cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(i);
                                }
                                TextBlock tb = DataGridHelper.GetVisualChild <TextBlock>(cell);
                                tb.TextDecorations = TextDecorations.Strikethrough;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string sNoMessage = ex.Message;
                }
            }
        }
Ejemplo n.º 26
0
        public override void GotoLineExecuted(object sender)
        {
            FilterTabViewModel filterTab = (FilterTabViewModel)CurrentTab();
            LogTabViewModel    logTab    = (LogTabViewModel)_LogViewModel.CurrentTab();

            if (filterTab != null && logTab != null)
            {
                int filterIndex = -1;
                int logIndex    = ((Selector)logTab.Viewer).SelectedIndex;

                if (logIndex <= logTab.ContentList.Count)
                {
                    filterIndex = logTab.ContentList[logIndex].FilterIndex;
                }
                else
                {
                    SetStatus("filter:gotoLine:error in index:" + filterIndex.ToString());
                    return;
                }

                if (filterIndex >= 0)
                {
                    SetStatus("filter:gotoLine:" + filterIndex.ToString());
                    ((Selector)filterTab.Viewer).SelectedIndex = filterIndex;

                    DataGrid       dataGrid       = (DataGrid)CurrentTab().Viewer;
                    FilterFileItem filterFileItem = CurrentFile().ContentItems.FirstOrDefault(x => x.Index == filterIndex);

                    dataGrid.ScrollIntoView(filterFileItem);
                    dataGrid.SelectedItem  = filterFileItem;
                    dataGrid.SelectedIndex = dataGrid.Items.IndexOf(filterFileItem);
                    dataGrid.UpdateLayout();

                    DataGridRow            row       = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(dataGrid.SelectedIndex);
                    DataGridCellsPresenter presenter = FindVisualChild <DataGridCellsPresenter>(row);

                    if (presenter != null)
                    {
                        DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(0) as DataGridCell;

                        if (cell != null)
                        {
                            cell.Focus();
                        }
                    }
                }
                else if (filterIndex == -1)
                {
                    // quick filter
                    if (QuickFindCombo != null)
                    {
                        Keyboard.Focus(QuickFindCombo);
                    }
                }
            }
        }
Ejemplo n.º 27
0
 public static DataGridCell GetCell(DataGrid dataGrid, DataGridRow row, int column)
 {
     if (row != null)
     {
         DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row);
         DataGridCell           cell      = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
         return(cell);
     }
     return(null);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// 返回DataGridRow中列号为columnIndex的单元格
 /// </summary>
 /// <param name="rowContainer">DataGridRow</param>
 /// <param name="columnIndex"></param>
 /// <returns></returns>
 public static DataGridCell GetCellInRow(this DataGridRow rowContainer, int columnIndex)
 {
     if (rowContainer != null)
     {
         DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
         DataGridCell           cell      = presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex) as DataGridCell;
         return(cell);
     }
     return(null);
 }
Ejemplo n.º 29
0
        public static DataGridCell GetCell(this DataGrid grid, DataGridRow row, int column)
        {
            if (row == null)
            {
                return(null);
            }

            DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(row);

            return((DataGridCell)presenter?.ItemContainerGenerator.ContainerFromIndex(column));
        }
Ejemplo n.º 30
0
        private DataGridCell GetCell(int row, int column)
        {
            DataGridRow rowContainer = GetRow(row);

            if (rowContainer != null)
            {
                DataGridCellsPresenter presenter = GetVisualChild <DataGridCellsPresenter>(rowContainer);
                return((DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column));
            }
            return(null);
        }