Exemplo n.º 1
0
        public override void SetDragPositionTopDownView(double?x = null, double?y = null, double?z = null)
        {
            if (!x.HasValue || !z.HasValue)
            {
                return;
            }

            PositionAngle posAngle = GetPositionAngle();
            double        dist     = MoreMath.GetDistanceBetween(posAngle.X, posAngle.Z, x.Value, z.Value);
            double        angle    = MoreMath.AngleTo_AngleUnits(posAngle.X, posAngle.Z, x.Value, z.Value);

            if (!KeyboardUtilities.IsCtrlHeld())
            {
                if (_useRecommendedArrowLength)
                {
                    SetRecommendedSize(dist);
                }
                else
                {
                    GetParentMapTracker().SetSize((float)(Scales ? dist : dist *Config.CurrentMapGraphics.MapViewScaleValue));
                }
            }
            if (!KeyboardUtilities.IsShiftHeld())
            {
                SetYaw(angle);
            }
        }
Exemplo n.º 2
0
        public override void SetDragPositionTopDownView(double?x = null, double?y = null, double?z = null)
        {
            if (!x.HasValue || !z.HasValue)
            {
                return;
            }

            PositionAngle posAngle = _posAngle.GetBasePositionAngle();
            double        dist     = MoreMath.GetDistanceBetween(posAngle.X, posAngle.Z, x.Value, z.Value);
            double        angle    = MoreMath.AngleTo_AngleUnits(posAngle.X, posAngle.Z, x.Value, z.Value);

            if (Rotates)
            {
                angle -= posAngle.Angle;
            }

            if (!KeyboardUtilities.IsCtrlHeld())
            {
                _posAngle.SetOffsetDist(dist);
            }
            if (!KeyboardUtilities.IsShiftHeld())
            {
                _posAngle.SetOffsetAngle(angle);
            }

            MapTracker mapTracker = GetParentMapTracker();

            mapTracker.SetSize((float)_posAngle.GetOffsetDist());
            mapTracker.SetLineWidth((float)_posAngle.GetOffsetAngle());
        }
Exemplo n.º 3
0
        private void pictureBoxDownArrow_Click(object sender, EventArgs e)
        {
            int numMoves = KeyboardUtilities.GetCurrentlyInputtedNumber() ?? 1;

            if (KeyboardUtilities.IsCtrlHeld())
            {
                numMoves = 0;
            }
            mapTab.flowLayoutPanelMapTrackers.MoveDownControl(this, numMoves);
        }
Exemplo n.º 4
0
 private void buttonMoveTabRight_Click(object sender, EventArgs e)
 {
     if (KeyboardUtilities.IsCtrlHeld() || KeyboardUtilities.IsNumberHeld())
     {
         ObjectOrderingUtilities.Move(true);
     }
     else
     {
         MoveTab(true);
     }
 }
Exemplo n.º 5
0
 public override void SetDragPositionTopDownView(double?x = null, double?y = null, double?z = null)
 {
     if (KeyboardUtilities.IsCtrlHeld())
     {
         z = null;
     }
     if (KeyboardUtilities.IsShiftHeld())
     {
         x = null;
     }
     GetPositionAngle().SetValues(x, y, z);
 }
Exemplo n.º 6
0
        private void OnSlotClick(object sender, EventArgs e)
        {
            // Make sure the tab has loaded
            if (_gui.TabControl.SelectedTab == null)
            {
                return;
            }

            ObjectSlot selectedSlot = sender as ObjectSlot;

            selectedSlot.Focus();

            bool isCtrlKeyHeld  = KeyboardUtilities.IsCtrlHeld();
            bool isShiftKeyHeld = KeyboardUtilities.IsShiftHeld();
            bool isAltKeyHeld   = KeyboardUtilities.IsAltHeld();

            DoSlotClickUsingInput(selectedSlot, isCtrlKeyHeld, isShiftKeyHeld, isAltKeyHeld);
        }
Exemplo n.º 7
0
        private void OnSlotClick(object sender, EventArgs e)
        {
            // Make sure the tab has loaded
            if (mainForm.tabControlMain.SelectedTab == null)
            {
                return;
            }

            ObjectSlot selectedSlot = sender as ObjectSlot;

            selectedSlot.Focus();

            bool isCtrlKeyHeld  = KeyboardUtilities.IsCtrlHeld();
            bool isShiftKeyHeld = KeyboardUtilities.IsShiftHeld();
            bool isAltKeyHeld   = KeyboardUtilities.IsAltHeld();
            int? numberHeld     = KeyboardUtilities.GetCurrentlyInputtedNumber();

            DoSlotClickUsingInput(selectedSlot, isCtrlKeyHeld, isShiftKeyHeld, isAltKeyHeld, numberHeld);
        }
Exemplo n.º 8
0
        private void InitializeTabRemoval()
        {
            tabControlMain.Click += (se, ev) =>
            {
                if (KeyboardUtilities.IsCtrlHeld())
                {
                    SavedSettingsConfig.RemoveTab(tabControlMain.SelectedTab);
                }
            };

            buttonTabAdd.ContextMenuStrip          = new ContextMenuStrip();
            buttonTabAdd.ContextMenuStrip.Opening += (se, ev) =>
            {
                buttonTabAdd.ContextMenuStrip.Items.Clear();
                SavedSettingsConfig.GetRemovedTabItems().ForEach(
                    item => buttonTabAdd.ContextMenuStrip.Items.Add(item));
            };

            SavedSettingsConfig.InvokeInitiallySavedRemovedTabs();
        }
Exemplo n.º 9
0
        public static List<ToolStripItem> CreateSelectionToolStripItems(
            Func<List<WatchVariableControl>> getVars,
            WatchVariableFlowLayoutPanel panel)
        {
            Action<WatchVariableControlSettings> apply = (WatchVariableControlSettings settings) =>
            {
                if (KeyboardUtilities.IsCtrlHeld())
                    WatchVariableControlSettingsManager.AddSettings(settings);
                else
                    getVars().ForEach(control => control.ApplySettings(settings));
            };

            ToolStripMenuItem itemHighlight = new ToolStripMenuItem("Highlight...");
            ControlUtilities.AddDropDownItems(
                itemHighlight,
                new List<string>() { "Highlight", "Don't Highlight" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeHighlighted: true, newHighlighted: true)),
                    () => apply(new WatchVariableControlSettings(changeHighlighted: true, newHighlighted: false)),
                });

            ToolStripMenuItem itemLock = new ToolStripMenuItem("Lock...");
            ControlUtilities.AddDropDownItems(
                itemLock,
                new List<string>() { "Lock", "Don't Lock" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeLocked: true, newLocked: true)),
                    () => apply(new WatchVariableControlSettings(changeLocked: true, newLocked: false)),
                });

            ToolStripMenuItem itemCopy = new ToolStripMenuItem("Copy...");
            Action<List<WatchVariableControl>, string> copyValues =
                (List<WatchVariableControl> controls, string separator) =>
            {
                Clipboard.SetText(
                    String.Join(separator, controls.ConvertAll(
                        control => control.GetValue(false))));
            };
            ControlUtilities.AddDropDownItems(
                itemCopy,
                new List<string>() {
                    "Copy with Commas",
                    "Copy with Tabs",
                    "Copy with Line Breaks",
                    "Copy for Code",
                },
                new List<Action>()
                {
                    () => copyValues(getVars(), ","),
                    () => copyValues(getVars(), "\t"),
                    () => copyValues(getVars(), "\r\n"),
                    () =>
                    {
                        List<WatchVariableControl> watchVars = getVars();
                        string prefix = KeyboardUtilities.IsCtrlHeld() ? DialogUtilities.GetStringFromDialog() : "";
                        List<string> lines = new List<string>();
                        foreach (WatchVariableControl watchVar in watchVars)
                        {
                            Type type = watchVar.GetMemoryType();
                            string line = String.Format(
                                "{0} {1}{2} = {3}{4};",
                                type != null ? TypeUtilities.TypeToString[watchVar.GetMemoryType()] : "double",
                                prefix,
                                watchVar.VarName.Replace(" ", ""),
                                watchVar.GetValue(false),
                                type == typeof(float) ? "f" : "");
                            lines.Add(line);
                        }
                        if (lines.Count > 0)
                        {
                            Clipboard.SetText(String.Join("\r\n", lines));
                        }
                    },
                });

            ToolStripMenuItem itemPaste = new ToolStripMenuItem("Paste");
            itemPaste.Click += (sender, e) =>
            {
                List<string> stringList = ParsingUtilities.ParseStringList(Clipboard.GetText());
                List<WatchVariableControl> varList = getVars();
                if (stringList.Count != varList.Count) return;

                Config.Stream.Suspend();
                for (int i = 0; i < stringList.Count; i++)
                {
                    varList[i].SetValue(stringList[i]);
                }
                Config.Stream.Resume();
            };

            ToolStripMenuItem itemRoundTo = new ToolStripMenuItem("Round to...");
            ToolStripMenuItem itemRoundToDefault = new ToolStripMenuItem("Default");
            itemRoundToDefault.Click += (sender, e) =>
                apply(new WatchVariableControlSettings(
                    changeRoundingLimit: true, changeRoundingLimitToDefault: true));
            ToolStripMenuItem itemRoundToNoRounding = new ToolStripMenuItem("No Rounding");
            itemRoundToNoRounding.Click += (sender, e) =>
                apply(new WatchVariableControlSettings(
                    changeRoundingLimit: true, newRoundingLimit: -1));
            List<ToolStripMenuItem> itemsRoundToNumDecimalPlaces = new List<ToolStripMenuItem>();
            for (int i = 0; i <= 10; i++)
            {
                int index = i;
                itemsRoundToNumDecimalPlaces.Add(new ToolStripMenuItem(index + " decimal place(s)"));
                itemsRoundToNumDecimalPlaces[index].Click += (sender, e) =>
                    apply(new WatchVariableControlSettings(
                        changeRoundingLimit: true, newRoundingLimit: index));
            }
            itemRoundTo.DropDownItems.Add(itemRoundToDefault);
            itemRoundTo.DropDownItems.Add(itemRoundToNoRounding);
            itemsRoundToNumDecimalPlaces.ForEach(setAllRoundingLimitsNumberItem =>
            {
                itemRoundTo.DropDownItems.Add(setAllRoundingLimitsNumberItem);
            });

            ToolStripMenuItem itemDisplayAsHex = new ToolStripMenuItem("Display as Hex...");
            ControlUtilities.AddDropDownItems(
                itemDisplayAsHex,
                new List<string>() { "Default", "Hex", "Decimal" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeDisplayAsHex: true, changeDisplayAsHexToDefault: true)),
                    () => apply(new WatchVariableControlSettings(changeDisplayAsHex: true, newDisplayAsHex: true)),
                    () => apply(new WatchVariableControlSettings(changeDisplayAsHex: true, newDisplayAsHex: false)),
                });

            ToolStripMenuItem itemAngleSigned = new ToolStripMenuItem("Angle: Signed...");
            ControlUtilities.AddDropDownItems(
                itemAngleSigned,
                new List<string>() { "Default", "Unsigned", "Signed" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeAngleSigned: true, changeAngleSignedToDefault: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleSigned: true, newAngleSigned: false)),
                    () => apply(new WatchVariableControlSettings(changeAngleSigned: true, newAngleSigned: true)),
                });

            ToolStripMenuItem itemAngleUnits = new ToolStripMenuItem("Angle: Units...");
            ToolStripMenuItem itemAngleUnitsDefault = new ToolStripMenuItem("Default");
            itemAngleUnitsDefault.Click += (sender, e) =>
                apply(new WatchVariableControlSettings(
                    changeAngleUnits: true, changeAngleUnitsToDefault: true));
            List<ToolStripMenuItem> itemsAngleUnitsValue = new List<ToolStripMenuItem>();
            foreach (AngleUnitType angleUnitType in Enum.GetValues(typeof(AngleUnitType)))
            {
                AngleUnitType angleUnitTypeFixed = angleUnitType;
                ToolStripMenuItem itemAngleUnitsValue = new ToolStripMenuItem(angleUnitTypeFixed.ToString());
                itemAngleUnitsValue.Click += (sender, e) =>
                    apply(new WatchVariableControlSettings(
                        changeAngleUnits: true, newAngleUnits: angleUnitTypeFixed));
                itemsAngleUnitsValue.Add(itemAngleUnitsValue);
            }
            itemAngleUnits.DropDownItems.Add(itemAngleUnitsDefault);
            itemsAngleUnitsValue.ForEach(setAllAngleUnitsValuesItem =>
            {
                itemAngleUnits.DropDownItems.Add(setAllAngleUnitsValuesItem);
            });

            ToolStripMenuItem itemAngleTruncateToMultipleOf16 = new ToolStripMenuItem("Angle: Truncate to Multiple of 16...");
            ControlUtilities.AddDropDownItems(
                itemAngleTruncateToMultipleOf16,
                new List<string>() { "Default", "Truncate to Multiple of 16", "Don't Truncate to Multiple of 16" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeAngleTruncateToMultipleOf16: true, changeAngleTruncateToMultipleOf16ToDefault: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleTruncateToMultipleOf16: true, newAngleTruncateToMultipleOf16: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleTruncateToMultipleOf16: true, newAngleTruncateToMultipleOf16: false)),
                });

            ToolStripMenuItem itemAngleConstrainToOneRevolution = new ToolStripMenuItem("Angle: Constrain to One Revolution...");
            ControlUtilities.AddDropDownItems(
                itemAngleConstrainToOneRevolution,
                new List<string>() { "Default", "Constrain to One Revolution", "Don't Constrain to One Revolution" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeAngleConstrainToOneRevolution: true, changeAngleConstrainToOneRevolutionToDefault: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleConstrainToOneRevolution: true, newAngleConstrainToOneRevolution: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleConstrainToOneRevolution: true, newAngleConstrainToOneRevolution: false)),
                });

            ToolStripMenuItem itemAngleDisplayAsHex = new ToolStripMenuItem("Angle: Display as Hex...");
            ControlUtilities.AddDropDownItems(
                itemAngleDisplayAsHex,
                new List<string>() { "Default", "Hex", "Decimal" },
                new List<Action>()
                {
                    () => apply(new WatchVariableControlSettings(changeAngleDisplayAsHex: true, changeAngleDisplayAsHexToDefault: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleDisplayAsHex: true, newAngleDisplayAsHex: true)),
                    () => apply(new WatchVariableControlSettings(changeAngleDisplayAsHex: true, newAngleDisplayAsHex: false)),
                });

            ToolStripMenuItem itemShowVariableXml = new ToolStripMenuItem("Show Variable XML");
            itemShowVariableXml.Click += (sender, e) =>
            {
                InfoForm infoForm = new InfoForm();
                infoForm.SetText(
                    "Variable Info",
                    "Variable XML",
                    String.Join("\r\n", getVars().ConvertAll(control => control.ToXml(true))));
                infoForm.Show();
            };

            ToolStripMenuItem itemShowVariableInfo = new ToolStripMenuItem("Show Variable Info");
            itemShowVariableInfo.Click += (sender, e) =>
            {
                InfoForm infoForm = new InfoForm();
                infoForm.SetText(
                    "Variable Info",
                    "Variable Info",
                    String.Join("\t",
                        WatchVariableWrapper.GetVarInfoLabels()) +
                        "\r\n" +
                        String.Join(
                            "\r\n",
                            getVars().ConvertAll(control => control.GetVarInfo())
                                .ConvertAll(infoList => String.Join("\t", infoList))));
                infoForm.Show();
            };

            ToolStripMenuItem itemMove = new ToolStripMenuItem("Move...");
            ControlUtilities.AddDropDownItems(
                itemMove,
                new List<string>() { "Start Move", "End Move", "Clear Move" },
                new List<Action>()
                {
                    () => panel.NotifyOfReorderingStart(getVars()),
                    () => panel.NotifyOfReorderingEnd(getVars()),
                    () => panel.NotifyOfReorderingClear(),
                });

            ToolStripMenuItem itemRemove = new ToolStripMenuItem("Remove");
            itemRemove.Click += (sender, e) => panel.RemoveVariables(getVars());

            ToolStripMenuItem itemEnableCustomization = new ToolStripMenuItem("Enable Customization");
            itemEnableCustomization.Click += (sender, e) => apply(new WatchVariableControlSettings(enableCustomization: true));

            ToolStripMenuItem itemOpenController = new ToolStripMenuItem("Open Controller");
            itemOpenController.Click += (sender, e) =>
            {
                List<WatchVariableControl> vars = getVars();
                VariableControllerForm varController =
                    new VariableControllerForm(
                        vars.ConvertAll(control => control.VarName),
                        vars.ConvertAll(control => control.WatchVarWrapper),
                        vars.ConvertAll(control => control.FixedAddressList));
                varController.Show();
            };

            ToolStripMenuItem itemOpenPopOut = new ToolStripMenuItem("Open Pop Out");
            itemOpenPopOut.Click += (sender, e) =>
            {
                VariablePopOutForm form = new VariablePopOutForm();
                form.Initialize(getVars().ConvertAll(control => control.CreateCopy()));
                form.ShowForm();
            };

            ToolStripMenuItem itemAddToTab = new ToolStripMenuItem("Add to Tab...");
            itemAddToTab.Click += (sender, e) => SelectionForm.ShowDataManagerSelectionForm(getVars());

            ToolStripMenuItem itemAddToCustomTab = new ToolStripMenuItem("Add to Custom Tab");
            itemAddToCustomTab.Click += (sender, e) => WatchVariableControl.AddVarsToTab(getVars(), Config.CustomManager);

            return new List<ToolStripItem>
            {
                itemHighlight,
                itemLock,
                itemCopy,
                itemPaste,
                new ToolStripSeparator(),
                itemRoundTo,
                itemDisplayAsHex,
                new ToolStripSeparator(),
                itemAngleSigned,
                itemAngleUnits,
                itemAngleTruncateToMultipleOf16,
                itemAngleConstrainToOneRevolution,
                itemAngleDisplayAsHex,
                new ToolStripSeparator(),
                itemShowVariableXml,
                itemShowVariableInfo,
                new ToolStripSeparator(),
                itemMove,
                itemRemove,
                itemEnableCustomization,
                itemOpenController,
                itemOpenPopOut,
                itemAddToTab,
                itemAddToCustomTab,
            };
        }
Exemplo n.º 10
0
        public VariableControllerForm(
            List <string> varNames, List <WatchVariableWrapper> watchVarWrappers, List <List <uint> > fixedAddressLists)
        {
            _varNames          = varNames;
            _watchVarWrappers  = watchVarWrappers;
            _fixedAddressLists = fixedAddressLists;

            _isDoingContinuousAdd      = false;
            _isDoingContinuousSubtract = false;

            InitializeComponent();
            FormManager.AddForm(this);
            FormClosing += (sender, e) => FormManager.RemoveForm(this);

            _textBoxVarName.Text = String.Join(",", _varNames);

            _addAction = (bool add, bool allowToggle) =>
            {
                List <string> values = ParsingUtilities.ParseStringList(_textBoxAddSubtract.Text);
                if (values.Count == 0)
                {
                    return;
                }
                for (int i = 0; i < _watchVarWrappers.Count; i++)
                {
                    _watchVarWrappers[i].AddValue(values[i % values.Count], add, allowToggle, _fixedAddressLists[i]);
                }
            };
            _buttonAdd.Click      += (s, e) => _addAction(true, true);
            _buttonSubtract.Click += (s, e) => _addAction(false, true);

            Timer addTimer = new Timer {
                Interval = 30
            };

            addTimer.Tick += (s, e) => { if (KeyboardUtilities.IsCtrlHeld())
                                         {
                                             _addAction(true, false);
                                         }
            };
            _buttonAdd.MouseDown += (sender, e) => addTimer.Start();
            _buttonAdd.MouseUp   += (sender, e) => addTimer.Stop();

            ControlUtilities.AddContextMenuStripFunctions(
                _buttonAdd,
                new List <string>()
            {
                "Start Continuous Add", "Stop Continuous Add"
            },
                new List <Action>()
            {
                () => _isDoingContinuousAdd = true, () => _isDoingContinuousAdd = false
            });

            Timer subtractTimer = new Timer {
                Interval = 30
            };

            subtractTimer.Tick += (s, e) => { if (KeyboardUtilities.IsCtrlHeld())
                                              {
                                                  _addAction(false, false);
                                              }
            };
            _buttonSubtract.MouseDown += (sender, e) => subtractTimer.Start();
            _buttonSubtract.MouseUp   += (sender, e) => subtractTimer.Stop();

            ControlUtilities.AddContextMenuStripFunctions(
                _buttonSubtract,
                new List <string>()
            {
                "Start Continuous Subtract", "Stop Continuous Subtract"
            },
                new List <Action>()
            {
                () => _isDoingContinuousSubtract = true, () => _isDoingContinuousSubtract = false
            });

            ToolStripMenuItem itemInvertedAdd      = new ToolStripMenuItem("Inverted");
            ToolStripMenuItem itemInvertedSubtract = new ToolStripMenuItem("Inverted");
            Action <bool>     setInverted          = (bool inverted) =>
            {
                tableLayoutPanel1.Controls.Remove(_buttonAdd);
                tableLayoutPanel1.Controls.Remove(_buttonSubtract);
                if (inverted)
                {
                    tableLayoutPanel1.Controls.Add(_buttonAdd, 0, 2);
                    tableLayoutPanel1.Controls.Add(_buttonSubtract, 2, 2);
                }
                else
                {
                    tableLayoutPanel1.Controls.Add(_buttonAdd, 2, 2);
                    tableLayoutPanel1.Controls.Add(_buttonSubtract, 0, 2);
                }
                itemInvertedAdd.Checked      = inverted;
                itemInvertedSubtract.Checked = inverted;
            };

            itemInvertedAdd.Click      += (sender, e) => setInverted(!itemInvertedAdd.Checked);
            itemInvertedSubtract.Click += (sender, e) => setInverted(!itemInvertedSubtract.Checked);
            _buttonAdd.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            _buttonAdd.ContextMenuStrip.Items.Add(itemInvertedAdd);
            _buttonSubtract.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            _buttonSubtract.ContextMenuStrip.Items.Add(itemInvertedSubtract);

            _buttonGet.Click += (s, e) => _textBoxGetSet.Text = GetValues();

            _buttonSet.Click += (s, e) => SetValues(true);
            _textBoxGetSet.AddEnterAction(() => SetValues(true));

            _checkBoxFixAddress.Click += (s, e) => ToggleFixedAddress();

            _checkBoxLock.Click += (s, e) =>
            {
                List <bool> lockedBools = new List <bool>();
                for (int i = 0; i < _watchVarWrappers.Count; i++)
                {
                    lockedBools.Add(_watchVarWrappers[i].GetLockedBool(_fixedAddressLists[i]));
                }
                bool anyLocked = lockedBools.Any(b => b);
                for (int i = 0; i < _watchVarWrappers.Count; i++)
                {
                    _watchVarWrappers[i].ToggleLocked(!anyLocked, _fixedAddressLists[i]);
                }
            };

            _checkBoxFixAddress.CheckState = BoolUtilities.GetCheckState(
                fixedAddressLists.ConvertAll(fixedAddressList => fixedAddressList != null));

            _textBoxCurrentValue.BackColor = GetColorForCheckState(BoolUtilities.GetCheckState(
                                                                       fixedAddressLists.ConvertAll(fixedAddressList => fixedAddressList != null)));
        }
Exemplo n.º 11
0
        private void AddItemsToContextMenuStrip()
        {
            ToolStripMenuItem resetVariablesItem = new ToolStripMenuItem("Reset Variables");

            resetVariablesItem.Click += (sender, e) => ResetVariables();

            ToolStripMenuItem clearAllButHighlightedItem = new ToolStripMenuItem("Clear All But Highlighted");

            clearAllButHighlightedItem.Click += (sender, e) => ClearAllButHighlightedVariables();

            ToolStripMenuItem fixVerticalScrollItem = new ToolStripMenuItem("Fix Vertical Scroll");

            fixVerticalScrollItem.Click += (sender, e) => FixVerticalScroll();

            ToolStripMenuItem addCustomVariablesItem = new ToolStripMenuItem("Add Custom Variables");

            addCustomVariablesItem.Click += (sender, e) =>
            {
                VariableCreationForm form = new VariableCreationForm();
                form.Initialize(this);
                form.Show();
            };

            ToolStripMenuItem addMappingVariablesItem = new ToolStripMenuItem("Add Mapping Variables");

            addMappingVariablesItem.Click += (sender, e) => AddVariables(MappingConfig.GetVariables());

            ToolStripMenuItem addDummyVariableItem = new ToolStripMenuItem("Add Dummy Variable...");
            List <string>     types = new List <string>(TypeUtilities.InGameTypeList);

            types.Add("string");
            foreach (string typeString in types)
            {
                ToolStripMenuItem typeItem = new ToolStripMenuItem(typeString);
                addDummyVariableItem.DropDownItems.Add(typeItem);
                typeItem.Click += (sender, e) =>
                {
                    int numEntries = 1;
                    if (KeyboardUtilities.IsCtrlHeld())
                    {
                        string numEntriesString = DialogUtilities.GetStringFromDialog(labelText: "Enter Num Vars:");
                        if (numEntriesString == null)
                        {
                            return;
                        }
                        int parsed = ParsingUtilities.ParseInt(numEntriesString);
                        parsed     = Math.Max(parsed, 0);
                        numEntries = parsed;
                    }

                    List <WatchVariableControl> controls = new List <WatchVariableControl>();
                    for (int i = 0; i < numEntries; i++)
                    {
                        string        specialType   = WatchVariableSpecialUtilities.AddDummyEntry(typeString);
                        WatchVariable watchVariable =
                            new WatchVariable(
                                name: specialType,
                                memoryTypeName: null,
                                specialType: specialType,
                                baseAddressType: BaseAddressTypeEnum.None,
                                offsetUS: null,
                                offsetJP: null,
                                offsetSH: null,
                                offsetEU: null,
                                offsetDefault: null,
                                mask: null,
                                shift: null,
                                handleMapping: true);
                        WatchVariableControlPrecursor precursor =
                            new WatchVariableControlPrecursor(
                                name: specialType,
                                watchVar: watchVariable,
                                subclass: typeString == "string" ? WatchVariableSubclass.String : WatchVariableSubclass.Number,
                                backgroundColor: null,
                                displayType: null,
                                roundingLimit: null,
                                useHex: null,
                                invertBool: null,
                                isYaw: null,
                                coordinate: null,
                                groupList: new List <VariableGroup>()
                        {
                            VariableGroup.Custom
                        });
                        WatchVariableControl control = precursor.CreateWatchVariableControl();
                        controls.Add(control);
                    }
                    AddVariables(controls);
                };
            }

            ToolStripMenuItem openSaveClearItem = new ToolStripMenuItem("Open / Save / Clear ...");

            ControlUtilities.AddDropDownItems(
                openSaveClearItem,
                new List <string>()
            {
                "Open", "Open as Pop Out", "Save in Place", "Save As", "Clear"
            },
                new List <Action>()
            {
                () => OpenVariables(),
                () => OpenVariablesAsPopOut(),
                () => SaveVariablesInPlace(),
                () => SaveVariables(),
                () => ClearVariables(),
            });

            ToolStripMenuItem doToAllVariablesItem = new ToolStripMenuItem("Do to all variables...");

            WatchVariableSelectionUtilities.CreateSelectionToolStripItems(
                () => GetCurrentVariableControls(), this)
            .ForEach(item => doToAllVariablesItem.DropDownItems.Add(item));

            ToolStripMenuItem filterVariablesItem = new ToolStripMenuItem("Filter Variables...");

            _filteringDropDownItems = _allGroups.ConvertAll(varGroup => CreateFilterItem(varGroup));
            UpdateFilterItemCheckedStatuses();
            _filteringDropDownItems.ForEach(item => filterVariablesItem.DropDownItems.Add(item));
            filterVariablesItem.DropDown.MouseEnter += (sender, e) =>
            {
                filterVariablesItem.DropDown.AutoClose = false;
            };
            filterVariablesItem.DropDown.MouseLeave += (sender, e) =>
            {
                filterVariablesItem.DropDown.AutoClose = true;
                filterVariablesItem.DropDown.Close();
            };

            ContextMenuStrip.Items.Add(resetVariablesItem);
            ContextMenuStrip.Items.Add(clearAllButHighlightedItem);
            ContextMenuStrip.Items.Add(fixVerticalScrollItem);
            ContextMenuStrip.Items.Add(addCustomVariablesItem);
            ContextMenuStrip.Items.Add(addMappingVariablesItem);
            ContextMenuStrip.Items.Add(addDummyVariableItem);
            ContextMenuStrip.Items.Add(openSaveClearItem);
            ContextMenuStrip.Items.Add(doToAllVariablesItem);
            ContextMenuStrip.Items.Add(filterVariablesItem);
        }
Exemplo n.º 12
0
        private void OnVariableClick()
        {
            this.Focus();

            bool isCtrlKeyHeld     = KeyboardUtilities.IsCtrlHeld();
            bool isShiftKeyHeld    = KeyboardUtilities.IsShiftHeld();
            bool isAltKeyHeld      = KeyboardUtilities.IsAltHeld();
            bool isFKeyHeld        = Keyboard.IsKeyDown(Key.F);
            bool isHKeyHeld        = Keyboard.IsKeyDown(Key.H);
            bool isLKeyHeld        = Keyboard.IsKeyDown(Key.L);
            bool isDKeyHeld        = Keyboard.IsKeyDown(Key.D);
            bool isRKeyHeld        = Keyboard.IsKeyDown(Key.R);
            bool isCKeyHeld        = Keyboard.IsKeyDown(Key.C);
            bool isBKeyHeld        = Keyboard.IsKeyDown(Key.B);
            bool isQKeyHeld        = Keyboard.IsKeyDown(Key.Q);
            bool isOKeyHeld        = Keyboard.IsKeyDown(Key.O);
            bool isTKeyHeld        = Keyboard.IsKeyDown(Key.T);
            bool isMKeyHeld        = Keyboard.IsKeyDown(Key.M);
            bool isNKeyHeld        = Keyboard.IsKeyDown(Key.N);
            bool isPKeyHeld        = Keyboard.IsKeyDown(Key.P);
            bool isXKeyHeld        = Keyboard.IsKeyDown(Key.X);
            bool isSKeyHeld        = Keyboard.IsKeyDown(Key.S);
            bool isDeletishKeyHeld = KeyboardUtilities.IsDeletishKeyHeld();
            bool isBacktickHeld    = Keyboard.IsKeyDown(Key.OemTilde);
            bool isZHeld           = Keyboard.IsKeyDown(Key.Z);
            bool isMinusHeld       = Keyboard.IsKeyDown(Key.OemMinus);
            bool isPlusHeld        = Keyboard.IsKeyDown(Key.OemPlus);
            bool isNumberHeld      = KeyboardUtilities.IsNumberHeld();

            if (isShiftKeyHeld && isNumberHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                BaseColor = ColorUtilities.GetColorForVariable();
            }
            //else if (isSKeyHeld)
            //{
            //    _watchVariablePanel.UnselectAllVariables();
            //    AddToTab(Config.CustomManager);
            //}
            //else if (isTKeyHeld)
            //{
            //    _watchVariablePanel.UnselectAllVariables();
            //    AddToTab(Config.TasManager);
            //}
            //else if (isMKeyHeld)
            //{
            //    _watchVariablePanel.UnselectAllVariables();
            //    AddToTab(Config.MemoryManager);
            //}
            else if (isNKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                WatchVarWrapper.ViewInMemoryTab();
            }
            else if (isFKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                ToggleFixedAddress();
            }
            else if (isHKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                ToggleHighlighted();
            }
            else if (isNumberHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                Color?color = ColorUtilities.GetColorForHighlight();
                ToggleHighlighted(color);
            }
            else if (isLKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                WatchVarWrapper.ToggleLocked(null, FixedAddressListGetter());
            }
            else if (isDKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                WatchVarWrapper.ToggleDisplayAsHex();
            }
            else if (isRKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                RenameMode = true;
            }
            else if (isCKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                WatchVarWrapper.ShowControllerForm();
            }
            else if (isBKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                WatchVarWrapper.ShowBitForm();
            }
            else if (isDeletishKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                RemoveFromPanel();
            }
            else if (isXKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                NotifyPanelOfReodering();
            }
            else if (isBacktickHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                AddToVarHackTab();
            }
            else if (isZHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                SetValue(0);
            }
            else if (isMinusHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                AddValue(1, false);
            }
            else if (isPlusHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                AddValue(1, true);
            }
            else if (isQKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                Color?newColor = ColorUtilities.GetColorFromDialog(BaseColor);
                if (newColor.HasValue)
                {
                    BaseColor = newColor.Value;
                    ColorUtilities.LastCustomColor = newColor.Value;
                }
            }
            else if (isOKeyHeld)
            {
                _watchVariablePanel.UnselectAllVariables();
                BaseColor = ColorUtilities.LastCustomColor;
            }
            else
            {
                _watchVariablePanel.NotifySelectClick(this, isCtrlKeyHeld, isShiftKeyHeld);
            }
        }
Exemplo n.º 13
0
        public TriangleManager(Control tabControl, string varFilePath, WatchVariableFlowLayoutPanel watchVariablePanel)
            : base(varFilePath, watchVariablePanel, ALL_VAR_GROUPS, VISIBLE_VAR_GROUPS)
        {
            _recordedTriangleAddresses = new List <uint>();

            SplitContainer splitContainerTriangles = tabControl.Controls["splitContainerTriangles"] as SplitContainer;

            _addressBox = splitContainerTriangles.Panel1.Controls["textBoxCustomTriangle"] as BetterTextbox;
            _useMisalignmentOffsetCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxVertexMisalignment"] as CheckBox;

            _addressBox.AddEnterAction(() => AddressBoxEnter());

            _radioButtonTriFloor           = splitContainerTriangles.Panel1.Controls["radioButtonTriFloor"] as RadioButton;
            _radioButtonTriFloor.Click    += (sender, e) => Mode_Click(sender, e, TriangleMode.Floor);
            _radioButtonTriWall            = splitContainerTriangles.Panel1.Controls["radioButtonTriWall"] as RadioButton;
            _radioButtonTriWall.Click     += (sender, e) => Mode_Click(sender, e, TriangleMode.Wall);
            _radioButtonTriCeiling         = splitContainerTriangles.Panel1.Controls["radioButtonTriCeiling"] as RadioButton;
            _radioButtonTriCeiling.Click  += (sender, e) => Mode_Click(sender, e, TriangleMode.Ceiling);
            _radioButtonTriCustom          = splitContainerTriangles.Panel1.Controls["radioButtonTriCustom"] as RadioButton;
            _radioButtonTriCustom.Click   += (sender, e) => Mode_Click(sender, e, TriangleMode.Custom);
            _radioButtonTriMapHover        = splitContainerTriangles.Panel1.Controls["radioButtonTriMapHover"] as RadioButton;
            _radioButtonTriMapHover.Click += (sender, e) => Mode_Click(sender, e, TriangleMode.MapHover);

            ControlUtilities.AddContextMenuStripFunctions(
                _radioButtonTriCustom,
                new List <string>()
            {
                "Paste Addresses",
            },
                new List <Action>()
            {
                () => EnterCustomText(Clipboard.GetText()),
            });

            Label labelTriangleSelection = splitContainerTriangles.Panel1.Controls["labelTriangleSelection"] as Label;

            ControlUtilities.AddContextMenuStripFunctions(
                labelTriangleSelection,
                new List <string>()
            {
                "Update Based on Coordinates",
                "Paste Triangles",
            },
                new List <Action>()
            {
                () => UpdateBasedOnCoordinates(),
                () => PasteTriangles(),
            });

            (splitContainerTriangles.Panel1.Controls["buttonGotoV1"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(
                       TriangleAddresses[0], 1, _useMisalignmentOffsetCheckbox.Checked ? TriangleVertexOffset.O_5 : TriangleVertexOffset.NONE);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV2"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(
                       TriangleAddresses[0], 2, _useMisalignmentOffsetCheckbox.Checked ? TriangleVertexOffset.O_5 : TriangleVertexOffset.NONE);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV3"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(
                       TriangleAddresses[0], 3, _useMisalignmentOffsetCheckbox.Checked ? TriangleVertexOffset.O_5 : TriangleVertexOffset.NONE);
            (splitContainerTriangles.Panel1.Controls["buttonGotoVClosest"] as Button).Click += (sender, e) =>
                                                                                               ButtonUtilities.GotoTriangleVertexClosest(
                TriangleAddresses[0], _useMisalignmentOffsetCheckbox.Checked ? TriangleVertexOffset.O_5 : TriangleVertexOffset.NONE);

            ControlUtilities.AddContextMenuStripFunctions(
                (splitContainerTriangles.Panel1.Controls["buttonGotoVClosest"] as Button),
                new List <string>()
            {
                "Goto Closest", "Goto Closest + 0.5", "Goto Closest + 0.999"
            },
                new List <Action>()
            {
                () => ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], TriangleVertexOffset.NONE),
                () => ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], TriangleVertexOffset.O_5),
                () => ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], TriangleVertexOffset.O_999),
            });

            (splitContainerTriangles.Panel1.Controls["buttonRetrieveTriangle"] as Button).Click
                += (sender, e) => ButtonUtilities.RetrieveTriangle(TriangleAddresses);

            Button buttonNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["buttonNeutralizeTriangle"] as Button;

            buttonNeutralizeTriangle.Click += (sender, e) => ButtonUtilities.NeutralizeTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonNeutralizeTriangle,
                new List <string>()
            {
                "Neutralize", "Neutralize with 0", "Neutralize with 0x15"
            },
                new List <Action>()
            {
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, false),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, true),
            });

            Button buttonAnnihilateTriangle = splitContainerTriangles.Panel1.Controls["buttonAnnihilateTriangle"] as Button;

            buttonAnnihilateTriangle.Click += (sender, e) => ButtonUtilities.AnnihilateTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonAnnihilateTriangle,
                new List <string>()
            {
                "Annihilate All Tri But Death Barriers",
                "Annihilate All Ceilings",
            },
                new List <Action>()
            {
                () => TriangleUtilities.AnnihilateAllTrianglesButDeathBarriers(),
                () => TriangleUtilities.AnnihilateAllCeilings(),
            });

            var trianglePosGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTrianglePos"] as GroupBox;

            ControlUtilities.InitializeThreeDimensionController(
                CoordinateSystem.Euler,
                true,
                trianglePosGroupBox,
                trianglePosGroupBox.Controls["buttonTrianglePosXn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYn"] as Button,
                trianglePosGroupBox.Controls["textBoxTrianglePosXZ"] as TextBox,
                trianglePosGroupBox.Controls["textBoxTrianglePosY"] as TextBox,
                trianglePosGroupBox.Controls["checkBoxTrianglePosRelative"] as CheckBox,
                (float hOffset, float vOffset, float nOffset, bool useRelative) =>
            {
                ButtonUtilities.MoveTriangle(
                    TriangleAddresses,
                    hOffset,
                    nOffset,
                    -1 * vOffset,
                    useRelative,
                    KeyboardUtilities.IsCtrlHeld());
            });

            var triangleNormalGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTriangleNormal"] as GroupBox;

            ControlUtilities.InitializeScalarController(
                triangleNormalGroupBox.Controls["buttontriangleNormalN"] as Button,
                triangleNormalGroupBox.Controls["buttontriangleNormalP"] as Button,
                triangleNormalGroupBox.Controls["textBoxTriangleNormal"] as TextBox,
                (float normalValue) =>
            {
                ButtonUtilities.MoveTriangleNormal(TriangleAddresses, normalValue);
            });

            _checkBoxNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["checkBoxNeutralizeTriangle"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowCoords"] as Button).Click
                += (sender, e) => ShowTriangleCoordinates();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowEquation"] as Button).Click
                += (sender, e) => ShowTriangleEquation();

            _recordTriangleDataCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRecordTriangleData"] as CheckBox;
            _recordTriangleCountLabel   = splitContainerTriangles.Panel1.Controls["labelRecordTriangleCount"] as Label;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowData"] as Button).Click
                += (sender, e) => ShowTriangleData();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowVertices"] as Button).Click
                += (sender, e) => ShowTriangleVertices();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAddresses"] as Button).Click
                += (sender, e) => ShowTriangleAddresses();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleClearData"] as Button).Click
                += (sender, e) => ClearTriangleData();

            _repeatFirstVertexCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRepeatFirstVertex"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowLevelTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetLevelTriangles());

            Button buttonTriangleShowObjTris = splitContainerTriangles.Panel1.Controls["buttonTriangleShowObjTris"] as Button;

            buttonTriangleShowObjTris.Click += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles());
            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleShowObjTris,
                new List <string>()
            {
                "Show All Object Tris", "Show Selected Object Tris"
            },
                new List <Action>()
            {
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles()),
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetSelectedObjectTriangles()),
            });

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAllTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetAllTriangles());

            var buttonTriangleNeutralizeAllTriangles = splitContainerTriangles.Panel1.Controls["buttonTriangleNeutralizeAllTriangles"] as Button;

            buttonTriangleNeutralizeAllTriangles.Click += (sender, e) => TriangleUtilities.NeutralizeTriangles();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleNeutralizeAllTriangles,
                new List <string>()
            {
                "Neutralize All Triangles",
                "Neutralize Wall Triangles",
                "Neutralize Floor Triangles",
                "Neutralize Ceiling Triangles",
                "Neutralize Death Barriers",
                "Neutralize Lava",
                "Neutralize Sleeping",
                "Neutralize Loading Zones"
            },
                new List <Action>()
            {
                () => TriangleUtilities.NeutralizeTriangles(),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Wall),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Floor),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Ceiling),
                () => TriangleUtilities.NeutralizeTriangles(0x0A),
                () => TriangleUtilities.NeutralizeTriangles(0x01),
                () => TriangleUtilities.NeutralizeSleeping(),
                () => {
                    TriangleUtilities.NeutralizeTriangles(0x1B);
                    TriangleUtilities.NeutralizeTriangles(0x1C);
                    TriangleUtilities.NeutralizeTriangles(0x1D);
                    TriangleUtilities.NeutralizeTriangles(0x1E);
                },
            });

            var buttonTriangleDisableAllCamCollision = splitContainerTriangles.Panel1.Controls["buttonTriangleDisableAllCamCollision"] as Button;

            buttonTriangleDisableAllCamCollision.Click += (sender, e) => TriangleUtilities.DisableCamCollision();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleDisableAllCamCollision,
                new List <string>()
            {
                "Disable Cam Collision for All Triangles",
                "Disable Cam Collision for Wall Triangles",
                "Disable Cam Collision for Floor Triangles",
                "Disable Cam Collision for Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.DisableCamCollision(),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Wall),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Floor),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Ceiling),
            });

            GroupBox groupBoxTriangleTypeConversion        = splitContainerTriangles.Panel1.Controls["groupBoxTriangleTypeConversion"] as GroupBox;
            ComboBox comboBoxTriangleTypeConversionConvert = groupBoxTriangleTypeConversion.Controls["comboBoxTriangleTypeConversionConvert"] as ComboBox;
            TextBox  textBoxTriangleTypeConversionFromType = groupBoxTriangleTypeConversion.Controls["textBoxTriangleTypeConversionFromType"] as TextBox;
            TextBox  textBoxTriangleTypeConversionToType   = groupBoxTriangleTypeConversion.Controls["textBoxTriangleTypeConversionToType"] as TextBox;
            Button   buttonTriangleTypeConversionConvert   = groupBoxTriangleTypeConversion.Controls["buttonTriangleTypeConversionConvert"] as Button;

            comboBoxTriangleTypeConversionConvert.DataSource = EnumUtilities.GetEnumValues <TriangleClassificationExtended>(typeof(TriangleClassificationExtended));

            buttonTriangleTypeConversionConvert.Click += (sender, e) =>
            {
                TriangleClassificationExtended classification = (TriangleClassificationExtended)comboBoxTriangleTypeConversionConvert.SelectedItem;
                short?fromType = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionFromType.Text);
                short?toType   = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionToType.Text);
                if (!fromType.HasValue || !toType.HasValue)
                {
                    return;
                }
                TriangleUtilities.ConvertSurfaceTypes(classification, fromType.Value, toType.Value);
            };
        }
        public static List <ToolStripItem> CreateSelectionToolStripItems(
            Func <List <WatchVariableControl> > getVars,
            WatchVariableFlowLayoutPanel panel)
        {
            Action <WatchVariableControlSettings, List <WatchVariableControl> > apply2 =
                (WatchVariableControlSettings settings, List <WatchVariableControl> vars) =>
            {
                if (KeyboardUtilities.IsCtrlHeld())
                {
                    WatchVariableControlSettingsManager.AddSettings(settings);
                }
                else
                {
                    vars.ForEach(control => control.ApplySettings(settings));
                }
            };

            Action <WatchVariableControlSettings> apply = (WatchVariableControlSettings settings) => apply2(settings, getVars());

            ToolStripMenuItem itemHighlight = new ToolStripMenuItem("Highlight...");

            ControlUtilities.AddDropDownItems(
                itemHighlight,
                new List <string>()
            {
                "Highlight", "Don't Highlight"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeHighlighted: true, newHighlighted: true)),
                () => apply(new WatchVariableControlSettings(changeHighlighted: true, newHighlighted: false)),
            });
            ToolStripMenuItem itemHighlightColor = new ToolStripMenuItem("Color...");

            ControlUtilities.AddDropDownItems(
                itemHighlightColor,
                new List <string>()
            {
                "Red",
                "Orange",
                "Yellow",
                "Green",
                "Blue",
                "Purple",
                "Pink",
                "Brown",
                "Black",
                "White",
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Red)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Orange)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Yellow)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Green)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Blue)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Purple)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Pink)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Brown)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.Black)),
                () => apply(new WatchVariableControlSettings(changeHighlightColor: true, newHighlightColor: Color.White)),
            });
            itemHighlight.DropDownItems.Add(itemHighlightColor);

            ToolStripMenuItem itemLock = new ToolStripMenuItem("Lock...");

            ControlUtilities.AddDropDownItems(
                itemLock,
                new List <string>()
            {
                "Lock", "Don't Lock"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeLocked: true, newLocked: true)),
                () => apply(new WatchVariableControlSettings(changeLocked: true, newLocked: false)),
            });

            ToolStripMenuItem itemFixAddress = new ToolStripMenuItem("Fix Address...");

            ControlUtilities.AddDropDownItems(
                itemFixAddress,
                new List <string>()
            {
                "Default", "Fix Address", "Don't Fix Address"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeFixedAddress: true, changeFixedAddressToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeFixedAddress: true, newFixedAddress: true)),
                () => apply(new WatchVariableControlSettings(changeFixedAddress: true, newFixedAddress: false)),
            });

            ToolStripMenuItem itemCopy = new ToolStripMenuItem("Copy...");

            CopyUtilities.AddDropDownItems(itemCopy, getVars);

            ToolStripMenuItem itemPaste = new ToolStripMenuItem("Paste");

            itemPaste.Click += (sender, e) =>
            {
                List <WatchVariableControl> varList = getVars();
                List <string> stringList            = ParsingUtilities.ParseStringList(Clipboard.GetText());
                if (stringList.Count == 0)
                {
                    return;
                }

                Config.Stream.Suspend();
                for (int i = 0; i < varList.Count; i++)
                {
                    varList[i].SetValue(stringList[i % stringList.Count]);
                }
                Config.Stream.Resume();
            };

            ToolStripMenuItem itemRoundTo        = new ToolStripMenuItem("Round to...");
            ToolStripMenuItem itemRoundToDefault = new ToolStripMenuItem("Default");

            itemRoundToDefault.Click += (sender, e) =>
                                        apply(new WatchVariableControlSettings(
                                                  changeRoundingLimit: true, changeRoundingLimitToDefault: true));
            ToolStripMenuItem itemRoundToNoRounding = new ToolStripMenuItem("No Rounding");

            itemRoundToNoRounding.Click += (sender, e) =>
                                           apply(new WatchVariableControlSettings(
                                                     changeRoundingLimit: true, newRoundingLimit: -1));
            List <ToolStripMenuItem> itemsRoundToNumDecimalPlaces = new List <ToolStripMenuItem>();

            for (int i = 0; i <= 10; i++)
            {
                int index = i;
                itemsRoundToNumDecimalPlaces.Add(new ToolStripMenuItem(index + " decimal place(s)"));
                itemsRoundToNumDecimalPlaces[index].Click += (sender, e) =>
                                                             apply(new WatchVariableControlSettings(
                                                                       changeRoundingLimit: true, newRoundingLimit: index));
            }
            itemRoundTo.DropDownItems.Add(itemRoundToDefault);
            itemRoundTo.DropDownItems.Add(itemRoundToNoRounding);
            itemsRoundToNumDecimalPlaces.ForEach(setAllRoundingLimitsNumberItem =>
            {
                itemRoundTo.DropDownItems.Add(setAllRoundingLimitsNumberItem);
            });

            ToolStripMenuItem itemDisplayAsHex = new ToolStripMenuItem("Display as Hex...");

            ControlUtilities.AddDropDownItems(
                itemDisplayAsHex,
                new List <string>()
            {
                "Default", "Hex", "Decimal"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeDisplayAsHex: true, changeDisplayAsHexToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeDisplayAsHex: true, newDisplayAsHex: true)),
                () => apply(new WatchVariableControlSettings(changeDisplayAsHex: true, newDisplayAsHex: false)),
            });

            ToolStripMenuItem itemAngleSigned = new ToolStripMenuItem("Angle: Signed...");

            ControlUtilities.AddDropDownItems(
                itemAngleSigned,
                new List <string>()
            {
                "Default", "Unsigned", "Signed"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeAngleSigned: true, changeAngleSignedToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeAngleSigned: true, newAngleSigned: false)),
                () => apply(new WatchVariableControlSettings(changeAngleSigned: true, newAngleSigned: true)),
            });

            ToolStripMenuItem itemAngleUnits        = new ToolStripMenuItem("Angle: Units...");
            ToolStripMenuItem itemAngleUnitsDefault = new ToolStripMenuItem("Default");

            itemAngleUnitsDefault.Click += (sender, e) =>
                                           apply(new WatchVariableControlSettings(
                                                     changeAngleUnits: true, changeAngleUnitsToDefault: true));
            List <ToolStripMenuItem> itemsAngleUnitsValue = new List <ToolStripMenuItem>();

            foreach (AngleUnitType angleUnitType in Enum.GetValues(typeof(AngleUnitType)))
            {
                AngleUnitType angleUnitTypeFixed = angleUnitType;
                string        stringValue        = angleUnitTypeFixed.ToString();
                if (stringValue == AngleUnitType.InGameUnits.ToString())
                {
                    stringValue = "In-Game Units";
                }
                ToolStripMenuItem itemAngleUnitsValue = new ToolStripMenuItem(stringValue);
                itemAngleUnitsValue.Click += (sender, e) =>
                                             apply(new WatchVariableControlSettings(
                                                       changeAngleUnits: true, newAngleUnits: angleUnitTypeFixed));
                itemsAngleUnitsValue.Add(itemAngleUnitsValue);
            }
            itemAngleUnits.DropDownItems.Add(itemAngleUnitsDefault);
            itemsAngleUnitsValue.ForEach(setAllAngleUnitsValuesItem =>
            {
                itemAngleUnits.DropDownItems.Add(setAllAngleUnitsValuesItem);
            });

            ToolStripMenuItem itemAngleTruncateToMultipleOf16 = new ToolStripMenuItem("Angle: Truncate to Multiple of 16...");

            ControlUtilities.AddDropDownItems(
                itemAngleTruncateToMultipleOf16,
                new List <string>()
            {
                "Default", "Truncate to Multiple of 16", "Don't Truncate to Multiple of 16"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeAngleTruncateToMultipleOf16: true, changeAngleTruncateToMultipleOf16ToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeAngleTruncateToMultipleOf16: true, newAngleTruncateToMultipleOf16: true)),
                () => apply(new WatchVariableControlSettings(changeAngleTruncateToMultipleOf16: true, newAngleTruncateToMultipleOf16: false)),
            });

            ToolStripMenuItem itemAngleConstrainToOneRevolution = new ToolStripMenuItem("Angle: Constrain to One Revolution...");

            ControlUtilities.AddDropDownItems(
                itemAngleConstrainToOneRevolution,
                new List <string>()
            {
                "Default", "Constrain to One Revolution", "Don't Constrain to One Revolution"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeAngleConstrainToOneRevolution: true, changeAngleConstrainToOneRevolutionToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeAngleConstrainToOneRevolution: true, newAngleConstrainToOneRevolution: true)),
                () => apply(new WatchVariableControlSettings(changeAngleConstrainToOneRevolution: true, newAngleConstrainToOneRevolution: false)),
            });

            ToolStripMenuItem itemAngleReverse = new ToolStripMenuItem("Angle: Reverse...");

            ControlUtilities.AddDropDownItems(
                itemAngleReverse,
                new List <string>()
            {
                "Default", "Reverse", "Don't Reverse"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeAngleReverse: true, changeAngleReverseToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeAngleReverse: true, newAngleReverse: true)),
                () => apply(new WatchVariableControlSettings(changeAngleReverse: true, newAngleReverse: false)),
            });

            ToolStripMenuItem itemAngleDisplayAsHex = new ToolStripMenuItem("Angle: Display as Hex...");

            ControlUtilities.AddDropDownItems(
                itemAngleDisplayAsHex,
                new List <string>()
            {
                "Default", "Hex", "Decimal"
            },
                new List <Action>()
            {
                () => apply(new WatchVariableControlSettings(changeAngleDisplayAsHex: true, changeAngleDisplayAsHexToDefault: true)),
                () => apply(new WatchVariableControlSettings(changeAngleDisplayAsHex: true, newAngleDisplayAsHex: true)),
                () => apply(new WatchVariableControlSettings(changeAngleDisplayAsHex: true, newAngleDisplayAsHex: false)),
            });

            ToolStripMenuItem itemShowVariableXml = new ToolStripMenuItem("Show Variable XML");

            itemShowVariableXml.Click += (sender, e) =>
            {
                InfoForm infoForm = new InfoForm();
                infoForm.SetText(
                    "Variable Info",
                    "Variable XML",
                    String.Join("\r\n", getVars().ConvertAll(control => control.ToXml(true))));
                infoForm.Show();
            };

            ToolStripMenuItem itemShowVariableInfo = new ToolStripMenuItem("Show Variable Info");

            itemShowVariableInfo.Click += (sender, e) =>
            {
                InfoForm infoForm = new InfoForm();
                infoForm.SetText(
                    "Variable Info",
                    "Variable Info",
                    String.Join("\t",
                                WatchVariableWrapper.GetVarInfoLabels()) +
                    "\r\n" +
                    String.Join(
                        "\r\n",
                        getVars().ConvertAll(control => control.GetVarInfo())
                        .ConvertAll(infoList => String.Join("\t", infoList))));
                infoForm.Show();
            };

            void createBinaryMathOperationVariable(BinaryMathOperation operation)
            {
                List <WatchVariableControl> controls = getVars();

                if (controls.Count % 2 == 1)
                {
                    controls.RemoveAt(controls.Count - 1);
                }

                for (int i = 0; i < controls.Count / 2; i++)
                {
                    WatchVariableControl control1 = controls[i];
                    WatchVariableControl control2 = controls[i + controls.Count / 2];
                    string specialType            = WatchVariableSpecialUtilities.AddBinaryMathOperationEntry(control1, control2, operation);

                    WatchVariable watchVariable =
                        new WatchVariable(
                            memoryTypeName: null,
                            specialType: specialType,
                            baseAddressType: BaseAddressTypeEnum.None,
                            offsetUS: null,
                            offsetJP: null,
                            offsetSH: null,
                            offsetEU: null,
                            offsetDefault: null,
                            mask: null,
                            shift: null,
                            handleMapping: true);
                    WatchVariableControlPrecursor precursor =
                        new WatchVariableControlPrecursor(
                            name: string.Format("{0} {1} {2}", control1.VarName, MathOperationUtilities.GetSymbol(operation), control2.VarName),
                            watchVar: watchVariable,
                            subclass: WatchVariableSubclass.Number,
                            backgroundColor: null,
                            displayType: null,
                            roundingLimit: null,
                            useHex: null,
                            invertBool: null,
                            isYaw: null,
                            coordinate: null,
                            groupList: new List <VariableGroup>()
                    {
                        VariableGroup.Custom
                    });
                    WatchVariableControl control = precursor.CreateWatchVariableControl();
                    panel.AddVariable(control);
                }
            }

            void createAggregateMathOperationVariable(AggregateMathOperation operation)
            {
                List <WatchVariableControl> controls = getVars();

                if (controls.Count == 0)
                {
                    return;
                }
                string        specialType   = WatchVariableSpecialUtilities.AddAggregateMathOperationEntry(controls, operation);
                WatchVariable watchVariable =
                    new WatchVariable(
                        memoryTypeName: null,
                        specialType: specialType,
                        baseAddressType: BaseAddressTypeEnum.None,
                        offsetUS: null,
                        offsetJP: null,
                        offsetSH: null,
                        offsetEU: null,
                        offsetDefault: null,
                        mask: null,
                        shift: null,
                        handleMapping: true);
                WatchVariableControlPrecursor precursor =
                    new WatchVariableControlPrecursor(
                        name: operation.ToString(),
                        watchVar: watchVariable,
                        subclass: WatchVariableSubclass.Number,
                        backgroundColor: null,
                        displayType: null,
                        roundingLimit: null,
                        useHex: null,
                        invertBool: null,
                        isYaw: null,
                        coordinate: null,
                        groupList: new List <VariableGroup>()
                {
                    VariableGroup.Custom
                });
                WatchVariableControl control = precursor.CreateWatchVariableControl();

                panel.AddVariable(control);
            }

            void createDistanceMathOperationVariable(bool use3D)
            {
                List <WatchVariableControl> controls = getVars();
                bool satisfies2D = !use3D && controls.Count >= 4;
                bool satisfies3D = use3D && controls.Count >= 6;

                if (!satisfies2D && !satisfies3D)
                {
                    return;
                }
                string specialType = WatchVariableSpecialUtilities.AddDistanceMathOperationEntry(controls, use3D);
                string name        = use3D ?
                                     string.Format(
                    "({0},{1},{2}) to ({3},{4},{5})",
                    controls[0].VarName,
                    controls[1].VarName,
                    controls[2].VarName,
                    controls[3].VarName,
                    controls[4].VarName,
                    controls[5].VarName) :
                                     string.Format(
                    "({0},{1}) to ({2},{3})",
                    controls[0].VarName,
                    controls[1].VarName,
                    controls[2].VarName,
                    controls[3].VarName);
                WatchVariable watchVariable =
                    new WatchVariable(
                        memoryTypeName: null,
                        specialType: specialType,
                        baseAddressType: BaseAddressTypeEnum.None,
                        offsetUS: null,
                        offsetJP: null,
                        offsetSH: null,
                        offsetEU: null,
                        offsetDefault: null,
                        mask: null,
                        shift: null,
                        handleMapping: true);
                WatchVariableControlPrecursor precursor =
                    new WatchVariableControlPrecursor(
                        name: name,
                        watchVar: watchVariable,
                        subclass: WatchVariableSubclass.Number,
                        backgroundColor: null,
                        displayType: null,
                        roundingLimit: null,
                        useHex: null,
                        invertBool: null,
                        isYaw: null,
                        coordinate: null,
                        groupList: new List <VariableGroup>()
                {
                    VariableGroup.Custom
                });
                WatchVariableControl control = precursor.CreateWatchVariableControl();

                panel.AddVariable(control);
            }

            void createRealTimeVariable()
            {
                List <WatchVariableControl> controls = getVars();

                for (int i = 0; i < controls.Count; i++)
                {
                    WatchVariableControl control = controls[i];
                    string specialType           = WatchVariableSpecialUtilities.AddRealTimeEntry(control);

                    WatchVariable watchVariable =
                        new WatchVariable(
                            memoryTypeName: null,
                            specialType: specialType,
                            baseAddressType: BaseAddressTypeEnum.None,
                            offsetUS: null,
                            offsetJP: null,
                            offsetSH: null,
                            offsetEU: null,
                            offsetDefault: null,
                            mask: null,
                            shift: null,
                            handleMapping: true);
                    WatchVariableControlPrecursor precursor =
                        new WatchVariableControlPrecursor(
                            name: string.Format("{0} Real Time", control.VarName),
                            watchVar: watchVariable,
                            subclass: WatchVariableSubclass.String,
                            backgroundColor: null,
                            displayType: null,
                            roundingLimit: null,
                            useHex: null,
                            invertBool: null,
                            isYaw: null,
                            coordinate: null,
                            groupList: new List <VariableGroup>()
                    {
                        VariableGroup.Custom
                    });
                    WatchVariableControl control2 = precursor.CreateWatchVariableControl();
                    panel.AddVariable(control2);
                }
            }

            ToolStripMenuItem itemAddVariables = new ToolStripMenuItem("Add Variable(s)...");

            ControlUtilities.AddDropDownItems(
                itemAddVariables,
                new List <string>()
            {
                "Addition",
                "Subtraction",
                "Multiplication",
                "Division",
                "Modulo",
                "Non-Negative Modulo",
                "Exponent",
                null,
                "Mean",
                "Median",
                "Min",
                "Max",
                null,
                "2D Distance",
                "3D Distance",
                null,
                "Real Time",
            },
                new List <Action>()
            {
                () => createBinaryMathOperationVariable(BinaryMathOperation.Add),
                () => createBinaryMathOperationVariable(BinaryMathOperation.Subtract),
                () => createBinaryMathOperationVariable(BinaryMathOperation.Multiply),
                () => createBinaryMathOperationVariable(BinaryMathOperation.Divide),
                () => createBinaryMathOperationVariable(BinaryMathOperation.Modulo),
                () => createBinaryMathOperationVariable(BinaryMathOperation.NonNegativeModulo),
                () => createBinaryMathOperationVariable(BinaryMathOperation.Exponent),
                () => { },
                () => createAggregateMathOperationVariable(AggregateMathOperation.Mean),
                () => createAggregateMathOperationVariable(AggregateMathOperation.Median),
                () => createAggregateMathOperationVariable(AggregateMathOperation.Min),
                () => createAggregateMathOperationVariable(AggregateMathOperation.Max),
                () => { },
                () => createDistanceMathOperationVariable(use3D: false),
                () => createDistanceMathOperationVariable(use3D: true),
                () => { },
                () => createRealTimeVariable(),
            });

            ToolStripMenuItem itemSetCascadingValues = new ToolStripMenuItem("Set Cascading Values");

            itemSetCascadingValues.Click += (sender, e) =>
            {
                List <WatchVariableControl> controls = getVars();
                object value1 = DialogUtilities.GetStringFromDialog(labelText: "Base Value:");
                object value2 = DialogUtilities.GetStringFromDialog(labelText: "Offset Value:");
                if (value1 == null || value2 == null)
                {
                    return;
                }
                double?number1 = ParsingUtilities.ParseDoubleNullable(value1);
                double?number2 = ParsingUtilities.ParseDoubleNullable(value2);
                if (!number1.HasValue || !number2.HasValue)
                {
                    return;
                }
                List <Func <object, bool> > setters = controls.SelectMany(control => control.GetSetters()).ToList();
                for (int i = 0; i < setters.Count; i++)
                {
                    setters[i](number1.Value + i * number2.Value);
                }
            };

            List <string> backgroundColorStringList = new List <string>();
            List <Action> backgroundColorActionList = new List <Action>();

            backgroundColorStringList.Add("Default");
            backgroundColorActionList.Add(
                () => apply(new WatchVariableControlSettings(changeBackgroundColor: true, changeBackgroundColorToDefault: true)));
            foreach (KeyValuePair <string, string> pair in ColorUtilities.ColorToParamsDictionary)
            {
                Color  color       = ColorTranslator.FromHtml(pair.Value);
                string colorString = pair.Key;
                if (colorString == "LightBlue")
                {
                    colorString = "Light Blue";
                }
                backgroundColorStringList.Add(colorString);
                backgroundColorActionList.Add(
                    () => apply(new WatchVariableControlSettings(changeBackgroundColor: true, newBackgroundColor: color)));
            }
            backgroundColorStringList.Add("Control (No Color)");
            backgroundColorActionList.Add(
                () => apply(new WatchVariableControlSettings(changeBackgroundColor: true, newBackgroundColor: SystemColors.Control)));
            backgroundColorStringList.Add("Custom Color");
            backgroundColorActionList.Add(
                () =>
            {
                List <WatchVariableControl> vars = getVars();
                Color?newColor = ColorUtilities.GetColorFromDialog(SystemColors.Control);
                if (newColor.HasValue)
                {
                    apply2(new WatchVariableControlSettings(changeBackgroundColor: true, newBackgroundColor: newColor.Value), vars);
                    ColorUtilities.LastCustomColor = newColor.Value;
                }
            });
            backgroundColorStringList.Add("Last Custom Color");
            backgroundColorActionList.Add(
                () => apply(new WatchVariableControlSettings(changeBackgroundColor: true, newBackgroundColor: ColorUtilities.LastCustomColor)));
            ToolStripMenuItem itemBackgroundColor = new ToolStripMenuItem("Background Color...");

            ControlUtilities.AddDropDownItems(
                itemBackgroundColor,
                backgroundColorStringList,
                backgroundColorActionList);

            ToolStripMenuItem itemMove = new ToolStripMenuItem("Move...");

            ControlUtilities.AddDropDownItems(
                itemMove,
                new List <string>()
            {
                "Start Move", "End Move", "Clear Move"
            },
                new List <Action>()
            {
                () => panel.NotifyOfReorderingStart(getVars()),
                () => panel.NotifyOfReorderingEnd(getVars()),
                () => panel.NotifyOfReorderingClear(),
            });

            ToolStripMenuItem itemRemove = new ToolStripMenuItem("Remove");

            itemRemove.Click += (sender, e) => panel.RemoveVariables(getVars());

            ToolStripMenuItem itemRename = new ToolStripMenuItem("Rename...");

            itemRename.Click += (sender, e) =>
            {
                List <WatchVariableControl> watchVars = getVars();
                string template = DialogUtilities.GetStringFromDialog("$");
                if (template == null)
                {
                    return;
                }
                foreach (WatchVariableControl control in watchVars)
                {
                    control.VarName = template.Replace("$", control.VarName);
                }
            };

            ToolStripMenuItem itemOpenController = new ToolStripMenuItem("Open Controller");

            itemOpenController.Click += (sender, e) =>
            {
                List <WatchVariableControl> vars          = getVars();
                VariableControllerForm      varController =
                    new VariableControllerForm(
                        vars.ConvertAll(control => control.VarName),
                        vars.ConvertAll(control => control.WatchVarWrapper),
                        vars.ConvertAll(control => control.FixedAddressList));
                varController.Show();
            };

            ToolStripMenuItem itemOpenTripletController = new ToolStripMenuItem("Open Triplet Controller");

            itemOpenTripletController.Click += (sender, e) =>
            {
                VariableTripletControllerForm form = new VariableTripletControllerForm();
                form.Initialize(getVars().ConvertAll(control => control.CreateCopy()));
                form.ShowForm();
            };

            ToolStripMenuItem itemOpenPopOut = new ToolStripMenuItem("Open Pop Out");

            itemOpenPopOut.Click += (sender, e) =>
            {
                VariablePopOutForm form = new VariablePopOutForm();
                form.Initialize(getVars().ConvertAll(control => control.CreateCopy()));
                form.ShowForm();
            };

            ToolStripMenuItem itemAddToTab = new ToolStripMenuItem("Add to Tab...");

            ControlUtilities.AddDropDownItems(
                itemAddToTab,
                new List <string>()
            {
                "Regular", "Fixed", "Grouped by Base Address", "Grouped by Variable"
            },
                new List <Action>()
            {
                () => SelectionForm.ShowDataManagerSelectionForm(getVars(), AddToTabTypeEnum.Regular),
                () => SelectionForm.ShowDataManagerSelectionForm(getVars(), AddToTabTypeEnum.Fixed),
                () => SelectionForm.ShowDataManagerSelectionForm(getVars(), AddToTabTypeEnum.GroupedByBaseAddress),
                () => SelectionForm.ShowDataManagerSelectionForm(getVars(), AddToTabTypeEnum.GroupedByVariable),
            });

            ToolStripMenuItem itemAddToCustomTab = new ToolStripMenuItem("Add to Custom Tab...");

            ControlUtilities.AddDropDownItems(
                itemAddToCustomTab,
                new List <string>()
            {
                "Regular", "Fixed", "Grouped by Base Address", "Grouped by Variable"
            },
                new List <Action>()
            {
                () => WatchVariableControl.AddVarsToTab(getVars(), Config.CustomManager, AddToTabTypeEnum.Regular),
                () => WatchVariableControl.AddVarsToTab(getVars(), Config.CustomManager, AddToTabTypeEnum.Fixed),
                () => WatchVariableControl.AddVarsToTab(getVars(), Config.CustomManager, AddToTabTypeEnum.GroupedByBaseAddress),
                () => WatchVariableControl.AddVarsToTab(getVars(), Config.CustomManager, AddToTabTypeEnum.GroupedByVariable),
            });

            return(new List <ToolStripItem>()
            {
                itemHighlight,
                itemLock,
                itemFixAddress,
                itemCopy,
                itemPaste,
                new ToolStripSeparator(),
                itemRoundTo,
                itemDisplayAsHex,
                new ToolStripSeparator(),
                itemAngleSigned,
                itemAngleUnits,
                itemAngleTruncateToMultipleOf16,
                itemAngleConstrainToOneRevolution,
                itemAngleReverse,
                itemAngleDisplayAsHex,
                new ToolStripSeparator(),
                itemShowVariableXml,
                itemShowVariableInfo,
                new ToolStripSeparator(),
                itemAddVariables,
                itemSetCascadingValues,
                new ToolStripSeparator(),
                itemBackgroundColor,
                itemMove,
                itemRemove,
                itemRename,
                itemOpenController,
                itemOpenTripletController,
                itemOpenPopOut,
                itemAddToTab,
                itemAddToCustomTab,
            });
        }
Exemplo n.º 15
0
        public void DrawOn2DControl(bool isMainGraphics)
        {
            List <MapObject> listOrderOnTop    = new List <MapObject>();
            List <MapObject> listOrderOnBottom = new List <MapObject>();
            List <MapObject> listOrderByY      = new List <MapObject>();

            MapType mapType = Config.CurrentMapGraphics.IsOrthographicViewEnabled ? MapType.Map2DOrthographic : MapType.Map2DTopDown;

            lock (_objectLock)
            {
                foreach (MapTracker mapTracker in Controls)
                {
                    List <MapObject> mapObjects = mapTracker.GetMapObjectsToDisplay(mapType);
                    switch (mapTracker.GetOrderType())
                    {
                    case MapTrackerOrderType.OrderOnTop:
                        listOrderOnTop.AddRange(mapObjects);
                        break;

                    case MapTrackerOrderType.OrderOnBottom:
                        listOrderOnBottom.AddRange(mapObjects);
                        break;

                    case MapTrackerOrderType.OrderByY:
                        listOrderByY.AddRange(mapObjects);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }

            listOrderOnTop.Reverse();
            listOrderOnBottom.Reverse();
            listOrderByY.Reverse();
            listOrderByY = listOrderByY.OrderBy(obj => obj.GetY()).ToList();
            List <MapObject> listCombined = listOrderOnBottom.Concat(listOrderByY).Concat(listOrderOnTop).ToList();

            if (!Config.MapGui.checkBoxMapOptionsDisableHitboxTris.Checked)
            {
                listCombined.Insert(0, _mapObjHitboxTris);
            }
            listCombined.Insert(0, _mapObjMap);
            listCombined.Insert(0, _mapObjBackground);

            MapObjectHoverData hoverData = null;

            if (isMainGraphics &&
                !Config.MapGui.checkBoxMapOptionsEnable3D.Checked &&
                Config.MapGui.checkBoxMapOptionsEnableObjectHover.Checked)
            {
                for (int i = listCombined.Count - 1; i >= 0; i--)
                {
                    MapObject mapObject = listCombined[i];
                    hoverData = mapObject.GetHoverData(false, false);
                    if (hoverData != null)
                    {
                        break;
                    }
                }
                if (hoverData == null || KeyboardUtilities.IsCtrlHeld())
                {
                    hoverData = MapObjectHoverData.GetMapObjectHoverDataForCursor(false);
                }
                if (Config.CurrentMapGraphics.DraggedObject != null)
                {
                    hoverData = Config.CurrentMapGraphics.DraggedObject;
                }
                if (!Equals(PreviousHoverData, hoverData))
                {
                    PreviousHoverData = hoverData;
                    MapObjectHoverData.HoverStartTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                    if (hoverData != null && hoverData.Tri != null)
                    {
                        MapObjectHoverData.LastTriangleAddress = hoverData.Tri.Address;
                    }
                }
                if (hoverData == null)
                {
                    Config.HideDebugText();
                }
                else
                {
                    Config.SetDebugText(hoverData);
                }
            }

            if (isMainGraphics)
            {
                ObjectDragData = null;
                if (!Config.MapGui.checkBoxMapOptionsEnable3D.Checked &&
                    Config.MapGui.checkBoxMapOptionsEnableObjectDrag.Checked)
                {
                    for (int i = listCombined.Count - 1; i >= 0; i--)
                    {
                        MapObject mapObject = listCombined[i];
                        if (mapObject.GetDragPosition().HasValue)
                        {
                            ObjectDragData = mapObject.GetHoverData(true, false);
                        }
                        if (ObjectDragData != null)
                        {
                            break;
                        }
                    }
                }
            }

            foreach (MapObject obj in listCombined)
            {
                obj.DrawOn2DControl(hoverData);
            }
        }