Esempio n. 1
0
        public CustomPropertiesDialog(string dialogTitle, xTile.ObjectModel.Component component)
        {
            InitializeComponent();

            this.Text   = dialogTitle;
            m_component = component;
        }
Esempio n. 2
0
        public CustomPropertiesDialog(string dialogTitle, xTile.ObjectModel.Component component)
        {
            InitializeComponent();

            this.Text = dialogTitle;
            m_component = component;
        }
        private TreeNode SearchComponent(TreeNode rootNode, xTile.ObjectModel.Component component)
        {
            if (rootNode.Tag == component)
            {
                return(rootNode);
            }

            foreach (TreeNode childNode in rootNode.Nodes)
            {
                TreeNode resultNode = SearchComponent(childNode, component);
                if (resultNode != null)
                {
                    return(resultNode);
                }
            }

            return(null);
        }
        private void OnAfterSelect(object sender, TreeViewEventArgs treeViewEventArgs)
        {
            TreeNode treeNode = m_treeView.SelectedNode;

            if (treeNode.Tag is Layer)
            {
                treeNode.NodeFont = new Font(m_treeView.Font, FontStyle.Bold);
                treeNode.Text     = treeNode.Text;
            }

            if (ComponentChanged != null)
            {
                object tag = treeNode.Tag;
                xTile.ObjectModel.Component component = tag is xTile.ObjectModel.Component
                    ? (xTile.ObjectModel.Component)tag : null;

                ComponentChanged(this,
                                 new MapTreeViewEventArgs(treeNode, component));
            }
        }
 public MapTreeViewEventArgs(TreeNode treeNode, xTile.ObjectModel.Component component)
 {
     m_treeNode  = treeNode;
     m_component = component;
 }
        public void UpdateTree()
        {
            /*
             * if (m_map == null)
             * {
             *  m_treeView.Nodes.Clear();
             *  return;
             * }*/

            xTile.ObjectModel.Component selectedComponent = SelectedComponent;

            TreeNode mapNode        = m_treeView.Nodes[0];
            TreeNode layersNode     = mapNode.Nodes[0];
            TreeNode tileSheetsNode = mapNode.Nodes[1];

            if (m_map == null)
            {
                mapNode.Tag = layersNode.Tag = tileSheetsNode.Tag = null;
                layersNode.Nodes.Clear();
                tileSheetsNode.Nodes.Clear();
                return;
            }

            mapNode.Tag = m_map;
            mapNode.ContextMenuStrip = m_mapContextMenuStrip;

            layersNode.Tag = m_map.Layers;
            layersNode.ContextMenuStrip = m_layersContextMenuStrip;

            tileSheetsNode.Tag = m_map.TileSheets;
            tileSheetsNode.ContextMenuStrip = m_tileSheetsContextMenuStrip;

            // layers
            UpdateLayersSubTree(layersNode);

            // tile sheets
            UpdateTileSheetsSubTree(tileSheetsNode);


            // map root node

            /*
             * TreeNode mapNode = null;
             * TreeNode layersNode = null;
             * TreeNode tileSheetsNode = null;
             * if (m_treeView.Nodes.Count == 0)
             * {
             *  // create root map node
             *  int mapImageIndex = m_imageList.Images.IndexOfKey("Map.png");
             *  mapNode = new TreeNode(m_map.Id, mapImageIndex, mapImageIndex);
             *  mapNode.ContextMenuStrip = m_mapContextMenuStrip;
             *  mapNode.Tag = m_map;
             *
             *  // create layer collection node
             *  string layersLabel = LanguageManager.GetText(typeof(MapTreeView), "Generic.Layers");
             *  int layerFolderImageIndex = m_imageList.Images.IndexOfKey("LayerFolder.png");
             *  layersNode = new TreeNode(layersLabel, layerFolderImageIndex, layerFolderImageIndex);
             *  layersNode.Name = "Generic.Layers";
             *  layersNode.ContextMenuStrip = m_layersContextMenuStrip;
             *  layersNode.Tag = m_map.Layers;
             *  mapNode.Nodes.Add(layersNode);
             *
             *  // create tilesheet collection node
             *  string tileSheetsLabel = LanguageManager.GetText(typeof(MapTreeView), "Generic.TileSheets");
             *  int tileSheetFolderImageIndex = m_imageList.Images.IndexOfKey("TileSheetFolder.png");
             *  tileSheetsNode = new TreeNode(tileSheetsLabel, tileSheetFolderImageIndex, tileSheetFolderImageIndex);
             *  tileSheetsNode.Name = "Generic.TileSheets";
             *  tileSheetsNode.ContextMenuStrip = m_tileSheetsContextMenuStrip;
             *  tileSheetsNode.Tag = m_map.TileSheets;
             *  mapNode.Nodes.Add(tileSheetsNode);
             *
             *  m_treeView.Nodes.Add(mapNode);
             *
             *  m_treeView.SelectedNode = mapNode;
             * }
             * else
             * {
             *  if (m_map != null)
             *  {
             *      // determine update map node
             *      TreeNode mapNode = m_treeView.Nodes[0];
             *      //mapNode.Text = m_map.Id;
             *      mapNode.Tag = m_map;
             *
             *      TreeNode layersNode = mapNode.Nodes[0];
             *      layersNode.Tag = m_map.Layers;
             *
             *      TreeNode tileSheetsNode = mapNode.Nodes[1];
             *      tileSheetsNode.Tag = m_map.TileSheets;
             *
             *      // layers
             *      UpdateLayersSubTree(layersNode);
             *
             *      // tile sheets
             *      UpdateTileSheetsSubTree(tileSheetsNode);
             *  }
             * }*/


            if (selectedComponent != null &&
                SearchComponent(m_treeView.Nodes[0], selectedComponent) != null)
            {
                SelectedComponent = selectedComponent;
            }
        }