Example #1
0
        private void ExportItemGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            // double-clicked node column cell, select a node!
            if (e.ColumnIndex == ColumnNode.Index)
            {
                if (Loader.Core.DoHitByNameDialog(null) && Loader.Core.SelNodeCount > 0)
                {
                    int        highestRowIndexEdited = e.RowIndex;
                    var        selectedRow           = ExportItemGridView.Rows[e.RowIndex];
                    ExportItem existingItem          = selectedRow.Tag as ExportItem;
                    IINode     node = Loader.Core.GetSelNode(0);

                    if (existingItem == null)
                    {
                        existingItem = TryAddExportItem(selectedRow, node.Handle);
                    }
                    else
                    {
                        existingItem.NodeHandle = node.Handle;
                    }

                    // may be null after trying to add a node that already exists in another row
                    if (existingItem != null)
                    {
                        SetRowData(selectedRow, existingItem);
                    }

                    // add remaining selected nodes as new rows
                    for (int i = 1; i < Loader.Core.SelNodeCount; ++i)
                    {
                        int rowIndex = ExportItemGridView.Rows.Add();
                        var newRow   = ExportItemGridView.Rows[rowIndex];

                        ExportItem newItem = TryAddExportItem(newRow, Loader.Core.GetSelNode(i).Handle);

                        // may be null after trying to add a node that already exists in another row
                        if (newItem == null)
                        {
                            continue;
                        }

                        SetRowData(newRow, newItem);
                        highestRowIndexEdited = rowIndex;
                    }

                    // have to explicitly set it dirty for an edge case:
                    // when a new row is added "automatically-programmatically", through notify cell dirty and endedit(),
                    //   if the user then clicks on the checkbox of the newly added row,
                    //     it doesn't add a new row "automatically", whereas otherwise it will.
                    ExportItemGridView.CurrentCell = ExportItemGridView[e.ColumnIndex, highestRowIndexEdited];
                    ExportItemGridView.NotifyCurrentCellDirty(true);
                    ExportItemGridView.EndEdit();
                }
            }
        }
Example #2
0
        private void ExportItemGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            // necessary for checkboxes, problem with datagridview
            if (e.ColumnIndex == ColumnExportCheckbox.Index)
            {
                ExportItemGridView.EndEdit();
            }
        }
Example #3
0
        private void ExportItemGridView_Populate(ExportItemList exportItemList)
        {
            ExportItemGridView.Rows.Clear();
            this.exportItemList = exportItemList;

            foreach (var item in exportItemList)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.Cells.Add(new DataGridViewCheckBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());
                SetRowData(row, item);
                ExportItemGridView.Rows.Add(row);
            }
            ExportItemGridView.AutoResizeColumns();
            ExportItemGridView.AllowUserToOrderColumns  = true;
            ExportItemGridView.AllowUserToResizeColumns = true;
        }
Example #4
0
        private void SceneExplorerOnClosed(object sender, EventArgs e)
        {
            List <IILayer> selectedLayers = layerSelector.SelectedLayers;

            if (selectedLayers.Count > 0)
            {
                int highestRowIndexEdited = layersRowIndex;
                var selectedRow           = ExportItemGridView.Rows[layersRowIndex];


                ExportItem existingItem = selectedRow.Tag as ExportItem;

                if (existingItem == null)
                {
                    existingItem = TryAddExportItem(selectedRow, selectedLayers);
                }
                else
                {
                    existingItem.SetExportLayers(selectedLayers);
                }

                // may be null after trying to add a node that already exists in another row
                if (existingItem != null)
                {
                    SetRowData(selectedRow, existingItem);
                }

                // have to explicitly set it dirty for an edge case:
                // when a new row is added "automatically-programmatically", through notify cell dirty and endedit(),
                //   if the user then clicks on the checkbox of the newly added row,
                //     it doesn't add a new row "automatically", whereas otherwise it will.
                ExportItemGridView.CurrentCell = ExportItemGridView[layersColumnIndex, highestRowIndexEdited];
                ExportItemGridView.NotifyCurrentCellDirty(true);
                ExportItemGridView.EndEdit();
            }
        }
Example #5
0
        private void ExportItemGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            // double-clicked node column cell, select a node!
            if (e.ColumnIndex == ColumnNode.Index)
            {
                if (Loader.Core.DoHitByNameDialog(null) && Loader.Core.SelNodeCount > 0)
                {
                    int        highestRowIndexEdited = e.RowIndex;
                    var        selectedRow           = ExportItemGridView.Rows[e.RowIndex];
                    ExportItem existingItem          = selectedRow.Tag as ExportItem;
                    IINode     node = Loader.Core.GetSelNode(0);

                    if (existingItem == null)
                    {
                        existingItem = TryAddExportItem(selectedRow, node.Handle);
                    }
                    else
                    {
                        if (existingItem.Layers != null && existingItem.Layers.Count > 0)
                        {
                            MessageBox.Show("You can't specify a Node when export is layer based");
                            return;
                        }
                        existingItem.NodeHandle = node.Handle;
                    }

                    // may be null after trying to add a node that already exists in another row
                    if (existingItem != null)
                    {
                        SetRowData(selectedRow, existingItem);
                    }

                    // add remaining selected nodes as new rows
                    for (int i = 1; i < Loader.Core.SelNodeCount; ++i)
                    {
                        int rowIndex = ExportItemGridView.Rows.Add();
                        var newRow   = ExportItemGridView.Rows[rowIndex];

                        ExportItem newItem = TryAddExportItem(newRow, Loader.Core.GetSelNode(i).Handle);

                        // may be null after trying to add a node that already exists in another row
                        if (newItem == null)
                        {
                            continue;
                        }

                        SetRowData(newRow, newItem);
                        highestRowIndexEdited = rowIndex;
                    }

                    // have to explicitly set it dirty for an edge case:
                    // when a new row is added "automatically-programmatically", through notify cell dirty and endedit(),
                    //   if the user then clicks on the checkbox of the newly added row,
                    //     it doesn't add a new row "automatically", whereas otherwise it will.
                    ExportItemGridView.CurrentCell = ExportItemGridView[e.ColumnIndex, highestRowIndexEdited];
                    ExportItemGridView.NotifyCurrentCellDirty(true);
                    ExportItemGridView.EndEdit();
                }
            }


            // double-clicked layers column cell, select some layers!
            if (e.ColumnIndex == ColumnLayers.Index)
            {
                layersRowIndex    = e.RowIndex;
                layersColumnIndex = e.ColumnIndex;
                ExportItem existingItem = ExportItemGridView.Rows[layersRowIndex].Tag as ExportItem;
                if (layerSelector == null || layerSelector.IsDisposed)
                {
                    layerSelector = new LayerSelector();
                    layerSelector.Show();
                    layerSelector.FillLayerSelector(existingItem?.Layers);

                    layerSelector.OnConfirmButtonClicked += LayerExplorerClosed;
                }
                else
                {
                    layerSelector.Focus();
                }
            }
        }