Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        void DeleteTheme(ChartTheme theme)
        {
            if (theme == null)
            {
                throw new ArgumentNullException();
            }

            ThemeNode node = FindTreeNode(theme);

            if (node != null)
            {
                node.Remove();
                DeleteThemes.Add(theme);
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 private void AttachNode(ThemeNode themeNode, TreeNode treeNode)
 {
     _objectsNode.Add(themeNode, treeNode);
     themeNode.PropertyChanged += new PropertyChangedEventHandler(themeNode_PropertyChanged);
 }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
 public bool TryGetNode(ThemeNode themeNode, out TreeNode node)
 {
     return _objectsNode.TryGetValue(themeNode, out node);
 }
Exemplo n.º 10
0
        //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;
        }
Exemplo n.º 11
0
 private void AddHandler(ThemeNode themeNode)
 {
     themeNode.PropertyChanged -= new PropertyChangedEventHandler(Item_PropertyChanged);
 }
Exemplo n.º 12
0
 public virtual bool CanAddTo(ThemeNode node)
 {
     return node is ContainerNode;
 }
Exemplo n.º 13
0
        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);
                }
        }
Exemplo n.º 14
0
        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;
        }
Exemplo n.º 15
0
		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();
			}
		}
Exemplo n.º 16
0
 public override bool CanAddTo(ThemeNode container)
 {
     return container is Case;
 }
Exemplo n.º 17
0
	    public ThemeNodeWrapper(ThemeNode node)
        {
            Node = node;
            node.PropertyChanged += new PropertyChangedEventHandler(node_PropertyChanged);
        }
Exemplo n.º 18
0
 public virtual bool CanContains(ThemeNode node)
 {
     return true;
 }
Exemplo n.º 19
0
 public virtual IEnumerable<NodeType> GetSubTypes(ThemeNode context)
 {
     yield break;
 }
Exemplo n.º 20
0
		public NodeEventArgs(ThemeNode node)
		{
			Node = node;
		}