Example #1
0
        /// <summary>
        /// Update guidelines
        /// </summary>
        /// <returns></returns>
        private async Task UpdateLines()
        {
            double cellWidth = DesignerCanvas.GridCellWidth;
            double w         = ModelDesignerCanvas.Width;
            double h         = ModelDesignerCanvas.Height;

            //For progress dialog glitch-free opening
            await Task.Delay(500);

            var geometry = await Task.Run(() => DesignerCanvas.CreateGridWithStreamGeometry(h, w, cellWidth));

            ModelDesignerCanvas.RefreshGuideLines(geometry);
        }
Example #2
0
        /// <summary>
        /// Bending point mark added or removed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void MarksOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (ConnectionPointMark mark in args.NewItems)
                {
                    ModelDesignerCanvas.Children.Add(mark.Mark);
                    DesignerCanvas.SetZIndex(mark.Mark, DesignerCanvas.ConnectionPointZIndex);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (ConnectionPointMark mark in args.OldItems)
                {
                    ModelDesignerCanvas.Children.Remove(mark.Mark);
                }
                break;
            }
        }
Example #3
0
        /// <summary>
        /// Add new label to canvas
        /// </summary>
        /// <param name="viewModel">Label viewmodel</param>
        private void AddLabelElement(LabelViewModel viewModel)
        {
            var content = new LabelContent(viewModel);
            RoutedEventHandler loadedEventHandler = null;

            loadedEventHandler = (sender, args) =>
            {
                MeasureToFit(content);
                DesignerCanvas.SetZIndex(content, DesignerCanvas.LabelUnselectedZIndex);
                DesignerCanvas.SetTop(content, viewModel.Top);
                DesignerCanvas.SetLeft(content, viewModel.Left);
                content.Height   = content.ActualHeight + 30;
                content.Width    = content.ActualWidth + 30;
                viewModel.Height = content.Height;
                viewModel.Width  = content.Width;
                content.Loaded  -= loadedEventHandler;
            };

            content.Loaded += loadedEventHandler;
            ModelDesignerCanvas.Children.Add(content);
        }
Example #4
0
        /// <summary>
        /// Dimensions changed
        /// </summary>
        /// <returns></returns>
        public async Task CanvasDimensionsChanged()
        {
            var settings = new MetroDialogSettings()
            {
                AnimateHide = true,
                AnimateShow = false
            };

            var parent = VisualTreeHelperEx.FindAncestorByType <MetroWindow>(this);

            var progressController = await parent.ShowProgressAsync("Please wait...", "Guidelines are updating", false, settings);

            await UpdateLines();

            await progressController.CloseAsync();

            StreamGeometry geometry = DesignerCanvas.CreateGridWithStreamGeometry(ViewModel.CanvasHeight, ViewModel.CanvasWidth,
                                                                                  DesignerCanvas.GridCellWidth);

            ModelDesignerCanvas.RefreshGuideLines(geometry);

            ViewModel.OnComputedPropertyChanged();
        }