Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GamePage"/> class. The given package group and node tree are
        /// wrapped by the page.
        /// </summary>
        /// <param name="packageGroup">The package group which the node tree maps to.</param>
        /// <param name="nodeTree">The prebuilt node tree to display.</param>
        /// <param name="version">The Warcraft version that the game page is contextually relevant for.</param>
        /// <param name="alias">The name of the page.</param>
        public GamePage(PackageGroup packageGroup, SerializedTree nodeTree, WarcraftVersion version, string alias)
        {
            this.Alias       = alias;
            _uiTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            _treeModel       = new FileTreeModel(nodeTree);
            this.GameContext = new WarcraftGameContext(version, packageGroup, _treeModel);

            _treeAlignment = new Alignment(0.5f, 0.5f, 1.0f, 1.0f)
            {
                TopPadding    = 1,
                BottomPadding = 1
            };

            _treeFilter = new TreeModelFilter(new TreeModelAdapter(_treeModel), null)
            {
                VisibleFunc = TreeModelVisibilityFunc
            };

            _treeSorter = new TreeModelSort(_treeFilter);

            _treeSorter.SetSortFunc(0, SortGameTreeRow);
            _treeSorter.SetSortColumnId(0, SortType.Descending);

            this.Tree = new TreeView(_treeSorter)
            {
                HeadersVisible  = true,
                EnableTreeLines = true
            };

            var nodeIconRenderer = new CellRendererPixbuf
            {
                Xalign = 0.0f
            };
            var nodeNameRenderer = new CellRendererText
            {
                Xalign = 0.0f
            };

            var column = new TreeViewColumn
            {
                Title   = "Data Files",
                Spacing = 4
            };

            column.PackStart(nodeIconRenderer, false);
            column.PackStart(nodeNameRenderer, false);

            column.SetCellDataFunc(nodeIconRenderer, RenderNodeIcon);
            column.SetCellDataFunc(nodeNameRenderer, RenderNodeName);

            this.Tree.AppendColumn(column);

            var sw = new ScrolledWindow
            {
                this.Tree
            };

            _treeAlignment.Add(sw);

            this.Tree.RowActivated      += OnRowActivated;
            this.Tree.ButtonPressEvent  += OnButtonPressed;
            this.Tree.Selection.Changed += OnSelectionChanged;

            _treeContextMenu = new Menu();

            // Save item context button
            _saveItem = new ImageMenuItem
            {
                UseStock     = true,
                Label        = Stock.Save,
                CanFocus     = false,
                TooltipText  = "Save the currently selected item to disk.",
                UseUnderline = true
            };
            _saveItem.Activated += OnSaveItem;
            _treeContextMenu.Add(_saveItem);

            // Export item context button
            _exportItem = new ImageMenuItem("Export")
            {
                Image       = new Image(Stock.Convert, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Exports the currently selected item to another format.",
            };
            _exportItem.Activated += OnExportItemRequested;
            _treeContextMenu.Add(_exportItem);

            // Open item context button
            _openItem = new ImageMenuItem
            {
                UseStock     = true,
                Label        = Stock.Open,
                CanFocus     = false,
                TooltipText  = "Open the currently selected item.",
                UseUnderline = true
            };
            _openItem.Activated += OnOpenItem;
            _treeContextMenu.Add(_openItem);

            // Queue for export context button
            _queueForExportItem = new ImageMenuItem("Queue for export")
            {
                Image       = new Image(Stock.Convert, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Queues the currently selected item for batch export.",
            };
            _queueForExportItem.Activated += OnQueueForExportRequested;
            _treeContextMenu.Add(_queueForExportItem);

            // Separator
            var separator = new SeparatorMenuItem();

            _treeContextMenu.Add(separator);

            // Copy path context button
            _copyPathItem = new ImageMenuItem("Copy path")
            {
                Image       = new Image(Stock.Copy, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Copy the path of the currently selected item.",
            };
            _copyPathItem.Activated += OnCopyPath;
            _treeContextMenu.Add(_copyPathItem);

            _treeAlignment.ShowAll();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GamePage"/> class. The given package group and node tree are
        /// wrapped by the page.
        /// </summary>
        /// <param name="packageGroup">The package group which the node tree maps to.</param>
        /// <param name="nodeTree">The prebuilt node tree to display.</param>
        /// <param name="version">The Warcraft version that the game page is contextually relevant for.</param>
        public GamePage(PackageGroup packageGroup, OptimizedNodeTree nodeTree, WarcraftVersion version)
        {
            this.Packages         = packageGroup;
            this.Version          = version;
            this.DatabaseProvider = new ClientDatabaseProvider(this.Version, this.Packages);

            this.TreeModel = new FileTreeModel(nodeTree);

            this.TreeAlignment = new Alignment(0.5f, 0.5f, 1.0f, 1.0f)
            {
                TopPadding    = 1,
                BottomPadding = 1
            };

            this.TreeFilter = new TreeModelFilter(new TreeModelAdapter(this.TreeModel), null)
            {
                VisibleFunc = TreeModelVisibilityFunc
            };

            this.TreeSorter = new TreeModelSort(this.TreeFilter);

            this.TreeSorter.SetSortFunc(0, SortGameTreeRow);
            this.TreeSorter.SetSortColumnId(0, SortType.Descending);

            this.Tree = new TreeView(this.TreeSorter)
            {
                HeadersVisible  = true,
                EnableTreeLines = true
            };

            CellRendererPixbuf nodeIconRenderer = new CellRendererPixbuf
            {
                Xalign = 0.0f
            };
            CellRendererText nodeNameRenderer = new CellRendererText
            {
                Xalign = 0.0f
            };

            TreeViewColumn column = new TreeViewColumn
            {
                Title   = "Data Files",
                Spacing = 4
            };

            column.PackStart(nodeIconRenderer, false);
            column.PackStart(nodeNameRenderer, false);

            column.SetCellDataFunc(nodeIconRenderer, RenderNodeIcon);
            column.SetCellDataFunc(nodeNameRenderer, RenderNodeName);

            this.Tree.AppendColumn(column);

            ScrolledWindow sw = new ScrolledWindow
            {
                this.Tree
            };

            this.TreeAlignment.Add(sw);

            this.Tree.RowActivated      += OnRowActivated;
            this.Tree.ButtonPressEvent  += OnButtonPressed;
            this.Tree.Selection.Changed += OnSelectionChanged;

            this.TreeContextMenu = new Menu();

            // Save item context button
            this.SaveItem = new ImageMenuItem
            {
                UseStock     = true,
                Label        = Stock.Save,
                CanFocus     = false,
                TooltipText  = "Save the currently selected item to disk.",
                UseUnderline = true
            };
            this.SaveItem.Activated += OnSaveItem;
            this.TreeContextMenu.Add(this.SaveItem);

            // Export item context button
            this.ExportItem = new ImageMenuItem("Export")
            {
                Image       = new Image(Stock.Convert, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Exports the currently selected item to another format.",
            };
            this.ExportItem.Activated += OnExportItemRequested;
            this.TreeContextMenu.Add(this.ExportItem);

            // Open item context button
            this.OpenItem = new ImageMenuItem
            {
                UseStock     = true,
                Label        = Stock.Open,
                CanFocus     = false,
                TooltipText  = "Open the currently selected item.",
                UseUnderline = true
            };
            this.OpenItem.Activated += OnOpenItem;
            this.TreeContextMenu.Add(this.OpenItem);

            // Queue for export context button
            this.QueueForExportItem = new ImageMenuItem("Queue for export")
            {
                Image       = new Image(Stock.Convert, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Queues the currently selected item for batch export.",
            };
            this.QueueForExportItem.Activated += OnQueueForExportRequested;
            this.TreeContextMenu.Add(this.QueueForExportItem);

            // Separator
            SeparatorMenuItem separator = new SeparatorMenuItem();

            this.TreeContextMenu.Add(separator);

            // Copy path context button
            this.CopyPathItem = new ImageMenuItem("Copy path")
            {
                Image       = new Image(Stock.Copy, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Copy the path of the currently selected item.",
            };
            this.CopyPathItem.Activated += OnCopyPath;
            this.TreeContextMenu.Add(this.CopyPathItem);

            this.TreeAlignment.ShowAll();
        }