protected override void OnElementChanged(ElementChangedEventArgs <SKFormsView> e) { if (e.OldElement != null) { var oldController = (ISKCanvasViewController)e.OldElement; // unsubscribe from events oldController.SurfaceInvalidated -= OnSurfaceInvalidated; oldController.GetCanvasSize -= OnGetCanvasSize; } if (e.NewElement != null) { var newController = (ISKCanvasViewController)e.NewElement; // create the native view var view = new InternalView(newController); view.IgnorePixelScaling = e.NewElement.IgnorePixelScaling; SetNativeControl(view); // subscribe to events from the user newController.SurfaceInvalidated += OnSurfaceInvalidated; newController.GetCanvasSize += OnGetCanvasSize; // paint for the first time Control.SetNeedsDisplay(); } base.OnElementChanged(e); }
protected override void OnElementChanged(ElementChangedEventArgs <SKFormsView> e) { if (e.OldElement != null) { var oldController = (ISKCanvasViewController)e.OldElement; // unsubscribe from events oldController.SurfaceInvalidated -= OnSurfaceInvalidated; } if (e.NewElement != null) { var newController = (ISKCanvasViewController)e.NewElement; // create the native view var view = new InternalView(newController); SetNativeControl(view); // subscribe to events from the user newController.SurfaceInvalidated += OnSurfaceInvalidated; // paint for the first time Control.Invalidate(); } base.OnElementChanged(e); }
protected override void OnElementChanged(ElementChangedEventArgs <SKFormsView> e) { if (e.OldElement != null) { var oldController = (ISKGLViewController)e.OldElement; // unsubscribe from events oldController.SurfaceInvalidated -= OnSurfaceInvalidated; oldController.GetCanvasSize -= OnGetCanvasSize; } if (e.NewElement != null) { var newController = (ISKGLViewController)e.NewElement; // create the native view var view = new InternalView(newController); SetNativeControl(view); // subscribe to events from the user newController.SurfaceInvalidated += OnSurfaceInvalidated; newController.GetCanvasSize += OnGetCanvasSize; // start the rendering SetupRenderLoop(false); } base.OnElementChanged(e); }
/// <summary> /// Gets graphic overrides for a category in view. /// </summary> /// <param name="category"></param> /// <returns></returns> public Revit.Filter.OverrideGraphicSettings GetCategoryOverrides(Category category) { Autodesk.Revit.DB.ElementId catId = category.InternalCategory.Id; if (!this.InternalView.IsCategoryOverridable(catId)) { throw new ArgumentException(Properties.Resources.CategoryVisibilityOverrideError); } return(new Filter.OverrideGraphicSettings(InternalView.GetCategoryOverrides(catId))); }
/// <summary> /// Set PartsVisibility of view /// </summary> /// <param name="partsVisibility"></param> /// <returns></returns> public View SetPartsVisibility(string partsVisibility) { PartsVisibility parts; parts = (PartsVisibility)Enum.Parse(typeof(PartsVisibility), partsVisibility); RevitServices.Transactions.TransactionManager.Instance.EnsureInTransaction(Application.Document.Current.InternalDocument); var param = InternalView.get_Parameter(BuiltInParameter.VIEW_PARTS_VISIBILITY); param.Set((int)parts); RevitServices.Transactions.TransactionManager.Instance.TransactionTaskDone(); return(this); }
/// <summary> /// Set DisplayStyle of View. /// </summary> /// <param name="displayStyle"></param> /// <returns></returns> public View SetDisplayStyle(string displayStyle) { DisplayStyle displaystyle; displaystyle = (DisplayStyle)Enum.Parse(typeof(DisplayStyle), displayStyle); RevitServices.Transactions.TransactionManager.Instance.EnsureInTransaction(Application.Document.Current.InternalDocument); if (InternalView.CanModifyDisplayStyle()) { InternalView.DisplayStyle = displaystyle; } else { throw new Exception(String.Format(Properties.Resources.CantModifyInView, "DisplayStyle")); } RevitServices.Transactions.TransactionManager.Instance.TransactionTaskDone(); return(this); }
/// <summary> /// Set Discipline of View. /// </summary> /// <param name="discipline"></param> /// <returns></returns> public View SetDiscipline(string discipline) { ViewDiscipline viewDiscipline; viewDiscipline = (ViewDiscipline)Enum.Parse(typeof(ViewDiscipline), discipline); RevitServices.Transactions.TransactionManager.Instance.EnsureInTransaction(Application.Document.Current.InternalDocument); if (InternalView.CanModifyViewDiscipline()) { var param = InternalView.get_Parameter(BuiltInParameter.VIEW_DISCIPLINE); param.Set((int)viewDiscipline); } else { throw new Exception(String.Format(Properties.Resources.CantModifyInView, "ViewDiscipline")); } RevitServices.Transactions.TransactionManager.Instance.TransactionTaskDone(); return(this); }
private void OnRowsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: InternalView.Insert(e.NewStartingIndex, ((LookupDataRow)e.NewItems[0]).RowObject); break; case NotifyCollectionChangedAction.Remove: InternalView.RemoveAt(e.OldStartingIndex); break; case NotifyCollectionChangedAction.Replace: InternalView.Remove(((LookupDataRow)e.OldItems[0]).RowObject); InternalView.Insert(e.NewStartingIndex, ((LookupDataRow)e.NewItems[0]).RowObject); break; case NotifyCollectionChangedAction.Reset: default: InternalView.Clear(); Rows.Select(r => r.RowObject).ToList().ForEach(o => InternalView.Add(o)); break; } }
/// <summary> /// Identifies if this view can be duplicated with specified viewDuplicateOption /// </summary> /// <param name="viewDuplicateOption">Enter View Duplicate Option: 0 = Duplicate. 1 = AsDependent. 2 = WithDetailing.</param> /// <returns></returns> public Boolean CanViewBeDuplicated(int viewDuplicateOption = 0) { ViewDuplicateOption Option = 0; switch (viewDuplicateOption) { case 0: Option = ViewDuplicateOption.Duplicate; break; case 1: Option = ViewDuplicateOption.AsDependent; break; case 2: Option = ViewDuplicateOption.WithDetailing; break; default: throw new ArgumentException(Properties.Resources.ViewDuplicateOptionOutofRange); } return(InternalView.CanViewBeDuplicated(Option)); }
public IEnumerator GetEnumerator() { return(InternalView.GetEnumerator()); }
/// <summary> /// Identifies if this view can be duplicated with specified viewDuplicateOption /// </summary> /// <param name="viewDuplicateOption">Enter View Duplicate Option: Duplicate, AsDependent or WithDetailing.</param> /// <returns></returns> public Boolean CanViewBeDuplicated(string viewDuplicateOption = "Duplicate") { ViewDuplicateOption Option = (ViewDuplicateOption)Enum.Parse(typeof(ViewDuplicateOption), viewDuplicateOption); return(InternalView.CanViewBeDuplicated(Option)); }
/// <summary> /// Checks if elements of the given category are set to be invisible (hidden) in this view. /// </summary> /// <param name="category"></param> /// <returns></returns> public bool IsCategoryHidden(Category category) { Autodesk.Revit.DB.ElementId catId = category.InternalCategory.Id; return(InternalView.GetCategoryHidden(catId)); }