示例#1
0
        public NodeRootViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, TreeReportingViewModel.NodeType type,
                                 string text, bool lazyLoad = true, bool bold = true, MvvmColor color = null) :
            base(trvTree, parent, text, type.ToString(), TreeReportingViewModel.IconType.Unknown.ToString(), type, lazyLoad, bold, color ?? MvvmColor.Red)
        {
            switch (NodeType)
            {
            case TreeReportingViewModel.NodeType.DimensionsRoot:
                Icon = TreeReportingViewModel.IconType.Dimension.ToString();
                break;

            case TreeReportingViewModel.NodeType.DataSourcesRoot:
                Icon = TreeReportingViewModel.IconType.Schema.ToString();
                break;

            case TreeReportingViewModel.NodeType.ReportsRoot:
                Icon = TreeReportingViewModel.IconType.Report.ToString();
                break;

            case TreeReportingViewModel.NodeType.File:
                Icon = TreeReportingViewModel.IconType.Field.ToString();
                break;

            case TreeReportingViewModel.NodeType.Table:
                Icon = TreeReportingViewModel.IconType.Path.ToString();
                break;
            }
        }
        private void trvExplorer_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop, true))
                {
                    string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];

                    if (fileNames != null && fileNames.Length > 0)
                    {
                        TreeViewItem           trvNode    = new BauMvvm.Views.Tools.ToolsWpf().FindAncestor <TreeViewItem>((DependencyObject)e.OriginalSource);
                        IHierarchicalViewModel nodeTarget = null;

                        // Si se ha encontrado algún nodo, recoge el objeto ViewModel
                        if (trvNode != null)
                        {
                            nodeTarget = trvNode.Header as IHierarchicalViewModel;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ViewModel.PlugStudioController.ControllerWindow.ShowMessage("Excepción al recoger los archivos: " + exception.Message);
            }
        }
示例#3
0
 /// <summary>
 ///		Inicia la operación de Drag & Drop
 /// </summary>
 public void InitDragOperation(TreeView tree, IHierarchicalViewModel node)
 {
     if (node != null)
     {
         DragDrop.DoDragDrop(tree, new DataObject(KeyDataObject, node), DragDropEffects.Move);
     }
 }
 public TreeExplorerNodeViewModel(TreeTracksViewModel trvTree, IHierarchicalViewModel parent, string text, object tag,
                                  bool lazyLoad, bool isBold = false, MvvmColor foreground = null)
     : base(parent, text, tag, lazyLoad, foreground)
 {
     // Asigna las propiedades básicas
     Tree        = trvTree;
     ToolTipText = text;
     IsBold      = isBold;
     // Asigna el tipo de nodo
     if (tag is TrackManagerModel)
     {
         NodeType = GlobalEnums.NodeTypes.TrackManager;
     }
     else if (tag is TrackModel)
     {
         NodeType = GlobalEnums.NodeTypes.Track;
     }
     else if (tag is CategoryModel)
     {
         NodeType = GlobalEnums.NodeTypes.Category;
     }
     else if (tag is EntryModel)
     {
         NodeType = GlobalEnums.NodeTypes.Entry;
     }
 }
 public NodeStorageContainerViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, StorageModel storage,
                                      string container)
     : base(trvTree, parent, container, NodeType.StorageContainer, IconType.Path, container, true,
            true, MvvmColor.Green)
 {
     Storage   = storage;
     Container = container;
 }
示例#6
0
 public BaseTreeNodeViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, string text,
                              NodeType type, IconType icon, object tag,
                              bool lazyLoad, bool isBold = false, MvvmColor foreground = null)
     : base(parent, text, tag, lazyLoad, isBold, foreground)
 {
     TreeViewModel = trvTree;
     Type          = type;
     Icon          = icon;
 }
示例#7
0
 public ExplorerProjectNodeViewModel(ExplorerProjectViewModel treeViewModel, IHierarchicalViewModel parent,
                                     string text, ProjectItemDefinitionModel itemDefinition,
                                     object tag = null, bool lazyLoad = true,
                                     BauMvvm.ViewModels.Media.MvvmColor foreground = null)
     : base(parent, text, tag, lazyLoad, foreground)
 {
     TreeViewModel  = treeViewModel;
     ItemDefinition = itemDefinition;
 }
 public NodeStorageContainerFileViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent,
                                          StorageModel storage, BlobNodeModel blob, bool isFolder)
     : base(trvTree, parent, blob.Name, NodeType.File, isFolder ? IconType.Path : IconType.File,
            blob, false, isFolder,
            isFolder ? MvvmColor.Navy : MvvmColor.Black)
 {
     IsFolder = isFolder;
     Storage  = storage;
     Blob     = blob;
 }
 private bool CheckForNameConflict(IHierarchicalViewModel candidateChild)
 {
     foreach (IHierarchicalViewModel c in Children)
     {
         if (c.Name.Equals(candidateChild.Name))
         {
             return(true);
         }
     }
     return(false);
 }
示例#10
0
        /// <summary>
        ///		Obtiene el nodo de archivo que se está arrastrando
        /// </summary>
        public IHierarchicalViewModel GetDragDropFileNode(IDataObject dataObject)
        {
            IHierarchicalViewModel node = null;

            // Obtiene los datos que se están arrastrando
            if (dataObject.GetDataPresent(KeyDataObject))
            {
                node = dataObject.GetData(KeyDataObject) as IHierarchicalViewModel;
            }
            // Devuelve los datos del nodo que se está arrastrando
            return(node);
        }
        public virtual T GetRelativeOfTypeAndName <T>(string name) where T : HierarchicalViewModel
        {
            List <T> ret = new List <T>();
            IHierarchicalViewModel root = this; //what if this.Parent == null?

            do
            {
                root = root.Parent;
            } while (root.Parent != null);

            return(root.GetDescendantOfTypeAndName <T>(name));
        }
 /// <summary>
 ///		Comprueba si un nodo estaba en la lista de nodos abiertos
 /// </summary>
 private bool CheckIsExpanded(IHierarchicalViewModel node, List <IHierarchicalViewModel> nodesExpanded)
 {
     // Recorre la colección
     foreach (IHierarchicalViewModel nodeExpanded in nodesExpanded)
     {
         if ((nodeExpanded as TreeExplorerNodeViewModel)?.Text == (node as TreeExplorerNodeViewModel)?.Text)
         {
             return(true);
         }
     }
     // Si ha llegado hasta aquí es porque no ha encontrado nada
     return(false);
 }
示例#13
0
 public TreeResultNodeViewModel(TreeSearchFilesResultViewModel trvTree, IHierarchicalViewModel parent,
                                string text, string fileName, int line, string textFound, bool isBold, MvvmColor foreground)
     : base(parent, text, null, false, isBold, foreground)
 {
     TreeViewModel = trvTree;
     if (!string.IsNullOrWhiteSpace(fileName) && line < 1)
     {
         Text = System.IO.Path.GetFileName(fileName);
     }
     FileName  = fileName;
     Line      = line;
     TextFound = textFound;
 }
        public virtual List <T> GetRelativesOfType <T>() where T : HierarchicalViewModel
        {
            List <T> ret = new List <T>();
            IHierarchicalViewModel root = this; //what if this.Parent == null?

            do
            {
                root = root.Parent;
            } while (root.Parent != null);

            ret = root.GetDescendantsOfType <T>();
            return(ret);
        }
示例#15
0
        public NodeRootViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, NodeType type, string text) :
            base(trvTree, parent, text, type, IconType.Connection, type, true, true, MvvmColor.Red)
        {
            switch (type)
            {
            case NodeType.ConnectionRoot:
                Icon = IconType.Connection;
                break;

            case NodeType.DeploymentRoot:
                Icon = IconType.Deployment;
                break;
            }
        }
示例#16
0
 protected ControlHierarchicalViewModel(IHierarchicalViewModel parent, string text, object tag = null,
                                        bool lazyLoad = true, bool isBold = false, Media.MvvmColor foreground = null)
     : base(text, tag, isBold, foreground)
 {
     // Asigna las propiedades
     Parent   = parent;
     LazyLoad = lazyLoad;
     Children = new ObservableCollection <IHierarchicalViewModel>();
     // Si se va a tratar con una carga posterior, se añade un nodo vacío para que se muestre el signo + junto al nodo
     if (lazyLoad)
     {
         Children.Add(new ControlHierarchicalViewModel(null, "-----", null, false));
     }
 }
示例#17
0
 public NodeColumnViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, NodeColumnType columnNodeType, string text, DataSourceColumnModel column) :
     base(trvTree, parent, text, Explorers.TreeReportingViewModel.NodeType.ConnectionRoot.ToString(),
          Explorers.TreeReportingViewModel.IconType.Connection.ToString(), column, false, false, MvvmColor.Black)
 {
     // Asigna la columna
     ColumnNodeType = columnNodeType;
     Column         = column;
     // Asigna las propiedades
     if (column == null)             // ... si no es una columna, es una cabecera
     {
         IsBold     = true;
         Foreground = MvvmColor.Red;
     }
     else             // ... es una columna, le asigna sus propiedades
     {
         CanSelect = true;
         SortOrder = BaseColumnRequestModel.SortOrder.Undefined;
     }
     // Asigna los filtros
     if (column != null && trvTree is TreeQueryReportViewModel tree)
     {
         FilterWhere  = new ListReportColumnFilterViewModel(tree.ReportViewModel, this);
         FilterHaving = new ListReportColumnFilterViewModel(tree.ReportViewModel, this);
     }
     // Carga el combo
     LoadComboAggregation();
     // Normaliza las propiedades
     NormalizeProperties();
     // Asigna el manejador de eventos
     PropertyChanged += (sender, args) => {
         if (args.PropertyName.Equals(nameof(IsChecked)) && Column != null)
         {
             NormalizeProperties();
         }
     };
     ComboAggregationTypes.PropertyChanged += (sender, args) =>
     {
         if (args.PropertyName.Equals(nameof(ComboViewModel.SelectedItem)) && Column != null)
         {
             NormalizeProperties();
         }
     };
     // Asigna los comandos
     SortOrderCommand = new BaseCommand(_ => UpdateSortOrder(), _ => CanSort)
                        .AddListener(this, nameof(CanSort));
     FilterWhereCommand = new BaseCommand(_ => UpdateFilter(true), _ => CanFilterWhere)
                          .AddListener(this, nameof(CanSort));
     FilterHavingCommand = new BaseCommand(_ => UpdateFilter(false), _ => CanFilterHaving)
                           .AddListener(this, nameof(CanSort));
 }
示例#18
0
        public EbookNodeViewModel(TreeEbookViewModel trvTree, IHierarchicalViewModel parent, string text, TreeEbookViewModel.NodeType type,
                                  string urlBase, object tag)
            : base(trvTree, parent, text, type.ToString(), string.Empty, tag, false, type == TreeEbookViewModel.NodeType.Package)
        {
            UrlBase = urlBase;
            switch (type)
            {
            case TreeEbookViewModel.NodeType.Package:
                Foreground = BauMvvm.ViewModels.Media.MvvmColor.Navy;
                break;

            case TreeEbookViewModel.NodeType.Page:
                Foreground = BauMvvm.ViewModels.Media.MvvmColor.Black;
                break;
            }
        }
 public NodeFileViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, string fileName, bool isFolder)
     : base(trvTree, parent, string.Empty, NodeType.File, isFolder ? IconType.Path : IconType.File,
            fileName, isFolder, isFolder,
            isFolder ? MvvmColor.Navy : MvvmColor.Black)
 {
     FileName = fileName;
     IsFolder = isFolder;
     if (!string.IsNullOrWhiteSpace(FileName))
     {
         Text        = System.IO.Path.GetFileName(FileName);
         ToolTipText = FileName;
     }
     else
     {
         Text = "...";
     }
 }
        public void RemoveChild(IHierarchicalViewModel child)
        {
            //check interfaces for events to remove handlers for.
            if (child is INavigate)
            {
                INavigate ele = child as INavigate;
                ele.NavigationEvent -= Navigate;
            }
            //if (child is ICanClose)
            //{
            //    ICanClose ele = child as ICanClose;
            //    ele.Close -= RequestClose;
            //}
            _Children.Remove(child);//what if child doesnt exist?

            NotifyPropertyChanged(nameof(Children));
        }
示例#21
0
        /// <summary>
        ///		Añade un nodo
        /// </summary>
        protected ExplorerProjectNodeViewModel AddNode(IHierarchicalViewModel parent, string text, ProjectItemDefinitionModel definition, object tag, bool lazyLoad = false)
        {
            ExplorerProjectNodeViewModel node = new ExplorerProjectNodeViewModel(this, parent, text, definition, tag, lazyLoad);

            // Cambia la negrita
            node.IsBold     = definition?.IsBold ?? false;
            node.Icon       = definition?.Icon;
            node.Foreground = definition?.Foreground ?? MvvmColor.Black;
            // Añade el nodo a la lista
            if (parent == null)
            {
                Children.Add(node);
            }
            else
            {
                parent.Children.Add(node);
            }
            // Devuelve el nodo
            return(node);
        }
        public void AddChild(IHierarchicalViewModel child, bool allowDuplicateNames = false)
        {
            if (_Children == null)
            {
                _Children = new ObservableCollection <IHierarchicalViewModel>();
            }
            if (!allowDuplicateNames)
            {
                if (CheckForNameConflict(child))
                {
                    //silently fix the name?
                    int    i        = 1;
                    string prevname = child.Name;
                    do
                    {
                        child.Name = prevname + "_" + i;
                        i++;
                    } while (CheckForNameConflict(child));
                }
            }
            //check interfaces for events to add handlers for.
            if (child is INavigate)
            {
                INavigate ele = child as INavigate;
                ele.NavigationEvent += Navigate;
            }
            if (child is Base.Interfaces.IReportMessage)
            {
                Base.Interfaces.IReportMessage ele = child as Base.Interfaces.IReportMessage;
                Base.Implementations.MessageHub.Register(ele);
            }
            //if (child.GetType().GetInterfaces().Contains(typeof(ICanClose)))
            //{
            //    ICanClose ele = child as ICanClose;
            //    ele.Close += RequestClose;
            //}

            _Children.Add(child);
            child.Parent = this;
            NotifyPropertyChanged(nameof(Children));
        }
示例#23
0
        /// <summary>
        ///		Añade un nodo
        /// </summary>
        protected ExplorerProjectNodeViewModel AddNode(IHierarchicalViewModel parent, string text, object tag, bool isBold, MvvmColor foreground,
                                                       string icon, bool lazyLoad = false)
        {
            ExplorerProjectNodeViewModel node = new ExplorerProjectNodeViewModel(this, parent, text, null, tag, lazyLoad, foreground);

            // Cambia la negrita
            node.IsBold     = isBold;
            node.Icon       = icon;
            node.Foreground = foreground;
            // Añade el nodo a la lista
            if (parent == null)
            {
                Children.Add(node);
            }
            else
            {
                parent.Children.Add(node);
            }
            // Devuelve el nodo
            return(node);
        }
示例#24
0
        public NodeRestViewModel(TreeRestApiViewModel trvTree, IHierarchicalViewModel parent, string text,
                                 TreeRestApiViewModel.NodeType type, object tag, bool bold, BauMvvm.ViewModels.Media.MvvmColor color = null) :
            base(trvTree, parent, text, type.ToString(), null, tag, true, bold, color)
        {
            switch (tag)
            {
            case null:
                switch (type)
                {
                case TreeRestApiViewModel.NodeType.ContextsRoot:
                    Icon = TreeRestApiViewModel.IconType.ContextsRoot.ToString();
                    break;

                case TreeRestApiViewModel.NodeType.MethodsRoot:
                    Icon = TreeRestApiViewModel.IconType.MethodsRoot.ToString();
                    break;
                }
                break;

            case RestApiModel:
                Type = TreeRestApiViewModel.NodeType.RestApi.ToString();
                Icon = TreeRestApiViewModel.IconType.RestApi.ToString();
                break;

            case ContextModel:
                Type     = TreeRestApiViewModel.NodeType.Context.ToString();
                Icon     = TreeRestApiViewModel.IconType.Context.ToString();
                LazyLoad = false;
                Children.Clear();
                break;

            case MethodModel:
                Type     = TreeRestApiViewModel.NodeType.Method.ToString();
                Icon     = TreeRestApiViewModel.IconType.Method.ToString();
                LazyLoad = false;
                Children.Clear();
                break;
            }
        }
        /// <summary>
        ///		Obtiene el nodo o el nodo padre de tipo seleccionado
        /// </summary>
        private TypeData GetParentNodeOfType <TypeData>() where TypeData : BaseModel
        {
            IHierarchicalViewModel node = SelectedNode;

            // Obtiene el nodo de pista
            while (node != null && !((node as TreeExplorerNodeViewModel)?.Tag is TypeData))
            {
                if (node.Parent != null)
                {
                    node = node.Parent;
                }
            }
            // Devuelve el nodo seleccionado
            if ((node as TreeExplorerNodeViewModel)?.Tag is TypeData data)
            {
                return(data);
            }
            else
            {
                return(null);
            }
        }
示例#26
0
        public NodeRootViewModel(TreeSolutionBaseViewModel trvTree, IHierarchicalViewModel parent, TreeConnectionsViewModel.NodeType type, string text, bool lazyLoad = true) :
            base(trvTree, parent, text, type.ToString(), TreeConnectionsViewModel.IconType.Connection.ToString(), type, lazyLoad, true, MvvmColor.Red)
        {
            switch (type)
            {
            case TreeConnectionsViewModel.NodeType.ConnectionRoot:
                Icon = TreeConnectionsViewModel.IconType.Connection.ToString();
                break;

            case TreeConnectionsViewModel.NodeType.SchemaRoot:
                Icon = TreeConnectionsViewModel.IconType.Schema.ToString();
                break;

            case TreeConnectionsViewModel.NodeType.DeploymentRoot:
                Icon = TreeConnectionsViewModel.IconType.Deployment.ToString();
                break;
            }
            PropertyChanged += (sender, args) => {
                if (args.PropertyName.Equals(nameof(IsChecked), StringComparison.CurrentCultureIgnoreCase))
                {
                    CheckChildNodes();
                }
            };
        }
示例#27
0
 public NodeDataWarehouseViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, DataWarehouseModel dataWarehouse) :
     base(trvTree, parent, dataWarehouse.Name, TreeReportingViewModel.NodeType.DataWarehouse.ToString(), TreeReportingViewModel.IconType.Connection.ToString(),
          dataWarehouse, true, true, MvvmColor.Red)
 {
     DataWarehouse = dataWarehouse;
 }
 public NodeConnectionViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, ConnectionModel connection) :
     base(trvTree, parent, connection.Name, NodeType.Connection, IconType.Connection, connection, true, true, MvvmColor.Red)
 {
     Connection = connection;
 }
示例#29
0
 public NodeStorageViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, StorageModel storage)
     : base(trvTree, parent, storage.Name, TreeStorageViewModel.NodeType.Storage.ToString(), TreeStorageViewModel.IconType.Storage.ToString(), storage, true, true, MvvmColor.Navy)
 {
     Storage = storage;
 }
示例#30
0
 public BaseTreeNodeAsyncViewModel(BaseTreeViewModel trvTree, IHierarchicalViewModel parent, string text,
                                   string type, string icon, object tag,
                                   bool lazyLoad, bool isBold = false, MvvmColor foreground = null)
     : base(trvTree, parent, text, type, icon, tag, lazyLoad, isBold, foreground)
 {
 }