Esempio n. 1
0
        private void grdData_DragDrop(object sender, DragEventArgs e)
        {
            int dropIndex;

            // Get the position on the grid where the dragged row(s) are to be dropped.
            //get the grid coordinates of the row (the drop zone)
            UIElement uieOver = grdData.DisplayLayout.UIElement.ElementFromPoint(grdData.PointToClient(new Point(e.X, e.Y)));

            //get the row that is the drop zone/or where the dragged row is to be dropped
            UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow;

            if (ugrOver != null)
            {
                dropIndex = ugrOver.Index;    //index/position of drop zone in grid

                //get the dragged row(s)which are to be dragged to another position in the grid
                SelectedRowsCollection SelRows = (SelectedRowsCollection)e.Data.GetData(typeof(SelectedRowsCollection)) as
                                                 SelectedRowsCollection;
                //get the count of selected rows and drop each starting at the dropIndex
                foreach (UltraGridRow aRow in SelRows)
                {
                    //move the selected row(s) to the drop zone
                    grdData.Rows.Move(aRow, dropIndex);
                }
            }
        }
Esempio n. 2
0
        public bool ExecPreprocessPendingObjects(CommandData cmdData)
        {
            IOutputService output = CommonServices.Output;

            output.SelectOutput("KBDoctor");
            SelectedRowsCollection selrows  = cmdData.Context as SelectedRowsCollection;
            List <KBObjectHistory> kbohList = GetGenericHistoryObjects(selrows);
            KBModel         model           = UIServices.KB.CurrentModel;
            List <KBObject> selectedObjects = new List <KBObject>();

            foreach (KBObjectHistory kboh in kbohList)
            {
                KBObject obj = model.Objects.Get(kboh.Key);
                if (obj != null)
                {
                    List <KBObject> objsInContainer = new List <KBObject>();
                    if (obj is Artech.Architecture.Common.Objects.Module)
                    {
                        objsInContainer = KBDoctorCore.Sources.Utility.ModuleObjects((Artech.Architecture.Common.Objects.Module)obj);
                    }
                    else
                    {
                        if (obj is Folder)
                        {
                            objsInContainer = KBDoctorCore.Sources.Utility.FolderObjects((Folder)obj);
                        }
                        else
                        {
                            selectedObjects.Add(obj);
                        }
                    }
                    foreach (KBObject objSelected in objsInContainer)
                    {
                        if (!selectedObjects.Contains(objSelected))
                        {
                            selectedObjects.Add(objSelected);
                        }
                    }
                }
            }
            Thread thread = new Thread(() => KBDoctorCore.Sources.API.PreProcessPendingObjects(UIServices.KB.CurrentKB, output, selectedObjects));

            thread.Start();
            return(true);
        }
Esempio n. 3
0
        private void ultraGrid1_DragDrop(object sender, DragEventArgs e)
        {
            int dropIndex;

            // Get the position on the grid where the dragged row(s) are to be dropped.
            //get the grid coordinates of the row (the drop zone)
            UIElement uieOver = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(ultraGrid1.PointToClient(new Point(e.X, e.Y)));

            //get the row that is the drop zone/or where the dragged row is to be dropped
            UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow;

            if (ugrOver != null)
            {
                dropIndex = ugrOver.Index;    //index/position of drop zone in grid
                string catID = ugrOver.Cells["CatID"].Value.ToString();
                //if it is leaf - get it's table, if it is level - get it's leaf table
                DataTable newDataTable = Regex.IsMatch(ugrOver.Band.Key, "Type") ? this._HierarchicalDataSet.Tables[ugrOver.Band.Key] :
                                         this._HierarchicalDataSet.Tables["Type" + ugrOver.Cells["Level"].Value.ToString()];
                //get the dragged row(s)which are to be dragged to another position in the grid
                SelectedRowsCollection SelRows = (SelectedRowsCollection)e.Data.GetData(typeof(SelectedRowsCollection)) as SelectedRowsCollection;
                //get the count of selected rows and drop each starting at the dropIndex
                for (int i = SelRows.Count - 1; i >= 0; i--) // go from bottom to delete rows from one table and insert to another
                {
                    UltraGridRow aRow = SelRows[i];
                    if (!aRow.Cells["CatID"].Value.ToString().Equals(catID))
                    {
                        DataRow newDataRow = newDataTable.NewRow();
                        foreach (DataColumn dataColumn in newDataTable.Columns)
                        {
                            newDataRow[dataColumn.ColumnName] = aRow.Cells[dataColumn.ColumnName].Value;
                        }
                        newDataRow["CatID"] = catID;
                        newDataTable.Rows.Add(newDataRow);
                        aRow.Delete(false);
                    }
                    else
                    {
                        //move the selected row(s) to the drop zone
                        ultraGrid1.Rows.Move(aRow, dropIndex);
                    }
                }
            }
        }
        private void AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
        {
            BindingList <ICompoundGroupItem> selectedCompounds = new BindingList <ICompoundGroupItem>();

            SelectedRowsCollection seletedRows = this.ultraGrid.Selected.Rows;

            if (seletedRows != null)
            {
                RowEnumerator enumerator = seletedRows.GetEnumerator();
                if (enumerator != null)
                {
                    while (enumerator.MoveNext())
                    {
                        UltraGridRow       row      = enumerator.Current;
                        ICompoundGroupItem compound = row.ListObject as ICompoundGroupItem;
                        if (compound != null)
                        {
                            selectedCompounds.Add(compound);
                        }
                    }
                }
            }
            this.Model.SelectedCompoundGroups = selectedCompounds;
        }
        private void AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
        {
            BindingList <ISample> selectedSamples = new BindingList <ISample>();

            SelectedRowsCollection seletedRows = this.ultraGrid.Selected.Rows;

            if (seletedRows != null)
            {
                RowEnumerator enumerator = seletedRows.GetEnumerator();
                if (enumerator != null)
                {
                    while (enumerator.MoveNext())
                    {
                        UltraGridRow row    = enumerator.Current;
                        ISample      sample = row.ListObject as ISample;
                        if (sample != null)
                        {
                            selectedSamples.Add(sample);
                        }
                    }
                }
            }
            this.Model.SelectedSamples = selectedSamples;
        }
Esempio n. 6
0
 public static List <KBObjectHistory> GetGenericHistoryObjects(SelectedRowsCollection rows)
 {
     return((from UltraGridRow row in rows
             where !row.IsGroupByRow // Quitamos las rows de grupo.
             select(KBObjectHistory) row.Cells["KBObjectHistory"].Value).ToList());
 }
Esempio n. 7
0
        private void ultraGrid1_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                int dropIndex;

                //Get the position on the grid where the dragged row(s) are to be dropped.
                //get the grid coordinates of the row (the drop zone)
                UIElement uieOver = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(ultraGrid1.PointToClient(new Point(e.X, e.Y)));

                //get the row that is the drop zone/or where the dragged row is to be dropped
                UltraGridRow ugrOver = uieOver.GetContext(typeof(UltraGridRow), true) as UltraGridRow;

                if (ugrOver != null)
                {
                    dropIndex = ugrOver.Index;    //index/position of drop zone in grid

                    //get the dragged row(s)which are to be dragged to another position in the grid
                    SelectedRowsCollection SelRows = (SelectedRowsCollection)e.Data.GetData(typeof(SelectedRowsCollection)) as SelectedRowsCollection;
                    //get the count of selected rows and drop each starting at the dropIndex
                    if (SelRows.Count > 0)
                    {
                        if (SelRows[0].Band.Key == "ReportSet")
                        {
                            foreach (UltraGridRow aRow in SelRows)
                            {
                                string  serieID = aRow.Cells["ReportSeries.ID"].Value.ToString();
                                DataRow dataRow = ((DataRowView)aRow.ListObject).Row;
                                if (ugrOver.Band.Key == "ReportSeries")
                                {
                                    dataRow["ReportSeries.ID"] = ugrOver.Cells["ID"].Value;
                                    dataRow["SerieName"]       = ugrOver.Cells["SerieName"].Value;
                                    dataRow["SiteID"]          = ugrOver.Cells["SiteID"].Value;
                                }
                                else
                                {
                                    dataRow["ReportSeries.ID"] = ugrOver.ParentRow.Cells["ID"].Value;
                                    dataRow["SerieName"]       = ugrOver.ParentRow.Cells["SerieName"].Value;
                                    dataRow["SiteID"]          = ugrOver.ParentRow.Cells["SiteID"].Value;
                                }
                                dataRow["SerieID"] = dataRow["ReportSeries.ID"];
                                SetModifiedDate(dataRow["SerieID"].ToString());
                                ultraGrid1.Rows.Move(aRow, dropIndex);
                                if (dataRow["SerieID"].ToString() == serieID) //serie ID didn't changed
                                {
                                    aRow.ParentCollection.Move(aRow, dropIndex);
                                }
                            }
                        }
                        else if (SelRows[0].Band.Key != "ReportSeries")
                        {
                            foreach (UltraGridRow aRow in SelRows)
                            {
                                DataRow row = _ReportSeries.Tables["ReportSet"].NewRow();
                                row["ReportSet.ID"] = _MinSetID;
                                _MinSetID--;
                                if (ugrOver.Band.Key == "ReportSeries")
                                {
                                    row["ReportSeries.ID"] = ugrOver.Cells["ID"].Value;
                                    row["SerieName"]       = ugrOver.Cells["SerieName"].Value;
                                    row["SiteID"]          = ugrOver.Cells["SiteID"].Value;
                                }
                                else
                                {
                                    row["ReportSeries.ID"] = ugrOver.ParentRow.Cells["ID"].Value;
                                    row["SerieName"]       = ugrOver.ParentRow.Cells["SerieName"].Value;
                                    row["SiteID"]          = ugrOver.ParentRow.Cells["SiteID"].Value;
                                }
                                SetModifiedDate(row["ReportSeries.ID"].ToString());
                                row["ReportMemorized"]    = aRow.Cells["ID"].Value;
                                row["ReportMemorized.ID"] = aRow.Cells["ID"].Value;
                                row["ReportType"]         = aRow.Cells["ReportType"].Value;
                                row["Order"]      = -1;
                                row["Expression"] = "";
                                row["SerieID"]    = row["ReportSeries.ID"];
                                row["ConfigXML"]  = aRow.Cells["ConfigXML"].Value;
                                row["Title"]      = aRow.Cells["Title"].Value;
                                _ReportSeries.Tables["ReportSet"].Rows.Add(row);
                            }
                        }
                        ultraGrid1.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error during drag&drop", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }