private void NewCommand(object sender, RoutedEventArgs e) { VplControl.NewFile(); //Performing Matrix scale var element = sender as UIElement; var transform = VplControl.RenderTransform as MatrixTransform; transform.Matrix = new Matrix(); VplControl.UpdateLayout(); this.FileTitle.Text = "New"; }
//Ugly way to trigger calculate private void Refresh(object sender, RoutedEventArgs e) { var nn = SortNodes.TSort(this.VplControl.NodeCollection as IEnumerable <Node>, n => NodeDependencyTree(n)); int CurrentProgress = 0; int TotalProgress = nn.Count(); Progress ProgressBar = Autodesk.Navisworks.Api.Application.BeginProgress("ENGyn", "Running nodes"); for (int i = 0; i < nn.Count(); i++) { using (Transaction tx = Autodesk.Navisworks.Api.Application.MainDocument.BeginTransaction(nn.ElementAt(i).Name)) { if (ProgressBar.IsCanceled) { break; } CurrentProgress++; nn.ElementAt(i).setToRun = true; try { nn.ElementAt(i).HasError = false; nn.ElementAt(i).TopComment.Visibility = Visibility.Hidden; nn.ElementAt(i).Calculate(); } catch (Exception except) { nn.ElementAt(i).HasError = true; nn.ElementAt(i).TopComment.Visibility = Visibility.Visible; nn.ElementAt(i).TopComment.Text = except.Message; VplControl.UpdateLayout(); } nn.ElementAt(i).setToRun = false; tx.Commit(); tx.Dispose(); ProgressBar.Update((double)CurrentProgress / TotalProgress); } } ProgressBar.EndSubOperation(true); Autodesk.Navisworks.Api.Application.EndProgress(); }
private void Canvas_MouseWheel(object sender, MouseWheelEventArgs e) { //Performing Matrix scale var element = sender as UIElement; var transform = VplControl.RenderTransform as MatrixTransform; var matrix = transform.Matrix; var scale = e.Delta >= 0 ? 1.1 : (1.0 / 1.1); var position = e.GetPosition(Vbox); { //Limit scale to 1.2 - 0.5 // scale = ((actualzoom > 0.5 || scale == 1.1) && (actualzoom < 1.2 || scale < 1)) ? scale : 1; matrix.ScaleAt(scale, scale, position.X, position.Y); transform.Matrix = matrix; actualzoom *= scale; } VplControl.UpdateLayout(); }