In this Controller are defined all the events fired by the Controller. Each event has a sender object of type CellContext that you can use to read the cell informations.
Inheritance: IController
        private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, Cells.Editors.EditorBase p_Editor, object p_Object)
        {
            grid[p_GridRow, p_GridCol]        = new Cells.Cell(p_PropInfo.GetValue(p_Object, null));
            grid[p_GridRow, p_GridCol].Editor = p_Editor;

            Cells.Controllers.BindProperty l_Bind = new Cells.Controllers.BindProperty(p_PropInfo, p_Object);
            grid[p_GridRow, p_GridCol].AddController(l_Bind);

            Cells.Controllers.CustomEvents l_CustomEvents = new Cells.Controllers.CustomEvents();
            l_CustomEvents.ValueChanged += new EventHandler(Grid_ValueChanged);
            grid[p_GridRow, p_GridCol].AddController(l_CustomEvents);
        }
		public void No_ValueChanging_Event_If_Value_Does_Not_Change()
		{
			CustomEvents events = new CustomEvents();
			events.ValueChanging += delegate(object sender, ValueChangeEventArgs e)
			{
				Assert.Fail("We did not change value, no event expected");
			};
			
			Grid grid = new Grid();
			grid.Redim(1, 1);
			grid[0, 0] = new SourceGrid.Cells.Cell(1, typeof(int));
			grid[0, 0].AddController(events);
			
			CellContext context = new CellContext(grid, new Position(0, 0));
			// assert that we have already 1 inside this cell
			Assert.AreEqual(1, context.Value);
			// change the value of the cell to the same value
			// this should not fire ValueChanged event handler
			context.Cell.Editor.SetCellValue(context, 1);
		}
示例#3
0
    private void CreateGrid()
    {
      IrssLog.Info("Creating configuration grid ...");

      try
      {
        int row = 0;

        gridPlugins.Rows.Clear();
        gridPlugins.Columns.SetCount(5);

        // Setup Column Headers
        gridPlugins.Rows.Insert(row);

        ColumnHeader header = new ColumnHeader(" ");
        header.AutomaticSortEnabled = false;
        gridPlugins[row, ColIcon] = header;

        gridPlugins[row, ColName] = new ColumnHeader("Name");
        gridPlugins[row, ColReceive] = new ColumnHeader("Receive");
        gridPlugins[row, ColTransmit] = new ColumnHeader("Transmit");
        gridPlugins[row, ColConfigure] = new ColumnHeader("Configure");
        gridPlugins.FixedRows = 1;

        foreach (PluginBase transceiver in _transceivers)
        {
          gridPlugins.Rows.Insert(++row);
          gridPlugins.Rows[row].Tag = transceiver;

          // Icon Cell
          if (transceiver.DeviceIcon != null)
          {
            Image iconCell = new Image(transceiver.DeviceIcon);
            iconCell.Editor.EnableEdit = false;

            gridPlugins[row, ColIcon] = iconCell;
          }
          else
          {
            gridPlugins[row, ColIcon] = new Cell();
          }

          // Name Cell
          Cell nameCell = new Cell(transceiver.Name);

          CustomEvents nameCellController = new CustomEvents();
          nameCellController.DoubleClick += PluginDoubleClick;
          nameCell.AddController(nameCellController);

          nameCell.AddController(new ToolTipText());
          nameCell.ToolTipText = String.Format("{0}\nVersion: {1}\nAuthor: {2}\n{3}", transceiver.Name,
                                               transceiver.Version, transceiver.Author, transceiver.Description);

          gridPlugins[row, ColName] = nameCell;

          // Receive Cell
          if (transceiver is IRemoteReceiver || transceiver is IMouseReceiver || transceiver is IKeyboardReceiver)
          {
            gridPlugins[row, ColReceive] = new CheckBox();
          }
          else
          {
            gridPlugins[row, ColReceive] = new Cell();
          }

          // Transmit Cell
          if (transceiver is ITransmitIR)
          {
            CheckBox checkbox = new CheckBox();

            CustomEvents checkboxcontroller = new CustomEvents();
            checkboxcontroller.ValueChanged += TransmitChanged;
            checkbox.Controller.AddController(checkboxcontroller);

            gridPlugins[row, ColTransmit] = checkbox;
          }
          else
          {
            gridPlugins[row, ColTransmit] = new Cell();
          }

          // Configure Cell
          if (transceiver is IConfigure)
          {
            Button button = new Button("Configure");

            SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button();
            buttonClickEvent.Executed += buttonClickEvent_Executed;
            button.Controller.AddController(buttonClickEvent);

            gridPlugins[row, ColConfigure] = button;
          }
          else
          {
            gridPlugins[row, ColConfigure] = new Cell();
          }
        }

        gridPlugins.Columns[ColIcon].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize;
        gridPlugins.Columns[ColName].AutoSizeMode = SourceGrid.AutoSizeMode.Default;
        gridPlugins.Columns[ColReceive].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize;
        gridPlugins.Columns[ColTransmit].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize;
        gridPlugins.Columns[ColConfigure].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize;
        gridPlugins.AutoStretchColumnsToFitWidth = true;
        gridPlugins.AutoSizeCells();
        gridPlugins.SortRangeRows(new RangeFullGridNoFixedRows(), ColName, true, new ValueCellComparer());
      }
      catch (Exception ex)
      {
        IrssLog.Error(ex);
        MessageBox.Show(this, ex.ToString(), "Error setting up plugin grid", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }
示例#4
0
		private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, Cells.Editors.EditorBase p_Editor, object p_Object)
		{
			grid[p_GridRow, p_GridCol] = new Cells.Cell(p_PropInfo.GetValue(p_Object,null));
			grid[p_GridRow, p_GridCol].Editor = p_Editor;

			Cells.Controllers.BindProperty l_Bind = new Cells.Controllers.BindProperty(p_PropInfo, p_Object);
			grid[p_GridRow, p_GridCol].AddController(l_Bind);

			Cells.Controllers.CustomEvents l_CustomEvents = new Cells.Controllers.CustomEvents();
			l_CustomEvents.ValueChanged += new EventHandler(Grid_ValueChanged);
			grid[p_GridRow, p_GridCol].AddController(l_CustomEvents);
		}
示例#5
0
		private void AddContextMenu()
		{
			var eventsController = new CustomEvents();
			var contextMenu = new ContextMenuStrip();
			var customEvents = new FrmSample21Events(this.grid1);
			contextMenu.Items.Add(customEvents.GetInsertRowItem());
			contextMenu.Items.Add(customEvents.GetRemoveRowItem());
			
			contextMenu.Items.Add(customEvents.GetInsertColItem());
			contextMenu.Items.Add(customEvents.GetRemoveColItem());
			
			eventsController.MouseDown += delegate(object sender, MouseEventArgs e)
			{
				if (e.Button != MouseButtons.Right)
					return;
				var context = (CellContext)sender;
				grid1.Selection.Focus(context.Position, true);
				grid1.Selection.SelectCell(context.Position, true);
				var rect = grid1.RangeToRectangle(new Range(context.Position, context.Position));
				customEvents.LastPosition = context.Position;
				contextMenu.Show(grid1, rect.Location);
			};
			grid1.Controller.AddController(eventsController);
		}
示例#6
0
        private void DoFull()
        {
            grid1.Redim(20, 12);
            grid1.FixedRows = 2;

            //1 Header Row
            grid1[0, 0]            = new MyHeader("3 Column Header");
            grid1[0, 0].ColumnSpan = 3;
            grid1[0, 3]            = new MyHeader("5 Column Header");
            grid1[0, 3].ColumnSpan = 5;
            grid1[0, 8]            = new MyHeader("1 Column Header");
            grid1[0, 9]            = new MyHeader("1 Column Header");

            //2 Header Row
            grid1[1, 0]  = new MyHeader("1");
            grid1[1, 1]  = new MyHeader("2");
            grid1[1, 2]  = new MyHeader("3");
            grid1[1, 3]  = new MyHeader("4");
            grid1[1, 4]  = new MyHeader("5");
            grid1[1, 5]  = new MyHeader("6");
            grid1[1, 6]  = new MyHeader("7");
            grid1[1, 7]  = new MyHeader("8");
            grid1[1, 8]  = new MyHeader("9");
            grid1[1, 9]  = new MyHeader("10");
            grid1[1, 10] = new MyHeader("11");
            grid1[1, 11] = new MyHeader("12");

            SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell();

            SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
            clickEvent.Click += new EventHandler(clickEvent_Click);

            for (int r = 2; r < grid1.RowsCount; r = r + 2)
            {
                grid1[r, 0]            = new SourceGrid.Cells.Cell(r.ToString(), typeof(string));
                grid1[r, 0].ColumnSpan = 2;

                grid1[r + 1, 0]            = new SourceGrid.Cells.Cell();
                grid1[r + 1, 0].ColumnSpan = 2;

                grid1[r, 2]            = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false);
                grid1[r, 2].ColumnSpan = 2;
                grid1[r, 2].RowSpan    = 2;

                grid1[r, 4]            = new SourceGrid.Cells.Link("Link Column/Row Span");
                grid1[r, 4].ColumnSpan = 2;
                grid1[r, 4].RowSpan    = 2;
                grid1[r, 4].AddController(clickEvent);

                grid1[r, 6]            = new SourceGrid.Cells.Button("Button Column/Row Span");
                grid1[r, 6].ColumnSpan = 2;
                grid1[r, 6].RowSpan    = 2;
                grid1[r, 6].AddController(clickEvent);

                grid1[r, 8]            = new SourceGrid.Cells.Cell("Image Column/Row Span");
                grid1[r, 8].View       = viewImage;
                grid1[r, 8].Image      = Properties.Resources.FACE02.ToBitmap();
                grid1[r, 8].ColumnSpan = 2;
                grid1[r, 8].RowSpan    = 2;

                grid1[r, 10]            = new SourceGrid.Cells.Cell("Text Span", typeof(string));
                grid1[r, 10].ColumnSpan = 2;
                grid1[r, 10].RowSpan    = 2;
            }

            grid1.ClipboardMode = SourceGrid.ClipboardMode.All;
            grid1.AutoSizeCells();
        }
示例#7
0
        private void SetupRuleGrid()
        {
            onChangeEventsController = new CustomEvents();
            onChangeEventsController.ValueChanged += delegate(object sender, EventArgs e)
            {
                if (inPreview)
                {
                    //need to catch here otherwise SG will catch the exception
                    try
                    {
                        PreviewRename();
                    }
                    catch (Exception ee)
                    {
                        SetStatus(ee.Message);
                    }
                    ruleGrid.AutoSizeCells();
                }
            };

            RuleOpenDialog.FileName = Properties.Settings.Default.LastRulePath;
            if (!RuleOpenDialog.FileName.Equals(String.Empty))
            {
                LoadFile(RuleOpenDialog.FileName);
            }

            ruleGrid.Controller.AddController(onChangeEventsController);

            //RuleGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableStretch;
            //RuleGrid.AutoSizeCells();
            //RuleGrid.PreviewKeyDown += delegate(object eventSender, PreviewKeyDownEventArgs karg)
            //{
            //    if (karg.KeyCode == Keys.A && karg.Modifiers == Keys.Control)
            //    {
            //        RuleGrid.Selection.SelectRange(new Range(new Position(1, 0), new Position(RuleGrid.RowsCount - 1, FileNewNameCol)), true);
            //    }

            //};
            //cellEditor = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
            //cellEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
        }
示例#8
0
		private void DoFull()
		{
			grid1.Redim(20, 12);
			grid1.FixedRows = 2;
			
			//1 Header Row
			grid1[0, 0] = new MyHeader("3 Column Header");
			grid1[0, 0].ColumnSpan = 3;
			grid1[0, 3] = new MyHeader("5 Column Header");
			grid1[0, 3].ColumnSpan = 5;
			grid1[0, 8] = new MyHeader("1 Column Header");
			grid1[0, 9] = new MyHeader("1 Column Header");

			//2 Header Row
			grid1[1, 0] = new MyHeader("1");
			grid1[1, 1] = new MyHeader("2");
			grid1[1, 2] = new MyHeader("3");
			grid1[1, 3] = new MyHeader("4");
			grid1[1, 4] = new MyHeader("5");
			grid1[1, 5] = new MyHeader("6");
			grid1[1, 6] = new MyHeader("7");
			grid1[1, 7] = new MyHeader("8");
			grid1[1, 8] = new MyHeader("9");
			grid1[1, 9] = new MyHeader("10");
			grid1[1, 10] = new MyHeader("11");
			grid1[1, 11] = new MyHeader("12");

			SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell();

			SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
			clickEvent.Click += new EventHandler(clickEvent_Click);

			for (int r = 2; r < grid1.RowsCount; r=r+2)
			{
				grid1[r, 0] = new SourceGrid.Cells.Cell(r.ToString(), typeof(string));
				grid1[r, 0].ColumnSpan = 2;

				grid1[r+1, 0] = new SourceGrid.Cells.Cell();
				grid1[r+1, 0].ColumnSpan = 2;

				grid1[r, 2] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false);
				grid1[r, 2].ColumnSpan = 2;
				grid1[r, 2].RowSpan = 2;

				grid1[r, 4] = new SourceGrid.Cells.Link("Link Column/Row Span");
				grid1[r, 4].ColumnSpan = 2;
				grid1[r, 4].RowSpan = 2;
				grid1[r, 4].AddController(clickEvent);

				grid1[r, 6] = new SourceGrid.Cells.Button("Button Column/Row Span");
				grid1[r, 6].ColumnSpan = 2;
				grid1[r, 6].RowSpan = 2;
				grid1[r, 6].AddController(clickEvent);

				grid1[r, 8] = new SourceGrid.Cells.Cell("Image Column/Row Span");
				grid1[r, 8].View = viewImage;
				grid1[r, 8].Image = Properties.Resources.FACE02.ToBitmap();
				grid1[r, 8].ColumnSpan = 2;
				grid1[r, 8].RowSpan = 2;
				
				grid1[r, 10] = new SourceGrid.Cells.Cell("Text Span", typeof(string));
				grid1[r, 10].ColumnSpan = 2;
				grid1[r, 10].RowSpan = 2;
			}

			grid1.ClipboardMode = SourceGrid.ClipboardMode.All;
			grid1.AutoSizeCells();
		}