Example #1
0
        /// <summary>
        /// Update group header totals
        /// </summary>
        private void GridExVillage_RowCheckStateChanged(object sender, RowCheckStateChangeEventArgs e)
        {
            GridEXRow groupToUpdate = e.Row;

            if (groupToUpdate == null)
            {
                // Column header checkbox click
                foreach (var row in GridExVillage.GetRows())
                {
                    UpdateGroupRecordText(row);
                }
                return;
            }

            if (e.Row.RowType == RowType.Record)
            {
                // Normal row
                groupToUpdate = e.Row.Parent;
            }

            if (groupToUpdate.RowType == RowType.GroupHeader)
            {
                if (groupToUpdate.Parent != null)
                {
                    UpdateGroupRecordText(groupToUpdate.Parent);
                }
                else
                {
                    UpdateGroupRecordText(groupToUpdate);
                }
            }
        }
Example #2
0
        /// <summary>
        /// The selected villages are exported to the clipboard
        /// </summary>
        private void ButtonGenerate_Click(object sender, System.EventArgs e)
        {
            if (GridExVillage.RowCount == 0)
            {
                MessageBox.Show(string.Format(ControlsRes.PolygonControl_EmptyGrid, LoadPolygonData.Text), ControlsRes.PolygonControl_StartHelpTitle);
                return;
            }

            var str = new StringBuilder();
            int villagesExported = 0;

            foreach (GridEXRow groupRow in GridExVillage.GetRows())
            {
                if (groupRow.RowType == RowType.GroupHeader)
                {
                    str.AppendLine();
                    str.AppendLine();
                    str.AppendLine(groupRow.GroupValue.ToString());
                    foreach (GridEXRow row in groupRow.GetChildRecords())
                    {
                        if (row.CheckState == RowCheckState.Checked)
                        {
                            villagesExported++;

                            var villageRow = (PolygonDataSet.VILLAGERow)((DataRowView)row.DataRow).Row;
                            if (!string.IsNullOrWhiteSpace(villageRow.Village.Type.GetDescription()))
                            {
                                str.AppendLine(villageRow.BBCODE + " (" + villageRow.Village.Type.GetDescription() + ")");
                            }
                            else
                            {
                                str.AppendLine(villageRow.BBCODE);
                            }
                        }
                    }
                }
            }

            if (WinForms.ToClipboard(str.ToString().Trim()))
            {
                MessageBox.Show(string.Format(ControlsRes.PolygonControl_ToClipboard, villagesExported), ControlsRes.PolygonControl_ToClipboardTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }