public void ScrollToSelectedItem(bool up = false) { if (CurrentModel.SelectedItem != null) { tbx_filter.Foreground = Brushes.Black; ActiveGrid.ScrollIntoView(CurrentModel.SelectedItem); if (up) { //var verticalScrollBar = GetScrollbar(ActiveGrid, Orientation.Vertical); //var firstRow = verticalScrollBar.Value; //if (ActiveGrid.SelectedIndex - firstRow > 5) //{ // var index = ActiveGrid.SelectedIndex + ActiveGrid.SelectedIndex - firstRow - 2; // if (CurrentModel.Items.Count > index && index >= 0) // { // ActiveGrid.ScrollIntoView(CurrentModel.Items[(int)index]); // } //} } } else { tbx_filter.Foreground = Brushes.Red; } }
/// <summary>Выбор строки или строк</summary> public void OnSelectFromList(EventArgs e = null) { if (!(formModes.HasFlag(FormModes.GetResult) && (ActiveGrid.Name.Equals(SelectionGridName) || string.IsNullOrWhiteSpace(SelectionGridName)) && ActiveGrid.Focused )) { return; } object selectedObject = null; var checkedIdx = ActiveGrid.GetCheckedRowsIdx(); if (formModes.HasFlag(FormModes.GetMultiResult)) { if (checkedIdx.Count > 0) { selectedObject = checkedIdx.Select(r => ActiveGrid.GetRowObject(r)).ToList(); } else { selectedObject = new List <object> { ActiveGrid.GetRowObject() } }; } else { selectedObject = CtrlsProc.PrepareParams(ActiveGrid.GetRowObject()); } // сбросить дальнейшую обработку нажатий var keyEvt = (e as KeyEventArgs); if (keyEvt != null) { keyEvt.Handled = true; } var ea = new SelectFromListEventArgs() { SelectedObject = selectedObject, Handled = false }; SelectFromList?.Invoke(this, ea); // стандартный возврат результата и выход, если это не отменили в обработчике события if (!ea.Handled) { Ctx.TransferObject = ea.SelectedObject; if (Ctx.TransferObject == null) { Loger.SendMess("Не получен выбранный объект!", true); } DialogResult = Ctx.TransferObject != null && Modal ? DialogResult.OK : DialogResult.Cancel; Close(); } }
/// <summary> /// add a new V grid line to the specified location /// </summary> public void AddVGridLine() { // verify that the mouse location is valid: it's inside the curtain grid area // & it doesn't lap over another grid line (it's not allowed to add a grid line to lap over another one) if (false == m_drawing.MouseLocationValid) { return; } // all the assistant lines (in "Add V (Vertical) Grid Line" operation, // there's only one dash line, this line indicates the location to be added) List <KeyValuePair <Line2D, Pen> > lines2D = m_drawing.DrawObject.Lines2D; if (lines2D.Count < 1) { return; } // the dash V line shown in the sample (incidates the location to be added) Line2D line2D = lines2D[0].Key; if (System.Drawing.Point.Empty == line2D.StartPoint || System.Drawing.Point.Empty == line2D.EndPoint) { return; } // get the point to be added int midX = (line2D.StartPoint.X + line2D.EndPoint.X) / 2; int midY = (line2D.StartPoint.Y + line2D.EndPoint.Y) / 2; // transform the 2D point to Autodesk.Revit.DB.XYZ format Autodesk.Revit.DB.XYZ pos = new Autodesk.Revit.DB.XYZ(midX, midY, 0); Vector4 vec = new Vector4(pos); vec = m_drawing.Coordinates.RestoreMatrix.Transform(vec); CurtainGridLine newLine; Transaction act = new Transaction(m_activeDocument, Guid.NewGuid().GetHashCode().ToString()); act.Start(); try { newLine = ActiveGrid.AddGridLine(false, new Autodesk.Revit.DB.XYZ(vec.X, vec.Y, vec.Z), false); } catch (System.Exception e) { TaskDialog.Show("Exception", e.Message); // "add V line" failed, so return directly return; } act.Commit(); // V line added, the U line's segment information changed, so reload all the geometry data this.ReloadGeometryData(); }
public virtual void ExportToExcel() { if (ActiveGrid == null && ActiveTreeList == null && ActivePivot == null) { return; } var fileName = ActiveGrid != null ? ActiveGrid.MainView.ViewCaption : string.Empty; var od = new SaveFileDialog { Filter = @"Excel Files (.xls)|*.xls", FileName = fileName }; if (od.ShowDialog() != DialogResult.OK) { return; } if (ActiveGrid != null) { if (!File.Exists(od.FileName)) { if (!File.Exists(od.FileName)) { var fs = File.Create(od.FileName); fs.Close(); } ActiveGrid.ExportToXls(od.FileName); } ActiveGrid.ExportToXls(od.FileName); } else if (ActiveTreeList != null) { ActiveTreeList.ExportToXls(od.FileName); } else if (ActivePivot != null) { ActivePivot.ExportToXls(od.FileName); } }