Ejemplo n.º 1
0
        public MainWindow(IContainer container)
        {
            InitializeComponent();
            _background = new SolidColorBrush(Color.FromRgb(0x24, 0x27, 0x28));

            //            _background =
            //                new ImageBrush(new BitmapImage(new Uri(@"Images/grid.jpg", UriKind.Relative)))
            //                {
            //                    Stretch = Stretch.None,
            //                    TileMode = TileMode.Tile,
            //                    AlignmentX = AlignmentX.Left,
            //                    AlignmentY = AlignmentY.Top,
            //                    Viewport = new Rect(0, 0, 128, 128),
            //                    ViewportUnits = BrushMappingMode.Absolute
            //                };

            Application.Current.Resources["Dunno"] = Application.Current.Resources["Dunno1"];

            var compositeNode = new CompositeNode(new NodeDispatcher("Graph Dispatcher"));// TestNodes.Test3(new NodeDispatcher("Graph Dispatcher"));
            _compositeNodeViewModel = new CompositeNodeViewModel(compositeNode, new Vector(), new ControlTypesResolver());
            MainNode.DataContext = _compositeNodeViewModel;

            var contextMenu = new ContextMenu();
            MainNode.ContextMenu = contextMenu;

            var nodeTypes = container != null ? container.ResolveNamed<IEnumerable<Type>>("NodeTypes") : Enumerable.Empty<Type>();

            foreach (var nodeType in nodeTypes)
            {
                var menuItem = new MenuItem { Header = nodeType.Name };
                menuItem.Click += (sender, args) => MenuItemOnClick(nodeType, MainNode.TranslatePosition(menuItem.TranslatePoint(new Point(), this)));
                contextMenu.Items.Add(menuItem);
            }
        }