Ejemplo n.º 1
0
 private static void BuildSubThemeForMap(TmNode node, IMap map)
 {
     TmNode newNode = new TmNode(TmNodeType.Theme, map.Name, node, new ThemeData(null, "Map Data Frame", null), null, null, null);
     node.Add(newNode);
     int count = map.LayerCount;
     for (int i = 0; i < count; i++)
         BuildSubThemeForLayer(newNode, map.Layer[i]);
 }
Ejemplo n.º 2
0
        private static void BuildSubThemeForLayer(TmNode node, ILayer subLayer)
        {
            if (subLayer is GroupLayer)
            {
                TmNode newNode = new TmNode(TmNodeType.Theme, subLayer.Name, node, new ThemeData(null, "Group Layer", null), null, null, null);
                node.Add(newNode);
                BuildSubThemesForGroupLayer(newNode, subLayer);
            }
            else
            {
                string dataType = LayerUtilities.GetLayerDescriptionFromLayer(subLayer);
                ThemeData data = new ThemeData(null, dataType, null);

                BuildThemeDataForLayer(data, subLayer);

                Metadata md = Metadata.Find(data);
                TmNode newNode = new TmNode(TmNodeType.Theme, subLayer.Name, node, data, md, null, null);
                node.Add(newNode);
            }
        }
Ejemplo n.º 3
0
 private void MoveNode(TmNode destinationNode, TmNode oldNode)
 {
     if (oldNode != destinationNode)
     {
         if (oldNode.Parent == null)
         {
             RootNodes.Remove(oldNode);
             var node = Nodes.Cast<TmTreeNode>().First(n => n.TmNode == oldNode);
             Nodes.Remove(node);
         }
         else
             oldNode.Delete();
         if (destinationNode == null)
             Add(oldNode);
         else
             destinationNode.Add(oldNode);
     }
 }
Ejemplo n.º 4
0
 private void CopyNode(TmNode destinationNode, TmNode oldNode)
 {
     //TmNode newNode = oldNode.Clone() as TmNode;
     TmNode newNode = oldNode.DeepCopy();
     Debug.Assert(newNode != null, "Could not clone node from clipboard");
     if (newNode != null)
     {
         if (destinationNode == null)
             Add(newNode);
         else
             destinationNode.Add(newNode);
     }
 }
Ejemplo n.º 5
0
        private void PasteAsTmNodeListAtTmNode(TmNode currentNode)
        {
            IEnumerable<TmNode> nodes = Clipboard.GetData("TmNodeList") as IEnumerable<TmNode>;
            if (nodes != null && nodes.Count() > 0)
            {

                if (currentNode == null)
                    foreach (TmNode node in nodes)
                        Add(node);
                else
                    foreach (TmNode node in nodes)
                        currentNode.Add(node);
                // select all the newly pasted nodes.
                //ClearSelectedNodes();
                // FIXME - I think each select will unselect the previously selected,
                // we may need a SelectNodes(Enumerable<TmTreeNode>) method
                //foreach (TmNode node in nodes)
                //    SelectNode(node);
            }
        }
Ejemplo n.º 6
0
 //Also called from the search form.
 internal void DisplaySearchResults(SearchParameters searchParams, IEnumerable<TmNode> results)
 {
     //I need to cache the enumeration for two reasons:
     // 1: I access the enumeration to get the count, and to access the nodes.
     //    A new search is done each time the enumeration is iterated (even for counting).
     // 2: The enumeration searches the treeviews _selected nodes.
     //    I clear the searchtrees selected node when I create the results, 
     //    therefore no results are returned if the search was done on the search tree.
     IList<TmNode> nodes = results.ToList();
     if (nodes == null || nodes.Count == 0)
         MessageBox.Show(string.Format("Sorry, your search for '{0}' in {1} has no results.",
                                       searchParams.Description, searchParams.Location));
     else
     {
         string resultsNodeLabel = string.Format("{0} result{1} for '{2}' in {3}",
             nodes.Count, nodes.Count == 1 ? "" : "s", searchParams.Label, searchParams.Location);
         searchTreeView.BeginUpdate();
         searchTreeView.ClearSelectedNodes();
         TmNode catNode = new TmNode(TmNodeType.Category, resultsNodeLabel);
         TmTreeNode newNode = searchTreeView.Add(catNode);
         if (newNode == null)
         {
             MessageBox.Show("Unable to add results to display");
             return;
         }
         foreach (TmNode node in nodes)
             catNode.Add(node.Copy());
         searchTreeView.SelectNode(newNode);
         newNode.Expand();
         searchTreeView.EndUpdate();
         CurrentTreeView = searchTreeView;
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new Theme List Node based on the contents of the current Category Node
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 internal TmNode CopyAsThemeList(string path)
 {
     Debug.Assert(this.IsCategory, "Should only be called on a Category Node");
     TmNode newNode = new TmNode(TmNodeType.ThemeList, this.Name, null, new ThemeData(path), this.Metadata.Clone() as Metadata, this.Description, null);
     ThemeListAuthor author = new ThemeListAuthor();
     author["Name"] = Environment.UserName;
     newNode.Author = author;
     foreach (var child in Children)
         newNode.Add(child.Copy());
     newNode.SaveAs(path);
     return newNode;
 }