Exemplo n.º 1
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     ColorDialog d = new ColorDialog();
     if (d.ShowDialog() == DialogResult.OK) {
         return ColorTranslator.ToHtml(Color.FromArgb(d.Color.ToArgb()));
     }
     return value;
 }
Exemplo n.º 2
0
 void OnClicked(object sender, ToolBarButtonClickEventArgs e)
 {
     ColorDialog dialog = new ColorDialog();
        if (dialog.ShowDialog(this) == DialogResult.OK) {
       color = dialog.Color;
       Invalidate();
        }
 }
 static void OnSetCustomColorDialog(object sender, GetColorEventArgs e)
 {
     m_dlg = new ColorDialog();
     if (m_dlg.ShowDialog(null) == DialogResult.Ok)
     {
       var c = m_dlg.Color;
       e.SelectedColor = System.Drawing.Color.FromArgb (c.Ab, c.Rb, c.Gb, c.Bb);
     }
 }
Exemplo n.º 4
0
 void EventProc(Object sender, EventArgs ea)
 {
     if ((ToolStripButton)sender == color_btn)
     {
         ColorDialog dlg = new ColorDialog();
         dlg.ShowDialog();
     }
     else if ((ToolStripButton)sender == comment_btn)
     {
         MessageBox.Show("StatusStrip 예제입니다.");
     }
 }
Exemplo n.º 5
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if ( (e.Clicks == 1||e.Clicks==2) && e.Button == MouseButtons.Left )
     {
         if (!Checked) Checked=true;
         else
         {
             ColorDialog cd = new ColorDialog(controller.colorInfo.ToColor());
             if (cd.ShowDialog()==DialogResult.OK)
                 controller.colorInfo.GrabFromColor(cd.SelectedColor);
         }
     }
 }
Exemplo n.º 6
0
 // Changes the background color of the form
 private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog colorDlg = new ColorDialog();
     if (colorDlg.ShowDialog() == DialogResult.OK)
     {
         // Checks if grid is currently hidden and sets the grid color to that color
         if (hideGridToolStripMenuItem.Text == "Show Grid")
         {
             lifeGrid.GridColor = colorDlg.Color;
             this.BackColor = colorDlg.Color;
         }
         else
         {
             this.BackColor = colorDlg.Color; // Sets a new background color for this form
         }
     }
 }
Exemplo n.º 7
0
        private static void LoadGroupProperty(TableLayoutPanel tabPanel, Property property, int index, int maxIndex, int propertyHeight)
        {
            if (!PropertyOperateType.IsThirdPartType(property.OptType))
            {
                return;
            }

            Panel panel = new Panel
            {
                Dock    = DockStyle.Fill,
                Margin  = new Padding(0, 0, 0, 0),
                Padding = new Padding(0, 0, 0, 0),
            };

            tabPanel.Controls.Add(panel, 0, index);

            //获取组件共享的PictureBox
            PictureBox GroupPictureBox = GlobalConfig.Controller.GetPictureBox(property.GetGroupPictureBoxId());

            if (GroupPictureBox == null)
            {
                GroupPictureBox = new PictureBox
                {
                    Name        = property.GetPictureBoxId(), //TODO to make sure
                    Size        = new Size(0, 0),
                    Margin      = new Padding(0, 0, 0, 0),
                    Padding     = new Padding(0, 0, 0, 0),
                    SizeMode    = PictureBoxSizeMode.Zoom,
                    BorderStyle = BorderStyle.FixedSingle,
                    Location    = new Point(0, 0),
                    BackColor   = Color.Gray,
                    Visible     = false,
                };

                GlobalConfig.Controller.SetPictureBox(property.GetGroupPictureBoxId(), GroupPictureBox);
                GroupPictureBox.Tag = new ThirdPartApiClient(property.OptType, GroupPictureBox, maxIndex + 1);
                panel.Controls.Add(GroupPictureBox);
            }

            tabPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, propertyHeight));

            Label label = new Label
            {
                Text      = property.Name,
                Location  = new Point(14, 0),
                Margin    = new Padding(0, 0, 0, 0),
                Padding   = new Padding(0, 0, 0, 0),
                Font      = new Font("微软雅黑", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                Height    = 20,
                Width     = 180,
                TextAlign = ContentAlignment.MiddleLeft,
            };
            TextBox text = new TextBox
            {
                Name        = property.GetTextBoxColorID(),
                AutoSize    = false,
                Width       = 35,
                Height      = 25,
                Location    = new Point(label.Width + GlobalConfig.UiConfig.PropertyLabelMargin, 0),
                Margin      = new Padding(0, 0, 0, 0),
                BorderStyle = BorderStyle.FixedSingle,
                Tag         = property.Type
            };

            ((ThirdPartApiClient)(GroupPictureBox.Tag)).SetParam(index, text);
            panel.Controls.Add(label);
            panel.Controls.Add(text);


            if (property.Type == PropertyType.Int)
            {
                text.Text = property.DefaultValue;
                string lastText = text.Text;
                text.TextChanged += new EventHandler(delegate(object _, EventArgs b)
                {
                    if (text.Text.Trim(' ').Length == 0)
                    {
                        text.Text = lastText;
                        return;
                    }


                    int min, max;
                    bool ok = property.GetRangeAllowValue(out min, out max);

                    int textNumber;
                    if (!int.TryParse(text.Text, out textNumber))
                    {
                        if (ok)
                        {
                            MessageBox.Show(string.Format("请输入{0}-{1}的整数", min, max), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show("请输入整数", "错误");
                        }

                        text.Text = lastText;
                        return;
                    }


                    if (ok && (textNumber < min || textNumber > max))
                    {
                        MessageBox.Show(string.Format("请输入{0}-{1}的整数", min, max), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        text.Text = lastText;
                        return;
                    }

                    if (text.Text == lastText)
                    {
                        GlobalConfig.Project.Editer.Remove(property.Id);
                    }
                    else
                    {
                        lastText = text.Text;
                        Property propertyCopy     = property.Clone();
                        propertyCopy.DefaultValue = text.Text;
                        GlobalConfig.Project.Editer.Set(property.Id, propertyCopy);

                        ((ThirdPartApiClient)(GroupPictureBox.Tag)).Call();
                        GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                    }
                });
            }
            else if (property.Type == PropertyType.Color)
            {
                Button button = new Button
                {
                    Location  = new Point(panel.Width - 100, 0),
                    Width     = 100,
                    Height    = 26,
                    Font      = new Font("微软雅黑", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                if (property.DefaultValue != null && property.DefaultValue.Length > 0)
                {
                    try
                    {
                        text.BackColor = Color.FromArgb(
                            Convert.ToInt32(property.DefaultValue.Substring(2, 2), 16),
                            Convert.ToInt32(property.DefaultValue.Substring(4, 2), 16),
                            Convert.ToInt32(property.DefaultValue.Substring(6, 2), 16));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }

                button.Text   = "设置颜色";
                button.Click += new EventHandler(delegate(object _, EventArgs b)
                {
                    ColorDialog dialog = new ColorDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        if (dialog.Color.ToArgb() != text.BackColor.ToArgb())
                        {
                            Property propertyCopy     = property.Clone();
                            propertyCopy.DefaultValue = "0x" + dialog.Color.R.ToString("X2") + dialog.Color.G.ToString("X2") + dialog.Color.B.ToString("X2");
                            GlobalConfig.Project.Editer.Set(property.Id, propertyCopy);

                            text.BackColor = dialog.Color;
                            ((ThirdPartApiClient)(GroupPictureBox.Tag)).Call();
                            GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                        }
                        else
                        {
                            text.BackColor = dialog.Color;
                            GlobalConfig.Project.Editer.Remove(property.Id);
                        }
                    }
                });
                panel.Controls.Add(button);
            }

            if (index == maxIndex) //index 从1开始开始计数, 当是最后一个时
            {
                ((ThirdPartApiClient)(GroupPictureBox.Tag)).Call();
                GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
            }
        }
Exemplo n.º 8
0
        private void colorButtons_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
            int         indexLight;

            // gets index Light from button Name
            int.TryParse(((Button)sender).Name.Split('_')[1], out indexLight);
            colorDialog.Color = Lights[indexLight - 1].Light.Color;

            // gets and sets color of Light
            if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Lights[indexLight - 1].Light.Color = colorDialog.Color;
                switch (indexLight)
                {
                case 1:
                    colorPanel1.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 2:
                    colorPanel2.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 3:
                    colorPanel3.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 4:
                    colorPanel4.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 5:
                    colorPanel5.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 6:
                    colorPanel6.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 7:
                    colorPanel7.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;

                case 8:
                    colorPanel8.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(colorDialog.Color.R,
                                                                                              colorDialog.Color.G,
                                                                                              colorDialog.Color.B));
                    break;
                }
            }
            model1.Invalidate();
        }
Exemplo n.º 9
0
        private void treeView_Click(object sender, EventArgs e)
        {
            MouseEventArgs m = e as MouseEventArgs;

            if (m == null || m.Button != MouseButtons.Right)
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(
                new Point(m.X, m.Y)
                );

            treeView.SelectedNode = info.Node;
            if (info.Node != null)
            {
                SensorNode node = info.Node.Tag as SensorNode;
                if (node != null && node.Sensor != null)
                {
                    treeContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Length > 0)
                    {
                        MenuItem item = new MenuItem("Parameters...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ShowParameterForm(node.Sensor);
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("Hide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = false;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("Unhide");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.IsVisible = true;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Pen Color...");
                        item.Click += delegate(object obj, EventArgs args) {
                            ColorDialog dialog = new ColorDialog();
                            dialog.Color = node.PenColor.GetValueOrDefault();
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                node.PenColor = dialog.Color;
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    {
                        MenuItem item = new MenuItem("Reset Pen Color");
                        item.Click += delegate(object obj, EventArgs args) {
                            node.PenColor = null;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Show in Tray");
                        item.Checked = systemTray.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                systemTray.Remove(node.Sensor);
                            }
                            else
                            {
                                systemTray.Add(node.Sensor, true);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (gadget != null)
                    {
                        MenuItem item = new MenuItem("Show in Gadget");
                        item.Checked = gadget.Contains(node.Sensor);
                        item.Click  += delegate(object obj, EventArgs args) {
                            if (item.Checked)
                            {
                                gadget.Remove(node.Sensor);
                            }
                            else
                            {
                                gadget.Add(node.Sensor);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.Sensor.Control != null)
                    {
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        IControl control     = node.Sensor.Control;
                        MenuItem controlItem = new MenuItem("Control");
                        MenuItem defaultItem = new MenuItem("Default");
                        defaultItem.Checked = control.ControlMode == ControlMode.Default;
                        controlItem.MenuItems.Add(defaultItem);
                        defaultItem.Click += delegate(object obj, EventArgs args) {
                            control.SetDefault();
                        };
                        MenuItem manualItem = new MenuItem("Manual");
                        controlItem.MenuItems.Add(manualItem);
                        manualItem.Checked = control.ControlMode == ControlMode.Software;
                        for (int i = 0; i <= 100; i += 5)
                        {
                            if (i <= control.MaxSoftwareValue &&
                                i >= control.MinSoftwareValue)
                            {
                                MenuItem item = new MenuItem(i + " %");
                                item.RadioCheck = true;
                                manualItem.MenuItems.Add(item);
                                item.Checked = control.ControlMode == ControlMode.Software &&
                                               Math.Round(control.SoftwareValue) == i;
                                int softwareValue = i;
                                item.Click += delegate(object obj, EventArgs args) {
                                    control.SetSoftware(softwareValue);
                                };
                            }
                        }
                        treeContextMenu.MenuItems.Add(controlItem);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }

                HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware != null)
                {
                    treeContextMenu.MenuItems.Clear();

                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate(object obj, EventArgs args) {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }
Exemplo n.º 10
0
 // Changes the color of the grid lines
 private void gridLineColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // If the grid is not currently hidden
     if (hideGridToolStripMenuItem.Text == "Hide Grid")
     {
         ColorDialog colorDlg = new ColorDialog();
         if (colorDlg.ShowDialog() == DialogResult.OK)
         {
             lifeGrid.GridColor = colorDlg.Color; // Sets a grid color
         }
         Invalidate(); // Forces paint event
     }
     else
     {
         MessageBox.Show("Cannot change grid color\n If grid is hidden!");
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 色選択ダイアログを表示します。
        /// </summary>
        public static Color? ShowColorDialog(Color? defaultColor, Window owner = null)
        {
            var dialog = new ColorDialog();
            if (owner != null)
            {
                dialog.Owner = owner;
            }

            // 必要ならデフォルト色を設定します。
            if (defaultColor != null)
            {
                dialog.SelectedColor = defaultColor.Value;
            }

            // OKボタンが押されたら、その色を返します。
            var result = dialog.ShowDialog();
            if (result != null && result.Value)
            {
                return dialog.SelectedColor;
            }

            return null;
        }
Exemplo n.º 12
0
 private void changeTextColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog colorDialog = new ColorDialog() { Color = richTextBox_main.ForeColor };
     if (colorDialog.ShowDialog() == DialogResult.OK)
         richTextBox_main.ForeColor = colorDialog.Color;
 }
Exemplo n.º 13
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            HClusterNode clickNode;

            if (linemode)
            {
                linemode = false;
                if (listNodes.Count > 0)
                {
                    SaveMarkedClusters.Enabled = true;
                    orderVis.Enabled           = true;
                }
                pictureBox1.Invalidate();
                return;
            }
            if (markflag)
            {
                clickNode = drawH.CheckClick(drawH.rootNode, e.X, e.Y);
                if (clickNode != null)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        if (listNodes.ContainsKey(clickNode))
                        {
                            listNodes.Remove(clickNode);
                        }
                    }
                    else
                    {
                        if (listNodes == null)
                        {
                            listNodes = new Dictionary <HClusterNode, Color>();
                        }
                        if (!listNodes.ContainsKey(clickNode))
                        {
                            listNodes.Add(clickNode, Color.Red);
                        }
                    }
                    if (listNodes.Count > 0)
                    {
                        SaveMarkedClusters.Enabled = true;
                        orderVis.Enabled           = true;
                    }
                    pictureBox1.Invalidate();
                }


                return;
            }
            clickNode = drawH.CheckClick(drawH.rootNode, e.X, e.Y);

            if (clickNode != null)
            {
                if (e.Button == MouseButtons.Right)
                {
                    drawH.rootNode = clickNode;
                    drawH.PrepareGraphNodes(buffer);
                    ClearBuffer();
                    pictureBox1.Invalidate();

                    //this.Invalidate();
                }
                else
                {
                    FormText info = new FormText(clickNode);
                    info.Show();
                }
            }
            string lab = drawH.CheckColorRegion(e.X, e.Y);

            if (lab != null)
            {
                DialogResult res;
                colorDialog1 = new ColorDialog();
                int [] colorTab = new int [drawH.classColor.Count];
                int    i        = 0;
                foreach (var item in drawH.classColor)
                {
                    colorTab[i++] = ColorTranslator.ToOle(item.Value);
                }
                colorDialog1.CustomColors = colorTab;

                colorDialog1.Color = drawH.classColor[lab];

                res = colorDialog1.ShowDialog();
                if (res == DialogResult.OK)
                {
                    drawH.classColor[lab] = Color.FromArgb(colorDialog1.Color.R, colorDialog1.Color.G, colorDialog1.Color.B);
                    buffer = null;
                    pictureBox1.Invalidate();
                    pictureBox1.Refresh();
                }
            }
        }
Exemplo n.º 14
0
 // Changes color of the cells
 private void cellColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog colorDlg = new ColorDialog();
     if (colorDlg.ShowDialog() == DialogResult.OK)
     {
         lifeGrid.CellColor = colorDlg.Color; // Sets a new cell color
     }
     Invalidate(); // Forces paint event
 }
Exemplo n.º 15
0
        private void changeBGColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();

            if (DialogResult.OK == cd.ShowDialog(this))
            {
                m_clrMapBGclear = cd.Color;
            }
        }
Exemplo n.º 16
0
 private void cellPointsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog cd = new ColorDialog();
     cd.Color = m_clrDots;
     if (DialogResult.OK == cd.ShowDialog(this))
     {
         m_clrDots = cd.Color;
     }
 }
Exemplo n.º 17
0
 private void tilesetToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog cd = new ColorDialog();
     if (DialogResult.OK == cd.ShowDialog(this))
     {
         m_clrTilesetBGClear = cd.Color;
     }
 }
Exemplo n.º 18
0
        private void colorDeFuenteToolStripMenuItem_Click(object sender, EventArgs e)
        {
           ColorDialog color = new ColorDialog();
           if (color.ShowDialog() == DialogResult.OK)
            {
                editor.ForeColor = color.Color;
            }

        }
Exemplo n.º 19
0
 private void p_zones_Click(object sender, System.EventArgs e)
 {
     ColorDialog cd = new ColorDialog();
     cd.SelectedColor = p_zones.BackColor;
     cd.ShowDialog();
     p_zones.BackColor = cd.SelectedColor;
 }
Exemplo n.º 20
0
        private void ButtonRenkSec_Click(object sender, EventArgs e)
        {
            DialogResult SecilenRenk = PickColor.ShowDialog();

            pictureBox1.BackColor = PickColor.Color;
        }
Exemplo n.º 21
0
        private ContextMenu CreateModListContextMenu(ModEntry m, ModTag tag)
        {
            var menu = new ContextMenu();

            if (m?.ID == null || tag == null)
            {
                return(menu);
            }

            // change color
            var changeColorItem = new MenuItem("Change color");

            var editColor = new MenuItem("Edit");

            editColor.Click += (sender, e) =>
            {
                var colorPicker = new ColorDialog
                {
                    AllowFullOpen = true,
                    Color         = tag.Color,
                    AnyColor      = true,
                    FullOpen      = true
                };

                if (colorPicker.ShowDialog() == DialogResult.OK)
                {
                    tag.Color = colorPicker.Color;
                }
            };

            changeColorItem.MenuItems.Add(editColor);

            var makePastelItem = new MenuItem("Make pastel");

            makePastelItem.Click += (sender, e) => tag.Color = tag.Color.GetPastelShade();

            changeColorItem.MenuItems.Add(makePastelItem);

            var changeShadeItem = new MenuItem("Random shade");

            changeShadeItem.Click += (sender, e) => tag.Color = tag.Color.GetRandomShade(0.33, 1.0);

            changeColorItem.MenuItems.Add(changeShadeItem);

            var randomColorItem = new MenuItem("Random color");

            randomColorItem.Click += (sender, e) => tag.Color = ModTag.RandomColor();

            changeColorItem.MenuItems.Add(randomColorItem);
            menu.MenuItems.Add(changeColorItem);

            menu.MenuItems.Add("-");

            // renaming tags
            var renameTagItem = new MenuItem($"Rename '{tag.Label}'");

            renameTagItem.Click += (sender, e) => RenameTagPrompt(m, tag, false);

            menu.MenuItems.Add(renameTagItem);

            var renameAllTagItem = new MenuItem($"Rename all '{tag.Label}'");

            renameAllTagItem.Click += (sender, e) => RenameTagPrompt(m, tag, true);
            menu.MenuItems.Add(renameAllTagItem);

            menu.MenuItems.Add("-");

            // removing tags
            var removeTagItem = new MenuItem($"Remove '{tag.Label}'");

            removeTagItem.Click += (sender, args) => m.Tags.Remove(tag.Label);
            menu.MenuItems.Add(removeTagItem);

            var removeAllTagItem = new MenuItem($"Remove all '{tag.Label}'");

            removeAllTagItem.Click += (sender, args) =>
            {
                if (MessageBox.Show($@"Are you sure you want to remove all instances of tag '{tag.Label}'?",
                                    @"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }

                foreach (var mod in Mods.All)
                {
                    for (int i = 0; i < mod.Tags.Count; ++i)
                    {
                        if (mod.Tags[i].ToLower().Equals(tag.Label.ToLower()))
                        {
                            mod.Tags.RemoveAt(i--);
                        }
                    }
                }
            };
            menu.MenuItems.Add(removeAllTagItem);

            return(menu);
        }
Exemplo n.º 22
0
        private void editColorsButton_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog(paletteControl.Items);
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < paletteControl.Items.Length; i++)
                    paletteControl.Items[i] = colorDialog.Items[i];

                if (currentPattern != null)
                {
                    for (int i = 0; i < paletteControl.Items.Length; i++)
                        currentPattern.ColorPalette.SetColor(i, AC.Palette.ColorPalette[paletteControl.Items[i]]);

                    LoadPattern(currentPattern);
                }
            }
        }
Exemplo n.º 23
0
        public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
                                bool balloonTip, PersistentSettings settings, UnitManager unitManager)
        {
            this.unitManager = unitManager;
            this.sensor      = sensor;
            this.notifyIcon  = new NotifyIconAdv();

            Color defaultColor = Color.Black;

            if (sensor.SensorType == SensorType.Load ||
                sensor.SensorType == SensorType.Control ||
                sensor.SensorType == SensorType.Level)
            {
                defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
            }
            Color = settings.GetValue(new Identifier(sensor.Identifier,
                                                     "traycolor").ToString(), defaultColor);

            this.pen = new Pen(Color.FromArgb(96, Color.Black));

            ContextMenuStrip  contextMenu  = new ContextMenuStrip();
            ToolStripMenuItem hideShowItem = new ToolStripMenuItem("Hide/Show");

            hideShowItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendHideShowCommand();
            };
            contextMenu.Items.Add(hideShowItem);
            contextMenu.Items.Add(new ToolStripSeparator());
            ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove Sensor");

            removeItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.Remove(this.sensor);
            };
            contextMenu.Items.Add(removeItem);
            ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color...");

            colorItem.Click += delegate(object obj, EventArgs args) {
                ColorDialog dialog = new ColorDialog();
                dialog.Color = Color;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Color = dialog.Color;
                    settings.SetValue(new Identifier(sensor.Identifier,
                                                     "traycolor").ToString(), Color);
                }
            };
            contextMenu.Items.Add(colorItem);
            contextMenu.Items.Add(new ToolStripSeparator());
            ToolStripMenuItem exitItem = new ToolStripMenuItem("Exit");

            exitItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendExitCommand();
            };
            contextMenu.Items.Add(exitItem);
            this.notifyIcon.ContextMenu  = contextMenu;
            this.notifyIcon.DoubleClick += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendHideShowCommand();
            };

            // get the default dpi to create an icon with the correct size
            float dpiX, dpiY;

            using (Bitmap b = new Bitmap(1, 1, PixelFormat.Format32bppArgb)) {
                dpiX = b.HorizontalResolution;
                dpiY = b.VerticalResolution;
            }

            // adjust the size of the icon to current dpi (default is 16x16 at 96 dpi)
            int width  = (int)Math.Round(16 * dpiX / 96);
            int height = (int)Math.Round(16 * dpiY / 96);

            // make sure it does never get smaller than 16x16
            width  = width < 16 ? 16 : width;
            height = height < 16 ? 16 : height;

            // adjust the font size to the icon size
            FontFamily family = SystemFonts.MessageBoxFont.FontFamily;
            float      baseSize;

            switch (family.Name)
            {
            case "Segoe UI": baseSize = 12; break;

            case "Tahoma": baseSize = 11; break;

            default: baseSize = 12; break;
            }

            this.font = new Font(family,
                                 baseSize * width / 16.0f, GraphicsUnit.Pixel);
            this.smallFont = new Font(family,
                                      0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel);

            this.bitmap   = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            this.graphics = Graphics.FromImage(this.bitmap);

            if (Environment.OSVersion.Version.Major > 5)
            {
                this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                this.graphics.SmoothingMode     = SmoothingMode.HighQuality;
            }
        }
Exemplo n.º 24
0
 private void btnCommand_Click(object sender, EventArgs e)
 {
     try
     {
         string entercommand = string.Empty;
         if (InputBox("RouteTycoon", "명령어를 입력하세요. (명령어 목록을 보려면 help 입력)", ref entercommand) == DialogResult.OK)
         {
             if (entercommand != string.Empty)
             {
                 char     enter   = ' ';
                 string[] cmdargs = entercommand.Split(enter);
                 #region score
                 if (cmdargs[0] == "score")
                 {
                     #region add
                     if (cmdargs[1] == "add")
                     {
                         try
                         {
                             score       += int.Parse(cmdargs[2]);
                             lbScore.Text = score.ToString() + unit;
                             changescore  = true;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region set
                     else if (cmdargs[1] == "set")
                     {
                         try
                         {
                             score        = int.Parse(cmdargs[2]);
                             lbScore.Text = score.ToString() + unit;
                             changescore  = true;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region remove
                     else if (cmdargs[1] == "remove")
                     {
                         try
                         {
                             score       -= int.Parse(cmdargs[2]);
                             lbScore.Text = score.ToString() + unit;
                             changescore  = true;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region reset
                     else if (cmdargs[1] == "reset")
                     {
                         try
                         {
                             score        = 0;
                             lbScore.Text = score.ToString() + unit;
                             changescore  = true;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region a
                     else if (cmdargs[1] == "a")
                     {
                         try
                         {
                             a           = int.Parse(cmdargs[2]);
                             changescore = true;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region b
                     else if (cmdargs[1] == "b")
                     {
                         try
                         {
                             b           = int.Parse(cmdargs[2]);
                             changescore = true;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                 }
                 #endregion
                 #region spawn
                 else if (cmdargs[0] == "spawn")
                 {
                     #region set
                     if (cmdargs[1] == "set")
                     {
                         try
                         {
                             retime = int.Parse(cmdargs[2]);
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region count
                     else if (cmdargs[1] == "count")
                     {
                         piccount = int.Parse(cmdargs[2]);
                     }
                     #endregion
                 }
                 #endregion
                 #region time
                 else if (cmdargs[0] == "time")
                 {
                     #region set
                     if (cmdargs[1] == "set")
                     {
                         try
                         {
                             time = int.Parse(cmdargs[2]);
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                 }
                 #endregion
                 #region image
                 else if (cmdargs[0] == "image")
                 {
                     #region set
                     if (cmdargs[1] == "set")
                     {
                         try
                         {
                             OpenFileDialog od = new OpenFileDialog();
                             od.Filter = "이미지|*.png;*.jpg;*.jpge;*.bmp;*.gif";
                             od.Title  = "RouteTycoon";
                             if (od.ShowDialog() == DialogResult.OK)
                             {
                                 img = Image.FromFile(od.FileName);
                             }
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region reset
                     else if (cmdargs[1] == "reset")
                     {
                         try
                         {
                             img = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "rt_icon_img.png", 5, 7, 1, 6));
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                 }
                 #endregion
                 #region sound
                 else if (cmdargs[0] == "sound")
                 {
                     #region set
                     if (cmdargs[1] == "set")
                     {
                         try
                         {
                             OpenFileDialog od = new OpenFileDialog();
                             od.Title  = "RouteTycoon";
                             od.Filter = "wav 파일|*.wav";
                             if (od.ShowDialog() == DialogResult.OK)
                             {
                                 soundurl = od.FileName;
                                 p        = new System.Media.SoundPlayer(soundurl);
                             }
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region start
                     try
                     {
                         p.PlayLooping();
                     }
                     catch (OverflowException)
                     {
                         MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                     catch (Exception)
                     {
                         MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                     #endregion
                     #region stop
                     try
                     {
                         p.Stop();
                     }
                     catch (OverflowException)
                     {
                         MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                     catch (Exception)
                     {
                         MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                     #endregion
                 }
                 #endregion
                 #region unit
                 else if (cmdargs[0] == "unit")
                 {
                     #region set
                     if (cmdargs[1] == "set")
                     {
                         try
                         {
                             unit         = cmdargs[2];
                             lbScore.Text = score.ToString() + unit;
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                 }
                 #endregion
                 #region background
                 else if (cmdargs[0] == "background")
                 {
                     #region color
                     if (cmdargs[1] == "color")
                     {
                         #region set
                         if (cmdargs[2] == "set")
                         {
                             try
                             {
                                 ColorDialog cd = new ColorDialog();
                                 cd.FullOpen = true;
                                 if (cd.ShowDialog() == DialogResult.OK)
                                 {
                                     this.BackColor        = cd.Color;
                                     panGamezone.BackColor = cd.Color;
                                 }
                             }
                             catch (OverflowException)
                             {
                                 MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                 return;
                             }
                             catch (Exception)
                             {
                                 MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                 return;
                             }
                         }
                         #endregion
                     }
                     #endregion
                     #region reset
                     else if (cmdargs[1] == "reset")
                     {
                         try
                         {
                             this.BackColor = Color.White;
                             this.BackgroundImage.Dispose();
                         }
                         catch (OverflowException)
                         {
                             MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                         catch (Exception)
                         {
                             MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             return;
                         }
                     }
                     #endregion
                     #region image
                     else if (cmdargs[1] == "image")
                     {
                         #region set
                         if (cmdargs[2] == "set")
                         {
                             try
                             {
                                 OpenFileDialog od = new OpenFileDialog();
                                 od.Title  = "RouteTycoon";
                                 od.Filter = "이미지|*.png;*.jpg;*.jpge;*.bmp;*.gif";
                                 if (od.ShowDialog() == DialogResult.OK)
                                 {
                                     this.BackgroundImage  = Image.FromFile(od.FileName);
                                     panGamezone.BackColor = Color.Transparent;
                                 }
                             }
                             catch (OverflowException)
                             {
                                 MessageBox.Show("숫자가 너무 큽니다.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                 return;
                             }
                             catch (Exception)
                             {
                                 MessageBox.Show("알 수 없는 오류가 발생하였습니다.\n다시 시도하십시오.", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                 return;
                             }
                         }
                         #endregion
                     }
                     #endregion
                 }
                 #endregion
                 #region help
                 else if (cmdargs[0] == "help")
                 {
                     #region cmd
                     string score, spawn, time, image, sound, unit, background, help;
                     string first = "<value> 에는 <,> 를 제외하고 원하는 숫자를 넣습니다.";
                     score      = "\nscore add <value> - 점수에 value 만큼을 더합니다.\nscore set <value> - 점수를 value 로 설정합니다.\nscore remove <value> - 점수를 value 만큼 뺍니다.\nscore reset - 점수를 0으로 만듭니다.\nscore a <value> - 지급 점수가 줄어들기 전에 얻는 점수를 value 로 설정합니다.\nscore b <value> - 지급 점수가 줄어든 후에 얻는 점수를 value 로 설정합니다.";
                     spawn      = "\nspawn set <value> - 아이콘이 생기는 주기를 value 로 설정합니다. (1초 = 1000)\nspawn count <value> - 한번에 아이콘이 생기는 갯수를 value 로 설정합니다.";
                     time       = "\ntime set <value> - 지급 점수가 줄어드는 단위를 value 로 설정합니다. (1초 = 1000)";
                     image      = "\nimage set - RouteTycoon 아이콘을 대체할 이미지를 선택하는 창을 엽니다.\nimage reset - 변경된 아이콘을 RouteTycoon 아이콘으로 되돌립니다.";
                     sound      = "\nsound set - 배경음악을 설정하는 창을 엽니다. wav 확장자만 지원합니다.\nsound play - 설정한 배경음악을 반복합니다. 음악이 끝나면 계속 반복됩니다.\nsound stop - 재생중인 배경음악을 정지 합니다.";
                     unit       = "\nunit set <value> - 점수 뒤에 붙을 글자를 설정합니다. 이 명령어에서의 <value> 에는 아무 글자나 상관 없이 입력할 수 있습니다.";
                     background = "\nbackground color set - 배경화면의 색을 선택하는 창을 엽니다.\nbackground image set - 배경화면의 이미지를 선택하는 창을 엽니다. (권장 사이즈 : 980x680)\nbackground reset - 배경화면을 초기 설정으로 되돌립니다.";
                     help       = "\nhelp - 명령어의 목록 및 설명을 봅니다.";
                     #endregion
                     MessageBox.Show(first + score + spawn + time + image + sound + unit + background + help, "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 #endregion
             }
         }
     }
     catch (Exception ex)
     {
         RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
     }
 }
Exemplo n.º 25
0
 private void OnButtonClick(object sender, EventArgs e)
 {
     if (sender == trackerBrowse)
     {
         using (var dialog = new FolderBrowserDialog())
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 trackerCustomSavesFolder.Text = dialog.SelectedPath;
             }
     }
     else if (sender == save || sender == cancel)
     {
         if (sender == save)
         {
             SaveSettings();
         }
         Close();
     }
     else if (sender == defaults)
     {
         string msg = "This will clear all customized settings, including user marked favorites and your custom save path. "
                      + "Are you sure you want to revert to the default settings?";
         if (MessageBox.Show(this, msg, "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             main.ResetToDefaults();
             main.Save();
             tracker.ResetToDefaults();
             tracker.Save();
             overlay.ResetToDefaults();
             overlay.Save();
             Directory.Delete(Paths.DIR_FAVORITES, true);
             Close();
         }
     }
     else if (sender == update)
     {
         UpdateHelper.TryCheckForUpdatesAsync(false);
     }
     else if (sender == about)
     {
         using (var dialog = new FAbout())
             dialog.ShowDialog();
     }
     else if (sender == overlayPickFavorites)
     {
         using (var dialog = new FPickFavorites(advancementTracker, achievementTracker, statisticsTracker))
             dialog.ShowDialog();
     }
     else if (sender == copyColorKey)
     {
         Clipboard.SetText($"#{overlayBackColor.BackColor.R:X2}{overlayBackColor.BackColor.G:X2}{overlayBackColor.BackColor.B:X2}");
     }
     else
     {
         using (var dialog = new ColorDialog())
         {
             dialog.Color = (sender as Control).BackColor;
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 (sender as Control).BackColor = dialog.Color;
                 if (sender == mainBackColor || sender == mainTextColor || sender == mainBorderColor)
                 {
                     mainTheme.SelectedItem = "Custom";
                 }
                 else if (sender == overlayBackColor)
                 {
                     copyColorKey.Text      = "Copy BG color " + $"#{overlayBackColor.BackColor.R:X2}{overlayBackColor.BackColor.G:X2}{overlayBackColor.BackColor.B:X2}" + " for OBS";
                     copyColorKey.LinkColor = dialog.Color;
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InitializeSettings();

            ToolTip.SetToolTip(this.RSearch, "Search for a random element.");
            ToolTip.SetToolTip(this.SearchButton, "Search for a element.");
            ToolTip.SetToolTip(this.pBox, "Image for element " + elementString.ToUpper() + ".");
            ToolTip.SetToolTip(this.AtomicTreeView, "Atomic tree-view.");

            this.FormClosing += delegate
            {
                try
                {
                    if (!File.Exists("log.element"))
                    {
                        File.Create("log.element");
                    }

                    if (Logger.GetLogData() != null)
                    {
                        using (StreamWriter sr = new StreamWriter("log.element"))
                        {
                            sr.WriteLine(("=============== " + DateTime.Now + " ===============").PadRight(20));
                            foreach (string l in Logger.GetLogData().Split(new char[] { '\n' }))
                            {
                                sr.WriteLine(l);
                            }

                            sr.Close();
                        }
                    }
                }
                catch
                {
                    return;
                }
            };

            foreach (Control c in this.groupBox2.Controls.OfType <Label>())
            {
                if (c.Name.Contains("Label"))
                {
                    c.Visible = false;
                }
            }

            foreach (Control c in this.groupBox1.Controls.OfType <RadioButton>())
            {
                RadioButton cb = c as RadioButton;
                cb.CheckedChanged += (object s, EventArgs args) =>
                {
                    if (this.numberCB.Checked)
                    {
                        SearchByName = false;
                    }
                    else
                    {
                        SearchByName = true;
                    }
                };
            }

            this.IsotopesButton.Enabled = false;

            this.BGWorker.ProgressChanged += (object sndr, ProgressChangedEventArgs args) =>
            {
                this.pBar.Value       = args.ProgressPercentage;
                this.StatusLabel.Text = (string)args.UserState;
            };

            // TOOLSTRIP MENU ITEMS

            this.aboutGuilhermeAlmeidaToolStripMenuItem.Click += delegate
            {
                // abriria um site se eu tivesse um, haha... triste vida
                MessageBox.Show("Hi, I'm Guilherme, most people just go by 'Gui' so... go the way you wish.\nI am the guy who spent 2 days developing this program using C# and a Web Scraper.", "Hello, Olá", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
            };

            this.fontToolStripMenuItem.Click += delegate
            {
                FontDialog f = new FontDialog();
                if (f.ShowDialog() != DialogResult.Cancel && f.Font.Size < 15)
                {
                    foreach (Control ctrl in this.Controls)
                    {
                        ctrl.Font = f.Font;
                    }

                    foreach (Control ctrl in this.groupBox1.Controls)
                    {
                        ctrl.Font = f.Font;
                    }

                    foreach (Control ctrl in this.groupBox2.Controls)
                    {
                        ctrl.Font = f.Font;
                    }
                }

                Logger.LogData("Changed current font to " + Font.Name);
                Scrapper.Properties.Settings.Default.font_custom = f.Font;
            };

            this.colorToolStripMenuItem.Click += delegate
            {
                ColorDialog c = new ColorDialog();
                if (c.ShowDialog() != DialogResult.Cancel)
                {
                    foreach (Control ctrl in this.Controls)
                    {
                        ctrl.ForeColor = c.Color;
                    }

                    foreach (Control ctrl in this.groupBox1.Controls)
                    {
                        ctrl.ForeColor = c.Color;
                    }

                    foreach (Control ctrl in this.groupBox2.Controls)
                    {
                        ctrl.ForeColor = c.Color;
                    }
                }

                Logger.LogData("Changed current color to to " + c.Color.ToArgb().ToString());
                Scrapper.Properties.Settings.Default.color_custom = c.Color;
            };

            this.saveToolStripMenuItem.Click += delegate
            {
                Scrapper.Properties.Settings.Default.Save();
                this.StatusLabel.Text = "Settings Saved";
                Logger.LogData("Settings Saved.");
            };

            this.resetToolStripMenuItem.Click += delegate
            {
                Scrapper.Properties.Settings.Default.color_custom  = Scrapper.Properties.Settings.Default.color_default;
                Scrapper.Properties.Settings.Default.font_custom   = Scrapper.Properties.Settings.Default.font_default_normal;
                Scrapper.Properties.Settings.Default.server_custom = Scrapper.Properties.Settings.Default.server_default;

                Scrapper.Properties.Settings.Default.Save();
                ResetUI();

                Logger.LogData("Setting Reset");
                this.StatusLabel.Text = "Settings Reset";
            };

            TBSearch.KeyDown += (object a, KeyEventArgs b) =>
            {
                if (b.KeyCode == Keys.Enter)
                {
                    SearchButton.PerformClick();
                }
            };

            TBSearch.LostFocus += (object a, EventArgs b) =>
            {
                TBSearch.Focus();
            };

            this.logToolStripMenuItem.Click += delegate
            {
                MessageBox.Show(Logger.GetLogData());
            };

            this.serverToolStripMenuItem.Click += delegate
            {
                ChangeServerForm svr = new ChangeServerForm();
                svr.ShowDialog();

                if (svr.serverResultString == "Invalid Server")
                {
                    return;
                }
            };

            this.getVariablesToolStripMenuItem.Click += delegate
            {
                string vars = "";

                foreach (System.Configuration.SettingsProperty p in Scrapper.Properties.Settings.Default.Properties)
                {
                    vars += string.Format("{0} = {1}**", p.Name, p.DefaultValue);
                }

                MessageBox.Show(vars.Replace("**", "\n"));
            };

            this.getVariablesToolStripMenuItem.Click += (object a, EventArgs b) =>
            {
            };
        }
Exemplo n.º 27
0
 private void changeBrush()
 {
     ColorDialog clrdiag = new ColorDialog();
     clrdiag.ShowDialog();
     _p = new Pen(clrdiag.Color,2f);
 }
Exemplo n.º 28
0
        /// <summary>
        /// ツールによって挿入コードを生成します。
        /// </summary>
        private string getCodeTool(TreeNode node)
        {
            var nodeTag = node.Tag?.ToString();

            switch (nodeTag)
            {
            case TagToolMessage:
                var DlgMsg = new Dialog.Text.Script.dlgEVcmdMessage(this.dbCtl.DBList);
                if (DlgMsg.ShowDialog() != DialogResult.OK)
                {
                    return("");
                }
                return(DlgMsg.Result);

            case TagToolFileName:
                var DlgFN = new Dialog.Common.dlgFileSelect(null, "", true, true, false);
                if (DlgFN.ShowDialog() != DialogResult.OK)
                {
                    return("");
                }
                //両端のダブルクォートとパス区切り記号のエスケープシーケンス化
                return("\"" + DlgFN.FileName.Replace("\\", "\\\\") + "\"");

            case TagToolEVID:
                if (this.ParentForm is Dialog.Map.dlgEVSettings)
                {
                    //イベント編集画面のときに限る
                    if (this.mgrMap.MapData == null)
                    {
                        //編集中のマップが存在しない
                        return("");
                    }

                    var DlgEVID = new Dialog.Common.dlgSelectInList("イベントIDの挿入");
                    for (var i = 0; i < this.mgrMap.MapData.EVCount; i++)
                    {
                        DlgEVID.AddItem(this.mgrMap.MapData[i].VisibleID, this.mgrMap.MapData[i].Name);
                    }

                    if (DlgEVID.ShowDialog() != DialogResult.OK)
                    {
                        //ダイアログ中断
                        return("");
                    }

                    if (!Settings.Default.Script_FixedIDHexMode)
                    {
                        //10進数のID表記
                        return(this.mgrMap.MapData[DlgEVID.GetResultIndex()].FixedID.ToString() + "/*" + DlgEVID.GetResultTitle() + "*/");
                    }
                    else
                    {
                        //16進数のID表記
                        return("0x" + this.mgrMap.MapData[DlgEVID.GetResultIndex()].FixedID.ToString("X") + "/*" + DlgEVID.GetResultTitle() + "*/");
                    }
                }
                else
                {
                    MessageBox.Show("イベントIDの挿入はマップエディター上のイベント編集画面でのみ有効です。", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return("");
                }

            case TagToolDBID:
            case TagToolDBColumn:
                var DlgDB2 = new Dialog.Text.Script.dlgInsertDB(this.dbCtl.DBList, (nodeTag == TagToolDBColumn) ? true : false, false);
                if (DlgDB2.ShowDialog() != DialogResult.OK)
                {
                    return("");
                }
                return(DlgDB2.Result);

            case TagToolChangeMap:
                var DlgMap = new Dialog.Text.Script.dlgEVcmdChangeMap(this.dbCtl.DBList);
                if (DlgMap.ShowDialog() != DialogResult.OK)
                {
                    return("");
                }
                return(DlgMap.Result);

            case TagToolColor:
                var DlgCLR = new ColorDialog {
                    AllowFullOpen = true,
                    FullOpen      = true
                };
                if (DlgCLR.ShowDialog() != DialogResult.OK)
                {
                    return("");
                }

                //RGBの順で3つの引数を作り、カラーコードを取得する関数をセットにする
                return(Resources.SQ_GetColor.Replace("$", $"{DlgCLR.Color.R}, {DlgCLR.Color.G}, {DlgCLR.Color.B}"));

            case TagToolPathNormalEV:
            case TagToolPathExtraEV:
            case TagToolPathExtraPlayer:
                var DlgPath = new Dialog.Text.Script.dlgEVcmdMoveTask(
                    nodeTag != TagToolPathNormalEV,
                    nodeTag == TagToolPathExtraPlayer
                    );
                if (DlgPath.ShowDialog() != DialogResult.OK)
                {
                    return("");
                }
                return(DlgPath.Result);

            case TagSQTagSummary:
                return(GenerateGlueCode.GenerateSQDocument.SQ_TAG + GenerateGlueCode.GenerateSQDocument.DOC_SUMMARY + "\r\n");

            case TagSQTagNode:
                return(GenerateGlueCode.GenerateSQDocument.SQ_TAG + GenerateGlueCode.GenerateSQDocument.DOC_PATH + "\r\n");

            case TagSQTagParameter:
                return(GenerateGlueCode.GenerateSQDocument.SQ_TAG + GenerateGlueCode.GenerateSQDocument.DOC_PARAM + "\r\n");

            case TagSQTagReturn:
                return(GenerateGlueCode.GenerateSQDocument.SQ_TAG + GenerateGlueCode.GenerateSQDocument.DOC_RETURN + "\r\n");

            case TagSQTagComment:
                return(GenerateGlueCode.GenerateSQDocument.SQ_TAG + GenerateGlueCode.GenerateSQDocument.DOC_COMMENT + "\r\n");
            }
            return("");
        }
Exemplo n.º 29
0
        private void TreeView_Click(object sender, EventArgs e)
        {
            if (!(e is MouseEventArgs m) || (m.Button != MouseButtons.Left && m.Button != MouseButtons.Right))
            {
                return;
            }

            NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));

            if (m.Button == MouseButtons.Left && info.Node != null)
            {
                if (info.Node.Tag is IExpandPersistNode expandPersistNode)
                {
                    expandPersistNode.Expanded = info.Node.IsExpanded;
                }

                return;
            }

            treeView.SelectedNode = info.Node;
            if (info.Node != null)
            {
                if (info.Node.Tag is SensorNode node && node.Sensor != null)
                {
                    treeContextMenu.MenuItems.Clear();
                    if (node.Sensor.Parameters.Count > 0)
                    {
                        MenuItem item = new MenuItem("Parameters...");
                        item.Click += delegate
                        {
                            ShowParameterForm(node.Sensor);
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate
                        {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.IsVisible)
                    {
                        MenuItem item = new MenuItem("Hide");
                        item.Click += delegate
                        {
                            node.IsVisible = false;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    else
                    {
                        MenuItem item = new MenuItem("Unhide");
                        item.Click += delegate
                        {
                            node.IsVisible = true;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Pen Color...");
                        item.Click += delegate
                        {
                            ColorDialog dialog = new ColorDialog {
                                Color = node.PenColor.GetValueOrDefault()
                            };
                            if (dialog.ShowDialog() == DialogResult.OK)
                            {
                                node.PenColor = dialog.Color;
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    {
                        MenuItem item = new MenuItem("Reset Pen Color");
                        item.Click += delegate
                        {
                            node.PenColor = null;
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    treeContextMenu.MenuItems.Add(new MenuItem("-"));
                    {
                        MenuItem item = new MenuItem("Show in Tray")
                        {
                            Checked = _systemTray.Contains(node.Sensor)
                        };
                        item.Click += delegate
                        {
                            if (item.Checked)
                            {
                                _systemTray.Remove(node.Sensor);
                            }
                            else
                            {
                                _systemTray.Add(node.Sensor, true);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (_gadget != null)
                    {
                        MenuItem item = new MenuItem("Show in Gadget")
                        {
                            Checked = _gadget.Contains(node.Sensor)
                        };
                        item.Click += delegate
                        {
                            if (item.Checked)
                            {
                                _gadget.Remove(node.Sensor);
                            }
                            else
                            {
                                _gadget.Add(node.Sensor);
                            }
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }
                    if (node.Sensor.Control != null)
                    {
                        treeContextMenu.MenuItems.Add(new MenuItem("-"));
                        IControl control     = node.Sensor.Control;
                        MenuItem controlItem = new MenuItem("Control");
                        MenuItem defaultItem = new MenuItem("Default")
                        {
                            Checked = control.ActualControlMode == ControlMode.Default
                        };
                        controlItem.MenuItems.Add(defaultItem);
                        defaultItem.Click += delegate
                        {
                            control.SetDefault();
                        };
                        MenuItem manualItem = new MenuItem("Value");
                        controlItem.MenuItems.Add(manualItem);
                        manualItem.Checked = control.ActualControlMode == ControlMode.Software;
                        for (int i = 0; i <= 100; i += 5)
                        {
                            if (i <= control.MaxSoftwareValue &&
                                i >= control.MinSoftwareValue)
                            {
                                MenuItem item = new MenuItem(i + " %")
                                {
                                    RadioCheck = true
                                };
                                manualItem.MenuItems.Add(item);
                                item.Checked = control.ActualControlMode == ControlMode.Software && Math.Round(control.SoftwareValue) == i;
                                int softwareValue = i;
                                item.Click += delegate
                                {
                                    control.SetSoftware(softwareValue);
                                };
                            }
                        }
                        MenuItem curveItem = new MenuItem("Curve");
                        controlItem.MenuItems.Add(curveItem);
                        curveItem.Checked = control.ActualControlMode == ControlMode.SoftwareCurve;
                        MenuItem newCurveItem = new MenuItem("New");
                        newCurveItem.Click += delegate(object obj, EventArgs args) {
                            var confirmSensorselect = MessageBox.Show("Select the other sensor after clicking OK.", "New Manual Curve", MessageBoxButtons.OKCancel);
                            if (confirmSensorselect == DialogResult.OK)
                            {
                                // Listen for user click on sensor
                                EventHandler selectorListener = null;
                                selectorListener = (curveselect_sender, curveselect_e) => {
                                    MouseEventArgs curveselect_m = curveselect_e as MouseEventArgs;
                                    if (curveselect_m == null || curveselect_m.Button != MouseButtons.Left)
                                    {
                                        this.treeView.Click -= selectorListener;
                                        return;
                                    }
                                    // Try find sensor user clicked
                                    NodeControlInfo curveselect_info = treeView.GetNodeControlInfoAt(new Point(curveselect_m.X, curveselect_m.Y));
                                    if (curveselect_info.Node != null)
                                    {
                                        SensorNode curveselect_node = curveselect_info.Node.Tag as SensorNode;
                                        if (curveselect_node != null && curveselect_node.Sensor != null)
                                        {
                                            new SensorControlForm(node.Sensor, curveselect_node.Sensor, null).ShowDialog();
                                            return;
                                        }
                                    }

                                    var tryagainSensorselect = MessageBox.Show("Could not find sensor. Try again?", "Manual Curve", MessageBoxButtons.RetryCancel);
                                    if (tryagainSensorselect != DialogResult.Retry)
                                    {
                                        this.treeView.Click -= selectorListener;
                                    }
                                };
                                treeView.Click += selectorListener;
                            }
                        };
                        curveItem.MenuItems.Add(newCurveItem);
                        var softwareCurve = node.Sensor.Control.GetSoftwareCurve();
                        if (softwareCurve != null)
                        {
                            // edit curve
                            MenuItem editCurveItem = new MenuItem("Edit");
                            curveItem.MenuItems.Add(editCurveItem);
                            editCurveItem.Click += delegate(object obj, EventArgs args)
                            {
                                new SensorControlForm(node.Sensor, softwareCurve.Sensor, softwareCurve.Points).ShowDialog();
                            };

                            if (control.ActualControlMode != ControlMode.SoftwareCurve)
                            {
                                // enable curve
                                MenuItem enableCurveItem = new MenuItem("Enable");
                                curveItem.MenuItems.Add(enableCurveItem);
                                enableCurveItem.Click += delegate
                                {
                                    node.Sensor.Control.SetSoftwareCurve(softwareCurve.Points, softwareCurve.Sensor);
                                };
                            }
                        }
                        treeContextMenu.MenuItems.Add(controlItem);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }

                if (info.Node.Tag is HardwareNode hardwareNode && hardwareNode.Hardware != null)
                {
                    treeContextMenu.MenuItems.Clear();

                    if (nodeTextBoxText.EditEnabled)
                    {
                        MenuItem item = new MenuItem("Rename");
                        item.Click += delegate
                        {
                            nodeTextBoxText.BeginEdit();
                        };
                        treeContextMenu.MenuItems.Add(item);
                    }

                    treeContextMenu.Show(treeView, new Point(m.X, m.Y));
                }
            }
        }
Exemplo n.º 30
0
        public ColourPalettePanel()
        {
            Palette = new Color[8];

            InitializeComponent();

            myColourBtns = new RadioButton[8];
            myPickerBtns = new Button[8];
            for (int i = 0; i < 8; ++i)
            {
                int index = i;

                RadioButton clrBtn = myColourBtns[i] = new RadioButton();
                tableLayoutPanel3.Controls.Add(clrBtn, 0, i);

                clrBtn.Dock       = System.Windows.Forms.DockStyle.Fill;
                clrBtn.Name       = "colour" + i;
                clrBtn.Appearance = Appearance.Button;
                clrBtn.Size       = new System.Drawing.Size(100, 26);
                clrBtn.Font       = new Font(new FontFamily("consolas"), 10.0f);
                clrBtn.TextAlign  = ContentAlignment.MiddleCenter;
                clrBtn.TabIndex   = 1;
                clrBtn.UseVisualStyleBackColor = false;
                clrBtn.ContextMenuStrip        = editHexStrip;

                clrBtn.Click += (sender, args) =>
                {
                    SelectedIndex = index;
                };

                Button pickBtn = myPickerBtns[i] = new Button();
                tableLayoutPanel3.Controls.Add(pickBtn, 1, i);

                pickBtn.Dock     = System.Windows.Forms.DockStyle.Fill;
                pickBtn.Image    = global::Spryt.Properties.Resources.color_wheel;
                pickBtn.Name     = "picker1";
                pickBtn.Size     = new System.Drawing.Size(26, 26);
                pickBtn.TabIndex = 0;
                pickBtn.UseVisualStyleBackColor = true;

                pickBtn.Click += (sender, args) =>
                {
                    ColorDialog dialog = new ColorDialog();
                    dialog.Color = clrBtn.BackColor;
                    DialogResult res = dialog.ShowDialog();

                    if (res == DialogResult.OK)
                    {
                        SetColour(index, dialog.Color);

                        if (PaletteChanged != null)
                        {
                            PaletteChanged(this, new PaletteChangedEventArgs(Palette));
                        }

                        if (SelectedIndex == index && SelectedColourChanged != null)
                        {
                            SelectedColourChanged(this, new SelectedColourChangedEventArgs(this));
                        }
                    }
                };

                int r = (stDefaultPalette[i] >> 16) & 0xff;
                int g = (stDefaultPalette[i] >> 08) & 0xff;
                int b = (stDefaultPalette[i] >> 00) & 0xff;

                SetColour(i, Color.FromArgb(r, g, b));
            }

            SelectedIndex = 0;
        }
Exemplo n.º 31
0
        //private void panel1_Paint(object sender, PaintEventArgs e)
        //{
        //int h=Form1.SetValueForWidth;
        //int v=Form1.SetValueForHeight;



        //int wd = 0;
        //int hd = 0;
        //int max = 0;
        //Graphics l = e.Graphics;
        //string input = Microsoft.VisualBasic.Interaction.InputBox("Enter the height of box for the row: "+0,
        //           "Define your height of this row boxes",
        //           "0",
        //           50,
        //           50);
        //v = Int32.Parse(input);
        //if (v > max)
        //{ max = v; }
        //else { max = 0; }
        //int rowCounter = 0;
        //for (int i = 0; i < (Form1.SetValueForNumberOfRows*Form1.SetValueForNumberOfCols); i++)
        //{
        //    rowCounter++;
        //    if (wd == (h * Form1.SetValueForNumberOfRows))
        //    {

        //        hd = hd + v;
        //        wd = wd - (h * Form1.SetValueForNumberOfRows);
        //        input = Microsoft.VisualBasic.Interaction.InputBox("Enter the height of box for the row: " + rowCounter,
        //           "Define your height of this row boxes",
        //           "0",
        //           500,
        //           500);
        //        v = Int32.Parse(input);
        //        int area = (h*Form1.SetValueForNumberOfCols) * v;

        //        TotalArea = TotalArea + area;
        //        //////////////////////
        //        if (v > max)
        //        { max = v; }
        //        else { max = 0; }
        //    }
        //    ///////////////////////////////////////////////////
        //    Button testbutton = new Button();
        //    testbutton.Location = new Point(wd,hd);
        //    testbutton.Size = new Size(h,v);
        //    testbutton.Visible = true;
        //    //testbutton.BringToFront();
        //    this.Controls.Add(testbutton);
        //    ///////////////////////////////////////////////////

        //    //l.DrawRectangle(Pens.Black, new System.Drawing.Rectangle(wd, hd, h, v));
        //    wd = wd + h;

        //}
        //MessageBox.Show("Area is: " + TotalArea);
        //label6.Text = TotalArea.ToString();
        //}
        private void LoadData()
        {
            //Setting the value for current scale

            //Setting the value for current scale
            //////////////////////////////////////////////////////////
            MyDialog = new ColorDialog();
            // Keeps the user from selecting a custom color.
            MyDialog.AllowFullOpen = true;
            // Allows the user to get help. (The default is false.)
            MyDialog.ShowHelp = true;
            // Sets the initial color select to the current text color.
            MyDialog.Color = button1.BackColor;
            // Update the text box color if the user clicks OK
            if (MyDialog.ShowDialog() == DialogResult.OK)
            {
                button1.BackColor    = MyDialog.Color;
                testbutton.BackColor = MyDialog.Color;
            }


            int    wd = 0;
            int    hd = 130;
            int    max = 0;
            string height, width;

            int h = 0, v = 0;

            /////////////////////////////////////////////////////////////////
            height = Microsoft.VisualBasic.Interaction.InputBox("Enter the height of box for the row: " + 1,
                                                                "Define the height of frame (feet) ",
                                                                "1",
                                                                500,
                                                                500);
            if (height == "")
            {
                MessageBox.Show("Please enter the height of frame 1 " + " to continue");
                return;
            }
            v           = Int32.Parse(height);
            totalHeight = totalHeight + v;
            //Converting feet to pixels
            v = v * currentScale * 96;
            //Taking the length for the width of rectangle
            width = Microsoft.VisualBasic.Interaction.InputBox("Enter the width of box for the row: " + 1,
                                                               "Define the width of frame (feet)",
                                                               "1",
                                                               500,
                                                               500);
            if (width == "")
            {
                MessageBox.Show("Please enter the width of frame 1 " + " to continue");
                return;
            }
            h            = Int32.Parse(width);
            starterStrip = starterStrip + h;

            h = h * currentScale * 96;
            //Taking the length for the width of rectangle
            ///////////////////////////////////////////////////////////////
            //h = Form1.SetValueForWidth;
            //v = Form1.SetValueForHeight;



            if (v > max)
            {
                max = v;
            }
            else
            {
                max = 0;
            }
            int rowCounter = 1;

            for (int i = 0; i < (Form1.SetValueForNumberOfRows * Form1.SetValueForNumberOfCols); i++)
            {
                int area = ((h / (currentScale * 96)) * (v / (currentScale * 96)));

                TotalArea = TotalArea + area;
                //MessageBox.Show("Area total inside loop is: " + TotalArea);

                if (wd == (h * Form1.SetValueForNumberOfRows))
                {
                    rowCounter++;
                    hd     = hd + v;
                    wd     = wd - (h * Form1.SetValueForNumberOfRows);
                    height = Microsoft.VisualBasic.Interaction.InputBox("Enter the height of box for the row(feet): " + rowCounter,
                                                                        "Define the height of frame ",
                                                                        "1",
                                                                        500,
                                                                        500);
                    if (height == "")
                    {
                        MessageBox.Show("Please enter the height of row : " + rowCounter);
                        return;
                    }
                    v           = Int32.Parse(height);
                    totalHeight = totalHeight + v;
                    //converting to feet
                    v = v * (currentScale * 96);
                    //For the width of box
                    width = Microsoft.VisualBasic.Interaction.InputBox("Enter the width of box for the row: " + rowCounter,
                                                                       "Define the width of frame ",
                                                                       "1",
                                                                       500,
                                                                       500);
                    if (width == "")
                    {
                        MessageBox.Show("Please enter the width of row : " + rowCounter);
                        return;
                    }
                    h = Int32.Parse(width);
                    if (i == 0)
                    {
                        starterStrip = starterStrip + h;
                    }
                    h = h * (currentScale * 96);
                    //area = ((h/1152) * (v/1152));
                    //MessageBox.Show("Area indide loop: " + area);
                    //TotalArea = TotalArea + area;
                    //////////////////////
                    if (v > max)
                    {
                        max = v;
                    }
                    else
                    {
                        max = 0;
                    }
                }
                ///////////////////////////////////////////////////
                testbutton          = new Button();
                testbutton.Location = new Point(wd, hd);
                testbutton.Size     = new Size(h, v);


                //////////////////////////////////////////////////////////
                // Get the controls index

                //////////////////////////////////////////////////////////

                testbutton.Visible   = true;
                testbutton.BackColor = MyDialog.Color;
                //testbutton.BringToFront();
                this.Controls.Add(testbutton);
                ///////////////////////////////////////////////////
                //Graphics l = e.Graphics;
                //l.DrawRectangle(Pens.Black, new System.Drawing.Rectangle(wd, hd, h, v));
                wd = (wd + h);
            }
            //MessageBox.Show("Area is: " + TotalArea);
            //MessageBox.Show("No.Of Cols is: " + Form1.SetValueForNumberOfRows);
            //MessageBox.Show("Scale is: " + (currentScale * 96));
            //label6.Text = TotalArea.ToString() + " ft";

            int rows = Form1.SetValueForNumberOfCols;

            int cols = Form1.SetValueForNumberOfRows;

            ///////////////////////////////////////////////////
            //MessageBox.Show("Form1.value ==> " + Form1.value);
            //TotalArea = TotalArea / Form1.value;
            ///////////////////////////////////////////////////
            //label4.Text = rows.ToString() + " ft";
            //label5.Text = cols.ToString() + " ft";
            //label8.Text = (TotalArea * 24 * 4).ToString() + " ft";
            //label10.Text = (starterStrip).ToString() + " ft";
            //label13.Text = (((Form1.SetValueForNumberOfRows) * 2) * (Form1.SetValueForNumberOfCols + 1)).ToString() + " ft";
            //label15.Text = (TotalArea).ToString() + " ft";
            //label17.Text = (starterStrip + totalHeight).ToString() + " ft";
            //label19.Text = (TotalArea).ToString() + " ft";
            //label21.Text = (((Form1.SetValueForNumberOfRows) * 2) * (Form1.SetValueForNumberOfCols + 1)).ToString() + " ft";
            //////////////////////////////////////////////////////////////////////////////////////////
            TheHorizontalFrames = rows.ToString();
            TheTotalArea        = TotalArea.ToString();
            TheVerticalFrames   = cols.ToString();
            TheRubber           = (TotalArea * 24 * 4).ToString();
            TheStarterStrip     = (starterStrip).ToString();
            TheShearBlock       = (((Form1.SetValueForNumberOfRows) * 2) * (Form1.SetValueForNumberOfCols + 1)).ToString();
            TheGlass            = (TotalArea).ToString();
            ThePerimeter        = (starterStrip + totalHeight).ToString();
            TheInstallation     = (TotalArea).ToString();
            TheFabrication      = (((Form1.SetValueForNumberOfRows) * 2) * (Form1.SetValueForNumberOfCols + 1)).ToString();
        }
        /// <summary>
        /// Sets the accent of the current theme, the colour used to highlight certain interface elements!
        /// </summary>
        private static void SetThemeAccent(object sender, EventArgs e)
        {
            var   btn       = (Button)sender;
            Color TempColor = btn.BackColor;

            if (btn.Name.Contains("Customizable"))
            {
                ColorDialog  ColorDialog = new ColorDialog();
                DialogResult ColorResult = ColorDialog.ShowDialog();
                if (ColorResult == DialogResult.OK)
                {
                    btn.BackColor = ColorDialog.Color;
                }
            }

            Program.BottomToolstrip.BackColor = btn.BackColor;

            foreach (Form MyFormList in Program.OpenedForms)
            {
                foreach (Control myControlX in MyFormList.Controls.OfType <Label>())
                {
                    if (myControlX.Name.StartsWith("TitleLbl_") == true)
                    {
                        myControlX.ForeColor = btn.BackColor;
                    }
                    if (myControlX.Name.StartsWith("TinyUI_TopLabel_") == true)
                    {
                        myControlX.ForeColor = btn.BackColor;
                    }
                    if (myControlX.Name.StartsWith("TitleLblSmall_") == true)
                    {
                        myControlX.ForeColor = btn.BackColor;
                    }
                    if (myControlX.Name.StartsWith("TxtLbl_") == true)
                    {
                        myControlX.ForeColor = btn.BackColor;
                    }
                    if (myControlX.Name.StartsWith("Txt_") == true)
                    {
                        myControlX.ForeColor = btn.BackColor;
                    }
                }
                foreach (Control myControlX in MyFormList.Controls.OfType <Button>())
                {
                    if (myControlX.Name.StartsWith("LrgBtnRnd_") == true)
                    {
                        myControlX.BackColor = btn.BackColor;
                    }
                    if (myControlX.Name.StartsWith("BtnRnd_") == true)
                    {
                        myControlX.BackColor = btn.BackColor;
                    }
                    if (myControlX.Name.StartsWith("Btn_") == true)
                    {
                        myControlX.BackColor = btn.BackColor;
                    }
                }
            }

            btn.BackColor = TempColor;
        }
Exemplo n.º 33
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            hoverColorIndex = GetColorIndexByPoint(e.Location);

            if (hoverColorIndex != -1)
            {
                Color color;

                if (hoverColorIndex == 41)
                {
                    using (ColorDialog cd = new ColorDialog())
                    {
                        cd.FullOpen = true;
                        cd.Color    = currentColor;
                        if (cd.ShowDialog() == DialogResult.OK)
                        {
                            color = GetTranparentedColor(cd.Color);
                        }
                        else
                        {
                            return;
                        }
                    }

                    PickColor(color);
                }
                else if ((e.Button & MouseButtons.Right) == MouseButtons.Right)
                {
                    using (ColorDialog cd = new ColorDialog())
                    {
                        cd.FullOpen = true;
                        cd.Color    = GetColorByIndex(hoverColorIndex);
                        if (cd.ShowDialog() == DialogResult.OK)
                        {
                            color = GetTranparentedColor(cd.Color);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    PickColor(GetColorByIndex(hoverColorIndex));
                }
            }
            else if (isAlphaPressed)
            {
                isAlphaPressed = false;

                int a = (int)((e.X - transparentRect.Left) * 255 / transparentRect.Width);
                if (a < 0)
                {
                    a = 0;
                }
                else if (a > 255)
                {
                    a = 255;
                }

                PickColor(Color.FromArgb(a, currentColor.R, currentColor.G, currentColor.B));
                //currentColor = Color.FromArgb(a, currentColor.R, currentColor.G, currentColor.B);
            }
            base.OnMouseUp(e);
        }
        private void Node_Click(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (MouseButtons.Right != e.Button)
            {
                return;
            }
            tv.SelectedNode = e.Node;
            TreeNode n = e.Node;

            if (n == null || n.Tag == null)
            {
                return;
            }

            ROI roi = (ROI)n.Tag;

            if (roi == null)
            {
                roi = (ROI)n.Parent.Tag;
            }

            int ind = 0;

            if (n.Text.IndexOf("Layer") > -1)
            {
                ind = int.Parse(n.Text.Substring(n.Text.LastIndexOf("r") + 1, n.Text.Length - n.Text.LastIndexOf("r") - 1));
            }

            //ColorBrowser
            ColorDialog colorDialog1 = new ColorDialog();

            colorDialog1.AllowFullOpen = true;
            colorDialog1.AnyColor      = true;
            colorDialog1.FullOpen      = true;
            colorDialog1.Color         = roi.colors[ind];
            //set Custom Colors
            if (IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] != "@")
            {
                List <int> colorsList = new List <int>();
                foreach (string j in IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex]
                         .Split(new[] { "\t" }, StringSplitOptions.None))
                {
                    colorsList.Add(int.Parse(j));
                }
                colorDialog1.CustomColors = colorsList.ToArray();
            }
            // Show the color dialog.
            DialogResult result = colorDialog1.ShowDialog();

            //Copy Custom Colors
            int[]  colors = (int[])colorDialog1.CustomColors.Clone();
            string txt    = "@";

            if (colors.Length > 0)
            {
                txt = colors[0].ToString();
                for (int j = 1; j < colors.Length; j++)
                {
                    txt += "\t" + colors[j].ToString();
                }
            }
            IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] = txt;
            IA.settings.Save();

            if (result == DialogResult.OK)
            {
                IA.AddToHistoryOld("Chart.SetSeriesColor(" + GetChanel(roi).ToString() + ","
                                   + roi.getID.ToString() + "," + ind.ToString() + "," + ColorTranslator.ToHtml(roi.colors[ind]) + ")");

                roi.colors[ind] = colorDialog1.Color;

                IA.AddToHistoryNew("Chart.SetSeriesColor(" + GetChanel(roi).ToString() + ","
                                   + roi.getID.ToString() + "," + ind.ToString() + "," + ColorTranslator.ToHtml(colorDialog1.Color) + ")");


                foreach (Color col in RefColors)
                {
                    if (colorDialog1.Color == col)
                    {
                        IA.ReloadImages();
                        return;
                    }
                }

                RefColors.Add(colorDialog1.Color);
                createImagesFortTV(colorDialog1.Color);

                IA.ReloadImages();
            }
        }
Exemplo n.º 35
0
        private static void LoadImageProperty(TableLayoutPanel tabPanel, Property property, int index, int maxIndex, int propertyHeight)
        {
            Panel panel = new Panel
            {
                Dock    = DockStyle.Fill,
                Margin  = new Padding(0, 0, 0, 0),
                Padding = new Padding(0, 0, 0, 0),
            };

            tabPanel.Controls.Add(panel, 0, index);

            PictureBox cachedPb;
            Image      image;

            if (property.RefPropertyId > 0)
            {
                cachedPb = GlobalConfig.Controller.GetPictureBox(property.RefPropertyId.ToString());
                if (cachedPb != null)
                {
                    image = cachedPb.Image;
                }
                else
                {
                    Log.Error("Flow1_FlowPanel", "LoadImageProperty", string.Format("property id={0} Get picture box nil", property.Id));
                    image = Image.FromFile(Path.Combine(GlobalConfig.Project.GetUserResourcesDir(), property.Value));
                }
            }
            else
            {
                image = Image.FromFile(Path.Combine(GlobalConfig.Project.GetUserResourcesDir(), property.Value));
            }

            PictureBox pictureBox = new PictureBox
            {
                Name        = property.GetPictureBoxId(),
                Size        = new Size(0, 0),
                Margin      = new Padding(0, 0, 0, 0),
                Padding     = new Padding(0, 0, 0, 0),
                Image       = image,
                SizeMode    = PictureBoxSizeMode.Zoom,
                BorderStyle = BorderStyle.FixedSingle,
                Location    = new Point(0, 0),
                BackColor   = Color.Gray,
                Visible     = false,
            };

            panel.Controls.Add(pictureBox);

            SortedDictionary <int, Property> brothers = GlobalConfig.Project.CarConfig.GetGroupSameLayerProperties(property.GroupId, property);

            if (brothers.Count > 1) //包含自己所以大于1
            {
                CheckBox checkBox = new CheckBox
                {
                    Name    = property.GetCheckBoxId(),
                    Margin  = new Padding(0, 0, 0, 0),
                    Padding = new Padding(0, 0, 0, 0),
                    Checked = brothers.FirstOrDefault().Key == property.Id,
                    Width   = 13,
                    Text    = "",
                };
                if (!checkBox.Checked)
                {
                    pictureBox.Enabled = false;
                }
                checkBox.CheckedChanged += new System.EventHandler(delegate(object sender, EventArgs e)
                {
                    if (checkBox.Checked)
                    {
                        pictureBox.Enabled = true;
                        foreach (Property brotherProperty in brothers.Values)
                        {
                            if (brotherProperty.GetCheckBoxId() == checkBox.Name)
                            {
                                continue;
                            }

                            Control[] pbControls = tabPanel.Controls.Find(brotherProperty.GetPictureBoxId(), true);
                            foreach (PictureBox pb in pbControls)
                            {
                                pb.Enabled = false;
                            }

                            Control[] ckControls = tabPanel.Controls.Find(brotherProperty.GetCheckBoxId(), true);
                            foreach (CheckBox ck in ckControls)
                            {
                                ck.Checked = false;
                            }
                        }
                    }
                    else
                    {
                        pictureBox.Enabled = false;
                    }

                    GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                });
                panel.Controls.Add(checkBox);
            }

            //每个Property的PictureBox都先注册到缓存中, 当有Property需要引用其他Property的图片时,直接取出
            GlobalConfig.Controller.SetPictureBox(property.Id.ToString(), pictureBox);

            if (!property.ShowLabel)
            {
                tabPanel.Controls.Add(pictureBox, 0, 0);  //若property不现实标签, 则直接挂载到table的第0行中
                return;
            }

            tabPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, propertyHeight));

            Label label = new Label
            {
                Text      = property.Name,
                Location  = new Point(14, 0),
                Margin    = new Padding(0, 0, 0, 0),
                Padding   = new Padding(0, 0, 0, 0),
                Font      = new Font("微软雅黑", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                Height    = 20,
                Width     = 180,
                TextAlign = ContentAlignment.MiddleLeft,
            };

            panel.Controls.Add(label);

            Button button = new Button
            {
                Location  = new Point(panel.Width - 100, 0),
                Width     = 100,
                Height    = 26,
                Font      = new Font("微软雅黑", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                TextAlign = ContentAlignment.MiddleCenter
            };

            if (property.OptType == PropertyOperateType.ReplaceImage)
            {
                button.Text   = "更换图片";
                button.Click += new EventHandler(delegate(object _, EventArgs b)
                {
                    try
                    {
                        OpenFileDialog openFileDialog = new OpenFileDialog
                        {
                            Filter = "Png|*.png|Jpg|*.jpg"
                        };
                        if (openFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            pictureBox.Image = Image.FromFile(openFileDialog.FileName);
                            pictureBox.Image.Save(Path.Combine(GlobalConfig.Project.GetUserUploadImageDir(), openFileDialog.SafeFileName));;
                            pictureBox.Refresh();

                            if (openFileDialog.FileName != property.Value)
                            {
                                Property propertyCopy = property.Clone();
                                propertyCopy.Value    = GlobalConfig.Project.GetPropertyImagePath(openFileDialog.SafeFileName);
                                GlobalConfig.Project.Editer.Add(property.Id, propertyCopy);
                            }
                            else
                            {
                                GlobalConfig.Project.Editer.Remove(property.Id);
                            }
                        }
                        GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                    }
                    catch (Exception)
                    { }
                });
                panel.Controls.Add(button);
            }
            else if (property.OptType == PropertyOperateType.AlphaWhiteImageSetColor)
            {
                TextBox text = new TextBox
                {
                    Name        = property.GetTextBoxColorID(),
                    AutoSize    = false,
                    Width       = 35,
                    Height      = 25,
                    Location    = new Point(label.Width + GlobalConfig.UiConfig.PropertyLabelMargin, 0),
                    Margin      = new Padding(0, 0, 0, 0),
                    BorderStyle = BorderStyle.FixedSingle,
                };

                if (property.DefaultValue != null && property.DefaultValue.Length > 0)
                {
                    try
                    {
                        text.BackColor = Color.FromArgb(
                            Convert.ToInt32(property.DefaultValue.Substring(2, 2), 16),
                            Convert.ToInt32(property.DefaultValue.Substring(4, 2), 16),
                            Convert.ToInt32(property.DefaultValue.Substring(6, 2), 16));

                        PngUtil.SetAlphaWhilteImage((Bitmap)image, text.BackColor);
                        pictureBox.Refresh();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }

                button.Text   = "设置颜色";
                button.Click += new EventHandler(delegate(object _, EventArgs b)
                {
                    ColorDialog dialog = new ColorDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        if (dialog.Color.ToArgb() != text.BackColor.ToArgb())
                        {
                            Property propertyCopy     = property.Clone();
                            propertyCopy.DefaultValue = "0x" + dialog.Color.R.ToString("X2") + dialog.Color.G.ToString("X2") + dialog.Color.B.ToString("X2");
                            GlobalConfig.Project.Editer.Set(property.Id, propertyCopy);
                        }
                        else
                        {
                            GlobalConfig.Project.Editer.Remove(property.Id);
                        }

                        PngUtil.SetAlphaWhilteImage((Bitmap)image, dialog.Color);
                        text.BackColor = dialog.Color;
                        pictureBox.Refresh();
                    }
                    GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                });
                panel.Controls.Add(text);
                panel.Controls.Add(button);
            }
            else if (property.OptType == PropertyOperateType.AlphaWhiteImageSetAlpha)
            {
                TextBox text = new TextBox
                {
                    Name     = property.GetTextBoxAlphaID(),
                    Width    = 35,
                    Location = new Point(label.Width + GlobalConfig.UiConfig.PropertyLabelMargin, 0),
                    Height   = 20,
                    Margin   = new Padding(0, 0, 0, 0),
                    Font     = new Font("微软雅黑", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                };
                if (property.DefaultValue == null || property.DefaultValue.Length == 0)
                {
                    text.Text = "0";
                }
                else
                {
                    text.Text = property.DefaultValue;
                    PngUtil.SetAlphaWhilteImage((Bitmap)image, Convert.ToInt32(property.DefaultValue));
                    pictureBox.Refresh();
                }

                string oldText = text.Text;
                button.Text   = "确定";
                button.Click += new EventHandler(delegate(object _, EventArgs b)
                {
                    if (oldText != text.Text)
                    {
                        Property propertyCopy     = property.Clone();
                        propertyCopy.DefaultValue = text.Text;
                        GlobalConfig.Project.Editer.Set(property.Id, propertyCopy);
                    }
                    else
                    {
                        GlobalConfig.Project.Editer.Remove(property.Id);
                    }
                    try
                    {
                        int alphaValue = Convert.ToInt32(text.Text);
                        PngUtil.SetAlphaWhilteImage((Bitmap)image, alphaValue);
                        pictureBox.Refresh();
                        GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                    }
                    catch (Exception)
                    { }
                });
                panel.Controls.Add(button);
                panel.Controls.Add(text);
            }
            else if (property.OptType == PropertyOperateType.ImageFilterColor)
            {
                TextBox textBox = new TextBox
                {
                    Width    = 35,
                    Location = new Point(label.Width + 20, 0),
                    Height   = 20,
                    Margin   = new Padding(0, 0, 0, 0),
                    Font     = new Font("微软雅黑", 11F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                    Text     = "0"
                };

                TrackBar trackBar = new TrackBar
                {
                    Location      = new Point(panel.Width - 150, 0),
                    Size          = new Size(150, 45),
                    Maximum       = 180,
                    Minimum       = -180,
                    Value         = 0,
                    TickFrequency = 30,
                };
                trackBar.ValueChanged += new EventHandler(delegate(object sender, EventArgs e)
                {
                    textBox.Text     = trackBar.Value.ToString();
                    pictureBox.Image = (Image)PngUtil.RelativeChangeColor((Bitmap)image, Convert.ToInt32(trackBar.Value) + 180);
                    pictureBox.Refresh();
                    GlobalConfig.Controller.ShowGroupOnCenterBoard(tabPanel, property.GetGroup());
                });
                panel.Controls.Add(textBox);
                panel.Controls.Add(trackBar);
            }
        }
Exemplo n.º 36
0
 private void c1_Click(object sender, EventArgs e)
 {
     if (colordia.ShowDialog() == DialogResult.OK)
     {
         c1.BackColor = colordia.Color;
     }
 }
Exemplo n.º 37
0
        private void ShowColorDialog(object sender, RoutedEventArgs eventArgs)
        {
            var colorDialog = new ColorDialog();

            colorDialog.ShowDialog();
        }
Exemplo n.º 38
0
        private void datasourcesGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                switch (e.ColumnIndex)
                {
                case DisplayOnGraphColumnIndex:
                case NameColumnIndex:
                case TypeColumnIndex:
                    var boolCell =
                        dataGridView.Rows[e.RowIndex].Cells[DisplayOnGraphColumnIndex] as DataGridViewCheckBoxCell;
                    if (boolCell != null)
                    {
                        bool value = (bool)boolCell.Value;
                        boolCell.Value = !value;

                        DataSourceItem dsi = ((DataSourceGridViewRow)dataGridView.Rows[e.RowIndex]).Dsi;
                        if (dsi != null)
                        {
                            if (!value)
                            {
                                designedGraph.DataSources.Add(dsi);
                            }
                            else
                            {
                                designedGraph.DataSources.Remove(dsi);
                            }
                        }
                    }
                    EnableControls();
                    break;

                case ColorColumnIndex:
                    var colorCell = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewTextBoxCell;
                    if (colorCell != null)
                    {
                        ColorDialog cd = new ColorDialog
                        {
                            Color          = (Color)colorCell.Value,
                            AllowFullOpen  = true,
                            AnyColor       = true,
                            FullOpen       = true,
                            SolidColorOnly = true
                        };
                        if (cd.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        colorCell.Value = cd.Color;

                        DataSourceItem dsi = ((DataSourceGridViewRow)dataGridView.Rows[e.RowIndex]).Dsi;
                        if (dsi != null)
                        {
                            dsi.Color        = cd.Color;
                            dsi.ColorChanged = true;
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 39
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Focus();

            if (e.Button == MouseButtons.Left)
            {
                if (columnSizingState == ColumnSizingState.Hot)
                {
                    columnSizingState = ColumnSizingState.Active;

                    int x = ClientRectangleInner.Width - (descriptionWidth + 6 - 2);
                    columnSizingOffset = e.X - x;

                    Invalidate();
                }
                else if (stateHotItem != null)
                {
                    if (stateHotItem.CheckEnabled && stateHotItem.StateCheckBox == ItemCheckBoxState.Hot)
                    {
                        stateHotItem.StateCheckBox = ItemCheckBoxState.Pressed;
                        statePressedCheckBox       = stateHotItem;
                        Invalidate();
                    }
                    else if (stateHotItem.BoundsIcon.Contains(e.Location))
                    {
                        Item i = stateHotItem;

                        using (ColorDialog dialog = new ColorDialog()) {
                            dialog.Color = i.Color;
                            dialog.ShowDialog(this);
                            i.Color = dialog.Color;

                            Invalidate();
                        }
                    }
                    else
                    {
                        stateFocusedItem  = stateHotItem;
                        stateSelectedItem = true;

                        if (!EnsureVisible(stateFocusedItem))
                        {
                            Invalidate();
                        }

                        OnItemSelectionChanged();
                    }
                }
                else
                {
                    if (stateSelectedItem)
                    {
                        stateSelectedItem = false;

                        Invalidate();

                        OnItemSelectionChanged();
                    }
                }
            }

            base.OnMouseDown(e);
        }
Exemplo n.º 40
0
        private void Getitem(object handler, EventArgs e)
        {
            bool   input         = (((Button)handler).Name[0].ToString(CultureInfo.InvariantCulture) == "1");
            string servercommand = ((Button)handler).Name.Substring(1);

            if (input)
            {
                if (servercommand != "DEVCOLOR")
                {
                    var form = new InputFrm("Input", m_descriptions[servercommand], "Confirm", "Cancel");
                    if (servercommand != "DEVCREATETEAM" && servercommand != "DEVMSG")
                    {
                        form.InputBox.KeyDown += Suppress_Space;
                    }

                    if (servercommand == "DEVCREATETEAM")
                    {
                        form.InputBox.MaxLength = 20;
                    }
                    else if (servercommand == "DEVMSG")
                    {
                        form.InputBox.MaxLength = 250;
                    }
                    else
                    {
                        form.InputBox.MaxLength = 14;
                    }

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        if (form.InputBox.Text == "")
                        {
                            MessageBox.Show("Input cannot be empty");
                            return;
                        }
                        Program.ChatServer.SendPacket(DevServerPackets.DevPointCommand,
                                                      JsonSerializer.SerializeToString(
                                                          new PacketCommand
                        {
                            Command = servercommand,
                            Data    = form.InputBox.Text.Trim()
                        }));
                    }
                }
                else
                {
                    var selectcolor = new ColorDialog();
                    if (selectcolor.ShowDialog() == DialogResult.OK)
                    {
                        Program.ChatServer.SendPacket(DevServerPackets.DevPointCommand,
                                                      JsonSerializer.SerializeToString(
                                                          new PacketCommand
                        {
                            Command = servercommand,
                            Data    = selectcolor.Color.R + "," + selectcolor.Color.G + "," + selectcolor.Color.B
                        }));
                    }
                }
            }
            else
            {
                if (servercommand == "NULL")
                {
                    Process.Start("http://ygopro.de/web-devpro/");
                    return;
                }

                if (MessageBox.Show("Confirm", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Program.ChatServer.SendPacket(DevServerPackets.DevPointCommand,
                                                  JsonSerializer.SerializeToString(
                                                      new PacketCommand
                    {
                        Command = servercommand
                    }));
                }
            }
        }
Exemplo n.º 41
0
        private void Panel12_DoubleClick(object sender, EventArgs e)
        {
            Panel panel = (Panel)sender;

            int i;

            if (panel == panel1)
            {
                i = 0;
            }
            else if (panel == panel2)
            {
                i = 1;
            }
            else if (panel == panel3)
            {
                i = 2;
            }
            else if (panel == panel4)
            {
                i = 3;
            }
            else if (panel == panel5)
            {
                i = 4;
            }
            else if (panel == panel6)
            {
                i = 5;
            }
            else if (panel == panel7)
            {
                i = 6;
            }
            else if (panel == panel8)
            {
                i = 7;
            }
            else if (panel == panel9)
            {
                i = 8;
            }
            else if (panel == panel10)
            {
                i = 9;
            }
            else if (panel == panel11)
            {
                i = 10;
            }
            else if (panel == panel12)
            {
                i = 11;
            }
            else
            {
                return;                 // i = -1;
            }
            using var dlg = new ColorDialog
                  {
                      AllowFullOpen = true,
                      AnyColor      = true,
                      Color         = _colors[i]
                  };

            // custom colors are ints, not Color structs?
            // and they don't work right unless the alpha bits are set to 0
            // and the rgb order is switched
            int[] customs = new int[12];
            for (int j = 0; j < customs.Length; j++)
            {
                customs[j] = _colors[j].R | _colors[j].G << 8 | _colors[j].B << 16;
            }

            dlg.CustomColors = customs;
            dlg.FullOpen     = true;

            var result = dlg.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                if (_colors[i] != dlg.Color)
                {
                    _colors[i]      = dlg.Color;
                    panel.BackColor = _colors[i];
                }
            }
        }
Exemplo n.º 42
0
		} // SetupListItems

		// ----------------------------------------------------------------------
		private void ButtonChangeColor( object sender, RoutedEventArgs e )
		{
			ColorDialog colorDialog = new ColorDialog();
			colorDialog.Color = WindowColor;
			colorDialog.FullOpen = true;
			if ( colorDialog.ShowDialog() )
			{
				WindowColor = colorDialog.Color;
			}
		} // ButtonChangeColor
Exemplo n.º 43
0
 private void brushColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorDialog.ShowDialog();
     color = ColorDialog.Color;
     Console.WriteLine("Canvas changed to Custom Color");
 }
Exemplo n.º 44
0
	private void btnColor_Click(object sender, System.EventArgs e)
	{
		ColorDialog dlgColor = new ColorDialog();
		dlgColor.ShowDialog(this);
		btnColor.BackColor = dlgColor.Color;

	}
Exemplo n.º 45
0
 private void btnChooseTextColor_Click(object sender, EventArgs e)
 {
     ColorDialog dialog = new ColorDialog();
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         panelTextColor.BackColor = dialog.Color;
         lblTest.ForeColor = dialog.Color;
     }
 }
Exemplo n.º 46
0
        private void editColorsButton_Click(object sender, EventArgs e)
        {
            using (ColorDialog colorDialog = new ColorDialog(paletteControl.Items))
            {
                patternEditor.BeginPreview();

                colorDialog.ColorPaletteChanged +=
                    (o, s) => patternEditor.SetColorPalette(colorDialog.GetAsPalette());
                if (colorDialog.ShowDialog() == DialogResult.OK)
                {
                    for (int i = 0; i < paletteControl.Items.Length; i++)
                        paletteControl.Items[i] = colorDialog.Items[i];

                    patternEditor.SetColorPalette(colorDialog.GetAsPalette());
                }
                else
                {
                    patternEditor.EndPreview();
                }
            }
        }
Exemplo n.º 47
0
 private void button1_Click(object sender, EventArgs e)
 {
     colorDlg.ShowDialog(this);
 }
Exemplo n.º 48
0
        private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex >0 && e.RowIndex >= 0)
            {
                ColorDialog cd = new ColorDialog();

                if (cd.ShowDialog() == DialogResult.OK)
                {
                    // 将先中的颜色设置为窗体的背景色
                    dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = cd.Color;
                    dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag = cd.Color;
                }
            }
        }
Exemplo n.º 49
0
        private void btnBackColor_Click_1(object sender, EventArgs e)
        {
            using (ColorDialog cdialog = new ColorDialog())
            {
                cdialog.AnyColor = true;
                if (cdialog.ShowDialog() == DialogResult.OK)
                {
                    this.b.BackColor = cdialog.Color;
                    this.btnBackColor.BackColor = this.b.BackColor;
                }//if
            }//using

        }
Exemplo n.º 50
0
        private void colorDeFondoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ColorDialog fondo = new ColorDialog();
            if (fondo.ShowDialog() == DialogResult.OK)
            {
                editor.BackColor = fondo.Color;
            }

        }
Exemplo n.º 51
0
 private void button3_Click(object sender, System.EventArgs e)
 {
     ColorDialog cd = new ColorDialog(Color.FromArgb(0, 0, 0));
     cd.ShowDialog();
 }
Exemplo n.º 52
0
 private void headerBTN_Click(object sender, EventArgs e)
 {
     var cp = new ColorDialog();
     cp.ShowDialog();
     headercolor = cp.Color;
 }
Exemplo n.º 53
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex > 0 && e.RowIndex >= 0)
            {
                ColorDialog cd = new ColorDialog();

                if (cd.ShowDialog() == DialogResult.OK)
                {
                    // 将先中的颜色设置为窗体的背景色
                    dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = cd.Color;
                    dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag = cd.Color;
                    //dt_zz.Rows[e.RowIndex][4] = "#"+string.Format("{0:X2}", cd.Color.R) + string.Format("{0:X2}", cd.Color.G) + string.Format("{0:X2}", cd.Color.B);

                }
            }
        }
Exemplo n.º 54
0
 private void iconbgBTN_Click(object sender, EventArgs e)
 {
     var cp = new ColorDialog();
     cp.ShowDialog();
     iconbg = cp.Color;
 }
Exemplo n.º 55
0
        private void dataGridView4_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2 && e.RowIndex >= 0)
            {
                ColorDialog cd = new ColorDialog();

                if (cd.ShowDialog() == DialogResult.OK)
                {
                    // 将先中的颜色设置为窗体的背景色
                    dataGridView4.Rows[e.RowIndex].Cells["曲线颜色"].Style.BackColor = cd.Color;
                    dt_zk.Rows[e.RowIndex][1] = "#" + string.Format("{0:X2}", cd.Color.R) + string.Format("{0:X2}", cd.Color.G) + string.Format("{0:X2}", cd.Color.B);

                }
            }
        }
 private void button3_Click(object sender, EventArgs e)
 {
     ColorDialog.ShowDialog();
     RefreshEnvSpriteTB();
 }