private void butExtras_Click(object sender, EventArgs e)
        {
            FormExtras   extras = new FormExtras();
            DialogResult dr     = extras.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                if (extras.cbManuallyEnterCode.Checked)
                {
                    string       id2Try  = extras.tbManuallyEnterCode.Text.Trim();
                    SymbolIdCode tryCode = new SymbolIdCode(id2Try);

                    if (tryCode.IsValid)
                    {
                        this.currentSymbol.Id = tryCode;

                        this.currentPane = PaneSequenceType.StartOver;

                        setSymbolState();
                    }
                    else
                    {
                        MessageBox.Show("Could not create symbol from ID:" + id2Try +
                                        ", Length:" + id2Try.Length, "Create Symbol Failed");
                    }
                }
            }
        }
        private void butReset_Click(object sender, EventArgs e)
        {
            currentPane = PaneSequenceType.AffiliationPane;

            resetSymbolState();

            SetPaneState();
        }
        private void butBackCol2_Click(object sender, EventArgs e)
        {
            if (currentColumn != 2)
            {
                System.Diagnostics.Trace.WriteLine("We shouldn't be here...");
                return;
            }

            currentColumn = 1;

            currentPane = PaneSequenceType.AffiliationPane;

            SetPaneState();
        }
        void setSymbolState(string valueSelected = "")
        {
            // TODO: Figure out a way to set this consistent naming scheme better
            string symbolSetName = currentSymbol.Id.SymbolSet.ToString().Replace("_", " ");

            if (string.IsNullOrEmpty(valueSelected))
            {
                // this is a special state (i.e. hack) to simulate a button press, to force
                // into the next state, when the previous panel is empty
            }
            else if (currentPane == PaneSequenceType.AffiliationPane)
            {
                string affiliationSelectedString = valueSelected;

                StandardIdentityAffiliationType affiliationSelection =
                    (StandardIdentityAffiliationType)
                    TypeUtilities.EnumHelper.getEnumFromString(
                        typeof(StandardIdentityAffiliationType), affiliationSelectedString);

                currentSymbol.Id.Affiliation = affiliationSelection;

                currentPane = PaneSequenceType.SymbolSetPane;
            }
            else if (currentPane == PaneSequenceType.SymbolSetPane)
            {
                string symbolSetSelectedString = valueSelected;

                SymbolSetType symbolSetSelection = (SymbolSetType)
                                                   TypeUtilities.EnumHelper.getEnumFromString(
                    typeof(SymbolSetType), symbolSetSelectedString);

                currentSymbol.Id.SymbolSet = symbolSetSelection;

                currentPane = PaneSequenceType.EntityPane;
            }
            else if (currentPane == PaneSequenceType.EntityPane)
            {
                if (valueSelected == NOT_SET)
                {
                    currentPane = PaneSequenceType.Modifier1Pane;
                }
                else
                {
                    currentEntityName = valueSelected;

                    string entityCode = symbolLookup.GetEntityCode(currentSymbol.Id.SymbolSet, currentEntityName);

                    currentSymbol.Id.EntityCode = entityCode;

                    currentPane = PaneSequenceType.EntityTypePane;
                }
            }
            else if (currentPane == PaneSequenceType.EntityTypePane)
            {
                if (valueSelected == NOT_SET)
                {
                    currentPane = PaneSequenceType.Modifier1Pane;
                }
                else
                {
                    currentEntityTypeName = valueSelected;

                    string entityCode = symbolLookup.GetEntityCode(currentSymbol.Id.SymbolSet,
                                                                   currentEntityName, currentEntityTypeName);

                    currentSymbol.Id.EntityCode = entityCode;

                    currentPane = PaneSequenceType.EntitySubTypePane;
                }
            }
            else if (currentPane == PaneSequenceType.EntitySubTypePane)
            {
                if (valueSelected == NOT_SET)
                {
                    currentPane = PaneSequenceType.Modifier1Pane;
                }
                else
                {
                    currentEntitySubTypeName = valueSelected;

                    string entityCode = symbolLookup.GetEntityCode(currentSymbol.Id.SymbolSet,
                                                                   currentEntityName, currentEntityTypeName, currentEntitySubTypeName);

                    currentSymbol.Id.EntityCode = entityCode;

                    currentPane = PaneSequenceType.Modifier1Pane;
                }
            }
            else if (currentPane == PaneSequenceType.Modifier1Pane)
            {
                string currentModifier1Name = valueSelected;

                string modifier1Code = symbolLookup.GetModifierCodeFromName(
                    currentSymbol.Id.SymbolSet, 1, currentModifier1Name);

                currentSymbol.Id.ModifierOne = modifier1Code;

                currentPane = PaneSequenceType.Modifier2Pane;
            }
            else if (currentPane == PaneSequenceType.Modifier2Pane)
            {
                string currentModifier2Name = valueSelected;

                string modifier2Code = symbolLookup.GetModifierCodeFromName(
                    currentSymbol.Id.SymbolSet, 2, currentModifier2Name);

                currentSymbol.Id.ModifierTwo = modifier2Code;

                currentPane = PaneSequenceType.EchelonMobilityPane;
            }
            else if (currentPane == PaneSequenceType.EchelonMobilityPane)
            {
                string currentEchelonMobilityName = valueSelected;

                EchelonMobilityType echelonMobilitySelection =
                    (EchelonMobilityType)
                    TypeUtilities.EnumHelper.getEnumFromString(
                        typeof(EchelonMobilityType), currentEchelonMobilityName);

                currentSymbol.Id.EchelonMobility = echelonMobilitySelection;

                currentPane = PaneSequenceType.HqTfFdPane;
            }
            else if (currentPane == PaneSequenceType.HqTfFdPane)
            {
                string currentHqTfFdName = valueSelected;

                HeadquartersTaskForceDummyType hqTfFdSelection =
                    (HeadquartersTaskForceDummyType)
                    TypeUtilities.EnumHelper.getEnumFromString(
                        typeof(HeadquartersTaskForceDummyType), currentHqTfFdName);

                currentSymbol.Id.HeadquartersTaskForceDummy = hqTfFdSelection;

                currentPane = PaneSequenceType.StatusPane;
            }
            else if (currentPane == PaneSequenceType.StatusPane)
            {
                string currentStatusName = valueSelected;

                StatusType statusSelection =
                    (StatusType)TypeUtilities.EnumHelper.getEnumFromString(
                        typeof(StatusType), currentStatusName);

                currentSymbol.Id.Status = statusSelection;

                currentPane = PaneSequenceType.StartOver;
            }
            else if (currentPane == PaneSequenceType.StartOver)
            {
                // Reset the other values
                resetSymbolState();

                // Go back when we are done
                currentPane = PaneSequenceType.SymbolSetPane;
            }

            setTagLabel();

            updatePictureBox();

            // Go To Next Pane
            SetPaneState();
        }
        public void SetPaneState()
        {
            bool changedState = (previousPane != currentPane);

            bool goingBackwards = (currentPane < previousPane);

            if (changedState)
            {
                System.Diagnostics.Trace.WriteLine("New Pane State: " + currentPane
                                                   + ", Old State = " + previousPane);

                if (currentPane == PaneSequenceType.AffiliationPane)
                {
                    this.labCol1.Text    = "Affiliation";
                    this.labCol2.Visible = false;
                    this.labCol3.Visible = false;

                    currentColValues = TypeUtilities.EnumHelper.getEnumValuesAsStrings(typeof(StandardIdentityAffiliationType));

                    currentColRowIndex = 0;

                    enableColumnButtons(1, true);
                    setVisibilityColumnButtons(2, false);
                    setVisibilityColumnButtons(3, false);
                    currentColumn = 1;
                    setColumnValues();
                }
                else if (currentPane == PaneSequenceType.SymbolSetPane)
                {
                    this.resetSymbolState();

                    this.labCol2.Text    = "Symbol Set";
                    this.labCol2.Visible = true;
                    this.labCol3.Visible = false;

                    currentColValues = TypeUtilities.EnumHelper.getEnumValuesAsStrings(typeof(SymbolSetType));

                    currentColRowIndex = 0;

                    currentColumn = 2;

                    enableColumnButtons(2, true);
                    setColumnValues();
                    enableColumnButtons(1, false);
                    setVisibilityColumnButtons(3, false);
                }
                else if ((currentPane == PaneSequenceType.EntityPane) ||
                         (currentPane == PaneSequenceType.EntityTypePane) ||
                         (currentPane == PaneSequenceType.EntitySubTypePane))
                {
                    this.labCol3.Text    = currentPane.ToString().Replace("Pane", ""); //  Entity/EntityType/etc.
                    this.labCol3.Visible = true;

                    if (currentPane == PaneSequenceType.EntityPane)
                    {
                        currentColValues = symbolLookup.GetDistinctEntries(this.currentSymbol.Id.SymbolSet);
                    }
                    else
                    if (currentPane == PaneSequenceType.EntityTypePane)
                    {
                        currentColValues = symbolLookup.GetDistinctEntries(
                            this.currentSymbol.Id.SymbolSet,
                            currentEntityName);
                    }
                    else
                    if (currentPane == PaneSequenceType.EntitySubTypePane)
                    {
                        currentColValues = symbolLookup.GetDistinctEntries(
                            this.currentSymbol.Id.SymbolSet,
                            currentEntityName,
                            currentEntityTypeName);
                    }

                    if (currentColValues.Count == 0)
                    {
                        // Advance to the next/previous pane if this is empty
                        if (goingBackwards)
                        {
                            currentPane--;
                        }
                        else
                        {
                            currentPane++;
                        }

                        resetColumn3State();
                    }
                    else
                    {
                        currentColValues.Insert(0, NOT_SET); // add as first element
                    }

                    currentColRowIndex = 0;

                    // if we are navigating backwards, and there were no entities (e.g. SpaceMet)
                    if (currentPane != PaneSequenceType.SymbolSetPane)
                    {
                        currentColumn = 3;
                        enableColumnButtons(3, true);
                        setColumnValues();
                        enableColumnButtons(1, false);
                        enableColumnButtons(2, false);
                    }
                }
                else if ((currentPane == PaneSequenceType.Modifier1Pane) ||
                         (currentPane == PaneSequenceType.Modifier2Pane))
                {
                    this.labCol3.Text    = currentPane.ToString().Replace("Pane", "");
                    this.labCol3.Visible = true;

                    if (currentPane == PaneSequenceType.Modifier1Pane)
                    {
                        currentColValues = symbolLookup.GetDistinctModifierNames(
                            this.currentSymbol.Id.SymbolSet, 1);
                    }
                    else
                    if (currentPane == PaneSequenceType.Modifier2Pane)
                    {
                        currentColValues = symbolLookup.GetDistinctModifierNames(
                            this.currentSymbol.Id.SymbolSet, 2);
                    }

                    if (currentColValues.Count == 0)
                    {
                        // Advance to the next/previous pane if this is empty
                        if (goingBackwards)
                        {
                            currentPane--;
                        }
                        else
                        {
                            currentPane++;
                        }

                        resetColumn3State();
                    }
                    else
                    {
                        currentColValues.Insert(0, NOT_SET); // Add as first element
                    }

                    currentColRowIndex = 0;

                    // if we are navigating backwards, and there were no modifiers (e.g. SpaceMet)
                    if (currentPane != PaneSequenceType.SymbolSetPane)
                    {
                        currentColumn = 3;
                        enableColumnButtons(3, true);
                        setColumnValues();
                        enableColumnButtons(1, false);
                        enableColumnButtons(2, false);
                    }
                }
                ////////////////////////////////////////////////////////////////
                //
                // Don't do these if non-framed
                //
                else if (currentPane == PaneSequenceType.EchelonMobilityPane)
                {
                    // Don't do if Non-framed
                    if (!TypeUtilities.HasFrame(this.currentSymbol.Id.SymbolSet))
                    {
                        if (goingBackwards)
                        {
                            currentPane = PaneSequenceType.EntitySubTypePane;
                        }
                        else
                        {
                            currentPane = PaneSequenceType.StartOver;
                        }

                        resetColumn3State();
                    }
                    else
                    {
                        this.labCol3.Text    = "Echelon/Mobility";
                        this.labCol3.Visible = true;

                        currentColValues = TypeUtilities.EnumHelper.getEnumValuesAsStrings(typeof(EchelonMobilityType));

                        currentColRowIndex = 0;

                        currentColumn = 3;
                        enableColumnButtons(3, true);
                        setColumnValues();
                        enableColumnButtons(1, false);
                        enableColumnButtons(2, false);
                    }
                }
                else if (currentPane == PaneSequenceType.HqTfFdPane)
                {
                    this.labCol3.Text    = "HQ/TF/FD";
                    this.labCol3.Visible = true;

                    currentColValues = TypeUtilities.EnumHelper.getEnumValuesAsStrings(typeof(HeadquartersTaskForceDummyType));

                    currentColRowIndex = 0;

                    currentColumn = 3;
                    enableColumnButtons(3, true);
                    setColumnValues();
                    enableColumnButtons(1, false);
                    enableColumnButtons(2, false);
                }
                else if (currentPane == PaneSequenceType.StatusPane)
                {
                    // Don't do if non-framed
                    if (!TypeUtilities.HasFrame(this.currentSymbol.Id.SymbolSet))
                    {
                        if (goingBackwards)
                        {
                            currentPane = PaneSequenceType.EntitySubTypePane;
                        }
                        else
                        {
                            currentPane = PaneSequenceType.StartOver;
                        }

                        resetColumn3State();
                    }
                    else
                    {
                        this.labCol3.Text    = "Op Condition";
                        this.labCol3.Visible = true;

                        currentColValues = TypeUtilities.EnumHelper.getEnumValuesAsStrings(typeof(StatusType));

                        currentColRowIndex = 0;

                        currentColumn = 3;
                        enableColumnButtons(3, true);
                        setColumnValues();
                        enableColumnButtons(1, false);
                        enableColumnButtons(2, false);
                    }
                }
                //
                // End of don't do if non-framed
                //
                ////////////////////////////////////////////////////////////////
                else if (currentPane == PaneSequenceType.StartOver)
                {
                    this.labCol3.Text    = "Finished";
                    this.labCol3.Visible = true;

                    currentColValues = new List <string>()
                    {
                        "Start Over"
                    };

                    currentColRowIndex = 0;

                    currentColumn = 3;
                    enableColumnButtons(3, true);
                    setColumnValues();
                    enableColumnButtons(1, false);
                    enableColumnButtons(2, false);
                }
            }

            previousPane = currentPane;
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            currentPane = PaneSequenceType.AffiliationPane;

            SetPaneState();
        }