void OnCurrentThemeChanged() { if (CurrentTheme != null) { mindMapView1.ApplyChartTheme(CurrentTheme); myPropertyGrid1.SelectedObject = CurrentTheme; TxbThemeName.Text = CurrentTheme.IsInternal ? Lang._(CurrentTheme.Name) : CurrentTheme.Name; TxbThemeName.ReadOnly = CurrentTheme.IsInternal; TsbCopy.Enabled = true; TsbDelete.Enabled = !CurrentTheme.IsInternal; TxbRemark.Text = CurrentTheme.Description; TxbRemark.ReadOnly = CurrentTheme.IsInternal; CkbDefaultTheme.Checked = IsDefaultTheme(CurrentTheme); } else { TxbThemeName.Text = string.Empty; TxbThemeName.ReadOnly = true; myPropertyGrid1.SelectedObject = null; TsbCopy.Enabled = false; TsbDelete.Enabled = false; TxbRemark.Text = string.Empty; TxbRemark.ReadOnly = true; CkbDefaultTheme.Checked = false; } ThemeNode node = FindTreeNode(CurrentTheme); if (node != null) { treeView1.SelectedNode = node; } }
void GenerateTree(TreeNodeCollection nodes, ChartThemeFolder folder) { ThemeFolderNode nodeFolder = new ThemeFolderNode(folder); nodeFolder.Text = Lang._(folder.Name); nodeFolder.ImageIndex = 0; nodeFolder.SelectedImageIndex = 0; nodes.Add(nodeFolder); foreach (var subFolder in folder.Folders) { GenerateTree(nodeFolder.Nodes, subFolder); } foreach (var theme in folder.Themes) { var nodeTheme = new ThemeNode(theme); if (theme.IsInternal) { nodeTheme.Text = Lang._(theme.Name); } nodeTheme.ImageIndex = nodeTheme.SelectedImageIndex = GetImageIndex(theme.Icon); nodeTheme.StateImageIndex = IsDefaultTheme(theme) ? 1 : 0; nodeFolder.Nodes.Add(nodeTheme); } }
ThemeNode CreateThemeNode(ChartTheme theme) { ThemeNode node = new ThemeNode(theme); node.ImageIndex = node.SelectedImageIndex = GetImageIndex(theme.Icon); node.StateImageIndex = IsDefaultTheme(theme) ? 1 : 0; // node.Text = theme.Name; return(node); }
void DeleteTheme(ChartTheme theme) { if (theme == null) { throw new ArgumentNullException(); } ThemeNode node = FindTreeNode(theme); if (node != null) { node.Remove(); DeleteThemes.Add(theme); } }
ThemeNode FindTreeNode(TreeNodeCollection nodes, ChartTheme theme) { foreach (TreeNode node in nodes) { if (node is ThemeNode && ((ThemeNode)node).Theme == theme) { return((ThemeNode)node); } ThemeNode sn = FindTreeNode(node.Nodes, theme); if (sn != null) { return(sn); } } return(null); }
private int AddNodeTypesMenu(ToolStripMenuItem parent, ThemeNode context, IEnumerable<NodeType> nodeTypes) { var count = 0; foreach (var nodeType in nodeTypes) if (nodeType.CanAddTo(context)) { var newMenu = new ToolStripMenuItem(nodeType.DisplayText ?? nodeType.Name); newMenu.Tag = nodeType; parent.DropDownItems.Add(newMenu); if(AddNodeTypesMenu(newMenu, context, nodeType.GetSubTypes(context)) == 0) newMenu.Click += new EventHandler(cmnAddNodes_Click); count++; } return count; }
private void AttachNode(ThemeNode themeNode, TreeNode treeNode) { _objectsNode.Add(themeNode, treeNode); themeNode.PropertyChanged += new PropertyChangedEventHandler(themeNode_PropertyChanged); }
private TreeNode AddNode(TreeNode parent, ThemeNode item) { var layer = item as Layer; if (layer != null) return AddLayerNode(parent, layer); var group = item as Group; if (group != null) return AddGroupNode(parent, group); var text = item as Text; if (text != null) return AddTextNode(parent, text); var style = item as Style; if (style != null) return AddStyleNode(parent, style); if (item is When || item is Else) return AddContainterNode(parent, new CaseItemWrapper((ContainerNode)item), cmnThemeNode); var containerNode = item as ContainerNode; if (containerNode != null) return AddContainterNode(parent, new ContainerNodeWrapper(containerNode), cmnThemeNode); Debug.WriteLine("Unknown type: " + item.GetType().Name); var parentNodes = parent != null ? parent.Nodes : _treeView.Nodes; var node = parentNodes.Add(item.LabelOrDefault); node.Tag = new ThemeNodeWrapper(item); node.Checked = item.Visible; AttachNode(item, node); return node; }
public bool TryGetNode(ThemeNode themeNode, out TreeNode node) { return _objectsNode.TryGetValue(themeNode, out node); }
//internal void InitializeRenderer(ThemeNode node, ExpressionContext context) //{ // if (node.Renderer == null) // node.Renderer = CreateRenderer(node, context); // if (node is Text) // { // var text = (Text)node; // if (text.LabelBox != null && text.LabelBox.Renderer == null) // text.LabelBox.Renderer = CreateRenderer(text.LabelBox, context); // } //} internal IBaseRenderer CreateRenderer(ThemeNode node, ExpressionContext context, IBaseRenderer parent) { if (node is Group) return new LayerGroupRenderer(this, (Group)node, parent); if (node is Layer) return new LayerRenderer(this, (Layer)node, parent); if (node is Case) return new CaseRenderer(this, (Case)node, parent); if (node is LinearCalibration) return new LinearCalibrationRenderer(this, (LinearCalibration)node, parent); if (node is Marker) return new MarkerRenderer(this, (Marker)node, parent); if (node is PointExtractor) return new PointExtractorRenderer(this, (PointExtractor)node, parent); if (node is Stroke) return new StrokeRenderer(this, (Stroke)node, parent); if (node is Text) return new TextRenderer(this, (Text)node, parent); if (node is VerticesEnumerator) return new VerticesEnumeratorRenderer(this, (VerticesEnumerator)node, parent); if (node is SolidFill) return new SolidFillRenderer(this, (SolidFill)node, parent); if (node is LineStyle) return new LineStyleRenderer(this, (LineStyle)node, parent); if (node is Style) return null; if (node is Window) return new WindowRenderer(this, (Window)node, parent); if (node is ContainerNode) return new ContainerNodeRenderer(this, (ContainerNode)node, parent); if (node is Variable) return new VarRenderer(this, (Variable)node, parent); if (node is Run) return new MacroExecuter(this, (Run)node, context, parent); Debug.Fail("No renderer"); return null; }
private void AddHandler(ThemeNode themeNode) { themeNode.PropertyChanged -= new PropertyChangedEventHandler(Item_PropertyChanged); }
public virtual bool CanAddTo(ThemeNode node) { return node is ContainerNode; }
private void FillCategory(TmNode node, int catId) { // A category can have categories and/or themes for children. List<Category> cats; _categoriesInCategories.TryGetValue(catId, out cats); if (cats != null) foreach (Category cat in cats) { TmNode newNode = new CategoryNode( cat.Name, node, MakeMetadataForCategory(cat.Link), cat.Description ); node.Add(newNode); FillCategory(newNode, cat.Id); } List<Theme> themes; _themesInCategories.TryGetValue(catId, out themes); if (themes != null) foreach (Theme theme in themes) { TmNode newNode = new ThemeNode( theme.Name, node, MakeThemeData(theme.Name, theme.DataSource, theme.Type), MakeMetadataForTheme(theme.Metadata), null, theme.PubDate ); node.Add(newNode); FillTheme(newNode, theme.Id); } }
internal TmNode BuildThemeFromId(int themeId) { if (!_loaded) Load(); Theme theme = FindThemebyId(themeId); TmNode newNode = new ThemeNode( theme.Name, null, MakeThemeData(theme.Name, theme.DataSource, theme.Type), MakeMetadataForTheme(theme.Metadata), null, theme.PubDate ); FillTheme(newNode, themeId); return newNode; }
private void UpdateStatus(ThemeNode node) { if (node == null) lblStatus.Text = string.Empty; else { var renderer = node.Renderer as IGroupRenderer; lblStatus.Text = (renderer != null) ? string.Format("{0} \"{1}\" [{2}] in {3}", node, node.LabelOrDefault, renderer.RenderCount > 0 ? renderer.FeatureCount.ToString() : "N/A", renderer.RenderTime) : string.Format("{0} \"{1}\"", node.GetType().Name, node.LabelOrDefault); statusStrip1.Refresh(); } }
public override bool CanAddTo(ThemeNode container) { return container is Case; }
public ThemeNodeWrapper(ThemeNode node) { Node = node; node.PropertyChanged += new PropertyChangedEventHandler(node_PropertyChanged); }
public virtual bool CanContains(ThemeNode node) { return true; }
public virtual IEnumerable<NodeType> GetSubTypes(ThemeNode context) { yield break; }
public NodeEventArgs(ThemeNode node) { Node = node; }