예제 #1
0
        public FrameworkElement CreateWidgetControl(IDiagram widget, ContextMenu contextMenu)
        {
            var viewModel = widget as EntityGridWidgetViewModel;
            Debug.Assert(viewModel != null);

            if (widget.DesignMode)
            {
                viewModel.RefreshSync();
                foreach (var entityScreenItemViewModel in viewModel.ResourceSelectorViewModel.EntityScreenItems)
                {
                    entityScreenItemViewModel.IsEnabled = false;
                }

            }

            var ret = new EntitySelectorView(viewModel.ResourceSelectorViewModel) { DataContext = viewModel.ResourceSelectorViewModel, ContextMenu = contextMenu, Tag = widget };

            var heightBinding = new Binding("Height") { Source = viewModel, Mode = BindingMode.TwoWay };
            var widthBinding = new Binding("Width") { Source = viewModel, Mode = BindingMode.TwoWay };
            var xBinding = new Binding("X") { Source = viewModel, Mode = BindingMode.TwoWay };
            var yBinding = new Binding("Y") { Source = viewModel, Mode = BindingMode.TwoWay };

            ret.SetBinding(InkCanvas.LeftProperty, xBinding);
            ret.SetBinding(InkCanvas.TopProperty, yBinding);
            ret.SetBinding(FrameworkElement.HeightProperty, heightBinding);
            ret.SetBinding(FrameworkElement.WidthProperty, widthBinding);

            return ret;
        }
        public FrameworkElement CreateWidgetControl(IDiagram widget, ContextMenu contextMenu)
        {
            var viewModel = widget as EntityGridWidgetViewModel;

            Debug.Assert(viewModel != null);

            if (widget.DesignMode)
            {
                viewModel.RefreshSync();
                foreach (var entityScreenItemViewModel in viewModel.ResourceSelectorViewModel.EntityScreenItems)
                {
                    entityScreenItemViewModel.IsEnabled = false;
                }
            }

            var ret = new EntitySelectorView(viewModel.ResourceSelectorViewModel)
            {
                DataContext = viewModel.ResourceSelectorViewModel, ContextMenu = contextMenu, Tag = widget
            };

            var heightBinding = new Binding("Height")
            {
                Source = viewModel, Mode = BindingMode.TwoWay
            };
            var widthBinding = new Binding("Width")
            {
                Source = viewModel, Mode = BindingMode.TwoWay
            };
            var xBinding = new Binding("X")
            {
                Source = viewModel, Mode = BindingMode.TwoWay
            };
            var yBinding = new Binding("Y")
            {
                Source = viewModel, Mode = BindingMode.TwoWay
            };

            ret.SetBinding(InkCanvas.LeftProperty, xBinding);
            ret.SetBinding(InkCanvas.TopProperty, yBinding);
            ret.SetBinding(FrameworkElement.HeightProperty, heightBinding);
            ret.SetBinding(FrameworkElement.WidthProperty, widthBinding);

            return(ret);
        }