Example #1
0
        private bool SetHue(Control ctrl, string cfg)
        {
            HueEntry h = new HueEntry(Config.GetInt(cfg));

            if (h.ShowDialog(this) == DialogResult.OK)
            {
                int hueIdx = h.Hue;
                Config.SetProperty(cfg, hueIdx);
                if (hueIdx > 0 && hueIdx < 3000)
                {
                    ctrl.BackColor = Ultima.Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    ctrl.BackColor = Color.White;
                }
                ctrl.ForeColor = (ctrl.BackColor.GetBrightness() < 0.35 ? Color.White : Color.Black);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public static void SetOverheadHue()
        {
            ListViewItem selectedItem = _listView.Items[_listView.SelectedIndices[0]];

            HueEntry h = new HueEntry(GetHue(selectedItem.SubItems[1].Text));

            if (h.ShowDialog(Engine.MainWindow) == DialogResult.OK)
            {
                int hueIdx = h.Hue;

                if (hueIdx > 0 && hueIdx < 3000)
                {
                    selectedItem.SubItems[1].BackColor = Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    selectedItem.SubItems[1].BackColor = Color.White;
                }

                selectedItem.SubItems[1].ForeColor = (selectedItem.SubItems[1].BackColor.GetBrightness() < 0.35
                    ? Color.White
                    : Color.Black);

                foreach (OverheadMessage list in OverheadManager.OverheadMessages)
                {
                    if (list.SearchMessage.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }
            }
        }
Example #3
0
        private bool SetContainerLabelHue()
        {
            ListViewItem selectedItem = containerView.Items[containerView.SelectedIndices[0]];

            HueEntry h = new HueEntry(GetHueFromListView(selectedItem.SubItems[0].Text));

            // TODO: BREAKING DRY!
            if (h.ShowDialog(this) == DialogResult.OK)
            {
                int hueIdx = h.Hue;

                if (hueIdx > 0 && hueIdx < 3000)
                {
                    selectedItem.SubItems[2].BackColor = Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    selectedItem.SubItems[2].BackColor = Color.White;
                }

                selectedItem.SubItems[2].ForeColor = (selectedItem.SubItems[2].BackColor.GetBrightness() < 0.35
                    ? Color.White
                    : Color.Black);

                foreach (Core.ContainerLabels.ContainerLabel list in Core.ContainerLabels.ContainerLabelList)
                {
                    if (list.Id.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }

                foreach (Core.ContainerLabels.ContainerLabel list in NewContainerEntries)
                {
                    if (list.Id.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        private void SetContainerLabelHue()
        {
            ListViewItem selectedItem = cliLocOverheadView.Items[cliLocOverheadView.SelectedIndices[0]];

            HueEntry h = new HueEntry(GetHueFromListView(selectedItem.SubItems[1].Text));

            // TODO: BREAKING DRY!
            if (h.ShowDialog(this) == DialogResult.OK)
            {
                int hueIdx = h.Hue;

                if (hueIdx > 0 && hueIdx < 3000)
                {
                    selectedItem.SubItems[1].BackColor = Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    selectedItem.SubItems[1].BackColor = Color.White;
                }

                selectedItem.SubItems[1].ForeColor = (selectedItem.SubItems[1].BackColor.GetBrightness() < 0.35
                    ? Color.White
                    : Color.Black);

                foreach (Core.OverheadMessages.OverheadMessage list in Core.OverheadMessages.OverheadMessageList)
                {
                    if (list.SearchMessage.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }

                foreach (Core.OverheadMessages.OverheadMessage list in NewOverheadEntries)
                {
                    if (list.SearchMessage.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }
            }
        }
Example #5
0
        public override void OnButtonPress(int num)
        {
            ConfigItem item = listBox.SelectedItem as ConfigItem;

            if (item == null)
            {
                return;
            }
            if (item.Value is string)
            {
                if (InputBox.Show("Input string") && !string.IsNullOrEmpty(InputBox.GetString()))
                {
                    item.Value = InputBox.GetString();
                }
            }
            else if (item.Value is bool)
            {
                item.Value = !(bool)item.Value;
            }
            else if (item.Value is uint)
            {
                Targeting.OneTimeTarget((l, s, p, g) =>
                {
                    item.Value = s == World.Player.Serial ? 0 : s.Value;
                    listBox.Items[listBox.SelectedIndex] = item;
                });
            }
            else if (item.Value is byte)
            {
                if (InputBox.Show("Input value") && (InputBox.GetInt(-1) >= 0 || InputBox.GetInt(-1) <= 100))
                {
                    item.Value = (byte)InputBox.GetInt(-1);
                }
            }
            else if (item.Value is ushort)
            {
                HueEntry hueEntry = new HueEntry((ushort)item.Value);
                if (hueEntry.ShowDialog(Engine.MainWindow) == DialogResult.OK)
                {
                    item.Value = (ushort)hueEntry.Hue;
                }
            }
            else if (item.Value.GetType().IsEnum)
            {
                Type type  = item.Value.GetType();
                int  value = (int)item.Value;
                while (!Enum.IsDefined(type, ++value))
                {
                    if (value >= Enum.GetValues(type).Length)
                    {
                        value = -1;
                    }
                }
                item.Value = Enum.ToObject(type, value);
            }
            else
            {
                throw new NotImplementedException();
            }
            listBox.Items[listBox.SelectedIndex] = item;
        }