A class for editing Cells that look like a ComboBox
Наследование: XPTable.Editors.DropDownCellEditor
Пример #1
0
        public void SetupTable()
        {
            SuspendLayout();

            // table
            table.ColumnModel = columnModel;
            table.EnableHeaderContextMenu = false;
            table.SelectionBackColor = Color.Yellow;
            table.SelectionForeColor = Color.Black;
            table.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            table.FullRowSelect = true;
            tableModel.RowHeight = 18;
            table.GridLineStyle = XPTable.Models.GridLineStyle.Dot;
            table.HeaderFont = new System.Drawing.Font("Arial", 9.0F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            table.Name = "table";
            table.NoItemsText = "There are no project folders to watch. Drag and drop your project folder here ...";
            table.TabIndex = 1;
            table.TableModel = tableModel;
            table.Text = "table";

            // columnModel
            columnModel.Columns.AddRange(new XPTable.Models.Column[] {
            nameColumn,
            folderColumn,
            typeColumn});

            // nameColumn
            nameColumn.Text = "Project";
            nameColumn.Width = 120;
            nameColumn.Renderer = new ProjectCellRenderer(imageListTypes);
            nameColumn.Editor = new ProjectCellEditor();

            // folderColumn
            folderColumn.Text = "Path";
            folderColumn.Width = 470;
            folderColumn.Renderer = new FolderCellRenderer();
            folderColumn.Editor = new FolderCellEditor();

            // typeColumn
            typeColumn.Text = "Type";
            typeColumn.Width = 80;
            ProjectTypeCellEditor typeEditor = new ProjectTypeCellEditor(imageListTypes);
            typeEditor.DropDownStyle = XPTable.Editors.DropDownStyle.DropDownList;
            typeEditor.FillItems += new ProjectTypeCellEditor.FillItemsHandler(ProjectTypePopulationEvent);
            typeEditor.HideDropDownEvent += new ProjectTypeCellEditor.HideDropDownEventHandler(ProjectTypeHideDropDownEvent);
            typeColumn.Editor = typeEditor;
            ProjectTypeCellRenderer typeRenderer = new ProjectTypeCellRenderer();
            typeColumn.Renderer = typeRenderer;

            table.KeyDown += new KeyEventHandler(OnKeyDown);
            table.CellPropertyChanged += new XPTable.Events.CellEventHandler(OnCellPropertyChanged);

            ResumeLayout(true);
        }
Пример #2
0
            public List<ProjecTypeItem> items; // items being prepared for editor

            #endregion Fields

            #region Constructors

            public DetectorData(string folder, ProjectTypeCellEditor editor)
            {
                this.folder = folder;
                this.editor = editor;
                this.items = new List<ProjecTypeItem>();
                this.counter = 0;
            }
Пример #3
0
        private void ProjectTypePopulation(ProjectTypeCellEditor editor)
        {
            // retrieve current row
            int row = editor.EditingCellPos.Row;

            // retrieve current folder path
            string folder = tableModel.Rows[row].Cells[1].Text;

            bool hasCache = Detector.Current.HasExtCache(folder);
            if (!hasCache)
            {
                // create waiting item, to signal progress
                ProjecTypeItem wait = new ProjecTypeItem();
                wait.Text = "Scanning";
                wait.Description = "Wait please ...";
                wait.ImageIndex = -1;
                wait.Mark = true;
                wait.ForeColor = Color.Red;
                editor.Items.Clear();
                editor.Items.Add(wait);
            }

            // cancel previous worker if running
            if (detectorWorker!=null)
            {
                DetectorCancel();
            }

            // create a background worker thread that ReportsProgress & SupportsCancellation
            // hook up the appropriate events.
            DetectorData detectorData = new DetectorData(folder, editor);

            detectorWorker = new BackgroundWorker();
            detectorWorker.WorkerReportsProgress = true;
            detectorWorker.WorkerSupportsCancellation = true;
            detectorWorker.ProgressChanged += new ProgressChangedEventHandler(DetectorProgressChanged);
            detectorWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DetectorWorkerCompleted);
            detectorWorker.DoWork += new DoWorkEventHandler(DetectorDoWork);
            Detector.Current.currentWorker = detectorWorker;
            detectorDatas.Add(detectorWorker, detectorData);
            if (!hasCache)
            {
                detectorWorker.RunWorkerAsync();
            }
            else
            {
                // we have cache, so do operation synchronously, to prevent UI blinking
                DetectorDoWork(detectorWorker, new DoWorkEventArgs(null));
                DetectorWorkerCompleted(detectorWorker, new RunWorkerCompletedEventArgs(null, null, false));
            }
        }