public DataItemAutomationFocusChangedEvent(ListItemProvider listItemProvider)
            : base(listItemProvider)
        {
            itemProvider = (DataGridProvider.DataGridDataItemProvider)listItemProvider;

            SWF.DataGridCell currentCell = itemProvider.DataGridProvider.DataGrid.CurrentCell;
            focused = currentCell.ColumnNumber == 0 && currentCell.RowNumber == itemProvider.Index;
        }
 public DataItemEditAutomationFocusChangedEvent(DataGridProvider.DataGridDataItemEditProvider listItemProvider)
     : base(listItemProvider)
 {
     itemProvider = listItemProvider;
     SWF.DataGridCell currentCell = itemProvider.ItemProvider.DataGridProvider.DataGrid.CurrentCell;
     focused = currentCell.ColumnNumber == itemProvider.ItemProvider.GetColumnIndexOf(itemProvider) &&
               currentCell.RowNumber == itemProvider.ItemProvider.Index;
 }
 private void OnCurrentCellChanged(object sender, EventArgs args)
 {
     SWF.DataGridCell currentCell = itemProvider.DataGridProvider.DataGrid.CurrentCell;
     if (currentCell.ColumnNumber == 0 && currentCell.RowNumber == itemProvider.Index)
     {
         RaiseAutomationPropertyChangedEvent();
     }
 }
 private void OnUIAGridCellChanged(object sender, CollectionChangeEventArgs args)
 {
     SWF.DataGridCell cell = (SWF.DataGridCell)args.Element;
     if (cell.ColumnNumber == 0 && cell.RowNumber == editProvider.Index)
     {
         RaiseAutomationPropertyChangedEvent();
     }
 }
 protected Brush ForeBrushForDataPaint(ref DataGridCell current, DataGridColumnStyle gridColumn, int column)
 {
     Brush brush = this.dgTable.IsDefault ? this.DataGrid.ForeBrush : this.dgTable.ForeBrush;
     if (this.Selected)
     {
         brush = this.dgTable.IsDefault ? this.DataGrid.SelectionForeBrush : this.dgTable.SelectionForeBrush;
     }
     return brush;
 }
 protected Brush BackBrushForDataPaint(ref DataGridCell current, DataGridColumnStyle gridColumn, int column)
 {
     Brush backBrush = this.GetBackBrush();
     if (this.Selected)
     {
         backBrush = this.dgTable.IsDefault ? this.DataGrid.SelectionBackBrush : this.dgTable.SelectionBackBrush;
     }
     return backBrush;
 }
Пример #7
0
		public DataGridDataSource (DataGrid owner, CurrencyManager list_manager, object data_source, string data_member, object view_data, DataGridCell current)
		{
			this.owner = owner;
			this.list_manager = list_manager;
			this.view = view_data;
			this.data_source = data_source;
			this.data_member = data_member;
			this.current = current;
		}
 private void OnFocusChangedEvent(object sender, EventArgs args)
 {
     SWF.DataGridCell currentCell = itemProvider.DataGridProvider.DataGrid.CurrentCell;
     if (currentCell.ColumnNumber == 0 && currentCell.RowNumber == itemProvider.Index)
     {
         if (focused)
         {
             RaiseAutomationEvent();
         }
         focused = !focused;
     }
 }
Пример #9
0
		public DataGridCellTests ()
		{
			DataGridCell dg = new DataGridCell ();
			Console.WriteLine ("DataGridCell default --- ");
			Console.WriteLine ("Column {0}", dg.RowNumber);
			Console.WriteLine ("Row {0}", dg.ColumnNumber);

			dg.RowNumber = 10;
			dg.ColumnNumber = 5;

			Console.WriteLine ("ToString {0}", dg.ToString ());
			Console.WriteLine ("GetHashCode {0}", dg.GetHashCode ());
		}
Пример #10
0
		public void TestDefaultValues ()
		{
			DataGridCell cell = new DataGridCell (5, 10);

			Assert.AreEqual (5, cell.RowNumber, "A1 RowNumber");
			Assert.AreEqual (10, cell.ColumnNumber, "A2 ColumnNumber");

			cell.ColumnNumber = 20;
			cell.RowNumber = 30;

			Assert.AreEqual (30, cell.RowNumber, "A3 RowNumber");
			Assert.AreEqual (20, cell.ColumnNumber, "A4 ColumnNumber");
		}
Пример #11
0
        private void duIzbrisi_Click(object sender, System.EventArgs e)
        {
            //Ako data set dsInstruktori nije prazan
            if (this.dsPolaganja1.Polaganja.Rows.Count > 0)
            {
                //Odabir trenutno oznacene celije
                DataGridCell selectedCell = dgPolaganja.CurrentCell;
                //Odabir podataka iz trenutne celije na poziciji kolona 1 i 2
                object o1 = dgPolaganja[selectedCell.RowNumber, 2];
                object o2 = dgPolaganja[selectedCell.RowNumber, 3];
                object o3 = dgPolaganja[selectedCell.RowNumber, 5];

                //Konvertovanje objekata o1 i o2 u stringove
                string Ime     = Convert.ToString(o1);
                string Prezime = Convert.ToString(o2);
                string Pokusaj = Convert.ToString(o3);

                //Prikaz dijalog boksa sa pitanjem, ako je rezultat opcija Yes
                //Onda izbriši odabrani zapis
                if (MessageBox.Show("Da li ste sigurni da želite izbrisati podatke o polaganju za kandidata: \nIme: " + Ime + " \nPrezime: " + Prezime + " \nPokusaj: " + Pokusaj + "", "Upozorenje !", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    System.Windows.Forms.DataGridCell celija = this.dgPolaganja.CurrentCell;
                    object B0          = this.dgPolaganja[celija.RowNumber, 0];
                    string PolaganjeID = Convert.ToString(B0);

                    try
                    {
                        //this.connPolaganja.Open();
                        SqlCommand kom = new SqlCommand("DELETE FROM Polaganja WHERE PolaganjeID = " + PolaganjeID + "", clsKonekcija.GetConnection());
                        kom.ExecuteNonQuery();
                        //this.connPolaganja.Close();

                        this.dsPolaganja1.Clear();
                        this.daPolaganja.Fill(this.dsPolaganja1);
                    }
                    catch (SqlException ex)
                    {
                        string iz = ex.Message.ToString();
                        MessageBox.Show("Došlo je do greške!", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
            }
            else
            {
                MessageBox.Show("Oznacili ste prazno polje.", "Upozorenje !", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Пример #12
0
        private void duIzbrisi_Click(object sender, System.EventArgs e)
        {
            //Ako data set dsInstruktori nije prazan
            if (this.dsKategorije1.Kategorije.Rows.Count > 0)
            {
                //Odabir trenutno oznacene celije
                DataGridCell selectedCell = dgKategorije.CurrentCell;
                //Odabir podataka iz trenutne celije na poziciji kolona 1 i 2
                object o1 = dgKategorije[selectedCell.RowNumber, 0];
                object o2 = dgKategorije[selectedCell.RowNumber, 1];

                //Konvertovanje objekata o1 i o2 u stringove
                string KategorijaID = Convert.ToString(o1);
                string Kategorija   = Convert.ToString(o2);

                //Prikaz dijalog boksa sa pitanjem, ako je rezultat opcija Yes
                //Onda izbriši odabrani zapis
                if (MessageBox.Show("Da li ste sigurni da želite izbrisati podatke o kategoriji: \nKategorija ID: " + KategorijaID + " \nKategorija: " + Kategorija + "", "Upozorenje !", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    System.Windows.Forms.DataGridCell celija = this.dgKategorije.CurrentCell;
                    object B0    = this.dgKategorije[celija.RowNumber, 0];
                    string KatID = Convert.ToString(B0);

                    try
                    {
                        this.connKategorije.Open();
                        SqlCommand kom = new SqlCommand("DELETE FROM Kategorije WHERE KategorijaID = " + KatID + "", this.connKategorije);
                        kom.ExecuteNonQuery();
                        this.connKategorije.Close();

                        this.dsKategorije1.Clear();
                        this.daKategorije.Fill(this.dsKategorije1);
                    }
                    catch (SqlException ex)
                    {
                        string iz = ex.Message.ToString();
                        MessageBox.Show("Došlo je do greške!", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
            }
            else
            {
                MessageBox.Show("Oznacili ste prazno polje.", "Upozorenje !", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Пример #13
0
        private void duIzbrisi_Click(object sender, System.EventArgs e)
        {
            //Ako data set dsKategorije1 nije prazan
            if (this.dsKategorije1.Kategorije.Rows.Count > 0)
            {
                //Odabir trenutno oznacene celije
                DataGridCell selectedCell = dgKategorijeInst.CurrentCell;
                //Odabir podataka iz trenutne celije na poziciji kolone 2
                object o1 = dgKategorijeInst[selectedCell.RowNumber, 2];

                //Konvertovanje objekta o1
                string Kategorija = Convert.ToString(o1);
                string Ime        = this.tbIme.Text.ToString();
                string Prezime    = this.tbPrezime.Text.ToString();

                //Prikaz dijalog boksa sa pitanjem, ako je rezultat opcija Yes
                //Onda izbriši odabrani zapis
                if (MessageBox.Show("Da li ste sigurni da želite izbrisati kategoriju: " + Kategorija + " \nZa instruktora: " + Ime + " " + Prezime + "", "Upozorenje !", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    System.Windows.Forms.DataGridCell celija = this.dgKategorijeInst.CurrentCell;
                    object B0        = this.dgKategorijeInst[celija.RowNumber, 0];
                    string KatInstID = Convert.ToString(B0);

                    try
                    {
                        SqlCommand kom = new SqlCommand("DELETE FROM KategorijeInstruktori WHERE KatInstID = " + KatInstID + "", clsKonekcija.GetConnection());
                        kom.ExecuteNonQuery();

                        ucitajKategorije();
                    }
                    catch (SqlException ex)
                    {
                        string iz = ex.Message.ToString();
                        MessageBox.Show("Došlo je do greške!", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
            }
            else
            {
                MessageBox.Show("Polje kategorija je prazno!", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Пример #14
0
        private void duIzbrisi_Click(object sender, System.EventArgs e)
        {
            if (this.dsVozila1.Vozila.Rows.Count > 0)
            {
                DataGridCell selectedCell = dgVozila.CurrentCell;
                object       o1           = dgVozila[selectedCell.RowNumber, 1];
                object       o2           = dgVozila[selectedCell.RowNumber, 2];
                string       Proizvodjac  = Convert.ToString(o1);
                string       Model        = Convert.ToString(o2);

                if (MessageBox.Show("Da li ste sigurni da želite izbrisati podatke o vozilu: \nProizvodjac: " + Proizvodjac + " \nModel: " + Model + "", "Upozorenje !", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    System.Windows.Forms.DataGridCell celija = this.dgVozila.CurrentCell;
                    object B0       = this.dgVozila[celija.RowNumber, 0];
                    string VoziloID = Convert.ToString(B0);

                    try
                    {
                        //this.connVozila.Open();
                        SqlCommand kom = new SqlCommand("DELETE FROM Vozila WHERE VoziloID = " + VoziloID + "", clsKonekcija.GetConnection());
                        kom.ExecuteNonQuery();
                        //this.connVozila.Close();

                        this.dsVozila1.Clear();
                        this.daVozila.Fill(this.dsVozila1);
                    }
                    catch (SqlException ex)
                    {
                        string iz = ex.Message.ToString();
                        MessageBox.Show("Došlo je do greške!", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
            }
            else
            {
                MessageBox.Show("Oznacili ste prazno polje.", "Upozorenje !", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Пример #15
0
 public object GetItemPropertyValue(ListItemProvider item,
                                    int propertyId)
 {
     if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id)
     {
         int index = item.Index;
         // We need to union last column and first column
         SD.Rectangle rect0 = datagrid.GetCellBounds(index, 0);
         SD.Rectangle rectN = datagrid.GetCellBounds(index, header.ChildrenCount);
         return(Helper.GetControlScreenBounds(SD.Rectangle.Union(rect0, rectN), datagrid));
     }
     else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id)
     {
         Rect bounds
             = (Rect)GetPropertyValue(AutomationElementIdentifiers.BoundingRectangleProperty.Id);
         return(Helper.IsOffScreen(bounds, datagrid, true));
     }
     else if (propertyId == AutomationElementIdentifiers.ClickablePointProperty.Id)
     {
         return(Helper.GetClickablePoint(this));
     }
     else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id)
     {
         return(true);
     }
     else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
     {
         SWF.DataGridCell currentCell = datagrid.CurrentCell;
         return(currentCell.ColumnNumber == 0 && currentCell.RowNumber == item.Index &&
                datagrid.Focused);
     }
     else
     {
         return(null);
     }
 }
Пример #16
0
		private bool FindInTable(DataView table, string searchString, bool lowerCase,
			DataGridCell startCell, DataGridCell endCell, bool wrap, out DataGridCell foundCell)
		{
			foundCell = new DataGridCell(-1, -1);
			if(table == null) return false;
			if(startCell.RowNumber < 0) startCell.RowNumber = 0;
			if(startCell.ColumnNumber < 0) startCell.ColumnNumber = 0;
			for(int searchRow = startCell.RowNumber; searchRow < table.Count; searchRow++)
			{
				if(this.stopSearch) break;
				if(endCell.RowNumber > startCell.RowNumber && searchRow > endCell.RowNumber) break;

				DataRowView tableRow = table[searchRow];
				for(int searchCol = (searchRow == startCell.RowNumber
					? startCell.ColumnNumber : 0); searchCol < table.Table.Columns.Count; searchCol++)
				{
					if(this.stopSearch) break;
					if(endCell.RowNumber > startCell.RowNumber && searchRow == endCell.RowNumber
						&& searchCol >= endCell.ColumnNumber) break;

					string value = tableRow[searchCol].ToString();
					if(lowerCase) value = value.ToLowerInvariant();
					if(value.IndexOf(searchString, StringComparison.Ordinal) >= 0)
					{
						foundCell.RowNumber = searchRow;
						foundCell.ColumnNumber = searchCol;
						return true;
					}
				}
			}
			if(wrap)
			{
				for(int searchRow = 0; searchRow <= endCell.RowNumber; searchRow++)
				{
					if(this.stopSearch) break;
					DataRowView tableRow = table[searchRow];
					for(int searchCol = 0; searchCol < (searchRow == endCell.RowNumber
						? endCell.ColumnNumber : table.Table.Columns.Count); searchCol++)
					{
						if(this.stopSearch) break;
						string value = tableRow[searchCol].ToString();
						if(lowerCase) value = value.ToLowerInvariant();
						if(value.IndexOf(searchString, StringComparison.Ordinal) >= 0)
						{
							foundCell.RowNumber = searchRow;
							foundCell.ColumnNumber = searchCol;
							return true;
						}
					}
				}
			}
			return false;
		}
        /// <summary>
        /// 执行转码
        /// </summary>
        /// <param name="fileName"></param>
        private List<DataGridCell> decodeAndReadPlist(string fileName)
        {
            PListRoot plist = PListRoot.Load(fileName);
            PListDict dic = (PListDict)plist.Root;

            List<DataGridCell> result = new List<DataGridCell>();
            DataGridCell cell = new DataGridCell();

            if (dic.ContainsKey("CFBundleExecutable"))
            {
                PListString name = (PListString)dic["CFBundleIdentifier"];
                cell.bundleID = name.Value;
            }

            if (dic.ContainsKey("CFBundleExecutable"))
            {
                PListString name = (PListString)dic["CFBundleExecutable"];
                cell.executeName = name.Value;
            }

            string schemes = "";
            if (dic.ContainsKey("CFBundleURLTypes"))
            {
                PListArray array = (PListArray)dic["CFBundleURLTypes"];
                foreach (Dictionary<string, IPListElement> url in array)
                {
                    if (url.ContainsKey("CFBundleURLSchemes"))
                    {
                        array = (PListArray)url["CFBundleURLSchemes"];
                        foreach (PListString scheme in array)
                        {
                            schemes = schemes + scheme + "; ";
                        }
                    }
                }
            }
            cell.scheme = schemes;
            result.Add(cell);

            return result;
        }
Пример #18
0
        public virtual int PaintData(Graphics g,
                                     Rectangle bounds,
                                     int firstVisibleColumn,
                                     int columnCount,
                                     bool alignToRight)
        {
            Debug.WriteLineIf(CompModSwitches.DGRowPaint.TraceVerbose, "Painting DataGridAddNewRow: bounds = " + bounds.ToString());

            Rectangle cellBounds = bounds;
            int       bWidth     = this.dgTable.IsDefault ? this.DataGrid.GridLineWidth : this.dgTable.GridLineWidth;
            int       cx         = 0;

            DataGridCell current = this.dgTable.DataGrid.CurrentCell;

            GridColumnStylesCollection columns = dgTable.GridColumnStyles;
            int nCols = columns.Count;

            for (int col = firstVisibleColumn; col < nCols; ++col)
            {
                if (cx > bounds.Width)
                {
                    break;
                }

                // if (!columns[col].Visible || columns[col].PropertyDescriptor == null)
                if (columns[col].PropertyDescriptor == null || columns[col].Width <= 0)
                {
                    continue;
                }

                cellBounds.Width = columns[col].Width - bWidth;

                if (alignToRight)
                {
                    cellBounds.X = bounds.Right - cx - cellBounds.Width;
                }
                else
                {
                    cellBounds.X = bounds.X + cx;
                }

                // Paint the data with the the DataGridColumn
                Brush backBr    = BackBrushForDataPaint(ref current, columns[col], col);
                Brush foreBrush = ForeBrushForDataPaint(ref current, columns[col], col);

                PaintCellContents(g,
                                  cellBounds,
                                  columns[col],
                                  backBr,
                                  foreBrush,
                                  alignToRight);

                // Paint the border to the right of each cell
                if (bWidth > 0)
                {
                    g.FillRectangle(this.dgTable.IsDefault ? this.DataGrid.GridLineBrush : this.dgTable.GridLineBrush,
                                    alignToRight ? cellBounds.X - bWidth : cellBounds.Right,
                                    cellBounds.Y,
                                    bWidth,
                                    cellBounds.Height);
                }
                cx += cellBounds.Width + bWidth;
            }

            // Paint any exposed area to the right ( or left ) of the data cell area
            if (cx < bounds.Width)
            {
                g.FillRectangle(this.dgTable.DataGrid.BackgroundBrush,
                                alignToRight ? bounds.X : bounds.X + cx,
                                bounds.Y,
                                bounds.Width - cx,
                                bounds.Height);
            }
            return(cx);
        }
Пример #19
0
        /// <include file='doc\DataGridRow.uex' path='docs/doc[@for="DataGridRow.BackBrushForDataPaint"]/*' />
        /// <devdoc>
        ///      Returns the BackColor and TextColor  that the Graphics object should use
        ///      for the appropriate values for a given row and column when painting the data.
        ///
        /// </devdoc>
        protected Brush BackBrushForDataPaint(ref DataGridCell current, DataGridColumnStyle gridColumn, int column) {
            Brush backBr = this.GetBackBrush();

            if (Selected) {
                backBr = this.dgTable.IsDefault ? this.DataGrid.SelectionBackBrush : this.dgTable.SelectionBackBrush;
            }            
            /*
            if (RowNumber == current.RowNumber && column == current.ColumnNumber) {
                backBr = grid.CurrentCellBackBrush;
            }
            */
            return backBr;
        }
Пример #20
0
		private void EnsureCellVisibility (DataGridCell cell)
		{
			if (cell.ColumnNumber <= first_visible_column ||
				cell.ColumnNumber + 1 >= first_visible_column + visible_column_count) {

				first_visible_column = GetFirstColumnForColumnVisibility (first_visible_column, cell.ColumnNumber);
				int pixel = GetColumnStartingPixel (first_visible_column);
				ScrollToColumnInPixels (pixel);
				horiz_scrollbar.Value = pixel;
				Update();
			}

			if (cell.RowNumber < first_visible_row ||
			    cell.RowNumber + 1 >= first_visible_row + visible_row_count) {

				if (cell.RowNumber + 1 >= first_visible_row + visible_row_count) {
					int old_first_visible_row = first_visible_row;
					first_visible_row = 1 + cell.RowNumber - visible_row_count;
					UpdateVisibleRowCount ();
					ScrollToRow (old_first_visible_row, first_visible_row);
				} else {
					int old_first_visible_row = first_visible_row;
					first_visible_row = cell.RowNumber;
					UpdateVisibleRowCount ();
					ScrollToRow (old_first_visible_row, first_visible_row);
				}

				vert_scrollbar.Value = first_visible_row;
			}
		}
Пример #21
0
		protected override void OnMouseDown (MouseEventArgs e)
		{
			base.OnMouseDown (e);

			bool ctrl_pressed = ((Control.ModifierKeys & Keys.Control) != 0);
			bool shift_pressed = ((Control.ModifierKeys & Keys.Shift) != 0);

			HitTestInfo testinfo;
			testinfo = HitTest (e.X, e.Y);

			switch (testinfo.Type) {
			case HitTestType.Cell:
				if (testinfo.Row < 0 || testinfo.Column < 0)
					break;

				if (rows[testinfo.Row].IsExpanded) {
					Rectangle relation_area = rows[testinfo.Row].relation_area;
					relation_area.Y = rows[testinfo.Row].VerticalOffset + cells_area.Y + rows[testinfo.Row].Height - rows[testinfo.Row].RelationHeight;
					if (relation_area.Contains (e.X, e.Y)) {
						/* the click happened in the relation area, navigate to the new table */
						int relative = e.Y - relation_area.Y;
						NavigateTo (testinfo.Row, CurrentTableStyle.Relations[relative / LinkFont.Height]);
						return;
					}
				}

				DataGridCell new_cell = new DataGridCell (testinfo.Row, testinfo.Column);

				if ((new_cell.Equals (current_cell) == false) || (!is_editing)) {
					ResetSelection ();
					CurrentCell = new_cell;
					Edit ();
				} else {
					CurrentTableStyle.GridColumnStyles[testinfo.Column].OnMouseDown (e, testinfo.Row, testinfo.Column);
				}

				break;

			case HitTestType.RowHeader:
				bool expansion_click = false;
				if (CurrentTableStyle.HasRelations) {
					if (e.X > row_headers_area.X + row_headers_area.Width / 2) {
						/* it's in the +/- space */
						if (IsExpanded (testinfo.Row))
							Collapse (testinfo.Row);
						else
							Expand (testinfo.Row);

						expansion_click = true;
					}
				}

				CancelEditing ();
				CurrentRow = testinfo.Row;

				if (!ctrl_pressed && !shift_pressed && !expansion_click) {
					ResetSelection (); // Invalidates selected rows
				}

				if ((shift_pressed || expansion_click) && selection_start != -1) {
					ShiftSelection (testinfo.Row);
				} else { // ctrl_pressed or single item
					selection_start = testinfo.Row;
					Select (testinfo.Row);
				}

				OnRowHeaderClick (EventArgs.Empty);

				break;

			case HitTestType.ColumnHeader:
				if (CurrentTableStyle.GridColumnStyles.Count == 0)
					break;

				if (AllowSorting == false)
					break;

				if (ListManager.List is IBindingList == false)
					break;

				// Don't do any sort if we are empty, as .net does
				if (ListManager.Count == 0)
					return;
			
				ListSortDirection direction = ListSortDirection.Ascending;
				PropertyDescriptor prop = CurrentTableStyle.GridColumnStyles[testinfo.Column].PropertyDescriptor;
				IBindingList list = (IBindingList) ListManager.List;

				if (list.SortProperty != null) {
					CurrentTableStyle.GridColumnStyles[list.SortProperty].ArrowDrawingMode 
						= DataGridColumnStyle.ArrowDrawing.No;
				}

				if (prop == list.SortProperty && list.SortDirection == ListSortDirection.Ascending) {
					direction = ListSortDirection.Descending;
				}
				
				CurrentTableStyle.GridColumnStyles[testinfo.Column].ArrowDrawingMode =
					direction == ListSortDirection.Ascending ? 
					DataGridColumnStyle.ArrowDrawing.Ascending : DataGridColumnStyle.ArrowDrawing.Descending;
				
				list.ApplySort (prop, direction);
				Refresh ();
				if (this.is_editing)
					//CurrentTableStyle.GridColumnStyles[CurrentColumn].UpdateUI ();
					this.InvalidateColumn (CurrentTableStyle.GridColumnStyles[CurrentColumn]);

				break;

			case HitTestType.ColumnResize:
				if (e.Clicks == 2) {
					EndEdit ();
					ColumnResize (testinfo.Column);
				} else {
					resize_column = testinfo.Column;
					column_resize_active = true;
					resize_column_x = e.X;
					resize_column_width_delta = 0;
					EndEdit ();
					DrawResizeLineVert (resize_column_x);
				}
				break;

			case HitTestType.RowResize:
				if (e.Clicks == 2) {
					EndEdit ();
					RowResize (testinfo.Row);
				} else {
					resize_row = testinfo.Row;
					row_resize_active = true;
					resize_row_y = e.Y;
					resize_row_height_delta = 0;
					EndEdit ();
					DrawResizeLineHoriz (resize_row_y);
				}
				break;

			case HitTestType.Caption:
				if (back_button_rect.Contains (e.X, e.Y)) {
					back_button_active = true;
					Invalidate (back_button_rect);
				}
				if (parent_rows_button_rect.Contains (e.X, e.Y)) {
					parent_rows_button_active = true;
					Invalidate (parent_rows_button_rect);
				}
				break;

			default:
				break;
			}
		}
Пример #22
0
		private void FindNext(object start)
		{
			string nodePath = (string) ((object[]) start)[0];
			DataGridCell startCell = (DataGridCell) ((object[]) start)[1];
            TreeNode searchNode = (TreeNode) ((object[]) start)[2];
			DataGridCell endCell = startCell;

			string searchString = this.findTextBox.Text;
			if(searchString.Length == 0) return;

			bool ignoreCase = true; // TODO: make this a configurable option?
			if(ignoreCase) searchString = searchString.ToLowerInvariant();
		
			if(!this.searchTreeCheckBox.Checked)
			{
				DataGridCell foundCell;
				startCell.ColumnNumber++;
				if(FindInTable((DataView) this.data[nodePath], searchString, ignoreCase,
					startCell, startCell, true, out foundCell))
				{
					#if SINGLETHREAD
					this.EndFind(new object[] { nodePath, foundCell });
					#else
					this.Invoke(new WaitCallback(this.EndFind), new object[] { new object[] { nodePath, foundCell } });
					#endif
					return;
				}
			}
			else
			{
				if(this.continueSearchRoot != null)
				{
					searchNode = this.FindNode(this.continueSearchRoot);
					startCell = this.continueSearchCell;
					endCell = this.continueSearchEndCell;
				}
				else
				{
					this.continueSearchRoot = searchNode.FullPath;
					this.continueSearchPath = this.continueSearchRoot;
					this.continueSearchEndCell = endCell;
				}
				//if(searchNode == null) return;
				ArrayList nodesList = new ArrayList();
				nodesList.Add(searchNode);
				this.GetFlatTreeNodes(searchNode.Nodes, nodesList, true, this.continueSearchRoot);
				TreeNode[] nodes = (TreeNode[]) nodesList.ToArray(typeof(TreeNode));
				int startNode = nodesList.IndexOf(this.FindNode(this.continueSearchPath));
				DataGridCell foundCell;
				startCell.ColumnNumber++;
				for(int i = startNode; i < nodes.Length; i++)
				{
					if(this.stopSearch) break;
					DataGridCell startCellOnThisNode = zeroCell;
					if(i == startNode) startCellOnThisNode = startCell;
					DataView table = this.GetTableForSearch(nodes[i].FullPath);
					if(table != null)
					{
						if(FindInTable(table, searchString, ignoreCase, startCellOnThisNode, zeroCell, false, out foundCell))
						{
							#if SINGLETHREAD
							this.EndFind(new object[] { nodes[i].FullPath, foundCell });
							#else
							this.Invoke(new WaitCallback(this.EndFind), new object[] { new object[] { nodes[i].FullPath, foundCell } });
							#endif
							return;
						}
					}
				}
				if(!this.stopSearch)
				{
					DataView table = this.GetTableForSearch(searchNode.FullPath);
					if(table != null)
					{
						if(FindInTable(table, searchString, ignoreCase, zeroCell, endCell, false, out foundCell))
						{
							#if SINGLETHREAD
							this.EndFind(new object[] { searchNode.FullPath, foundCell });
							#else
							this.Invoke(new WaitCallback(this.EndFind), new object[] { new object[] { searchNode.FullPath, foundCell } });
							#endif
							return;
						}
					}
				}
			}
			#if SINGLETHREAD
			this.EndFind(null);
			#else
			this.Invoke(new WaitCallback(this.EndFind), new object[] { null });
			#endif
		}
Пример #23
0
 /// <summary>
 /// Uruchamia formatke do edytowania wpisu historii.
 /// </summary>
 public void edytujWpis(bool aEdytuj, DataGridCell aWybranaKomorka)
 {
     //MessageBox.Show("To be implemented..");
     model.edytujWpis(aEdytuj, aWybranaKomorka);
 }
Пример #24
0
		public bool BeginEdit (DataGridColumnStyle gridColumn, int rowNumber)
		{
			if (is_changing)
				return false;

			int column = CurrentTableStyle.GridColumnStyles.IndexOf (gridColumn);
			if (column < 0)
				return false;

			CurrentCell = new DataGridCell (rowNumber, column);

			/* force editing of CurrentCell if we aren't already editing */
			Edit ();

			return true;
		}
Пример #25
0
 public Rectangle GetCellBounds(DataGridCell dgc)
 {
     throw new NotImplementedException("GetCellBounds");
 }
Пример #26
0
		public Rectangle GetCellBounds(DataGridCell dgc)
		{
			throw new NotImplementedException("GetCellBounds");
		}
Пример #27
0
		public System.Object this[DataGridCell cell] 
		{
 			get
			{
				throw new NotImplementedException("Item");
			}

 			set
			{
				throw new NotImplementedException("Item");
			}

 		}
Пример #28
0
        protected Brush ForeBrushForDataPaint(ref DataGridCell current, DataGridColumnStyle gridColumn, int column) {
            // Brush foreBrush = gridColumn.ForeBrush;
            Brush foreBrush = this.dgTable.IsDefault ? this.DataGrid.ForeBrush : this.dgTable.ForeBrush;

            if (Selected) {
                foreBrush = this.dgTable.IsDefault ? this.DataGrid.SelectionForeBrush : this.dgTable.SelectionForeBrush;
            }
            /*
            if (RowNumber == current.RowNumber && column == current.ColumnNumber) {
                foreColor = grid.CurrentCellForeColor;
            }
            */
            return foreBrush;
        }
Пример #29
0
		private void EndFind(object result)
		{
			lock(syncRoot)
			{
				this.searching = false;
				this.refreshButton.Enabled = true;
				this.findStopButton.Visible = false;
				this.searchTreeCheckBox.Visible = true;
				this.findTextBox.Enabled = true;
				this.findButton.Text = "Find";
				this.findButton.Enabled = true;
				this.dataGrid.CaptionBackColor = SystemColors.ActiveCaption;
				this.dataGrid.CaptionForeColor = SystemColors.ActiveCaptionText;
				this.dataGrid.CaptionText = this.CurrentNodePath;
				if(result != null)
				{
					string nodePath = (string) ((object[]) result)[0];
					DataGridCell foundCell = (DataGridCell) ((object[]) result)[1];
					this.GoTo(nodePath, foundCell);
					this.dataGrid.Focus();
					this.continueSearchPath = nodePath;
					this.continueSearchCell = foundCell;
					if(this.searchTreeCheckBox.Checked) this.searchTreeCheckBox.Text = "Continue";
				}
				else
				{
					this.continueSearchRoot = null;
					this.continueSearchPath = null;
					this.searchTreeCheckBox.Text = "In Subtree";
				}
				this.SetCursor();
			}
		}
Пример #30
0
		private void GoTo(string nodePath, DataGridCell cell)
		{
			lock(syncRoot)
			{
				if(this.tablesLoading == null) return;  // The tree is being loaded
				if(this.navigating) return;  // This method is already on the callstack

				DataView table = (DataView) this.data[nodePath];
				if(table != null && table == this.dataGrid.DataSource)
				{
					// Grid is already in view
					if(!cell.Equals(anyCell)) this.dataGrid.CurrentCell = cell;
					return;
				}
				if(cell.Equals(anyCell)) cell = zeroCell;

				if(this.historyBack.Count == 0 || nodePath != (string) this.historyBack.Peek())
				{
					this.historyBack.Push(nodePath);
					if(this.cellHistoryBack.Count > 0 && this.historyForward != null)
					{
						this.cellHistoryBack.Pop();
						this.cellHistoryBack.Push(this.dataGrid.CurrentCell);
					}
					this.cellHistoryBack.Push(cell);
				}
				if(this.historyForward != null)
				{
					this.historyForward.Clear();
					this.cellHistoryForward.Clear();
				}

				if(table != null || nodePath.Length == 0 || this.dataProviderMap[nodePath] == null)
				{
					this.dataGrid.CaptionText = nodePath;
					this.dataGrid.CaptionBackColor = SystemColors.ActiveCaption;
					this.dataGrid.CaptionForeColor = SystemColors.ActiveCaptionText;
					this.dataGrid.DataSource = table;
					this.dataGrid.CurrentCell = cell;
					this.dataGrid.Focus();
				}
				else
				{
					this.dataGrid.CaptionText = nodePath + " (loading...)";
					this.dataGrid.CaptionBackColor = SystemColors.InactiveCaption;
					this.dataGrid.CaptionForeColor = SystemColors.InactiveCaptionText;
					this.dataGrid.DataSource = table;
					if(!this.tablesLoading.Contains(nodePath))
					{
						this.tablesLoading.Add(nodePath);
						this.SetCursor();
						#if SINGLETHREAD
						this.LoadTable(nodePath);
						#else
						new WaitCallback(this.LoadTable).BeginInvoke(nodePath, null, null);
						#endif
					}
				}

				this.findButton.Enabled = this.findTextBox.Text.Length > 0 && !searching;

				TreeNode treeNode = this.FindNode(nodePath);
				if(treeNode != this.treeView.SelectedNode)
				{
					this.navigating = true;
					this.treeView.SelectedNode = treeNode;
					this.navigating = false;
				}
			}
		}
Пример #31
0
		private void OnListManagerPositionChanged (object sender, EventArgs e)
		{
			// Set the field directly, as we are empty now and using CurrentRow
			// directly would add a new row in this case.
			if (list_manager.Count == 0) {
				current_cell = new DataGridCell (0, 0);
				return;
			}

			from_positionchanged_handler = true;
			CurrentRow = list_manager.Position;
			from_positionchanged_handler = false;
		}
Пример #32
0
		public Rectangle GetCellBounds (DataGridCell dgc)
		{
			return GetCellBounds (dgc.RowNumber, dgc.ColumnNumber);
		}
Пример #33
0
		public object this [DataGridCell cell] {
			get { return this [cell.RowNumber, cell.ColumnNumber]; }
			set { this [cell.RowNumber, cell.ColumnNumber] = value; }
		}
Пример #34
0
		protected bool ProcessGridKey (KeyEventArgs ke)
		{
			bool ctrl_pressed = ((ke.Modifiers & Keys.Control) != 0);
			//bool alt_pressed = ((ke.Modifiers & Keys.Alt) != 0);
			bool shift_pressed = ((ke.Modifiers & Keys.Shift) != 0);

			switch (ke.KeyCode) {
			case Keys.Escape:
				if (is_changing)
					AbortEditing ();
				else {
					CancelEditing ();

					if (cursor_in_add_row && CurrentRow > 0)
						CurrentRow--;
				}

				Edit ();
				return true;
				
			case Keys.D0:
				if (ctrl_pressed) {
					if (is_editing)
						CurrentTableStyle.GridColumnStyles[CurrentColumn].EnterNullValue ();
					return true;
				}
				return false;

			case Keys.Enter:
				if (is_changing)
					CurrentRow ++;
				return true;

			case Keys.Tab:
				if (shift_pressed) {
					if (CurrentColumn > 0)
						CurrentColumn --;
					else if ((CurrentRow > 0) && (CurrentColumn == 0))
						CurrentCell = new DataGridCell (CurrentRow - 1, CurrentTableStyle.GridColumnStyles.Count - 1);
				} else {
					if (CurrentColumn < CurrentTableStyle.GridColumnStyles.Count - 1)
						CurrentColumn ++;
					else if ((CurrentRow <= RowsCount) && (CurrentColumn == CurrentTableStyle.GridColumnStyles.Count - 1))
						CurrentCell = new DataGridCell (CurrentRow + 1, 0);
				}

				UpdateSelectionAfterCursorMove (false);

				return true;

			case Keys.Right:
				if (ctrl_pressed) {
					CurrentColumn = CurrentTableStyle.GridColumnStyles.Count - 1;
				} else {
					if (CurrentColumn < CurrentTableStyle.GridColumnStyles.Count - 1) {
						CurrentColumn ++;
					} else if (CurrentRow < RowsCount - 1
						   || (CurrentRow == RowsCount - 1
						       && !cursor_in_add_row)) {
						CurrentCell = new DataGridCell (CurrentRow + 1, 0);
					}
				}

				UpdateSelectionAfterCursorMove (false);

				return true;

			case Keys.Left:
				if (ctrl_pressed) {
					CurrentColumn = 0;
				} else {
					if (current_cell.ColumnNumber > 0)
						CurrentColumn --;
					else if (CurrentRow > 0)
						CurrentCell = new DataGridCell (CurrentRow - 1, CurrentTableStyle.GridColumnStyles.Count - 1);
				}

				UpdateSelectionAfterCursorMove (false);

				return true;

			case Keys.Up:
				if (ctrl_pressed)
					CurrentRow = 0;
				else if (CurrentRow > 0)
					CurrentRow --;

				UpdateSelectionAfterCursorMove (shift_pressed);

				return true;

			case Keys.Down:
				if (ctrl_pressed)
					CurrentRow = RowsCount - 1;
				else if (CurrentRow < RowsCount - 1)
					CurrentRow ++;
				else if (CurrentRow == RowsCount - 1 && cursor_in_add_row && (add_row_changed || is_changing))
					CurrentRow ++;
				else if (CurrentRow == RowsCount - 1 && !cursor_in_add_row && !shift_pressed)
					CurrentRow ++;

				UpdateSelectionAfterCursorMove (shift_pressed);

				return true;

			case Keys.PageUp:
				if (CurrentRow > VLargeChange)
					CurrentRow -= VLargeChange;
				else
					CurrentRow = 0;

				UpdateSelectionAfterCursorMove (shift_pressed);

				return true;

			case Keys.PageDown:
				if (CurrentRow < RowsCount - VLargeChange)
					CurrentRow += VLargeChange;
				else
					CurrentRow = RowsCount - 1;

				UpdateSelectionAfterCursorMove (shift_pressed);

				return true;

			case Keys.Home:
				if (ctrl_pressed)
					CurrentCell = new DataGridCell (0, 0);
				else
					CurrentColumn = 0;

				UpdateSelectionAfterCursorMove (ctrl_pressed && shift_pressed);

				return true;

			case Keys.End:
				if (ctrl_pressed)
					CurrentCell = new DataGridCell (RowsCount - 1, CurrentTableStyle.GridColumnStyles.Count - 1);
				else
					CurrentColumn = CurrentTableStyle.GridColumnStyles.Count - 1;

				UpdateSelectionAfterCursorMove (ctrl_pressed && shift_pressed);

				return true;

			case Keys.Delete:
				if (is_editing)
					return false;
				else if (selected_rows.Keys.Count > 0) {
					// the removal of the items in the source will cause to
					// reset the selection, so we need a copy of it.
					int [] rows = new int [selected_rows.Keys.Count];
					selected_rows.Keys.CopyTo (rows, 0);

					// reverse order to keep index sanity
					int edit_row_index = ShowEditRow ? RowsCount : -1; // new cell is +1
					for (int i = rows.Length - 1; i >= 0; i--)
						if (rows [i] != edit_row_index)
							ListManager.RemoveAt (rows [i]);

					CalcAreasAndInvalidate ();
				}

				return true;
			}

			return false; // message not processed
		}
Пример #35
0
 protected void InEditMode(int columnCount)
 {
     this.editCell = this.dgList.CurrentCell;
     this.tbQty.Text = Convert.ToDecimal(this.dgList[this.editCell.RowNumber, columnCount - 2].ToString()).ToString("0.########");
     Rectangle cellPos = this.dgList.GetCellBounds(this.editCell.RowNumber, columnCount - 2);
     this.tbQty.Left = cellPos.Left - 1;
     this.tbQty.Top = cellPos.Top + dgList.Top - 1;
     this.tbQty.Width = cellPos.Width + 2;
     this.tbQty.Height = cellPos.Height + 2;
     this.tbQty.Visible = true;
     this.inEditMode = true;
     this.tbQty.Focus();
     this.tbQty.SelectAll();
 }
Пример #36
0
		private void SetDataSource (object source, string member, bool recreate_rows)
		{
			CurrencyManager old_lm = list_manager;

			/* we need this bool flag to work around a
			 * problem with OnBindingContextChanged.  once
			 * that stuff works properly, remove this
			 * hack */
			if (in_setdatasource)
				return;
			in_setdatasource = true;

#if false
			if (datasource == source && member == datamember)
				return;
#endif

			if (source != null && source as IListSource != null && source as IList != null)
				throw new Exception ("Wrong complex data binding source");

			datasource = source;
			datamember = member;

			if (is_editing)
				CancelEditing ();

			current_cell = new DataGridCell ();

			if (list_manager != null)
				DisconnectListManagerEvents ();

			list_manager = null;

			/* create the new list manager */
			if (BindingContext != null && datasource != null)
				list_manager = (CurrencyManager) BindingContext [datasource, datamember];

			if (list_manager != null)
				ConnectListManagerEvents ();

			if (old_lm != list_manager) {
				BindColumns ();

				/* reset first_visible_row to 0 here before
				 * doing anything that'll requires us to
				 * figure out if we need a scrollbar. */
				vert_scrollbar.Value = 0;
				horiz_scrollbar.Value = 0;
				first_visible_row = 0;

				if (recreate_rows)
					RecreateDataGridRows (false);
			}

			CalcAreasAndInvalidate ();

			in_setdatasource = false;

			OnDataSourceChanged (EventArgs.Empty);
		}
 protected override void OnMouseDown(MouseEventArgs e)
 {
     HitTestInfo info;
     base.OnMouseDown(e);
     this.gridState[0x80000] = false;
     this.gridState[0x100] = false;
     if (this.listManager != null)
     {
         info = this.HitTest(e.X, e.Y);
         Keys modifierKeys = Control.ModifierKeys;
         bool flag = ((modifierKeys & Keys.Control) == Keys.Control) && ((modifierKeys & Keys.Alt) == Keys.None);
         bool flag2 = (modifierKeys & Keys.Shift) == Keys.Shift;
         if (e.Button != MouseButtons.Left)
         {
             return;
         }
         if (info.type == HitTestType.ColumnResize)
         {
             if (e.Clicks > 1)
             {
                 this.ColAutoResize(info.col);
                 return;
             }
             this.ColResizeBegin(e, info.col);
             return;
         }
         if (info.type == HitTestType.RowResize)
         {
             if (e.Clicks > 1)
             {
                 this.RowAutoResize(info.row);
                 return;
             }
             this.RowResizeBegin(e, info.row);
             return;
         }
         if (info.type == HitTestType.ColumnHeader)
         {
             this.trackColumnHeader = this.myGridTable.GridColumnStyles[info.col].PropertyDescriptor;
             return;
         }
         if (info.type == HitTestType.Caption)
         {
             Rectangle caption = this.layout.Caption;
             this.caption.MouseDown(e.X - caption.X, e.Y - caption.Y);
             return;
         }
         if (this.layout.Data.Contains(e.X, e.Y) || this.layout.RowHeaders.Contains(e.X, e.Y))
         {
             int rowFromY = this.GetRowFromY(e.Y);
             if (rowFromY > -1)
             {
                 Point point = this.NormalizeToRow(e.X, e.Y, rowFromY);
                 if (this.DataGridRows[rowFromY].OnMouseDown(point.X, point.Y, this.layout.RowHeaders, this.isRightToLeft()))
                 {
                     this.CommitEdit();
                     DataGridRow[] rowArray = this.DataGridRows;
                     if (((rowFromY < this.DataGridRowsLength) && (rowArray[rowFromY] is DataGridRelationshipRow)) && ((DataGridRelationshipRow) rowArray[rowFromY]).Expanded)
                     {
                         this.EnsureVisible(rowFromY, 0);
                     }
                     this.Edit();
                     return;
                 }
             }
         }
         if (info.type != HitTestType.RowHeader)
         {
             if (info.type == HitTestType.ParentRows)
             {
                 this.EndEdit();
                 this.parentRows.OnMouseDown(e.X, e.Y, this.isRightToLeft());
             }
             if ((info.type == HitTestType.Cell) && !this.myGridTable.GridColumnStyles[info.col].MouseDown(info.row, e.X, e.Y))
             {
                 DataGridCell cell = new DataGridCell(info.row, info.col);
                 if (this.policy.AllowEdit && this.CurrentCell.Equals(cell))
                 {
                     this.ResetSelection();
                     this.EnsureVisible(this.currentRow, this.currentCol);
                     this.Edit();
                 }
                 else
                 {
                     this.ResetSelection();
                     this.CurrentCell = cell;
                 }
             }
             return;
         }
         this.EndEdit();
         if (!(this.DataGridRows[info.row] is DataGridAddNewRow))
         {
             int currentRow = this.currentRow;
             this.CurrentCell = new DataGridCell(info.row, this.currentCol);
             if (((info.row != currentRow) && (this.currentRow != info.row)) && (this.currentRow == currentRow))
             {
                 return;
             }
         }
         if (flag)
         {
             if (this.IsSelected(info.row))
             {
                 this.UnSelect(info.row);
             }
             else
             {
                 this.Select(info.row);
             }
             goto Label_035E;
         }
         if ((this.lastRowSelected == -1) || !flag2)
         {
             this.ResetSelection();
             this.Select(info.row);
             goto Label_035E;
         }
         int num3 = Math.Min(this.lastRowSelected, info.row);
         int num4 = Math.Max(this.lastRowSelected, info.row);
         int lastRowSelected = this.lastRowSelected;
         this.ResetSelection();
         this.lastRowSelected = lastRowSelected;
         DataGridRow[] dataGridRows = this.DataGridRows;
         for (int i = num3; i <= num4; i++)
         {
             dataGridRows[i].Selected = true;
             this.numSelectedRows++;
         }
         this.EndEdit();
     }
     return;
 Label_035E:
     this.lastRowSelected = info.row;
 }
Пример #38
0
		public DataGrid ()
		{
			allow_navigation = true;
			background_color = def_background_color;
			border_style = BorderStyle.Fixed3D;
			caption_backcolor = def_caption_backcolor;
			caption_forecolor = def_caption_forecolor;
			caption_text = string.Empty;
			caption_visible = true;
			datamember = string.Empty;
			parent_rows_backcolor = def_parent_rows_backcolor;
			parent_rows_forecolor = def_parent_rows_forecolor;
			parent_rows_visible = true;
			current_cell = new DataGridCell ();
			parent_rows_label_style = DataGridParentRowsLabelStyle.Both;
			selected_rows = new Hashtable ();
			selection_start = -1;
			rows = new DataGridRelationshipRow [0];

			grid_style_stack = new Stack ();
			data_grid_table_style_stack = new Stack ();
			default_style = new DataGridTableStyle (true);
			grid_style = new DataGridTableStyle ();

			styles_collection = new GridTableStylesCollection (this);
			styles_collection.CollectionChanged += new CollectionChangeEventHandler (OnTableStylesCollectionChanged);

			CurrentTableStyle = grid_style;

			horiz_scrollbar = new ImplicitHScrollBar ();
			horiz_scrollbar.Scroll += new ScrollEventHandler (GridHScrolled);
			vert_scrollbar = new ImplicitVScrollBar ();
			vert_scrollbar.Scroll += new ScrollEventHandler (GridVScrolled);

			SetStyle (ControlStyles.UserMouse, true);

			data_source_stack = new Stack ();

			back_button_image = ResourceImageLoader.Get ("go-previous.png");
			back_button_image.MakeTransparent (Color.Transparent);
			parent_rows_button_image = ResourceImageLoader.Get ("go-top.png");
			parent_rows_button_image.MakeTransparent (Color.Transparent);
		}
        private void ColumnDateTimePicker_ValueChanged(object sender , EventArgs e)
        {
            if(ColumnDateTimePicker.CustomFormat != " ")
            {
                DataGridCell objCell = new DataGridCell(_rowNum,_col);
                this.DataGridTableStyle.DataGrid.CurrentCell = objCell;
                this.TextBox.Text = ColumnDateTimePicker.Value.ToString(ColumnDateTimePicker.CustomFormat);
                if(TextChangedDTP != null)
                {
                    TextChangedDTP(this,null);
                }
                _source.Position = _rowNum;
                if(ColumnDateTimePicker.Value != DateTime.MinValue)
                    SetColumnValueAtRow(_source,_rowNum, ColumnDateTimePicker.Value.ToString(ColumnDateTimePicker.CustomFormat));
                else
                    SetColumnValueAtRow(_source,_rowNum, DBNull.Value);

                _isEditing = false;
                Invalidate();
                ColumnDateTimePicker.Hide();
            }
        }
Пример #40
0
 private void PackingsGrid_CurrentCellChanged(object sender, EventArgs e)
 {
     if (this.PackingsGrid.CurrentCell.ColumnNumber < 3)
     {
         this.PackingsGrid.ReadOnly = true;
     }
     else
     {
         this.PackingsGrid.ReadOnly = false;
     }
     try
     {
         if ((this.clLastCell.ColumnNumber == 6) || (this.clLastCell.ColumnNumber == 7))
         {
             foreach (DataRow row in this.dtPackings.Rows)
             {
                 row[this.clLastCell.ColumnNumber] = this.PackingsGrid[this.clLastCell];
             }
         }
         this.clLastCell = this.PackingsGrid.CurrentCell;
         this.dtPackings.AcceptChanges();
     }
     catch (Exception exception)
     {
         BusinessLogic.MyMessageBox(exception.Message);
         BusinessLogic.MyMessageBox("Please Enter valid data!");
     }
 }
Пример #41
0
 public void edytujWpis(bool aEdytuj, DataGridCell aWybranaKomorka)
 {
     Console.WriteLine ("wk = {0}", aWybranaKomorka);
     //historia.Tables[TAB_DNI].Columns[aWybranaKomorka.ColumnNumber].ReadOnly = aEdytuj;
     Console.WriteLine ("Model edytuj wpis");
 }
Пример #42
0
        /// <summary>
        /// When moving the mouse over other "loaded" check box while keeping the left mouse button pressed,
        /// change the "loaded" state to the new state when the left mouse button was pressed.
        /// </summary>
        /// <param name="e"></param>
        public void DataGrid_MouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            Dvtk.Sessions.Session theSession = GetSessionTreeViewManager().GetSelectedSession();

            if (e.Button == MouseButtons.Left)
            {
                System.Windows.Forms.DataGrid.HitTestInfo theHitTestInfo;

                theHitTestInfo = _DataGridSopClasses.HitTest(e.X, e.Y);

                switch (theHitTestInfo.Type)
                {
                    case System.Windows.Forms.DataGrid.HitTestType.Cell:
                        // If this is the "loaded" column...
                        if (theHitTestInfo.Column == 0)
                        {
                            // If another "loaded" check box is pointed to, not the one where the state has
                            // last been changed...
                            if (theHitTestInfo.Row != _MouseEventInfoForDataGrid_LoadedStateChangedForRow)
                            {
                                DefinitionFile theDefinitionFile = (DefinitionFile)_DefinitionFilesInfoForDataGrid[theHitTestInfo.Row];
                                bool theCurrentLoadedState = theDefinitionFile.Loaded;

                                // Only if the state will change...
                                if (theCurrentLoadedState != _MouseEventInfoForDataGrid_LoadedStatedAfterMouseDown)
                                {
                                    // Get the column style for the "loaded" column.
                                    DataGridColumnStyle theDataGridColumnStyle;
                                    theDataGridColumnStyle = _DataGridSopClasses.TableStyles[0].GridColumnStyles[0];

                                    // Change the "loaded" stated in _DefinitionFilesInfoForDataGrid and the data grid itself.
                                    _DataGridSopClasses.BeginEdit(theDataGridColumnStyle, theHitTestInfo.Row);
                                    theDefinitionFile.Loaded = _MouseEventInfoForDataGrid_LoadedStatedAfterMouseDown;
                                    _DataGridSopClasses.EndEdit (theDataGridColumnStyle, theHitTestInfo.Row, false);

                                    // Change the "loaded" state in the session object.
                                    string theFullFileName = System.IO.Path.Combine(theDefinitionFile.DefinitionRoot, theDefinitionFile.Filename);

                                    if (_MouseEventInfoForDataGrid_LoadedStatedAfterMouseDown)
                                    {
                                        // The definition file was not loaded yet. Load it now.
                                        theSession.DefinitionManagement.LoadDefinitionFile(theFullFileName);
                                    }
                                    else
                                    {
                                        // The definition file was loaded. Unload it now.
                                        theSession.DefinitionManagement.UnLoadDefinitionFile(theFullFileName);
                                    }

                                    // Remember the cell we've changed. We don't want to change the loaded
                                    // state with each minor mouse move.
                                    _MouseEventInfoForDataGrid_LoadedStateChangedForRow = theHitTestInfo.Row;

                                    // Notify the rest of the world.
                                    SessionChange theSessionChange = new SessionChange(theSession, SessionChange.SessionChangeSubTypEnum.SOP_CLASSES_LOADED_STATE);
                                    Notify(theSessionChange);
                                }
                                else
                                    // State will not change. The cell under the mouse will not be selected. This
                                    // results in scrolling that will not work when the mouse is moved to the bottom
                                    // of the datagrid.
                                    //
                                    // To solve this, explicitly make the cell under the mouse selected.
                                {
                                    DataGridCell currentSelectedCell = _DataGridSopClasses.CurrentCell;
                                    DataGridCell newSelectedCell = new DataGridCell(theHitTestInfo.Row, currentSelectedCell.ColumnNumber);

                                    _DataGridSopClasses.CurrentCell = newSelectedCell;
                                }
                            }
                        }
                        break;
                }
            }
        }
Пример #43
0
 public Rectangle GetCellBounds(DataGridCell dgc)
 {
     throw null;
 }