Пример #1
0
    /// <summary>
    /// 构造节点面板
    /// </summary>
    public virtual void CreateGraphView()
    {
        nodeView = new NodeBaseView
        {
            name = "NodeView"
        };

        nodeView.StretchToParentSize();
        rootVisualElement.Add(nodeView);

        //添加目录
        var toolbar = new Toolbar();

        var addButton = new Button(OnClickForToolBarAddNode);

        addButton.text = "添加节点";
        toolbar.Add(addButton);

        var saveButton = new Button(OnClickForToolBarSave);

        saveButton.text = "保存";
        toolbar.Add(saveButton);

        var loadButton = new Button(OnClickForToolBarLoad);

        loadButton.text = "读取";
        toolbar.Add(loadButton);

        rootVisualElement.Add(toolbar);
    }
Пример #2
0
        private UIElement LocateForModel(object o, DependencyObject dependencyObject, object arg3)
        {
            if (o is NodeBaseViewModel)
            {
                Type type = o.GetType();

                NodeBaseView diagramBaseView = new NodeBaseView();

                if (type.IsSubclassOf(typeof(NodeBaseViewModel)))
                {
                    UIElement        element = OriginalLocateForModel(o, dependencyObject, arg3);
                    FrameworkElement fe      = element as FrameworkElement;

                    diagramBaseView.Content = fe;
                    ViewModelBinder.Bind(o, element, arg3);
                    return(diagramBaseView);
                }
                return(diagramBaseView);
            }
            return(OriginalLocateForModel(o, dependencyObject, arg3));
        }