Exemplo n.º 1
0
        public DataBindingDialogModel(DataPanelModel model, SceneNode targetElement, ReferenceStep targetProperty)
            : base(targetElement, targetProperty)
        {
            this.isBinding = true;
            this.addXmlDataSourceCommand        = model.AddXmlDataSourceCommand;
            this.createSampleDataCommand        = model.CreateSampleDataCommand;
            this.createSampleDataFromXmlCommand = model.CreateSampleDataFromXmlCommand;
            this.addClrObjectDataSourceCommand  = model.AddClrObjectDataSourceCommand;
            DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(targetElement, (IPropertyId)targetProperty, true);

            if (dataContextInfo.DataSource.IsValidWithSource)
            {
                ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource(dataContextInfo.DataSource.SourceNode);
                if (schemaForDataSource != null && !(schemaForDataSource is EmptySchema))
                {
                    this.dataContext = schemaForDataSource.GetNodePathFromPath(dataContextInfo.DataSource.Path);
                }
            }
            this.bindsTwoWayByDefault = this.BindsTwoWayByDefault(targetElement, targetProperty);
            this.bindingFilterModes   = new ObservableCollection <BindingFilterMode>();
            this.bindingFilterModes.Add(BindingFilterMode.None);
            this.bindingFilterModes.Add(BindingFilterMode.FilterByType);
            ICollectionView defaultView = CollectionViewSource.GetDefaultView((object)this.bindingFilterModes);

            defaultView.MoveCurrentTo((object)BindingFilterMode.FilterByType);
            this.bindingSources  = new ObservableCollection <IBindingSourceModel>();
            this.dataSourceModel = new DataSourceBindingSourceModel(model, new DataSchemaItemFilter(this.BindingFilter));
            this.AddBindingSource((IBindingSourceModel)this.dataSourceModel);
            if (targetElement.ViewModel.ActiveEditingContainer is SceneElement)
            {
                this.elementPropertyModel = new ElementPropertyBindingSourceModel(targetElement, new DataSchemaItemFilter(this.BindingFilter));
                this.AddBindingSource((IBindingSourceModel)this.elementPropertyModel);
            }
            this.explicitDataContextModel = new ExplicitDataContextBindingSourceModel(targetElement, targetProperty, new DataSchemaItemFilter(this.BindingFilter));
            this.AddBindingSource((IBindingSourceModel)this.explicitDataContextModel);
            this.bindingSourcesProxy = new BindingProxy <IBindingSourceModel>();
            this.bindingSourcesProxy.PropertyChanged += new PropertyChangedEventHandler(this.BindingSourcesProxy_PropertyChanged);
            this.bindingSourcesView = (CollectionView) new DataBindingProxyCollectionView <IBindingSourceModel>(this.bindingSources, (IDataBindingProxy <IBindingSourceModel>) this.bindingSourcesProxy);
            BindingSceneNode binding = targetElement.GetBinding((IPropertyId)targetProperty);

            if (binding != null)
            {
                this.SetExistingBindingValues(binding);
            }
            else if (!(this.explicitDataContextModel.Schema is EmptySchema))
            {
                this.bindingSourcesView.MoveCurrentTo((object)this.explicitDataContextModel);
            }
            else
            {
                this.bindingSourcesView.MoveCurrentTo((object)this.dataSourceModel);
            }
            if (binding == null || !binding.IsModeSet)
            {
                this.CurrentBindingMode = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, this.CurrentDataPath).Mode;
            }
            this.bindingSourcesView.CurrentChanging += new CurrentChangingEventHandler(this.BindingSourcesView_CurrentChanging);
            defaultView.CurrentChanged += new EventHandler(this.BindingFilterModesView_CurrentChanged);
            this.PropertyChanged       += new PropertyChangedEventHandler(this.DataBindingDialogModel_PropertyChanged);
        }
 public void Unhook()
 {
     if (this.model != null)
     {
         this.model.PropertyChanged -= new PropertyChangedEventHandler(this.Model_PropertyChanged);
         this.model = (DataPanelModel)null;
     }
     this.UnhookCurrentDataSource();
 }
Exemplo n.º 3
0
 public DataSchemaItem(DataSchemaNodePath nodePath, SchemaItem schemaItem, DataPanelModel model, SelectionContext <DataModelItemBase> selectionContext)
     : base(selectionContext)
 {
     this.nodePath           = nodePath;
     this.schemaItem         = schemaItem;
     this.model              = model;
     this.doubleClickCommand = (ICommand) new DelegateCommand(new DelegateCommand.SimpleEventHandler(this.OnDoubleClicked));
     this.PropertyChanged   += new PropertyChangedEventHandler(this.DataSchemaItem_PropertyChanged);
 }
 public DataSourceBindingSourceModel(DataPanelModel model, DataSchemaItemFilter dataSchemaFilter)
 {
     this.model = model;
     this.Model.PropertyChanged          += new PropertyChangedEventHandler(this.Model_PropertyChanged);
     this.dataSchemaFilter                = dataSchemaFilter;
     this.dataSources                     = new ObservableCollection <DataSourceItem>();
     this.dataSourcesView                 = CollectionViewSource.GetDefaultView((object)this.dataSources);
     this.dataSourcesView.CurrentChanged += new EventHandler(this.DataSourcesView_CurrentChanged);
     this.RefreshDataSources();
 }
Exemplo n.º 5
0
 public XmlDataSourceDialogModel(DataPanelModel dataPanelModel, string initialDataSourceName, DataSourceDialogMode mode)
 {
     this.dataPanelModel          = dataPanelModel;
     this.initialDataSourceName   = initialDataSourceName;
     this.dataSourceName          = initialDataSourceName;
     this.suggestedName           = initialDataSourceName;
     this.browseForXmlFileCommand = (ICommand) new DelegateCommand(new DelegateCommand.SimpleEventHandler(this.OnBrowseForXmlFile));
     this.mode = mode;
     this.UpdateIsProjectScope(true);
 }
Exemplo n.º 6
0
 private void ViewService_ActiveViewChanged(object sender, ViewChangedEventArgs e)
 {
     if (this.model == null || this.model.ViewModel != this.ActiveSceneViewModel)
     {
         this.model = this.ActiveSceneViewModel == null ? new DataPanelModel((SceneViewModel)null, false) : this.ActiveSceneViewModel.DataPanelModel;
         this.model.AddDataSourceMenuHost = this.menuHost;
         this.DataContext = (object)this.model;
     }
     this.UpdatePaneVisibility();
 }
 public ClrAssemblyDataSourceModel(SelectionContext <TypeItem> selectionContext, DataPanelModel model, Assembly runtimeAssembly, Assembly referenceAssembly, bool hideSystemTypesWithoutDefaultConstructor, bool hideCustomTypesWithoutDefaultConstructor, bool hideAbstractSystemTypes)
     : base(model.ViewModel, runtimeAssembly, referenceAssembly)
 {
     this.model            = model;
     this.selectionContext = selectionContext;
     this.HideSystemTypesWithoutDefaultConstructor = hideSystemTypesWithoutDefaultConstructor;
     this.HideCustomTypesWithoutDefaultConstructor = hideCustomTypesWithoutDefaultConstructor;
     this.hideAbstractSystemTypes = hideAbstractSystemTypes;
     this.LoadAssembly();
 }
Exemplo n.º 8
0
        private DataBindingDialog(SceneNode targetElement, ReferenceStep targetProperty)
        {
            FrameworkElement element = Microsoft.Expression.DesignSurface.FileTable.GetElement("Resources\\DataPane\\DataBindingDialog.xaml");

            this.DialogContent  = (UIElement)element;
            this.ResizeMode     = ResizeMode.NoResize;
            this.SizeToContent  = SizeToContent.WidthAndHeight;
            this.Title          = StringTable.CreateDatabindingDialogTitle;
            this.dataPanelModel = new DataPanelModel(targetElement.ViewModel, true);
            this.model          = new DataBindingDialogModel(this.dataPanelModel, targetElement, targetProperty);
            element.DataContext = (object)this.model;
        }
Exemplo n.º 9
0
 internal DataPane(DesignerContext designerContext)
 {
     this.designerContext = designerContext;
     this.dropUtility     = new FileDropUtility(this.designerContext.ProjectManager, (FrameworkElement)this, new IDocumentType[1]
     {
         designerContext.DocumentTypeManager.DocumentTypes[DocumentTypeNamesHelper.Xml]
     });
     this.model = this.ActiveSceneViewModel == null ? new DataPanelModel((SceneViewModel)null, false) : this.ActiveSceneViewModel.DataPanelModel;
     this.designerContext.ViewService.ActiveViewChanged           += new ViewChangedEventHandler(this.ViewService_ActiveViewChanged);
     this.designerContext.WorkspaceService.ActiveWorkspaceChanged += new EventHandler(this.WorkspaceService_ActiveWorkspaceChanged);
     this.InitializeComponent();
 }
Exemplo n.º 10
0
        public XmlDataSourceDialog(DataPanelModel dataPanelModel, string initialDataSourceName, DataSourceDialogMode mode)
        {
            this.model = new XmlDataSourceDialogModel(dataPanelModel, initialDataSourceName, mode);
            FrameworkElement element = FileTable.GetElement("Resources\\DataPane\\XmlDataSourceDialog.xaml");

            ((UIElement)element.FindName("XmlDataSourceUrlTextBox")).LostFocus += new RoutedEventHandler(this.DataSourceUrlTextBox_LostFocus);
            element.DataContext           = (object)this.model;
            this.DialogContent            = (UIElement)element;
            this.Title                    = this.DialogTitle;
            this.SizeToContent            = SizeToContent.WidthAndHeight;
            this.controlNameMessageBubble = new MessageBubbleHelper((UIElement)(element.FindName("DataSourceNameTextBox") as TextBox), (IMessageBubbleValidator) new DataSourceNameValidator(this.model));
        }
Exemplo n.º 11
0
 public DataHostItem(DataSourceHost dataSourceHost, DataPanelModel model, string name, string automationId)
     : base(model.SelectionContext)
 {
     this.dataSourceHost      = dataSourceHost;
     this.DataSources         = new ObservableCollectionAggregator();
     this.ResourceDataSources = new DataSourcesCollection <DataSourceItem>(this);
     this.FileDataSources     = new DataSourcesCollection <FileBasedDataSourceItem>(this);
     this.DataSources.AddCollection((IList)this.ResourceDataSources);
     this.DataSources.AddCollection((IList)this.FileDataSources);
     this.doubleClickCommand = (ICommand) new DelegateCommand(new DelegateCommand.SimpleEventHandler(this.OnDoubleClick));
     this.name              = name;
     this.automationId      = automationId;
     this.documentHasErrors = this.CalculateDocumentHasErrors();
 }
Exemplo n.º 12
0
 public SchemaItem(ISchema schema, DataPanelModel model, SelectionContext <DataModelItemBase> selectionContext)
 {
     this.model = model;
     this.itemSelectionContext = selectionContext ?? (SelectionContext <DataModelItemBase>) new SingleSelectionContext <DataModelItemBase>();
     this.itemSelectionContext.PropertyChanged += new PropertyChangedEventHandler(this.itemSelectionContext_PropertyChanged);
     this.schema    = schema;
     this.flattener = new VirtualizingTreeItemFlattener <DataModelItemBase>((ITreeViewItemProvider <DataModelItemBase>) this);
     if (this.schema.Root != null)
     {
         DataSchemaNodePath nodePath = new DataSchemaNodePath(this.schema, this.schema.Root);
         this.itemSelectionContext.Clear();
         this.ClearSchemaItemTree(this.root);
         this.root = new DataSchemaItem(nodePath, this, this.model, this.itemSelectionContext);
         this.root.EnsureChildrenExpanded();
     }
     this.OnPropertyChanged("Root");
     this.flattener.RebuildList();
 }
Exemplo n.º 13
0
        protected ObjectDataSourceDialog(DataPanelModel model, string defaultName)
        {
            this.Model = model;
            FrameworkElement element = FileTable.GetElement("Resources\\DataPane\\ClrObjectDataSourceDialog.xaml");

            element.DataContext = (object)this;
            this.DialogContent  = (UIElement)element;
            HeaderedContentControl headeredContentControl = (HeaderedContentControl)LogicalTreeHelper.FindLogicalNode((DependencyObject)this.DialogContent, "DataSourceNameContainer");

            headeredContentControl.ApplyTemplate();
            this.dataSourceNameTextBox      = (TextBox)headeredContentControl.Template.FindName("DataSourceNameTextBox", (FrameworkElement)headeredContentControl);
            this.dataSourceNameTextBox.Text = defaultName;
            this.Initialize(this.Model.DesignerContext);
            this.ResizeMode    = ResizeMode.CanResizeWithGrip;
            this.SizeToContent = SizeToContent.Manual;
            this.Width         = 400.0;
            this.Height        = 600.0;
            this.suggestedName = this.dataSourceNameTextBox.Text;
        }
Exemplo n.º 14
0
 public DesignObjectDataSourceDialog(DataPanelModel model)
     : base(model, "SampleData")
 {
     this.Title = StringTable.DesignObjectDataSourceDialogTitle;
 }
Exemplo n.º 15
0
        public static SceneNode CreateClrObjectDataSource(out string dataSourceName, out Type dataSourceType, DataPanelModel model)
        {
            SceneNode sceneNode = (SceneNode)null;

            dataSourceName = (string)null;
            dataSourceType = (Type)null;
            ClrObjectDataSourceDialog dataSourceDialog = new ClrObjectDataSourceDialog(model);
            bool?nullable = dataSourceDialog.ShowDialog();

            if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? true : false)) != 0)
            {
                PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.AddClrDataSource);
                dataSourceType = dataSourceDialog.ObjectType;
                dataSourceName = dataSourceDialog.DataSourceName;
                if (dataSourceDialog.ObjectType != (Type)null)
                {
                    dataSourceName = dataSourceName.Trim();
                    SceneViewModel activeSceneViewModel = model.DesignerContext.ActiveSceneViewModel;
                    DocumentNode   node = (DocumentNode)activeSceneViewModel.Document.DocumentContext.CreateNode(dataSourceDialog.ObjectType);
                    sceneNode = activeSceneViewModel.GetSceneNode(node);
                }
            }
            return(sceneNode);
        }
Exemplo n.º 16
0
 private ClrObjectDataSourceDialog(DataPanelModel model)
     : base(model, ClrObjectDataSourceDialog.DefaultClrObjectDataSourceName)
 {
     this.Title = StringTable.AddClrObjectDataSourceDialogTitle;
 }
Exemplo n.º 17
0
 public DataSourceItem(ISchema schema, DataPanelModel model)
     : base(model.SelectionContext)
 {
     this.model      = model;
     this.schemaItem = new SchemaItem(schema, model, model.SelectionContext);
 }
Exemplo n.º 18
0
 public FileBasedDataSourceItem(ISchema schema, DataPanelModel model, IProjectItem designDataFile)
     : base(schema, model)
 {
     this.DesignDataFile = designDataFile;
 }