Exemplo n.º 1
0
        /// <summary>
        /// Handles KeyDown events when the TreeView has focus.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeView1_KeyDown(object sender, KeyEventArgs e)
        {
            //Debug.Print("treeView1_KeyDown fired. [" + e.KeyData.ToString() + "] [" + e.Modifiers.ToString() + "]");

            // Handle Control+Enter as an expansion/load ALL request.
            if (e.KeyData.HasFlag(Keys.Enter) && e.KeyData.HasFlag(Keys.Control))
            {
                HandleExpansionRequest(loadAllLevels: true);
                return;
            }


            // Handle Shift+Enter as an expansion/load request.
            if (e.KeyData.HasFlag(Keys.Enter) && e.KeyData.HasFlag(Keys.Shift))
            {
                HandleExpansionRequest();
                return;
            }

            // Handle the Enter key similarly to a click.
            if (e.KeyData == Keys.Enter)
            {
                Debug.Print("Selection Request");
                HellionExplorerProgram.RefreshSelectedOjectPathBarText(treeView1.SelectedNode);
                HellionExplorerProgram.RefreshListView(treeView1.SelectedNode);
                HellionExplorerProgram.RefreshSelectedObjectSummaryText(treeView1.SelectedNode);
                HellionExplorerProgram.RefreshStatusStrip(treeView1.SelectedNode);
                return;
            }
        }
Exemplo n.º 2
0
        private void ThisObjectInGameDataViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                throw new NullReferenceException("SelectedNode was null.");
            }
            else
            {
                Type t = treeView1.SelectedNode.GetType();
                if (t.Equals(typeof(SolarSystem_TN)))
                {
                    SolarSystem_TN node = (SolarSystem_TN)treeView1.SelectedNode;
                    treeView1.SelectedNode = node.LinkedGameDataNode;

                    // Trigger refresh
                    HellionExplorerProgram.RefreshSelectedOjectPathBarText(treeView1.SelectedNode);
                    HellionExplorerProgram.RefreshListView(treeView1.SelectedNode);
                    HellionExplorerProgram.RefreshSelectedObjectSummaryText(treeView1.SelectedNode);
                    HellionExplorerProgram.RefreshStatusStrip(treeView1.SelectedNode);
                }
                else
                {
                    throw new InvalidOperationException("Unexpected node type " + t.ToString());
                }
            }
        }
Exemplo n.º 3
0
        private void ListView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Update the object information panel
            if (HellionExplorerProgram.docCurrent != null) // && Program.docCurrent.IsFileReady)
            {
                TreeNode node = null;

                ListView.SelectedListViewItemCollection selection = listView1.SelectedItems;

                foreach (ListViewItem item in selection)
                {
                    // We only process the first
                    node = (TreeNode)item.Tag;
                    break;
                }

                if (node == null)
                {
                    // We get two updates, the first one has no data as it's the
                    // deselection event, in this case we do nothing
                }
                else
                {
                    // Update the object path + name + Tag in the object identifier bar
                    HellionExplorerProgram.RefreshSelectedOjectPathBarText(node);
                    //Program.RefreshListView(node);
                    HellionExplorerProgram.RefreshSelectedObjectSummaryText(node);
                    HellionExplorerProgram.RefreshStatusStrip(node);
                }
            }
        }
Exemplo n.º 4
0
        private void RevertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //string currentFileName = HellionExplorerProgram.docCurrent.GameData.SaveFile.File.FullName;

            //HellionExplorerProgram.FileClose();

            // Calling FileOpen with an already existing file will trigger the FileClose.
            HellionExplorerProgram.FileOpen(HellionExplorerProgram.docCurrent.GameData.SaveFile.File.FullName);

            //HellionExplorerProgram.FileRevert();
        }
Exemplo n.º 5
0
 private void buttonFindNext_Click(object sender, EventArgs e)
 {
     if (haveQueryControlsBeenModified)
     {
         haveQueryControlsBeenModified = false;
         HellionExplorerProgram.EditFind(NewQuery: true);
     }
     else
     {
         HellionExplorerProgram.EditFind();
     }
 }
Exemplo n.º 6
0
        private void RootOfDockingTreeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // This is only applicable in the Solar System View
            SolarSystem_TN node = (SolarSystem_TN)treeView1.SelectedNode;

            treeView1.SelectedNode = node.DockingTreeRoot;

            // Trigger refresh
            HellionExplorerProgram.RefreshSelectedOjectPathBarText(treeView1.SelectedNode);
            HellionExplorerProgram.RefreshListView(treeView1.SelectedNode);
            HellionExplorerProgram.RefreshSelectedObjectSummaryText(treeView1.SelectedNode);
            HellionExplorerProgram.RefreshStatusStrip(treeView1.SelectedNode);
        }
Exemplo n.º 7
0
 private void buttonFindAll_Click(object sender, EventArgs e)
 {
     if (haveQueryControlsBeenModified)
     {
         haveQueryControlsBeenModified = false;
         HellionExplorerProgram.EditFind(NewQuery: true, JumpToResultsSet: true);
     }
     else
     {
         HellionExplorerProgram.EditFind(JumpToResultsSet: true);
     }
     Hide();
 }
Exemplo n.º 8
0
        /// <summary>
        /// Handles an expansion request when the keyboard has been used to issue the request.
        /// </summary>
        /// <param name="populateDepth"></param>
        private void HandleExpansionRequest(bool loadAllLevels = false)
        {
            // TODO - this may need to run parts asynchronously for large collections of
            // objects - the Ships collection for example.

            TreeNode node = HellionExplorerProgram.MainForm.treeView1.SelectedNode;

            if (node != null && node.GetType() == typeof(Json_TN))
            {
                // Make a note of the starting time
                DateTime startingTime = DateTime.Now;

                // Update the status bar
                HellionExplorerProgram.RefreshStatusStrip("Starting node loading and generation...");

                // Set mouse cursor.
                Cursor = Cursors.WaitCursor;

                // Suppress repainting the TreeView until all the objects have been created.
                treeView1.BeginUpdate();


                if (loadAllLevels)
                {
                    // Load all levels up to the default maximum.
                    Debug.Print("Load (all) Request");
                    LoadLevels(GameData.Def_LoadAllNodeDepth, skipThroughPopulatedNodes: true);
                }
                else
                {
                    // Load next level
                    Debug.Print("Load (next) Request");
                    LoadLevels(1, skipThroughPopulatedNodes: true);
                }

                // Begin repainting the TreeView.
                treeView1.EndUpdate();

                // Reset cursor.
                Cursor = Cursors.Default;

                // Update the status bar
                HellionExplorerProgram.RefreshStatusStrip(string.Format(
                                                              "Node loading and generation completed in {0:mm}m{0:ss}s", DateTime.Now - startingTime));

                // Expand the current node
                node.Expand();
            }
        }
Exemplo n.º 9
0
        private void EditToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //Base_TN node = (Base_TN)HellionExplorerProgram.MainForm.treeView1.SelectedNode;

            Type t = HellionExplorerProgram.MainForm.treeView1.SelectedNode.GetType();

            if (t == typeof(Json_TN))
            {
                HellionExplorerProgram.CreateNewJsonDataView((Json_TN)HellionExplorerProgram.MainForm.treeView1.SelectedNode);
            }

            //else if (t.Equals(typeof(Base_TN)) && node.NodeType == Base_TN_NodeType.StationBlueprintFile)
            //{
            //    LaunchBlueprintEditor();

            //}
        }
Exemplo n.º 10
0
 private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Show About Dialog Box
     MessageBox.Show(HellionExplorerProgram.GenerateAboutBoxText(), "About " + Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 11
0
 private void SetDataFolderLocationToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HellionExplorerProgram.SetGameDataFolder();
 }
Exemplo n.º 12
0
        private void TreeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            // Update the object path + name + Tag in the object identifier bar
            HellionExplorerProgram.RefreshSelectedOjectPathBarText(e.Node);
            HellionExplorerProgram.RefreshListView(e.Node);
            HellionExplorerProgram.RefreshSelectedObjectSummaryText(e.Node);
            HellionExplorerProgram.RefreshStatusStrip(e.Node);

            // Show menu only if the right mouse button is clicked.
            if (e.Button == MouseButtons.Right)
            {
                Base_TN node = (Base_TN)e.Node;
                // Get the node that the user has clicked.
                if (node == null)
                {
                    return;
                }

                // Select in the TreeView the node the user has clicked.
                treeView1.SelectedNode = node;

                // Determine node type and activate appropriate jump to menu items.
                Type t = node.GetType();
                // Handles Json_TN nodes for the Game Data representation.
                if (t.Equals(typeof(Json_TN)))
                {
                    // We're working with a GAME DATA node

                    // Enable the Json Data View
                    //jsonDataViewToolStripMenuItem.Enabled = true;

                    // Editing of Json is now handled by the Edit menu item on the
                    // context menu. At this point only Objects seem
                    // suitable for use in the Json editor - otherwise de-serialisation
                    // fails and changes can't be applied to the main document.

                    switch (node.NodeType)
                    {
                    case Base_TN_NodeType.SaveFile:
                    case Base_TN_NodeType.DataFile:
                    case Base_TN_NodeType.StationBlueprintFile:
                    case Base_TN_NodeType.JsonObject:
                        //case Base_TN_NodeType.JsonArray:
                        // Show the Edit menu item.
                        editToolStripMenuItem1.Enabled = true;
                        break;

                    default:
                        // Disable the Edit menu item.
                        editToolStripMenuItem1.Enabled = false;
                        break;
                    }



                    // Enable the Jump to sub-menu
                    jumpToToolStripMenuItem.Enabled = true;

                    // GD nodes always have load items visible, even if enabled
                    loadNextLevelToolStripMenuItem.Enabled = true;
                    loadAllLevelsToolStripMenuItem.Enabled = true;

                    // We're in the Game Data already, so disable selection of it
                    thisObjectInGameDataViewToolStripMenuItem.Enabled = false;
                    thisObjectInGameDataViewToolStripMenuItem.Checked = true;

                    // Disable these two as they're Solar System related
                    rootOfDockingTreeToolStripMenuItem.Enabled   = false;
                    parentCelestialBodyToolStripMenuItem.Enabled = false;

                    // Cast the node to an Json_TN type
                    Json_TN gDnode = (Json_TN)treeView1.SelectedNode;

                    // Disable the LoadNextLevel item if it's already been loaded.
                    if (gDnode.ChildNodesLoaded)
                    {
                        loadNextLevelToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        loadNextLevelToolStripMenuItem.Enabled = true;
                    }

                    if (gDnode.LinkedSolarSystemNode != null)
                    {
                        // It's a Game Data node that has a linked Solar System node
                        // Enable the Jump to menu item
                        thisObjectInSolarSystemViewToolStripMenuItem.Enabled = true;
                        thisObjectInSolarSystemViewToolStripMenuItem.Checked = false;
                    }
                    else
                    {
                        thisObjectInSolarSystemViewToolStripMenuItem.Enabled = false;
                        thisObjectInSolarSystemViewToolStripMenuItem.Checked = false;
                    }
                }

                else if (t.Equals(typeof(Base_TN)) && node.NodeType == Base_TN_NodeType.StationBlueprintFile)
                {
                    // Enable the Edit menu item.
                    editToolStripMenuItem1.Enabled = true;

                    // Disable the Jump to sub-menu
                    jumpToToolStripMenuItem.Enabled = false;

                    // Disable Jump to sub-items.
                    thisObjectInGameDataViewToolStripMenuItem.Enabled    = false;
                    thisObjectInGameDataViewToolStripMenuItem.Checked    = false;
                    thisObjectInSolarSystemViewToolStripMenuItem.Enabled = false;
                    thisObjectInSolarSystemViewToolStripMenuItem.Checked = false;
                    rootOfDockingTreeToolStripMenuItem.Enabled           = false;
                    parentCelestialBodyToolStripMenuItem.Enabled         = false;

                    // Disable load items.
                    loadNextLevelToolStripMenuItem.Enabled = false;
                    loadAllLevelsToolStripMenuItem.Enabled = false;
                }


                // Handles SolarSystem_TN Nodes for the Solar System representation.
                else if (t.Equals(typeof(SolarSystem_TN)))
                {
                    // We're working with a SOLAR SYSTEM node

                    // Hide the Edit menu item.
                    editToolStripMenuItem1.Enabled = false;

                    // Disable the Json Data View option.
                    //jsonDataViewToolStripMenuItem.Enabled = false;

                    // Solar System nodes never have load options
                    loadNextLevelToolStripMenuItem.Enabled = false;
                    loadAllLevelsToolStripMenuItem.Enabled = false;

                    // We're in the Solar System already, so disable selection of it
                    thisObjectInSolarSystemViewToolStripMenuItem.Enabled = false;
                    thisObjectInSolarSystemViewToolStripMenuItem.Checked = true;

                    // Cast the node as an SolarSystem_TN type
                    SolarSystem_TN sSnode = (SolarSystem_TN)treeView1.SelectedNode;

                    if (sSnode.GUID == -1 || sSnode.NodeType == Base_TN_NodeType.SolarSystemView ||
                        sSnode.NodeType == Base_TN_NodeType.BlueprintHierarchyView)
                    {
                        // We're dealing with the Solar System Root Node or a Blueprint Hierarchy
                        // View node, special cases.

                        jumpToToolStripMenuItem.Enabled = false;
                        thisObjectInGameDataViewToolStripMenuItem.Enabled = false;
                        thisObjectInGameDataViewToolStripMenuItem.Checked = false;
                    }
                    else
                    {
                        if (sSnode.LinkedGameDataNode == null) // throw new NullReferenceException("sNode.LinkedGameDataNode was null.");
                        {
                            thisObjectInGameDataViewToolStripMenuItem.Enabled = false;
                            thisObjectInGameDataViewToolStripMenuItem.Checked = false;
                        }
                        else
                        {
                            thisObjectInGameDataViewToolStripMenuItem.Enabled = true;
                            thisObjectInGameDataViewToolStripMenuItem.Checked = false;
                        }
                        // Enable the Jump to sub-menu unless it's the Solar System root node
                        if (sSnode.GUID != -1)
                        {
                            jumpToToolStripMenuItem.Enabled = true;
                        }
                        else
                        {
                            jumpToToolStripMenuItem.Enabled = false;
                        }

                        // Enable the Root of Docking Tree option only if the node's parent type
                        // is a ship, indicating it is docked to something (rather than something
                        // being docked *to* this node i.e. child nodes).
                        rootOfDockingTreeToolStripMenuItem.Enabled = sSnode.IsDockedToParent;
                    }
                }

                // Handles Blueprint_TN for blueprint files.
                else if (t.Equals(typeof(Blueprint_TN)))
                {
                    // Some decision making logic needed here

                    if (node.NodeType == Base_TN_NodeType.StationBlueprintFile)
                    {
                        // Show the Edit menu item.
                        editToolStripMenuItem1.Enabled = true;
                    }
                    else
                    {
                        editToolStripMenuItem1.Enabled = false;
                    }



                    // Disable the Json Data View
                    //jsonDataViewToolStripMenuItem.Enabled = false;

                    // Disable the Jump to sub-menu
                    jumpToToolStripMenuItem.Enabled = false;

                    // Disable the Solar System Jump to option
                    thisObjectInSolarSystemViewToolStripMenuItem.Enabled = false;
                    thisObjectInSolarSystemViewToolStripMenuItem.Checked = false;

                    // Disable the Game Data Jump to option
                    thisObjectInGameDataViewToolStripMenuItem.Enabled = false;
                    thisObjectInGameDataViewToolStripMenuItem.Checked = false;

                    // Disable these two as they're Solar System related
                    rootOfDockingTreeToolStripMenuItem.Enabled   = false;
                    parentCelestialBodyToolStripMenuItem.Enabled = false;

                    // Disable the load options
                    loadNextLevelToolStripMenuItem.Enabled = false;
                    loadAllLevelsToolStripMenuItem.Enabled = false;
                }

                // Default behaviour - handles other node types.
                else
                {
                    // Hide the Edit menu item.
                    editToolStripMenuItem1.Enabled = false;

                    // Disable the Json Data View
                    //jsonDataViewToolStripMenuItem.Enabled = false;

                    // Disable the Jump to sub-menu
                    jumpToToolStripMenuItem.Enabled = false;

                    // Disable the Solar System Jump to option
                    thisObjectInSolarSystemViewToolStripMenuItem.Enabled = false;
                    thisObjectInSolarSystemViewToolStripMenuItem.Checked = false;

                    // Disable the Game Data Jump to option
                    thisObjectInGameDataViewToolStripMenuItem.Enabled = false;
                    thisObjectInGameDataViewToolStripMenuItem.Checked = false;

                    // Disable these two as they're Solar System related
                    rootOfDockingTreeToolStripMenuItem.Enabled   = false;
                    parentCelestialBodyToolStripMenuItem.Enabled = false;

                    // Disable the load options
                    loadNextLevelToolStripMenuItem.Enabled = false;
                    loadAllLevelsToolStripMenuItem.Enabled = false;
                }

                // Show the ContextMenuStrip.
                contextMenuStrip1.Show(treeView1, e.Location);
            }
        }
Exemplo n.º 13
0
 private void UserGuideToolStripMenuItem_Click(object sender, EventArgs e) => HellionExplorerProgram.LaunchUserGuide();
Exemplo n.º 14
0
 /// <summary>
 /// Called when the main form is closing, used to catch the user clicking the X control.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FrmMainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     // User closed the window - call the exit routine
     HellionExplorerProgram.ControlledExit();
 }
Exemplo n.º 15
0
 private void FindToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HellionExplorerProgram.ShowFindForm();
 }
Exemplo n.º 16
0
 private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // User selected MainFile, Exit - call the exit routine
     HellionExplorerProgram.ControlledExit();
 }
Exemplo n.º 17
0
 private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //opens a file
     HellionExplorerProgram.FileOpen();
 }
Exemplo n.º 18
0
 private void CloseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HellionExplorerProgram.FileClose();
 }
Exemplo n.º 19
0
 private void VerifyDataFolderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HellionExplorerProgram.VerifyGameDataFolder();
 }
Exemplo n.º 20
0
 private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HellionExplorerProgram.FileSaveAs();
 }