/// <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); }
private string GetIndexpasien(DataGridRow row) { DataRowView v = (DataRowView)dgTerapi.Items[row.GetIndex()]; return (string)v[0].ToString(); }
private void _buildRowHeader(DataGridRow row) { if (this._owner != null) { if ((this.HeadersVisibility & DataGridHeadersVisibility.Row) == DataGridHeadersVisibility.Row) { var rowIndex = row.GetIndex(); Int64 startRow = 0; if (this._owner.PageSize > 0) startRow = (this._owner.PageCurrent - 1) * this._owner.PageSize; var maxRownum = "" + (startRow + ((this._owner.PageSize > 0) ? this._owner.PageSize : this._owner.DS.Count())); var maxRownumLen = maxRownum.Length; var numFmt = new String('0', maxRownumLen); // ReSharper disable FormatStringProblem var rnum = String.Format("{0:" + numFmt + "} ", startRow + rowIndex + 1); // ReSharper restore FormatStringProblem if (!this._owner.SuppressMultiselection && this._owner.Multiselection) { var v_hpan = new StackPanel(); v_hpan.HorizontalAlignment = HorizontalAlignment.Right; v_hpan.Orientation = Orientation.Horizontal; v_hpan.FlowDirection = FlowDirection.LeftToRight; var v_htxt = new TextBlock(); v_htxt.Text = rnum; v_hpan.Children.Add(v_htxt); var rowData = (CRTObject)row.DataContext; var v_hcbx = new CheckBox(); var v_is_selected = this._owner.Selection.CheckSelected(rowData); if (this._owner.Selection.Inversion) v_hcbx.IsChecked = !v_is_selected; else v_hcbx.IsChecked = v_is_selected; v_hpan.Children.Add(v_hcbx); v_hcbx.Checked += (s1, e1) => this._doOnRowCheckedChanged(rowData, true); v_hcbx.Unchecked += (s1, e1) => this._doOnRowCheckedChanged(rowData, false); rowData.ExtObject = v_hcbx; row.Header = v_hpan; } else row.Header = rnum; //} } } }
private string GetIndexObat(DataGridRow row) { DataRowView v = (DataRowView)dgObat.Items[row.GetIndex()]; return (string)v[0].ToString(); }
private void dataGrid_MouseRightClick(object sender, MouseButtonEventArgs e) { WPFdataGrid.DataGridControl wPFdataGrid = elementHost1.Child as WPFdataGrid.DataGridControl; var dataGridView = wPFdataGrid.grid; DependencyObject Hit = (DependencyObject)e.OriginalSource; while (Hit == null || !(Hit is Control.DataGridRow)) { Hit = VisualTreeHelper.GetParent(Hit); } Control.DataGridRow dataRow = Hit as Control.DataGridRow; var detailGrids = FindVisualChildren <Control.DataGrid>(dataGridView); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(dataRow.Item); Pokemon = new Pokemon(); string PName = properties["PName"].GetValue(dataRow.Item)?.ToString(); Int16 HP = 0; Int16 Attack = 0; Int16 Defense = 0; Int16 SPAttack = 0; Int16 SPDefense = 0; Int16 Speed = 0; string Type1 = null; string Type2 = null; if (properties["HP"] != null && properties["Attack"] != null && properties["Defense"] != null && properties["SPAttack"] != null && properties["SPDefense"] != null && properties["Speed"] != null) { Int16.TryParse(properties["HP"].GetValue(dataRow.Item).ToString(), out HP); Int16.TryParse(properties["Attack"].GetValue(dataRow.Item).ToString(), out Attack); Int16.TryParse(properties["Defense"].GetValue(dataRow.Item).ToString(), out Defense); Int16.TryParse(properties["SPAttack"].GetValue(dataRow.Item).ToString(), out SPAttack); Int16.TryParse(properties["SPDefense"].GetValue(dataRow.Item).ToString(), out SPDefense); Int16.TryParse(properties["Speed"].GetValue(dataRow.Item).ToString(), out Speed); Type1 = properties["Type1"].GetValue(dataRow.Item)?.ToString(); Type2 = properties["Type2"].GetValue(dataRow.Item)?.ToString(); } else { using (Pokemon db = new Pokemon()) { HP = db.PokemonBaseStats.Where(p => p.PName == PName).Single().HP; Attack = db.PokemonBaseStats.Where(p => p.PName == PName).Single().Attack; Defense = db.PokemonBaseStats.Where(p => p.PName == PName).Single().Defense; SPAttack = db.PokemonBaseStats.Where(p => p.PName == PName).Single().SPAttack; SPDefense = db.PokemonBaseStats.Where(p => p.PName == PName).Single().SPDefense; Speed = db.PokemonBaseStats.Where(p => p.PName == PName).Single().Speed; } } Int16 CapRate = 0; Int16 ExpDrop = 0; if (detailGrids.Count() > 0 && pokemonCapRates.Count > 0 && dataRow.DetailsVisibility == Visibility.Visible) { foreach (var detailGrid in detailGrids.Where(g => g.Items.CurrentItem.GetType().GetProperty("PName").GetValue(g.Items.CurrentItem).ToString() == dataRow.Item.GetType().GetProperty("PName").GetValue(dataRow.Item).ToString())) { PropertyDescriptorCollection detailProperties = TypeDescriptor.GetProperties(detailGrid.Items.CurrentItem); Int16.TryParse(detailProperties["CapRate"].GetValue(detailGrid.Items.CurrentItem).ToString(), out CapRate); Int16.TryParse(detailProperties["ExpDrop"].GetValue(detailGrid.Items.CurrentItem).ToString(), out ExpDrop); } } else { using (Pokemon db = new Pokemon()) { if (pokemonCapRates.Count > 0) { try { CapRate = pokemonCapRates.Where(p => p.PName == PName).Single().CapRate; ExpDrop = pokemonCapRates.Where(p => p.PName == PName).Single().ExpDrop; } catch { CapRate = db.PokemonBaseStats.Where(p => p.PName == PName).Single().PokemonCapRate.CapRate; ExpDrop = db.PokemonBaseStats.Where(p => p.PName == PName).Single().PokemonCapRate.ExpDrop; } } else { try { CapRate = db.PokemonBaseStats.Where(p => p.PName == PName).Single().PokemonCapRate.CapRate; ExpDrop = db.PokemonBaseStats.Where(p => p.PName == PName).Single().PokemonCapRate.ExpDrop; } catch { CapRate = 0; ExpDrop = 0; } } } } if (dataRow.GetIndex() <= dataGridView.Items.Count - 2 && pokemon != null) { PokemonBaseStat monster; try { monster = (from p in Pokemon.PokemonBaseStats where p.PName == PName select p).First(); } catch { monster = null; } if (monster == null) { contextMenuStrip.Items[0].Visible = true; contextMenuStrip.Items[1].Visible = false; contextMenuStrip.Items[2].Visible = false; contextMenuStrip.Show(System.Windows.Forms.Cursor.Position); } } if (dataRow.GetIndex() <= dataGridView.Items.Count - 2 && pokemon != null && Control.Validation.GetHasError(dataRow) == false) { if (properties["HP"] != null && properties["Attack"] != null && properties["Defense"] != null && properties["SPAttack"] != null && properties["SPDefense"] != null && properties["Speed"] != null) { PokemonBaseStat monster; try { monster = (from p in Pokemon.PokemonBaseStats where p.PName == PName select p).Single(); } catch { monster = null; return; } if (monster.PName == pokemon.PName && (monster.HP != pokemon.HP || monster.Attack != pokemon.Attack || monster.Defense != pokemon.Defense || monster.SPAttack != pokemon.SPAttack || monster.SPDefense != pokemon.SPDefense || monster.Speed != pokemon.Speed || monster.Type1 != pokemon.Type1 || monster.Type2 != pokemon.Type2 || monster.PokemonCapRate.CapRate != pokemon.PokemonCapRate.CapRate || monster.PokemonCapRate.ExpDrop != pokemon.PokemonCapRate.ExpDrop)) { contextMenuStrip.Items[0].Visible = false; contextMenuStrip.Items[1].Visible = true; contextMenuStrip.Items[2].Visible = false; contextMenuStrip.Show(System.Windows.Forms.Cursor.Position); } } } if (dataRow.GetIndex() <= dataGridView.Items.Count - 2 && Control.Validation.GetHasError(dataRow) == false) { var monster = (from p in Pokemon.PokemonBaseStats where p.PName == PName select p).First(); pokemon = new PokemonBaseStat() { PName = properties["PName"].GetValue(dataRow.Item).ToString(), HP = HP, Attack = Attack, Defense = Defense, SPAttack = SPAttack, SPDefense = SPDefense, Speed = Speed, Type1 = Type1, Type2 = Type2, PokemonCapRate = new PokemonCapRate() { PName = properties["PName"].GetValue(dataRow.Item).ToString(), CapRate = CapRate, ExpDrop = ExpDrop } }; if (Type1 == "") { Type1 = null; } if (Type2 == "") { Type2 = null; } if (monster.PName == PName && monster.HP == HP && monster.Attack == Attack && monster.Defense == Defense && monster.SPAttack == SPAttack && monster.SPDefense == SPDefense && monster.Speed == Speed && monster.Type1 == pokemon.Type1 && monster.Type2 == pokemon.Type2 && monster.PokemonCapRate.CapRate == CapRate && monster.PokemonCapRate.ExpDrop == ExpDrop) { contextMenuStrip.Items[0].Visible = false; contextMenuStrip.Items[1].Visible = false; contextMenuStrip.Items[2].Visible = true; contextMenuStrip.Show(System.Windows.Forms.Cursor.Position); } } }
/// <summary> /// Updates the specified row. /// </summary> /// <param name="row">DataGridRow</param> private void UpdateRow(DataGridRow row) { BugTraceObject loadingItem = (BugTraceObject)row.DataContext; BugTraceObject selectedItem = null; string selectedHeader = null; if (this.BugTraceView.CurrentCell != null && this.BugTraceView.CurrentCell.Item is BugTraceObject) { selectedItem = (BugTraceObject)this.BugTraceView.CurrentCell.Item; selectedHeader = (string)this.BugTraceView.CurrentCell.Column.Header; } if (this.SearchTextBox.Text.Length > 0 && this.SearchQueryCache.ContainsKey(this.SearchTextBox.Text)) { int rowId = row.GetIndex(); if (this.SearchQueryCache[this.SearchTextBox.Text].Contains(rowId)) { this.RestoreRow(row); } else { this.FadeRow(row); } } else if (selectedItem != null && selectedHeader != null && ((selectedHeader.Equals("Type") && !loadingItem.Type.Equals(selectedItem.Type)) || (selectedHeader.Equals("Machine") && !loadingItem.Machine.Equals(selectedItem.Machine)) || (selectedHeader.Equals("State") && !loadingItem.MachineState.Equals(selectedItem.MachineState)) || (selectedHeader.Equals("Action") && !loadingItem.Action.Equals(selectedItem.Action)) || (selectedHeader.Equals("Target Machine") && !loadingItem.TargetMachine.Equals(selectedItem.TargetMachine)))) { if (this.IsTraceViewCollapsed) { this.CollapseRow(row); } else { this.FadeRow(row); } } else { this.RestoreRow(row); } }
private void _buildRowHeader(DataGridRow row) { if (this._owner != null) { if ((this.HeadersVisibility & DataGridHeadersVisibility.Row) == DataGridHeadersVisibility.Row) { //if (row.Header == null) { Int32 v_row_index = row.GetIndex(); Int64 v_start_row = 0; if (this._owner._jsClient.pageSize > 0) v_start_row = (this._owner._jsClient.pageCurrent - 1) * this._owner._jsClient.pageSize; String v_max_rownum = "" + (v_start_row + ((this._owner._jsClient.pageSize > 0) ? this._owner._jsClient.pageSize : this._owner._jsClient.DS.Count())); var v_max_rownum_len = v_max_rownum.Length; String v_num_fmt = new String('0', v_max_rownum_len); String v_rnum = String.Format("{0:" + v_num_fmt + "} ", v_start_row + v_row_index + 1); if (this._owner._jsClient.jsMetadata.multiselection) { var v_hpan = new StackPanel(); v_hpan.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; v_hpan.Orientation = Orientation.Horizontal; v_hpan.FlowDirection = System.Windows.FlowDirection.LeftToRight; var v_htxt = new TextBlock(); v_htxt.Text = v_rnum; v_hpan.Children.Add(v_htxt); var v_row_data = row.DataContext as CRTObject; var v_hcbx = new CheckBox(); var v_is_selected = this._owner._multiselection.CheckSelected(v_row_data); if (this._owner._multiselection.Inversion) v_hcbx.IsChecked = !v_is_selected; else v_hcbx.IsChecked = v_is_selected; v_hpan.Children.Add(v_hcbx); v_hcbx.Checked += new RoutedEventHandler((s1, e1) => { this._doOnRowCheckedChanged(v_row_data, true); }); v_hcbx.Unchecked += new RoutedEventHandler((s1, e1) => { this._doOnRowCheckedChanged(v_row_data, false); }); v_row_data.ExtObject = v_hcbx; row.Header = v_hpan; } else row.Header = v_rnum; //} } } }
//@Bahar : Ambil ID Karyawan dari DataGrid yang diselect private string GetIndexKaryawan(DataGridRow row) { DataRowView v = (DataRowView)dgUsers.Items[row.GetIndex()]; return (string)v[0].ToString(); }