public TmNode(TmNodeType nodeType, string name, TmNode parent, ThemeData data, Metadata metadata, string desc, DateTime? pubDate) { _type = nodeType; _name = name; Parent = parent; _pubDate = pubDate.HasValue ? pubDate.Value : DefaultPubDate; //_readonly = (Parent == null) ? false : Parent._readonly; _description = desc; // Always create a data and Metadata object, else data binding in properties form won't work. _data = data ?? new ThemeData(); _data.PropertyChanged += Data_PropertyChanged; Metadata = metadata ?? new Metadata(); Metadata.PropertyChanged += Metadata_PropertyChanged; if (_type == TmNodeType.ThemeList) { Author = new ThemeListAuthor(); _status = ThemeListStatus.Created; _dataStore = TryToGetDataStore(); // TryToGetDataStore() will set _readonly for theme ThemeList = this; } }
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]); }
internal static void BuildSubThemesForMapDocument(TmNode node) { IMapDocument mapDoc = MapUtilities.GetMapDocumentFromFileName(node.Data.Path); int count = mapDoc.MapCount; for (int i = 0; i < count; i++) BuildSubThemeForMap(node, mapDoc.Map[i]); mapDoc.Close(); }
//Load From MDB, SubTheme, overloads public ThemeNode(string name, TmNode parent, ThemeData data, Metadata metadata, string desc, DateTime? pubDate) : base(name, parent, metadata, desc) { IsInitialized = false; Data = data; PubDate = pubDate.HasValue ? pubDate.Value : DefaultPubDate; //Age is not a saved property, so calling the setter will not flag the node as edited Age = CalculateAge(); IsInitialized = true; }
public ShortcutNode(TmNode target) : this() { if (target == null) throw new ArgumentNullException("target"); IsInitialized = false; Name = "Shortcut to " + target.Name; Target = target; IsInitialized = true; }
private static void BuildSubThemesForGroupLayer(TmNode node, ILayer layer) { // GroupLayer implements IGroupLayer and ICompositeLayer Debug.Assert(layer is ICompositeLayer, "BuildSubThemes must be called with a Group Layer."); if (!(layer is ICompositeLayer)) return; ICompositeLayer gl = (ICompositeLayer)layer; int count = gl.Count; for (int i = 0; i < count; i++) BuildSubThemeForLayer(node, gl.Layer[i]); }
public TmNode(string name, TmNode parent, Metadata metadata, string desc) { IsInitialized = false; Name = name; Description = desc; Metadata = metadata; Parent = parent; if (parent != null) IsUpdating = parent.IsUpdating; IsInitialized = true; //FIXME: Check that I don't send messages or updates while Initializing. }
public TmTreeNode(TmNode tmNode) { if (tmNode == null) throw new ArgumentNullException("tmNode"); TmNode = tmNode; UpdateProperties(); tmNode.PropertyChanged += Data_PropertyChanged; tmNode.NodeHasBeenUpdated += Data_ReloadNode; tmNode.ChildRemoved += Data_ChildRemoved; tmNode.ChildAdded += Data_ChildAdded; foreach (TmNode child in tmNode.Children) Nodes.Add(new TmTreeNode(child)); }
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); } }
private static void ReloadTheme(TmNode node) { Debug.Assert(node != null, "There is no bound TMNode for this property panel"); if (node == null) { MessageBox.Show("Internal Error: Unable to find the node to reload."); return; } LoadingForm form = new LoadingForm(); if (node is ThemeNode) form.Message = "Reloading " + node.Name + "..."; else form.Message = "Reloading all themes in " + node.Name + "..."; form.AllowCancel = true; form.Node = node; form.Command = form.ReloadNode; form.ShowDialog(); //Treeview may need updating. //Data type (icon) may have changed, and sub-themes may have been added/removed. node.BroadcastNodeHasBeenUpdatedEvent(); }
internal static void BuildThemesForLayerFile(TmNode tmNode) { ILayer layer = null; try { layer = LayerUtilities.GetLayerFromLayerFile(tmNode.Data.Path); } catch (Exception ex) { Debug.Print("Unable to load layer file: " + tmNode.Data.Path + " " + ex.Message); tmNode.Data.Type = "Unable to load layer file (" + ex.Message + ")"; return; } tmNode.Data.Type = LayerUtilities.GetLayerDescriptionFromLayer(layer); if (tmNode.Data.Type == "Group Layer") { BuildSubThemesForGroupLayer(tmNode, layer); } else BuildThemeDataForLayer(tmNode.Data, layer); LayerUtilities.CloseOpenLayerFile(); }
private void DisplayPropertyPanel(Control.ControlCollection controls, TmNode node) { controls.Clear(); if (node == null) return; if (propertiesForm == null) propertiesForm = new PropertiesForm().CommonInit(); if (node is ThemeListNode) { AddPropertyPanelToForm(controls, propertiesForm.themelistPanel, node.IsReadOnly); PopulateThemeListPropertyPanel(propertiesForm, (ThemeListNode)node); } if (node is CategoryNode) { AddPropertyPanelToForm(controls, propertiesForm.categoryPanel, node.IsReadOnly); PopulateCategoryPropertyPanel(propertiesForm, (CategoryNode)node); } if (node is ThemeNode || node is SubThemeNode) { AddPropertyPanelToForm(controls, propertiesForm.themePanel, node.IsReadOnly); PopulateThemePropertyPanel(propertiesForm, (ThemeNode)node); } }
private void UpdateInfoDisplay() { TmNode node = CurrentTMNode; int newStyleSheetIndex = styleSheetComboBox.SelectedIndex; if (_infoPagesAreVisible) { switch (infoTabControl.SelectedIndex) { case 0: if (node == null || node != _previousMetadataNode || newStyleSheetIndex != _previousStyleSheetIndex) { DisplayMetadata(node); _previousMetadataNode = node; _previousStyleSheetIndex = newStyleSheetIndex; } break; case 1: if (node == null || node != _previousPreviewNode) { DisplayPreview(node); _previousPreviewNode = node; } break; case 2: if (node == null || node != _previousPropertiesNode) { DisplayProperties(node); _previousPropertiesNode = node; } break; default: break; } } }
private void DisplayPreview(TmNode node) { Trace.TraceInformation("Display map preview for node: " + (node == null ? "null" : node.ToString())); ThemeNode tNode = node as ThemeNode; if (tNode == null) { ShowTextInPreviewPage("Select a theme"); } else { if (tNode.HasDataToPreview) { string msg = null; try { if (!MapInPreviewPage) ShowTextInPreviewPage("Loading map viewer..."); msg = MapViewer.LoadMapFileInControl(tNode.Data.Path, tabPage5); } catch (Exception ex) { msg = ex.Message; } if (!string.IsNullOrEmpty(msg)) { ShowTextInPreviewPage(msg); } } else { ShowTextInPreviewPage("Theme cannot be previewed, please select another theme"); } } }
private void DisplayProperties(TmNode node) { Trace.TraceInformation("Display properties for node: " + (node == null ? "null" : node.ToString())); if (node == null) { ShowTextInPropertiesPage("Select a Theme List, Category, or Theme"); } else { DisplayPropertyPanel(tabPage6.Controls, node); } }
private void SaveAs(TmNode node) { saveFileDialog1.FileName = node.Name; if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) { try { if (node is ThemeListNode) ((ThemeListNode)node).SaveAs(saveFileDialog1.FileName); else if (node is CategoryNode) { themesTreeView.Add(((CategoryNode)node).ToThemeList(saveFileDialog1.FileName)); } else MessageBox.Show("Save As... is only valid on a Theme List or a Category"); } catch (Exception ex) { MessageBox.Show(string.Format("Unable to save Theme List '{0}'\n in file '{1}'\n{2}", node.Name, saveFileDialog1.FileName, ex.Message), "Oh no!"); } } }
private void DisplayMetadata(TmNode node) { Trace.TraceInformation("Display metadata for node: " + (node == null ? "null" : node.ToString())); if (node == null) { LoadDefaultBrowser(); //Loads a default start page return; } Debug.Assert(node.Metadata != null, "Node has no metadata object to display"); if (node.Metadata == null) { LoadDefaultBrowser(); //Loads a default start page return; } if (_cachedSafeNoMetadataTemplate == null) _cachedSafeNoMetadataTemplate = GetSafeNoMetadataTemplate(); if (string.IsNullOrEmpty(node.Metadata.Path)) webBrowser.DocumentText = string.Format(_cachedSafeNoMetadataTemplate, node.Name, node, "<empty>", "No Metadata", null); else { try { node.Metadata.Display(webBrowser, styleSheetComboBox.SelectedItem as StyleSheet); } catch (MetadataDisplayException ex) { webBrowser.DocumentText = string.Format(_cachedSafeNoMetadataTemplate, node.Name, node, node.Metadata.Path, ex.Message, ex); } } }
//Load from MDB, ThemeBuilder, overloads public SubThemeNode(string name, TmNode parent, ThemeData data, Metadata metadata, string desc, DateTime? pubDate) : base(name, parent, data, metadata, desc, pubDate) { }
//MDB Load, overloads public CategoryNode(string name, TmNode parent, Metadata metadata, string desc) : base(name, parent, metadata, desc) { }
internal DataTable ListThemesWithUnknownIcon(TmNode themeList, BackgroundWorker bw) { DataTable data = new DataTable(); data.Columns.Add(new DataColumn("Category", typeof(string))); data.Columns.Add(new DataColumn("Theme", typeof(string))); data.Columns.Add(new DataColumn("Type", typeof(string))); data.Columns.Add(new DataColumn("Data Path", typeof(string))); data.Columns.Add(new DataColumn("Data Type", typeof(string))); foreach (var theme in themeList.Recurse(x => x.Children) .Where(n => (n.IsTheme || n.IsSubTheme) && (n.ImageKey == "Theme" || n.ImageKey == "Themelock" || n.ImageKey == "Themenew"))) { DataRow row = data.NewRow(); row["Category"] = theme.CategoryPath(); row["Theme"] = theme.Name; row["Type"] = (theme.IsTheme) ? "Theme" : "SubTheme"; row["Data Path"] = theme.Data.Path; row["Data Type"] = theme.Data.Type; data.Rows.Add(row); if (bw.CancellationPending) return data; } return data; }
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); } }
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); } }
private TmTreeNode Add(TmNode node, TreeNodeCollection nodes) { if (node.IsHidden && !Settings.Default.ShowHiddenThemes) return null; TmTreeNode newNode = new TmTreeNode(node); nodes.Add(newNode); return newNode; }
internal DataTable ListDataSources(TmNode themeList, BackgroundWorker bw) { DataTable data = new DataTable(); data.Columns.Add(new DataColumn("Category", typeof(string))); data.Columns.Add(new DataColumn("Theme", typeof(string))); data.Columns.Add(new DataColumn("Type", typeof(string))); data.Columns.Add(new DataColumn("Data Path", typeof(string))); data.Columns.Add(new DataColumn("Data Set Name", typeof(string))); data.Columns.Add(new DataColumn("Data Type", typeof(string))); data.Columns.Add(new DataColumn("Workspace Type", typeof(string))); data.Columns.Add(new DataColumn("Workspace ProgID", typeof(string))); data.Columns.Add(new DataColumn("Workspace Path", typeof(string))); data.Columns.Add(new DataColumn("Container", typeof(string))); data.Columns.Add(new DataColumn("Container Type", typeof(string))); data.Columns.Add(new DataColumn("Data Source", typeof(string))); data.Columns.Add(new DataColumn("Data Set Type", typeof(string))); data.Columns.Add(new DataColumn("Data Source Path", typeof(string))); foreach (var theme in themeList.Recurse(x => x.Children) .Where(n => (n.IsTheme || n.IsSubTheme))) { DataRow row = data.NewRow(); //reload cannot be done in the background, because treeview // on UI thread gets property updates //theme.ReloadTheme(); row["Category"] = theme.CategoryPath(); row["Theme"] = theme.Name; row["Type"] = (theme.IsTheme) ? "Theme" : "SubTheme"; row["Data Path"] = theme.Data.Path; row["Data Set Name"] = theme.Data.DataSetName; row["Data Type"] = theme.Data.Type; row["Workspace Type"] = theme.Data.WorkspaceType; row["Workspace ProgID"] = theme.Data.WorkspaceProgId; row["Workspace Path"] = theme.Data.WorkspacePath; row["Container"] = theme.Data.Container; row["Container Type"] = theme.Data.ContainerType; row["Data Source"] = theme.Data.DataSourceName; row["Data Set Type"] = theme.Data.DataSetType; row["Data Source Path"] = theme.Data.DataSource; data.Rows.Add(row); if (bw.CancellationPending) return data; } return data; }
public TmTreeNode Insert(int index, TmNode inNode, TreeNode atNode) { if (inNode == null) throw new ArgumentNullException("inNode"); TreeNode newParentNode = atNode ?? SelectedNode; TreeNodeCollection nodes = newParentNode == null ? Nodes : newParentNode.Nodes; if (nodes == Nodes) RootNodes.Add(inNode); if (index < 0 || index > nodes.Count) index = nodes.Count; //FIXME - I think this is broken. // I am using index to place this TM node in a treeview, with no // check on the structure of the tree that the TM node lives in. TmTreeNode newNode = new TmTreeNode(inNode); nodes.Insert(index, newNode); return newNode; }
internal void Add(TmNode child) { if (_children == null) _children = new List<TmNode>(); _children.Add(child); child.Parent = this; //My age is based on age of my youngest child Age = CalculateAge(); MarkAsChanged(); OnChildAdded(child, _children.Count - 1); }
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); } }
private void Remove(TmNode child) { if (_children != null && child != null) { _children.Remove(child); //My age is based on age of my youngest child Age = CalculateAge(); MarkAsChanged(); OnChildRemoved(child); } }
// When you add a node to the tree, it goes in to the root collection. // if you want to add a node at a lower point in the tree, then add it to a TmNode\ public TmTreeNode Add(TmNode newNode) { Debug.Assert(newNode != null, "Null argument exception for node"); if (newNode == null) return null; // Do not allow the same list loaded twice. if (newNode is ThemeListNode && //(string.IsNullOrEmpty(newNode.Data.Path) || FindThemeListNode(((ThemeListNode)newNode).FilePath) != null) return null; RootNodes.Add(newNode); return Add(newNode, Nodes); }
protected void OnChildRemoved(TmNode node) { TmNodeEventHandler handle = ChildRemoved; if (handle != null && !IsUpdating && IsInitialized) handle(this, new TmNodeEventArgs { Index = -1, Node = node }); }