コード例 #1
0
            public void AddContextMenuItems(MapTab tab, ContextMenuStrip menu)
            {
                var myItem = new ToolStripMenuItem($"{triangle.Classification} Triangle 0x{triangle.Address.ToString("x8")}");

                var itemCopyTriangleAddress = new ToolStripMenuItem("Copy Triangle Address");

                itemCopyTriangleAddress.Click += (_, __) =>
                {
                    if (triangle != null)
                    {
                        Clipboard.SetText($"0x{triangle.Address.ToString("x8")}");
                    }
                };
                myItem.DropDownItems.Add(itemCopyTriangleAddress);

                var itemCopyPosition = new ToolStripMenuItem("Copy Position");

                itemCopyPosition.Click += (_, __) =>
                {
                    if (triangle != null)
                    {
                        if (tab.graphics.view.mode == MapView.ViewMode.TopDown)
                        {
                            float y = triangle.IsWall() ? mapCursorOnRightClick.Y : (float)triangle.GetHeightOnTriangle(mapCursorOnRightClick.X, mapCursorOnRightClick.Z);
                            CopyUtilities.CopyPosition(new Vector3(mapCursorOnRightClick.X, y, mapCursorOnRightClick.Z));
                        }
                    }
                };
                myItem.DropDownItems.Add(itemCopyPosition);

                menu.Items.Add(myItem);
            }
コード例 #2
0
ファイル: HoverDatas.cs プロジェクト: chaosBrick/STROOP
            public void AddContextMenuItems(MapTab tab, ContextMenuStrip menu)
            {
                var myItem           = new ToolStripMenuItem(ToString());
                var copyPositionItem = new ToolStripMenuItem("Copy Position");

                copyPositionItem.Click += (_, __) =>
                {
                    CopyUtilities.CopyPosition(GetPosition());
                };
                myItem.DropDownItems.Add(copyPositionItem);

                var pastePositionItem = new ToolStripMenuItem("Paste Position");

                pastePositionItem.Click += (_, __) =>
                {
                    if (CopyUtilities.TryPastePosition(out Vector3 v))
                    {
                        SetPosition(v);
                    }
                };
                myItem.DropDownItems.Add(pastePositionItem);

                if (tab.graphics.view.mode != MapView.ViewMode.TopDown)
                {
                    var pivotItem = new ToolStripMenuItem("Make Pivot Point");
                    pivotItem.Click += (_, __) => Pivot(tab);
                    myItem.DropDownItems.Add(pivotItem);
                }
                menu.Items.Add(myItem);
            }
        }
コード例 #3
0
            public void AddContextMenuItems(MapTab tab, ContextMenuStrip menu)
            {
                var myItem           = new ToolStripMenuItem("Tape Measure");
                var copyPositionItem = new ToolStripMenuItem("Copy Position");

                copyPositionItem.Click += (_, __) =>
                {
                    Vector2 src = dragA ? parent.a : parent.b;
                    CopyUtilities.CopyPosition(new Vector3(src.X, cursorY, src.Y));
                };
                myItem.DropDownItems.Add(copyPositionItem);

                var pastePositionItem = new ToolStripMenuItem("Paste Position");

                pastePositionItem.Click += (_, __) =>
                {
                    if (CopyUtilities.TryPastePosition(out Vector3 textVector))
                    {
                        if (dragA)
                        {
                            parent.a = new Vector2(textVector.X, textVector.Z);
                        }
                        else
                        {
                            parent.b = new Vector2(textVector.X, textVector.Z);
                        }
                    }
                };
                myItem.DropDownItems.Add(pastePositionItem);
                menu.Items.Add(myItem);
            }
        }
コード例 #4
0
ファイル: PngChunk.cs プロジェクト: WertherHu/Orc.Toolkit
        /// <summary>
        /// Read bytes from this chunk.
        /// </summary>
        /// <param name="buffer">
        /// Buffer into which to write bytes.
        /// </param>
        /// <param name="offset">
        /// Offset in buffer at which to start
        ///     writing bytes.
        /// </param>
        /// <param name="count">
        /// Maximum number of bytes to fetch.
        /// </param>
        /// <returns>
        /// The number of bytes placed into the buffer. If the
        ///     buffer is larger than the amount of remaining data, this will
        ///     be less than count. Returns 0 to indicate that no data is left.
        /// </returns>
        public int Read(byte[] buffer, int offset, int count)
        {
            int dataLength = this.m_data == null ? 0 : this.m_data.Length;

            if (this.m_data == null)
            {
                this.m_length   = new byte[4];
                this.m_crcBytes = NetworkOrderBitConverter.GetBytes(Crc32.Crc(this.m_chunkType));
            }

            int written = 0;

            while (written < count)
            {
                int amount = 1;
                if (this.position < 4)
                {
                    amount = CopyUtilities.WriteAsMuchDataAsPossible(
                        buffer, offset + written, offset + count, this.m_length, this.position);
                }
                else if (this.position < 8)
                {
                    amount = CopyUtilities.WriteAsMuchDataAsPossible(
                        buffer, offset + written, offset + count, this.m_chunkType, this.position - 4);
                }
                else if (this.position < (8 + dataLength))
                {
                    amount = CopyUtilities.WriteAsMuchDataAsPossible(
                        buffer, offset + written, offset + count, this.m_data, this.position - 8);
                }
                else if (this.position < (12 + dataLength))
                {
                    amount = CopyUtilities.WriteAsMuchDataAsPossible(
                        buffer, offset + written, offset + count, this.m_crcBytes, this.position - (8 + dataLength));
                }
                else
                {
                    return(written);
                }

                this.position += amount;
                written       += amount;
            }

            return(count);
        }
コード例 #5
0
        public CustomManager(string varFilePath, Control customControl, WatchVariableFlowLayoutPanel variableTable)
            : base(varFilePath, variableTable)
        {
            SplitContainer splitContainerCustom         = customControl.Controls["splitContainerCustom"] as SplitContainer;
            SplitContainer splitContainerCustomControls = splitContainerCustom.Panel1.Controls["splitContainerCustomControls"] as SplitContainer;

            // Panel 1 controls

            Button buttonOpenVars = splitContainerCustomControls.Panel1.Controls["buttonOpenVars"] as Button;

            buttonOpenVars.Click += (sender, e) => _variablePanel.OpenVariables();
            ControlUtilities.AddContextMenuStripFunctions(
                buttonOpenVars,
                new List <string>()
            {
                "Open Mario State Data",
            },
                new List <Action>()
            {
                () => _variablePanel.OpenVariables(@"Config/MarioStateData.xml"),
            });

            Button buttonSaveVars = splitContainerCustomControls.Panel1.Controls["buttonSaveVars"] as Button;

            buttonSaveVars.Click += (sender, e) => _variablePanel.SaveVariables();
            ControlUtilities.AddContextMenuStripFunctions(
                buttonSaveVars,
                new List <string>()
            {
                "Save Pop Outs"
            },
                new List <Action>()
            {
                () => FormManager.SavePopOuts()
            });

            Button buttonCopyVars = splitContainerCustomControls.Panel1.Controls["buttonCopyVars"] as Button;

            buttonCopyVars.Click           += (sender, e) => CopyUtilities.Copy(_variablePanel.GetCurrentVariableControls(), _copyType);
            buttonCopyVars.ContextMenuStrip = new ContextMenuStrip();
            CopyUtilities.AddContextMenuStripFunctions(
                buttonCopyVars, _variablePanel.GetCurrentVariableControls);
            buttonCopyVars.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            ToolStripMenuItem itemSetDefaultCopyType = new ToolStripMenuItem("Set Default Copy Type");

            buttonCopyVars.ContextMenuStrip.Items.Add(itemSetDefaultCopyType);
            ControlUtilities.AddCheckableDropDownItems(
                itemSetDefaultCopyType,
                CopyUtilities.GetCopyNames(),
                EnumUtilities.GetEnumValues <CopyTypeEnum>(typeof(CopyTypeEnum)),
                copyType => _copyType = copyType,
                _copyType);

            Button buttonPasteVars = splitContainerCustomControls.Panel1.Controls["buttonPasteVars"] as Button;

            buttonPasteVars.Click += (sender, e) => PasteUtilities.Paste(_variablePanel.GetCurrentVariableControls());

            Button buttonClearVars = splitContainerCustomControls.Panel1.Controls["buttonClearVars"] as Button;

            buttonClearVars.Click += (sender, e) => _variablePanel.ClearVariables();
            ControlUtilities.AddContextMenuStripFunctions(
                buttonClearVars,
                new List <string>()
            {
                "Clear All Vars", "Clear Default Vars"
            },
                new List <Action>()
            {
                () => _variablePanel.ClearVariables(),
                () => _variablePanel.RemoveVariableGroup(VariableGroup.NoGroup),
            });

            _checkBoxCustomRecordValues        = splitContainerCustomControls.Panel1.Controls["checkBoxCustomRecordValues"] as CheckBox;
            _checkBoxCustomRecordValues.Click += (sender, e) => ToggleRecording();

            _labelRecordValuesCount = splitContainerCustomControls.Panel1.Controls["labelRecordValuesCount"] as Label;

            _buttonCustomShowValues        = splitContainerCustomControls.Panel1.Controls["buttonCustomShowValues"] as Button;
            _buttonCustomShowValues.Click += (sender, e) => ShowRecordedValues();

            _buttonCustomClearValues        = splitContainerCustomControls.Panel1.Controls["buttonCustomClearValues"] as Button;
            _buttonCustomClearValues.Click += (sender, e) => ClearRecordedValues();

            _checkBoxUseValueAtStartOfGlobalTimer = splitContainerCustomControls.Panel1.Controls["checkBoxUseValueAtStartOfGlobalTimer"] as CheckBox;

            _labelCustomRecordingFrequencyValue = splitContainerCustomControls.Panel1.Controls["labelCustomRecordingFrequencyValue"] as Label;

            _labelCustomRecordingGapsValue = splitContainerCustomControls.Panel1.Controls["labelCustomRecordingGapsValue"] as Label;

            _recordedValues = new Dictionary <int, List <object> >();
            _lastTimer      = null;
            _numGaps        = 0;
            _recordFreq     = 1;

            // Panel 2 controls

            Button buttonResetVariableSizeToDefault = splitContainerCustomControls.Panel2.Controls["buttonResetVariableSizeToDefault"] as Button;

            buttonResetVariableSizeToDefault.Click += (sender, e) =>
            {
                WatchVariableControl.VariableNameWidth  = WatchVariableControl.DEFAULT_VARIABLE_NAME_WIDTH;
                WatchVariableControl.VariableValueWidth = WatchVariableControl.DEFAULT_VARIABLE_VALUE_WIDTH;
                WatchVariableControl.VariableHeight     = WatchVariableControl.DEFAULT_VARIABLE_HEIGHT;
                WatchVariableControl.VariableTextSize   = WatchVariableControl.DEFAULT_VARIABLE_TEXT_SIZE;
                WatchVariableControl.VariableOffset     = WatchVariableControl.DEFAULT_VARIABLE_OFFSET;
            };

            GroupBox groupBoxVarNameWidth = splitContainerCustomControls.Panel2.Controls["groupBoxVarNameWidth"] as GroupBox;

            InitializeAddSubtractGetSetFuncionality(
                groupBoxVarNameWidth.Controls["buttonVarNameWidthSubtract"] as Button,
                groupBoxVarNameWidth.Controls["buttonVarNameWidthAdd"] as Button,
                groupBoxVarNameWidth.Controls["buttonVarNameWidthGet"] as Button,
                groupBoxVarNameWidth.Controls["buttonVarNameWidthSet"] as Button,
                groupBoxVarNameWidth.Controls["betterTextboxVarNameWidthAddSubtract"] as TextBox,
                groupBoxVarNameWidth.Controls["betterTextboxVarNameWidthGetSet"] as TextBox,
                (int value) => { WatchVariableControl.VariableNameWidth = value; },
                () => WatchVariableControl.VariableNameWidth);

            GroupBox groupBoxVarValueWidth = splitContainerCustomControls.Panel2.Controls["groupBoxVarValueWidth"] as GroupBox;

            InitializeAddSubtractGetSetFuncionality(
                groupBoxVarValueWidth.Controls["buttonVarValueWidthSubtract"] as Button,
                groupBoxVarValueWidth.Controls["buttonVarValueWidthAdd"] as Button,
                groupBoxVarValueWidth.Controls["buttonVarValueWidthGet"] as Button,
                groupBoxVarValueWidth.Controls["buttonVarValueWidthSet"] as Button,
                groupBoxVarValueWidth.Controls["betterTextboxVarValueWidthAddSubtract"] as TextBox,
                groupBoxVarValueWidth.Controls["betterTextboxVarValueWidthGetSet"] as TextBox,
                (int value) => { WatchVariableControl.VariableValueWidth = value; },
                () => WatchVariableControl.VariableValueWidth);

            GroupBox groupBoxVarHeight = splitContainerCustomControls.Panel2.Controls["groupBoxVarHeight"] as GroupBox;

            InitializeAddSubtractGetSetFuncionality(
                groupBoxVarHeight.Controls["buttonVarHeightSubtract"] as Button,
                groupBoxVarHeight.Controls["buttonVarHeightAdd"] as Button,
                groupBoxVarHeight.Controls["buttonVarHeightGet"] as Button,
                groupBoxVarHeight.Controls["buttonVarHeightSet"] as Button,
                groupBoxVarHeight.Controls["betterTextboxVarHeightAddSubtract"] as TextBox,
                groupBoxVarHeight.Controls["betterTextboxVarHeightGetSet"] as TextBox,
                (int value) => { WatchVariableControl.VariableHeight = value; },
                () => WatchVariableControl.VariableHeight);

            GroupBox groupBoxVarTextSize = splitContainerCustomControls.Panel2.Controls["groupBoxVarTextSize"] as GroupBox;

            InitializeAddSubtractGetSetFuncionality(
                groupBoxVarTextSize.Controls["buttonVarTextSizeSubtract"] as Button,
                groupBoxVarTextSize.Controls["buttonVarTextSizeAdd"] as Button,
                groupBoxVarTextSize.Controls["buttonVarTextSizeGet"] as Button,
                groupBoxVarTextSize.Controls["buttonVarTextSizeSet"] as Button,
                groupBoxVarTextSize.Controls["betterTextboxVarTextSizeAddSubtract"] as TextBox,
                groupBoxVarTextSize.Controls["betterTextboxVarTextSizeGetSet"] as TextBox,
                (int value) => { WatchVariableControl.VariableTextSize = value; },
                () => WatchVariableControl.VariableTextSize);

            GroupBox groupBoxVarOffset = splitContainerCustomControls.Panel2.Controls["groupBoxVarOffset"] as GroupBox;

            InitializeAddSubtractGetSetFuncionality(
                groupBoxVarOffset.Controls["buttonVarOffsetSubtract"] as Button,
                groupBoxVarOffset.Controls["buttonVarOffsetAdd"] as Button,
                groupBoxVarOffset.Controls["buttonVarOffsetGet"] as Button,
                groupBoxVarOffset.Controls["buttonVarOffsetSet"] as Button,
                groupBoxVarOffset.Controls["betterTextboxVarOffsetAddSubtract"] as TextBox,
                groupBoxVarOffset.Controls["betterTextboxVarOffsetGetSet"] as TextBox,
                (int value) => { WatchVariableControl.VariableOffset = value; },
                () => WatchVariableControl.VariableOffset);
        }
コード例 #6
0
        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,
            });
        }
コード例 #7
0
        public override void InitializeTab()
        {
            base.InitializeTab();

            buttonOpenVars.Click += (sender, e) => watchVariablePanelCustom.OpenVariables();

            buttonSaveVars.Click += (sender, e) => watchVariablePanelCustom.SaveVariables();

            buttonCopyVars.Click           += (sender, e) => CopyUtilities.Copy(watchVariablePanelCustom.GetCurrentVariableControls(), _copyType);
            buttonCopyVars.ContextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem itemSetDefaultCopyType = new ToolStripMenuItem("Set Default Copy Type");

            buttonCopyVars.ContextMenuStrip.Items.Add(itemSetDefaultCopyType);
            buttonCopyVars.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            ControlUtilities.AddCheckableDropDownItems(
                itemSetDefaultCopyType,
                CopyUtilities.GetCopyNames(),
                EnumUtilities.GetEnumValues <CopyTypeEnum>(typeof(CopyTypeEnum)),
                copyType => _copyType = copyType,
                _copyType);
            CopyUtilities.AddContextMenuStripFunctions(
                buttonCopyVars, watchVariablePanelCustom.GetCurrentVariableControls);

            Button buttonClearVars = splitContainerCustomControls.Panel1.Controls["buttonClearVars"] as Button;

            buttonClearVars.Click += (sender, e) => watchVariablePanelCustom.ClearVariables();
            ControlUtilities.AddContextMenuStripFunctions(
                buttonClearVars,
                new List <string>()
            {
                "Clear All Vars", "Clear Default Vars"
            },
                new List <Action>()
            {
                () => watchVariablePanelCustom.ClearVariables(),
                () => watchVariablePanelCustom.RemoveVariableGroup(VariableGroup.NoGroup),
            });

            checkBoxCustomRecordValues.Click += (sender, e) => ToggleRecording();

            buttonCustomShowValues.Click += (sender, e) => ShowRecordedValues();

            buttonCustomClearValues.Click += (sender, e) => ClearRecordedValues();

            // Panel 2 controls

            Button buttonResetVariableSizeToDefault = splitContainerCustomControls.Panel2.Controls["buttonResetVariableSizeToDefault"] as Button;

            buttonResetVariableSizeToDefault.Click += (sender, e) =>
            {
                WatchVariableControl.VariableNameWidth  = WatchVariableControl.DEFAULT_VARIABLE_NAME_WIDTH;
                WatchVariableControl.VariableValueWidth = WatchVariableControl.DEFAULT_VARIABLE_VALUE_WIDTH;
                WatchVariableControl.VariableHeight     = WatchVariableControl.DEFAULT_VARIABLE_HEIGHT;
                WatchVariableControl.VariableTextSize   = WatchVariableControl.DEFAULT_VARIABLE_TEXT_SIZE;
                WatchVariableControl.VariableOffset     = WatchVariableControl.DEFAULT_VARIABLE_OFFSET;
            };

            InitializeAddSubtractGetSetFuncionality(
                buttonVarNameWidthSubtract,
                buttonVarNameWidthAdd,
                buttonVarNameWidthGet,
                buttonVarNameWidthSet,
                betterTextboxVarNameWidthAddSubtract,
                betterTextboxVarNameWidthGetSet,
                (int value) => { WatchVariableControl.VariableNameWidth = value; },
                () => WatchVariableControl.VariableNameWidth);

            InitializeAddSubtractGetSetFuncionality(
                buttonVarValueWidthSubtract,
                buttonVarValueWidthAdd,
                buttonVarValueWidthGet,
                buttonVarValueWidthSet,
                betterTextboxVarValueWidthAddSubtract,
                betterTextboxVarValueWidthGetSet,
                (int value) => { WatchVariableControl.VariableValueWidth = value; },
                () => WatchVariableControl.VariableValueWidth);

            InitializeAddSubtractGetSetFuncionality(
                buttonVarHeightSubtract,
                buttonVarHeightAdd,
                buttonVarHeightGet,
                buttonVarHeightSet,
                betterTextboxVarHeightAddSubtract,
                betterTextboxVarHeightGetSet,
                (int value) => { WatchVariableControl.VariableHeight = value; },
                () => WatchVariableControl.VariableHeight);

            InitializeAddSubtractGetSetFuncionality(
                buttonVarTextSizeSubtract,
                buttonVarTextSizeAdd,
                buttonVarTextSizeGet,
                buttonVarTextSizeSet,
                betterTextboxVarTextSizeAddSubtract,
                betterTextboxVarTextSizeGetSet,
                (int value) => { WatchVariableControl.VariableTextSize = value; },
                () => WatchVariableControl.VariableTextSize);

            InitializeAddSubtractGetSetFuncionality(
                buttonVarOffsetSubtract,
                buttonVarOffsetAdd,
                buttonVarOffsetGet,
                buttonVarOffsetSet,
                betterTextboxVarOffsetAddSubtract,
                betterTextboxVarOffsetGetSet,
                (int value) => { WatchVariableControl.VariableOffset = value; },
                () => WatchVariableControl.VariableOffset);
        }