/// <summary>
 ///     Constructs a new instance of these event arguments. 
 /// </summary>
 /// <param name="column">The column of the cell that just entered edit mode.</param>
 /// <param name="row">The row container that contains the cell container that just entered edit mode.</param>
 /// <param name="editingEventArgs">The event arguments, if any, that led to the cell being placed in edit mode.</param> 
 /// <param name="cell">The cell container that just entered edit mode.</param>
 /// <param name="editingElement">The editing element within the cell container.</param> 
 public DataGridPreparingCellForEditEventArgs(DataGridColumn column, DataGridRow row, RoutedEventArgs editingEventArgs, FrameworkElement editingElement) 
 {
     _dataGridColumn = column; 
     _dataGridRow = row;
     _editingEventArgs = editingEventArgs;
     _editingElement = editingElement;
 } 
 /// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 /// <param name="column">The column of the cell that is about to exit edit mode.</param>
 /// <param name="row">The row container of the cell container that is about to exit edit mode.</param>
 /// <param name="editingElement">The editing element within the cell.</param>
 /// <param name="editingUnit">The editing unit that is about to leave edit mode.</param>
 public DataGridCellEditEndingEventArgs(DataGridColumn column, DataGridRow row, FrameworkElement editingElement, DataGridEditAction editAction)
 {
     _dataGridColumn = column;
     _dataGridRow = row;
     _editingElement = editingElement;
     _editAction = editAction;
 }
        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
        {
            if (this.OwningDataGrid != null &&
                this.OwningDataGrid.DataConnection != null &&
                row >= 0 && row < this.OwningDataGrid.SlotCount &&
                column >= 0 && column < this.OwningDataGrid.Columns.Count)
            {
                object item = null;
                if (!this.OwningDataGrid.IsSlotVisible(this.OwningDataGrid.SlotFromRowIndex(row)))
                {
                    item = this.OwningDataGrid.DataConnection.GetDataItem(row);
                }
                this.OwningDataGrid.ScrollIntoView(item, this.OwningDataGrid.Columns[column]);

                DataGridRow dgr = this.OwningDataGrid.DisplayData.GetDisplayedRow(row);
                if (this.OwningDataGrid.ColumnsInternal.RowGroupSpacerColumn.IsRepresented)
                {
                    column++;
                }
                Debug.Assert(column >= 0);
                Debug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count);
                DataGridCell   cell = dgr.Cells[column];
                AutomationPeer peer = CreatePeerForElement(cell);
                if (peer != null)
                {
                    return(ProviderFromPeer(peer));
                }
            }
            return(null);
        }
        private void UpdateOlympiadID()
        {
            var selectedRow = dataGridOlympiads.GetSelectedRow();

            if (previousRow != selectedRow)
            {
                previousRow = selectedRow;
            }
            else
            {
                return;
            }

            if (selectedRow == null)
            {
                //throw new Exception("Please, select proper Olympiad");
                return;
            }
            var columnCell = dataGridOlympiads.GetCell(selectedRow, 0).Content;

            int olyID;
            int.TryParse((columnCell as TextBlock).Text,out olyID);
            OlympiadID = olyID;
            GenerateOlympiadResults();
        }
Example #5
0
        private void Button_Click_3(object sender, System.Windows.RoutedEventArgs e)
        {
            //OpenFileDialog openfile = new OpenFileDialog();


            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            //Static File From Base Path...........
            //Microsoft.Office.Interop.Excel.Workbook excelBook = excelApp.Workbooks.Open(AppDomain.CurrentDomain.BaseDirectory + "TestExcel.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            //Dynamic File Using Uploader...........
            Microsoft.Office.Interop.Excel.Workbook  excelBook  = excelApp.Workbooks.Open(TextFile.Text.ToString(), 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelBook.Worksheets.get_Item(1);;
            Microsoft.Office.Interop.Excel.Range     excelRange = excelSheet.UsedRange;

            string strCellData = "";
            double douCellData;
            int    rowCnt = 0;
            int    colCnt = 0;

            DataTable dt = new DataTable();

            for (colCnt = 1; colCnt <= excelRange.Columns.Count; colCnt++)
            {
                string strColumn = "";
                strColumn = (string)(excelRange.Cells[1, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
                //dt.Header = strColumn;
                //dt.Binding = new Binding(strColumn);
                //datagrid.Columns.Add(dt);
                dt.Columns.Add(strColumn, typeof(string));
            }
            string      strData = "";
            DataGridRow dr      = new System.Windows.Controls.DataGridRow();

            for (rowCnt = 2; rowCnt <= excelRange.Rows.Count; rowCnt++)
            {
                for (colCnt = 1; colCnt <= excelRange.Columns.Count; colCnt++)
                {
                    try
                    {
                        strCellData = (string)(excelRange.Cells[rowCnt, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
                        strData    += strCellData + "|";
                    }
                    catch (Exception ex)
                    {
                        douCellData = (excelRange.Cells[rowCnt, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
                        strData    += douCellData.ToString() + "|";
                    }
                }
                strData = strData.Remove(strData.Length - 1, 1);
                ObservableCollection <ItemModel> Listgrid = new ObservableCollection <ItemModel>();

                dt.Rows.Add(strData.Split('|'));
                //datagrid.Rows.Add(strData);
                //datagrid.Items.Add(strData);
            }

            //datagrid.ItemsSource = dt.DefaultView;
            excelBook.Close(true, null, null);
            excelApp.Quit();
        }
Example #6
0
 private void FormatRow(DataGridRow row)
 {
     Product product = (Product)row.DataContext;
     if (product.UnitCost > 100)
         row.Background = highlightBrush;
     else
         row.Background = normalBrush;
 }   
 /// <summary>
 /// AutomationPeer for DataGridRow
 /// </summary>
 /// <param name="owner">DataGridRow</param>
 public DataGridRowAutomationPeer(DataGridRow owner)
     : base(owner)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("owner");
     }
 }
 /// <summary>
 /// Initializes a new instance of the 
 /// <see cref="T:System.Windows.Controls.Data.DataGridBeginningEditEventArgs" /> class.
 /// </summary>
 /// <param name="column">
 /// The column that contains the cell to be edited.
 /// </param>
 /// <param name="row">
 /// The row that contains the cell to be edited.
 /// </param>
 /// <param name="editingEventArgs">
 /// Information about the user gesture that caused the cell to enter edit mode.
 /// </param>
 public DataGridBeginningEditEventArgs(DataGridColumn column,
                                       DataGridRow row,
                                       RoutedEventArgs editingEventArgs)
 {
     this.Column = column;
     this.Row = row;
     this.EditingEventArgs = editingEventArgs;
 }
        internal void UpdateRowPeerEventsSource(DataGridRow row)
        {
            DataGridRowAutomationPeer peer = FromElement(row) as DataGridRowAutomationPeer;

            if (peer != null && _itemPeers.ContainsKey(row.DataContext))
            {
                peer.EventsSource = _itemPeers[row.DataContext];
            }
        }
        /// <summary>
        /// Row number
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            System.Windows.Controls.DataGridRow row = value as System.Windows.Controls.DataGridRow;
            if (row == null)
            {
                return(0);
            }

            return(row.GetIndex() + 1);
        }
 public void Update(DataGridRow row)
 {
     var record = (Record)row.Item;
     var content = GetContent(row);
     if (content == null)
     {
         return;
     }
     content.Text = record.Properties[_descriptor.Index].ValueAsString;
 }
Example #12
0
 public GridDragRowState(swc.DataGridRow row, int childIndex)
 {
     Row = row;
     //Item = row.Item;
     BorderThickness = row.BorderThickness;
     BorderBrush     = row.BorderBrush;
     Background      = row.Background;
     Foreground      = row.Foreground;
     ChildIndex      = childIndex;
 }
 public System.Windows.Controls.DataGridRow GetRow(int index)
 {
     System.Windows.Controls.DataGridRow row = (System.Windows.Controls.DataGridRow)DataGrid2.ItemContainerGenerator.ContainerFromIndex(index);
     if (row == null)
     {
         // may be virtualized, bring into view and try again
         DataGrid2.ScrollIntoView(DataGrid2.Items[index]);
         row = (System.Windows.Controls.DataGridRow)DataGrid2.ItemContainerGenerator.ContainerFromIndex(index);
     }
     return(row);
 }
Example #14
0
 public bool IsEqual(swc.DataGridRow row, int childIndex)
 {
     if (!ReferenceEquals(row, Row))
     {
         return(false);
     }
     if (childIndex != ChildIndex)
     {
         return(false);
     }
     return(true);
 }
Example #15
0
        private void dataGrid_RowDetailsVisibilityChanged(object sender, Control.DataGridRowDetailsEventArgs e)
        {
            WPFdataGrid.DataGridControl dataGrid = elementHost1.Child as WPFdataGrid.DataGridControl;
            Control.DataGrid            grid     = dataGrid.grid;

            Control.DataGrid data = e.DetailsElement.FindName("details") as Control.DataGrid;

            Control.DataGridRow dataRow = e.Row as Control.DataGridRow;

            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(dataRow.Item);

            var PName = properties["PName"]?.GetValue(dataRow.Item)?.ToString();

            using (Pokemon db = new Pokemon())
            {
                if (detailsObservable == null || !(detailsObservable.Any(p => p.PName == PName)) && db.PokemonBaseStats.Any(p => p.PName == PName))
                {
                    var monsterDetails = (from p in db.PokemonBaseStats
                                          select p.PokemonCapRate).ToList();

                    foreach (var monster in monsterDetails)
                    {
                        detailsObservable.Add(monster);
                    }

                    ListCollectionView detailsView = new ListCollectionView(detailsObservable);

                    detailsView.Filter = (p) => {
                        PokemonCapRate capRate = p as PokemonCapRate;
                        if (capRate.PName == PName)
                        {
                            return(true);
                        }
                        return(false);
                    };

                    if (!(monsterDetails == null))
                    {
                        data.ItemsSource = detailsView;
                    }
                }
                else
                {
                    data.ItemsSource = (from p in detailsObservable
                                        where p.PName == PName
                                        select p).ToList();
                }
            }

            data.IsReadOnly      = grid.IsReadOnly;
            data.SelectedIndex   = -1;
            data.CellEditEnding += new EventHandler <Control.DataGridCellEditEndingEventArgs>(detailGrid_CellValueChanged);
        }
Example #16
0
        private void Expander_Expanded(object sender, RoutedEventArgs e)
        {
            DependencyObject Hit = (DependencyObject)e.OriginalSource;

            while (Hit == null || !(Hit is Controls.DataGridRow))
            {
                Hit = VisualTreeHelper.GetParent(Hit);
            }

            Controls.DataGridRow dataRow = Hit as Controls.DataGridRow;

            dataRow.DetailsVisibility = Visibility.Visible;
        }
 public void GridRowNumberConverter_Convert_WhenInputIsEmpty_ReturnsAZero()
 {
     //------------Setup for test--------------------------
     var converter = new GridRowNumberConverter();
     DataGrid dataGrid = new DataGrid { AutoGenerateColumns = true };
     var itemsSource = new List<string> { "Item 1 ", "Item 2" };
     dataGrid.ItemsSource = itemsSource;
     dataGrid.SelectedItem = itemsSource[0];
     var row = new DataGridRow();
     //------------Execute Test---------------------------
     var result = converter.Convert(row, typeof(string), null, CultureInfo.CurrentCulture);
     //------------Assert Results-------------------------
     Assert.AreEqual(0, result);
 }
Example #18
0
        private int GetCurrentRowIndex(GetPosition pos, System.Windows.Controls.DataGrid MarksDataGrid)
        {
            int curIndex = -1;

            for (int i = 0; i < MarksDataGrid.Items.Count; i++)
            {
                System.Windows.Controls.DataGridRow itm = GetRowItem(i, MarksDataGrid);
                if (GetMouseTargetRow(itm, pos))
                {
                    curIndex = i;
                    break;
                }
            }
            return(curIndex);
        }
        /// <summary>
        /// Collapse/Expands the selected DataGridRow.
        /// </summary>
        /// <param name="parameter">The DataGridRowHeader</param>
        public void Execute(object parameter)
        {
            var rowHeader = parameter as DataGridRowHeader;
            var row = DataGridHelper.FindTemplatedParent<DataGridRow>(rowHeader) as DataGridRow;
            if (_prevRow is DataGridRow
                && _prevRow != row
                && DataGridHelper.FindVisualParent<DataGrid>(_prevRow) == DataGridHelper.FindVisualParent<DataGrid>(rowHeader))
            {	//collapse the previously selected row
                _prevRow.DetailsVisibility = Visibility.Collapsed;
            }
            if (row.DetailsVisibility == Visibility.Visible)
                row.DetailsVisibility = Visibility.Collapsed;
            else
                row.DetailsVisibility = Visibility.Visible;

            _prevRow = row;
        }
Example #20
0
 /// <summary>フォーカス取得時処理</summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DataGrid_GotFocus(object sender, RoutedEventArgs e)
 {
     if (dgVariable.SelectedItems.Count < 1)
     {
         dgVariable.SelectedItem = dgVariable.Items[0];
     }
     else
     {
         if (_isTabKey)
         {
             System.Windows.Controls.DataGridRow  dgrow = (System.Windows.Controls.DataGridRow)dgVariable.ItemContainerGenerator.ContainerFromItem(dgVariable.Items[dgVariable.SelectedIndex]);
             System.Windows.Controls.DataGridCell dgc   = dgVariable.Columns[0].GetCellContent(dgrow).Parent as System.Windows.Controls.DataGridCell;
             FocusManager.SetFocusedElement(dgVariable, dgc as IInputElement);
         }
     }
     _isTabKey = false;
 }
Example #21
0
 /// <summary>フォーカス取得時処理</summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DataGrid_GotFocus(object sender, RoutedEventArgs e)
 {
     ((SolidColorBrush)dgJobValue.Resources["SelectionColorKey"]).Color = SystemColors.HighlightColor;
     if (dgJobValue.SelectedItems.Count < 1)
     {
         dgJobValue.SelectedItem = dgJobValue.Items[0];
     }
     else
     {
         if (_isTabKey)
         {
             System.Windows.Controls.DataGridRow  dgrow = (System.Windows.Controls.DataGridRow)dgJobValue.ItemContainerGenerator.ContainerFromItem(dgJobValue.Items[dgJobValue.SelectedIndex]);
             System.Windows.Controls.DataGridCell dgc   = dgJobValue.Columns[0].GetCellContent(dgrow).Parent as System.Windows.Controls.DataGridCell;
             FocusManager.SetFocusedElement(dgJobValue, dgc as IInputElement);
         }
     }
     _isTabKey = false;
 }
        public System.Windows.Controls.DataGridCell GetCell(int row, int column)
        {
            System.Windows.Controls.DataGridRow rowContainer = GetRow(row);

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

                // try to get the cell but it may possibly be virtualized
                System.Windows.Controls.DataGridCell cell = (System.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                if (cell == null)
                {
                    // now try to bring into view and retreive the cell
                    DataGrid2.ScrollIntoView(rowContainer, DataGrid2.Columns[column]);
                    cell = (System.Windows.Controls.DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
                }
                return(cell);
            }
            return(null);
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.wrap = ((System.Windows.Controls.WrapPanel)(target));

            #line 15 "..\..\OptionWindow.xaml"
                this.wrap.AddHandler(System.Windows.FrameworkContentElement.LoadedEvent, new System.Windows.RoutedEventHandler(this.Wrap_Loaded));

            #line default
            #line hidden
                return;

            case 2:
                this.the = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 3:
                this.qe = ((System.Windows.Controls.Primitives.DataGridRowHeader)(target));
                return;

            case 4:
                this.qsds = ((System.Windows.Controls.Primitives.DataGridRowHeader)(target));
                return;

            case 5:
                this.one = ((System.Windows.Controls.DataGridRow)(target));
                return;

            case 6:
                this.two = ((System.Windows.Controls.DataGridRow)(target));
                return;

            case 7:
                this.three = ((System.Windows.Controls.DataGridRow)(target));
                return;
            }
            this._contentLoaded = true;
        }
Example #24
0
 /// <summary>フォーカス取得時処理</summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgCalendar_GotFocus(object sender, RoutedEventArgs e)
 {
     if (dgCalendarBootTime.Items.Count <= 0)
     {
         return;
     }
     if (dgCalendarBootTime.SelectedItems.Count < 1)
     {
         dgCalendarBootTime.SelectedItem = dgCalendarBootTime.Items[0];
     }
     else
     {
         if (_isTabKey)
         {
             System.Windows.Controls.DataGridRow  dgrow = (System.Windows.Controls.DataGridRow)dgCalendarBootTime.ItemContainerGenerator.ContainerFromItem(dgCalendarBootTime.Items[dgCalendarBootTime.SelectedIndex]);
             System.Windows.Controls.DataGridCell dgc   = dgCalendarBootTime.Columns[0].GetCellContent(dgrow).Parent as System.Windows.Controls.DataGridCell;
             FocusManager.SetFocusedElement(dgCalendarBootTime, dgc as IInputElement);
             _isTabKey = false;
         }
     }
     ((SolidColorBrush)dgCalendarBootTime.Resources["SelectionColorKeyCalendar"]).Color     = SystemColors.HighlightColor;
     ((SolidColorBrush)dgCalendarBootTime.Resources["SelectionColorKeyCalendarText"]).Color = SystemColors.HighlightTextColor;
 }
 internal void RaiseAutomationCellSelectedEvent(int slot, int column)
 {
     if (slot >= 0 && slot < this.OwningDataGrid.SlotCount &&
         column >= 0 && column < this.OwningDataGrid.Columns.Count &&
         this.OwningDataGrid.IsSlotVisible(slot))
     {
         DataGridRow row = this.OwningDataGrid.DisplayData.GetDisplayedElement(slot) as DataGridRow;
         if (row != null)
         {
             if (this.OwningDataGrid.ColumnsInternal.RowGroupSpacerColumn.IsRepresented)
             {
                 column++;
             }
             Debug.Assert(column >= 0);
             Debug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count);
             DataGridCell   cell = row.Cells[column];
             AutomationPeer peer = CreatePeerForElement(cell);
             if (peer != null)
             {
                 peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected);
             }
         }
     }
 }
Example #26
0
        public void SetRowLogo(DataGrid DtGrid, DataGridRow row, string entityCode)
        {
            if (DtGrid.ItemsSource == null)
            {
                return;
            }

            Image logo = DtGrid.Columns[0].GetCellContent(row).FindName("entityLogo") as Image;
            if (logo == null)
            {
                return;
            }

            if (Application.Current.Resources["RowLogo" + entityCode] != null)
            {
                string strPpath = Application.Current.Resources["RowLogo" + entityCode].ToString();
                logo.Margin = new Thickness(2, 2, 0, 0);
                logo.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(strPpath, UriKind.Relative));
                return;
            }

            SMT.Saas.Tools.PermissionWS.PermissionServiceClient client = new SMT.Saas.Tools.PermissionWS.PermissionServiceClient();
            client.GetSysMenuByEntityCodeCompleted += new EventHandler<SMT.Saas.Tools.PermissionWS.GetSysMenuByEntityCodeCompletedEventArgs>(client_GetSysMenuByEntityCodeCompleted);
            client.GetSysMenuByEntityCodeAsync(entityCode);

            //if (string.IsNullOrEmpty(EntityLogo))
            //{
            //    SMT.Saas.Tools.PermissionWS.PermissionServiceClient client = new SMT.Saas.Tools.PermissionWS.PermissionServiceClient();
            //    client.GetSysMenuByEntityCodeCompleted += new EventHandler<SMT.Saas.Tools.PermissionWS.GetSysMenuByEntityCodeCompletedEventArgs>(client_GetSysMenuByEntityCodeCompleted);
            //    client.GetSysMenuByEntityCodeAsync(entityCode, logo);
            //}
            //else
            //{
            //    logo.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(EntityLogo, UriKind.Relative));
            //}
        }
        private void DataGrid2_LoadingRow(object sender, System.Windows.Controls.DataGridRowEventArgs e)
        {
            System.Windows.Controls.DataGridRow row  = e.Row;
            TableColumnsMetadataItem            item = (TableColumnsMetadataItem)row.Item;

            DataGrid2.SelectedItem = item;

            //DataGridCell cell = GetCell(DataGrid2.SelectedIndex, NamespaceColumn.DisplayIndex);

            //if (item.ColumnsSemantic == string.Empty)
            //{
            //    if (cell != null)
            //    {
            //        cell.IsEnabled = false;
            //    }
            //}
            //else
            //{
            //    if (cell != null)
            //    {
            //        cell.IsEnabled = true;
            //    }
            //}
        }
 // Token: 0x060046E0 RID: 18144 RVA: 0x0014189F File Offset: 0x0013FA9F
 internal void PrepareCell(object item, ItemsControl cellsPresenter, DataGridRow ownerRow)
 {
     this.PrepareCell(item, ownerRow, cellsPresenter.ItemContainerGenerator.IndexFromContainer(this));
 }
 /// <summary>
 /// Gets the command used to move another row below this one using drag and drop.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <returns>The command to move a row below this instance.</returns>
 public static ICommand GetMoveBelowCommand(DataGridRow dataGridRow)
 {
     return (ICommand)dataGridRow.GetValue(MoveBelowCommandProperty);
 }
 /// <summary>
 /// Gets the deselection enabled property. If enabled, and the row is clicked while selected, the row is deselected.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <returns><c>true</c> if deselecting row when selected and clicked, otherwise <c>false</c>.</returns>
 public static bool GetIsDeselectionEnabled(DataGridRow dataGridRow)
 {
     return (bool)dataGridRow.GetValue(IsDeselectionEnabledProperty);
 }
 /// <summary>
 /// Sets the content template when this instance is being dragged above or below another row.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <param name="value">A data template used when this instance is being dragged above or below another row.</param>
 public static void SetMoveDragContentTemplate(DataGridRow dataGridRow, DataTemplate value)
 {
     dataGridRow.SetValue(MoveDragContentTemplateProperty, value);
 }
 /// <summary>
 /// Sets the is read only flag for the row.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <param name="value">if set to <c>true</c> the row is read only.</param>
 public static void SetIsReadOnly(DataGridRow dataGridRow, bool value)
 {
     dataGridRow.SetValue(IsReadOnlyProperty, value);
 }
 /// <summary>
 /// Gets the drag format when this instance is being dragged above or below another row.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <returns>The drag format used when this instance is being dragged above or below another row.</returns>
 public static string GetMoveDragFormat(DataGridRow dataGridRow)
 {
     return (string)dataGridRow.GetValue(MoveDragFormatProperty);
 }
Example #34
0
 /// <summary>
 ///     Clears the cell of references.
 /// </summary>
 internal void ClearCell(DataGridRow ownerRow)
 {
     Debug.Assert(_owner == ownerRow, "_owner should be the same as the DataGridRow that is clearing the cell.");
     _owner = null;
 }
Example #35
0
 private void PickUpCard(object sender, MouseEventArgs e)
 {
     if (MouseButtonState.Pressed.Equals(e.LeftButton) && dragActive)
     {
         DataGridRow SearchCard = new DataGridRow();
         var row = (DataRowView)resultsGrid.SelectedItem;
         if (row == null) return;
         if (CardAdded == null) return;
         var rowid = row["id"] as string;
         if (rowid != null)
         {
             DataNew.Entities.MultiCard getCard = Game.GetCardById(Guid.Parse(rowid)).ToMultiCard();
             DataObject dragCard = new DataObject("Card", getCard);
             DragDrop.DoDragDrop(SearchCard, dragCard, DragDropEffects.Copy);
         }
     }
     dragActive = false;
 }
 /// <summary>
 /// Instantiates a new instance of this class.
 /// </summary>
 /// <param name="column">The column of the cell that has just exited edit mode.</param>
 /// <param name="row">The row container of the cell container that has just exited edit mode.</param>
 /// <param name="editAction">The editing action that has been taken.</param>
 public DataGridCellEditEndedEventArgs(DataGridColumn column, DataGridRow row, DataGridEditAction editAction)
 {
     this.Column     = column;
     this.Row        = row;
     this.EditAction = editAction;
 }
 public DataGridCellCollection(DataGridRow owningRow)
 {
     this._owningRow = owningRow;
     this._cells     = new List <DataGridCell>();
 }
 public System.Windows.FrameworkElement GetCellContent(DataGridRow dataGridRow)
 {
     return(default(System.Windows.FrameworkElement));
 }
        internal void RaiseAutomationInvokeEvents(DataGridEditingUnit editingUnit, DataGridColumn column, DataGridRow row)
        {
            switch (editingUnit)
            {
            case DataGridEditingUnit.Cell:
            {
                DataGridCell   cell = row.Cells[column.Index];
                AutomationPeer peer = FromElement(cell);
                if (peer != null)
                {
                    peer.InvalidatePeer();
                }
                else
                {
                    peer = CreatePeerForElement(cell);
                }

                if (peer != null)
                {
                    peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
                }
                break;
            }

            case DataGridEditingUnit.Row:
            {
                DataGridItemAutomationPeer peer = GetOrCreateItemPeer(row.DataContext);
                peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
                break;
            }
            }
        }
Example #40
0
 public DataGridRowDetailsEventArgs(DataGridRow row, FrameworkElement detailsElement)
 {
     Row            = row;
     DetailsElement = detailsElement;
 }
Example #41
0
        /// <summary>
        ///     Retrieves the visual tree that was generated for a particular row and column.
        /// </summary>
        /// <param name="dataGridRow">The row that corresponds to the desired cell.</param>
        /// <returns>The element if found, null otherwise.</returns>
        public FrameworkElement GetCellContent(DataGridRow dataGridRow)
        {
            if (dataGridRow == null)
            {
                throw new ArgumentNullException("dataGridRow");
            }

            if (_dataGridOwner != null)
            {
                int columnIndex = _dataGridOwner.Columns.IndexOf(this);
                if (columnIndex >= 0)
                {
                    DataGridCell cell = dataGridRow.TryGetCell(columnIndex);
                    if (cell != null)
                    {
                        return cell.Content as FrameworkElement;
                    }
                }
            }

            return null;
        }
 // This method is called from DataGrid.OnBeginningEdit/OnCommittingEdit/OnCancelingEdit
 // Raises Invoked event when row begin/cancel/commit edit
 internal void RaiseAutomationRowInvokeEvents(DataGridRow row)
 {
     DataGridItemAutomationPeer dataGridItemAutomationPeer = FindOrCreateItemAutomationPeer(row.Item) as DataGridItemAutomationPeer;
     if (dataGridItemAutomationPeer != null)
     {
         dataGridItemAutomationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
     }
 }
Example #43
0
 public DataGridRowEventArgs(DataGridRow row)
 {
 }
 // This method is called from DataGrid.OnBeginningEdit/OnCommittingEdit/OnCancelingEdit
 // Raises Invoked event when cell begin/cancel/commit edit
 internal void RaiseAutomationCellInvokeEvents(DataGridColumn column, DataGridRow row)
 {
     DataGridItemAutomationPeer dataGridItemAutomationPeer = FindOrCreateItemAutomationPeer(row.Item) as DataGridItemAutomationPeer;
     if (dataGridItemAutomationPeer != null)
     {
         DataGridCellItemAutomationPeer cellPeer = dataGridItemAutomationPeer.GetOrCreateCellItemPeer(column);
         if (cellPeer != null)
         {
             cellPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
         }
     }
 }
        protected override void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            lock (syncLock)
            {
                Dictionary<string, string> inputVariableList = GadgetOptions.InputVariableList;

                this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToProcessingState));
                this.Dispatcher.BeginInvoke(new SimpleCallback(ClearResults));

                SetGraphDelegate setGraph = new SetGraphDelegate(SetGraph);
                System.Collections.Generic.Dictionary<string, System.Data.DataTable> Freq_ListSet = new Dictionary<string, System.Data.DataTable>();

                string freqVar = string.Empty;
                string weightVar = string.Empty;
                string strataVar = string.Empty;
                bool includeMissing = false;
                int lagTime = 7;
                double deviations = 3;

                if (inputVariableList.ContainsKey("freqvar"))
                {
                    freqVar = inputVariableList["freqvar"];
                }

                if (inputVariableList.ContainsKey("weightvar"))
                {
                    weightVar = inputVariableList["weightvar"];
                }

                if (inputVariableList.ContainsKey("stratavar"))
                {
                    strataVar = inputVariableList["stratavar"];
                }

                if (inputVariableList.ContainsKey("lagtime"))
                {
                    int.TryParse(inputVariableList["lagtime"], out lagTime);
                }
                if (inputVariableList.ContainsKey("deviations"))
                {
                    double.TryParse(inputVariableList["deviations"], out deviations);
                }

                if (inputVariableList.ContainsKey("includemissing"))
                {
                    if (inputVariableList["includemissing"].Equals("true"))
                    {
                        includeMissing = true;
                    }
                }

                deviations = deviations - 0.001;

                List<string> stratas = new List<string>();
                if (!string.IsNullOrEmpty(strataVar))
                {
                    stratas.Add(strataVar);
                }

                try
                {
                    RequestUpdateStatusDelegate requestUpdateStatus = new RequestUpdateStatusDelegate(RequestUpdateStatusMessage);
                    CheckForCancellationDelegate checkForCancellation = new CheckForCancellationDelegate(IsCancelled);

                    GadgetOptions.GadgetStatusUpdate += new GadgetStatusUpdateHandler(requestUpdateStatus);
                    GadgetOptions.GadgetCheckForCancellation += new GadgetCheckForCancellationHandler(checkForCancellation);

                    if (this.DataFilters != null && this.DataFilters.Count > 0)
                    {
                        GadgetOptions.CustomFilter = this.DataFilters.GenerateDataFilterString(false);
                    }
                    else
                    {
                        GadgetOptions.CustomFilter = string.Empty;
                    }

                    Dictionary<DataTable, List<DescriptiveStatistics>> stratifiedFrequencyTables = dashboardHelper.GenerateFrequencyTable(GadgetOptions/*, freqVar, weightVar, stratas, string.Empty, useAllPossibleValues, sortHighLow, includeMissing*/);

                    if (stratifiedFrequencyTables == null || stratifiedFrequencyTables.Count == 0)
                    {
                        this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), DashboardSharedStrings.GADGET_MSG_NO_DATA);
                        this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                        return;
                    }
                    else if (worker.CancellationPending)
                    {
                        this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), SharedStrings.DASHBOARD_GADGET_STATUS_OPERATION_CANCELLED);
                        this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                        return;
                    }
                    else
                    {
                        string formatString = string.Empty;

                        foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                        {
                            AddFillerRows(tableKvp.Key);

                            if (tableKvp.Key.Rows.Count > 366)
                            {
                                string exMessage = string.Format(DashboardSharedStrings.ERROR_TOO_MANY_VALUES, freqVar, tableKvp.Key.Rows.Count, 366);
                                throw new ApplicationException(exMessage);
                            }

                            string strataValue = tableKvp.Key.TableName;

                            double count = 0;
                            foreach (DescriptiveStatistics ds in tableKvp.Value)
                            {
                                count = count + ds.observations;
                            }

                            if (count == 0 && stratifiedFrequencyTables.Count == 1)
                            {
                                // this is the only table and there are no records, so let the user know
                                this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), SharedStrings.NO_RECORDS_SELECTED);
                                this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                                return;
                            }
                            DataTable frequencies = tableKvp.Key;

                            if (frequencies.Rows.Count == 0)
                            {
                                continue;
                            }
                        }

                        foreach (KeyValuePair<DataTable, List<DescriptiveStatistics>> tableKvp in stratifiedFrequencyTables)
                        {
                            string strataValue = tableKvp.Key.TableName;

                            double count = 0;
                            foreach (DescriptiveStatistics ds in tableKvp.Value)
                            {
                                count = count + ds.observations;
                            }

                            if (count == 0)
                            {
                                continue;
                            }
                            DataTable frequencies = tableKvp.Key;

                            if (frequencies.Rows.Count == 0)
                            {
                                continue;
                            }

                            string tableHeading = tableKvp.Key.TableName;

                            if (stratifiedFrequencyTables.Count > 1)
                            {
                                tableHeading = freqVar;
                            }

                            double lastAvg = double.NegativeInfinity;
                            double lastStdDev = double.NegativeInfinity;
                            Queue<double> frame = new Queue<double>();
                            List<SimpleDataValue> actualValues = new List<SimpleDataValue>();
                            List<SimpleDataValue> trendValues = new List<SimpleDataValue>();
                            List<SimpleDataValue> aberrationValues = new List<SimpleDataValue>();
                            List<DataGridRow> aberrationDetails = new List<DataGridRow>();
                            int rowCount = 1;
                            foreach (System.Data.DataRow row in frequencies.Rows)
                            {
                                if (!row[freqVar].Equals(DBNull.Value) || (row[freqVar].Equals(DBNull.Value) && includeMissing == true))
                                {
                                    DateTime displayValue = DateTime.Parse(row[freqVar].ToString());

                                    frame.Enqueue((double)row["freq"]);
                                    SimpleDataValue actualValue = new SimpleDataValue();
                                    actualValue.IndependentValue = displayValue;
                                    actualValue.DependentValue = (double)row["freq"];
                                    actualValues.Add(actualValue);
                                    if (frame.Count > lagTime - 1 /*6*/)
                                    {
                                        double[] frameArray = frame.ToArray();
                                        double frameAvg = frameArray.Average();
                                        frame.Dequeue();
                                        double stdDev = CalculateStdDev(frameArray);
                                        if (lastAvg != double.NegativeInfinity)
                                        {
                                            SimpleDataValue trendValue = new SimpleDataValue();
                                            trendValue.IndependentValue = displayValue;
                                            trendValue.DependentValue = lastAvg;
                                            trendValues.Add(trendValue);
                                            if ((double)row["freq"] > lastAvg + (/*2.99*/deviations * lastStdDev))
                                            {
                                                SimpleDataValue aberrationValue = new SimpleDataValue();
                                                aberrationValue.IndependentValue = displayValue;
                                                aberrationValue.DependentValue = (double)row["freq"];
                                                aberrationValues.Add(aberrationValue);
                                                DataGridRow aberrationDetail = new DataGridRow()
                                                {
                                                    Date = displayValue,
                                                    Frequency = (double)row["freq"],
                                                    RunningAverage = lastAvg,
                                                    StandardDeviation = lastStdDev
                                                };
                                                aberrationDetails.Add(aberrationDetail);
                                            }
                                        }
                                        lastAvg = frameAvg;
                                        lastStdDev = stdDev;
                                    }

                                    rowCount++;
                                }
                            }

                            this.Dispatcher.BeginInvoke(setGraph, strataValue, actualValues, trendValues, aberrationValues, aberrationDetails);
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                    this.Dispatcher.BeginInvoke(new SimpleCallback(RenderFinish));
                    this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                }
                catch (Exception ex)
                {
                    this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), ex.Message);
                    this.Dispatcher.BeginInvoke(new SimpleCallback(SetGadgetToFinishedState));
                }
            }
        }
        public void Dev2DataGrid_SetFocusToInserted_ItemIsNotInserted_DoesNotInvokeFocusOnGridRowChild()
        {
            //------------Setup for test--------------------------      
            var element = new FrameworkElement();
            var dataGrid = new Dev2DataGrid(r => element) { ItemsSource = CreateModelItemCollection(3, false, false, false) };

            var dataGridRow = new DataGridRow();
            dataGridRow.DataContext = dataGrid.Items[1];    // Second item is not flagged as inserted

            //------------Execute Test---------------------------
            var result = dataGrid.SetFocusToInserted(dataGridRow);

            //------------Assert Results-------------------------
            Assert.IsFalse(result);
        }
 /// <summary>
 /// Sets the deselection enabled property. If enabled, and the row is clicked while selected, the row is deselected.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <param name="value">if set to <c>true</c> deselects the row when selected and clicked.</param>
 public static void SetIsDeselectionEnabled(DataGridRow dataGridRow, bool value)
 {
     dataGridRow.SetValue(IsDeselectionEnabledProperty, value);
 }
        public void Dev2DataGrid_GetFocusElement_RowIsNotNull_GetVisualChildResult()
        {
            //------------Setup for test--------------------------      
            var element = new FrameworkElement();
            var dataGrid = new Dev2DataGrid(r => element) { ItemsSource = CreateModelItemCollection(3, false, false, false) };
            var dataGridRow = new DataGridRow();

            //------------Execute Test---------------------------
            var result = dataGrid.GetFocusElement(dataGridRow);

            //------------Assert Results-------------------------
            Assert.AreSame(element, result);
        }
 /// <summary>
 /// Sets the command used to move another row below this one using drag and drop.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <param name="command">The command to move a row below this instance.</param>
 public static void SetMoveBelowCommand(DataGridRow dataGridRow, ICommand command)
 {
     dataGridRow.SetValue(MoveBelowCommandProperty, command);
 }
 /// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 /// <param name="column">The column of the cell that is about to enter edit mode.</param>
 /// <param name="row">The row container of the cell container that is about to enter edit mode.</param>
 /// <param name="editingEventArgs">The event arguments, if any, that led to the cell entering edit mode.</param>
 public DataGridBeginningEditEventArgs(DataGridColumn column, DataGridRow row, RoutedEventArgs editingEventArgs)
 {
     _dataGridColumn = column;
     _dataGridRow = row;
     _editingEventArgs = editingEventArgs;
 }
 /// <summary>
 /// Sets the drag format when this instance is being dragged above or below another row.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <param name="format">The drag format used when this instance is being dragged above or below another row.</param>
 public static void SetMoveDragFormat(DataGridRow dataGridRow, string format)
 {
     dataGridRow.SetValue(MoveDragFormatProperty, format);
 }
 private void FocusRow(DataGridRow row)
 {
     DataGridCell cell = row.FindDescendant<DataGridCell>();
     if (cell != null)
     {
         cell.Focus();
     }
 }
 /// <summary>
 /// Gets the is read only flag for the row.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <returns><c>true</c> if the row is read only, otherwise <c>false</c>.</returns>
 public static bool GetIsReadOnly(DataGridRow dataGridRow)
 {
     return (bool)dataGridRow.GetValue(IsReadOnlyProperty);
 }
 /// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 /// <param name="row">The row container of the cell container that is about to exit edit mode.</param>
 /// <param name="editingUnit">The editing unit that is about to leave edit mode.</param>
 public DataGridRowEditEndingEventArgs(DataGridRow row, DataGridEditAction editAction)
 {
     _dataGridRow = row;
     _editAction  = editAction;
 }
 /// <summary>
 /// Gets the content template when this instance is being dragged above or below another row.
 /// </summary>
 /// <param name="dataGridRow">The data grid row.</param>
 /// <returns>A data template used when this instance is being dragged above or below another row.</returns>
 public static DataTemplate GetMoveDragContentTemplate(DataGridRow dataGridRow)
 {
     return (DataTemplate)dataGridRow.GetValue(MoveDragContentTemplateProperty);
 }
 static void MessageBoxEvent(DataGridRow item)
 {
     item.Selected += delegate
     {
         MessageBox.Show("");
     };
 }
 // Token: 0x060046E2 RID: 18146 RVA: 0x00141975 File Offset: 0x0013FB75
 internal void ClearCell(DataGridRow ownerRow)
 {
     this._owner = null;
 }
Example #58
0
 /// <summary>
 /// Instantiates a new instance of this class.
 /// </summary>
 /// <param name="row">The row container of the cell container that has just exited edit mode.</param>
 /// <param name="editAction">The editing action that has been taken.</param>
 public DataGridRowEditEndedEventArgs(DataGridRow row, DataGridEditAction editAction)
 {
     this.Row        = row;
     this.EditAction = editAction;
 }
 /// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 /// <param name="column">The column of the cell that is about to enter edit mode.</param>
 /// <param name="row">The row container of the cell container that is about to enter edit mode.</param>
 /// <param name="editingEventArgs">The event arguments, if any, that led to the cell entering edit mode.</param>
 public DataGridBeginningEditEventArgs(DataGridColumn column, DataGridRow row, RoutedEventArgs editingEventArgs)
 {
     _dataGridColumn   = column;
     _dataGridRow      = row;
     _editingEventArgs = editingEventArgs;
 }
 internal InternalTestHook(DataGridRow row)
 {
     _row = row;
 }