private void EditWatch(bool duplicate = false)
        {
            var indexes = SelectedIndices.ToList();

            if (SelectedWatches.Any())
            {
                var we = new WatchEditor
                {
                    InitialLocation = this.ChildPointToScreen(WatchListView),
                    MemoryDomains   = MemoryDomains
                };

                we.SetWatch(SelectedWatches.First().Domain, SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit);

                if (this.ShowDialogWithTempMute(we) == DialogResult.OK)
                {
                    if (duplicate)
                    {
                        _watches.AddRange(we.Watches);
                        WatchListView.RowCount = _watches.Count;
                        UpdateWatchCount();
                    }
                    else
                    {
                        for (var i = 0; i < we.Watches.Count; i++)
                        {
                            _watches[indexes[i]] = we.Watches[i];
                        }
                    }
                    Changes();
                }

                GeneralUpdate();
            }
            else if (SelectedSeparators.Any() && !duplicate)
            {
                var inputPrompt = new InputPrompt
                {
                    Text          = "Edit Separator",
                    StartLocation = this.ChildPointToScreen(WatchListView),
                    Message       = "Separator Text:",
                    TextInputType = InputPrompt.InputType.Text
                };

                if (this.ShowDialogWithTempMute(inputPrompt) == DialogResult.OK)
                {
                    Changes();

                    for (int i = 0; i < SelectedSeparators.Count(); i++)
                    {
                        var sep = SelectedSeparators.ToList()[i];
                        sep.Notes            = inputPrompt.PromptText;
                        _watches[indexes[i]] = sep;
                    }
                }

                GeneralUpdate();
            }
        }
Esempio n. 2
0
        private void EditWatch(bool duplicate = false)
        {
            var indexes = SelectedIndices.ToList();

            if (SelectedWatches.Any())
            {
                foreach (var sw in SelectedWatches)
                {
                    if (sw.Domain != SelectedWatches.First().Domain)
                    {
                        throw new InvalidOperationException("Can't edit multiple watches on varying memory domains");
                    }
                }

                var we = new WatchEditor
                {
                    InitialLocation = this.ChildPointToScreen(WatchListView),
                    MemoryDomains   = MemoryDomains
                };

                we.SetWatch(SelectedWatches.First().Domain, SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit);

                var result = we.ShowHawkDialog(this);
                if (result == DialogResult.OK)
                {
                    Changes();
                    if (duplicate)
                    {
                        _watches.AddRange(we.Watches);
                        WatchListView.ItemCount = _watches.Count;
                        UpdateWatchCount();
                    }
                    else
                    {
                        for (var i = 0; i < we.Watches.Count; i++)
                        {
                            _watches[indexes[i]] = we.Watches[i];
                        }
                    }
                }

                UpdateValues();
            }
            else if (SelectedSeparators.Any() && !duplicate)
            {
                var inputPrompt = new InputPrompt
                {
                    Text          = "Edit Separator",
                    StartLocation = this.ChildPointToScreen(WatchListView),
                    Message       = "Separator Text:",
                    TextInputType = InputPrompt.InputType.Text
                };

                var result = inputPrompt.ShowHawkDialog();

                if (result == DialogResult.OK)
                {
                    Changes();

                    for (int i = 0; i < SelectedSeparators.Count(); i++)
                    {
                        var sep = SelectedSeparators.ToList()[i];
                        sep.Notes            = inputPrompt.PromptText;
                        _watches[indexes[i]] = sep;
                    }
                }

                UpdateValues();
            }
        }