Esempio n. 1
0
        /// <summary>
        /// Add table to canvas
        /// </summary>
        /// <param name="viewModel">Viewmodel of table</param>
        private void AddTableElement(TableViewModel viewModel)
        {
            var content = new TableContent(viewModel);
            var owner   = Window.GetWindow(this) as MainWindow;

            content.AddNewRow                  += owner.AddNewRowHandler;
            content.EditSelectedRow            += owner.EditRowHandler;
            content.RenameTable                += owner.RenameTableHandler;
            content.RemoveSelectedRow          += owner.RemoveRowHandler;
            content.DropTable                  += owner.DropTableHandler;
            content.UpdatePrimaryKeyConstraint += owner.UpdatePrimaryKeyConstraintHandler;

            RoutedEventHandler loadedEventHandler = null;

            loadedEventHandler = (sender, args) =>
            {
                MeasureToFit(content);
                DesignerCanvas.SetZIndex(content, DesignerCanvas.TableUnselectedZIndex);
                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;
                viewModel.OnTableLoaded(content);
                content.Loaded -= loadedEventHandler;
            };

            content.Loaded += loadedEventHandler;
            ModelDesignerCanvas.Children.Add(content);
        }
Esempio n. 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;
            }
        }
Esempio n. 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);
        }