コード例 #1
0
ファイル: ColorPicker.cs プロジェクト: juhav/ScriptKeys
    public override void Run(string[] parameters)
    {
        string result = "";

        using (var form = new Cyotek.Windows.Forms.ColorPickerDialog()
        {
            StartPosition = FormStartPosition.Manual,
            TopMost = true
        })
        {
            form.SetDesktopLocation(Cursor.Position.X - 20, Cursor.Position.Y - 20);
            var dialogResult = form.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                Color c = form.Color;

                if (c.A == 255)
                {
                    result = "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
                }
                else
                {
                    result = "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2") + c.A.ToString("X2");
                }
            }
        }

        InputSimulator.SimulateTextEntry(result);
    }
コード例 #2
0
 private void pictureBoxEndColor_Click(object sender, EventArgs e)
 {
     var dialog = new ColorPickerDialog();
     dialog.Color = EndColor;
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         EndColor = dialog.Color;
     }
 }
コード例 #3
0
 private void btn_BackgroundColor_Click(object sender, EventArgs e)
 {
     ColorPickerDialog colorDialog = new ColorPickerDialog();
     DialogResult result = colorDialog.ShowDialog();
     switch (result)
     {
         case DialogResult.OK:
             Game.BackgroundColor = GameGraphics.ConvertSystemColorToXNA(colorDialog.Color);
             return;
         default:
             return;
     }
 }
コード例 #4
0
 protected virtual void EditColor(int colorIndex)
 {
     using (ColorPickerDialog dialog = new ColorPickerDialog())
       {
     dialog.Color = this.GetColor(colorIndex);
     if (dialog.ShowDialog(this) == DialogResult.OK)
     {
       this.BeginUpdate();
       this.SetColor(colorIndex, dialog.Color);
       this.Color = dialog.Color;
       this.EndUpdate();
     }
       }
 }
コード例 #5
0
ファイル: ColorGrid.cs プロジェクト: samarjeet27/ynotesamples
 protected virtual void EditColor(int colorIndex)
 {
     using (var dialog = new ColorPickerDialog())
     {
         dialog.Color = GetColor(colorIndex);
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             BeginUpdate();
             SetColor(colorIndex, dialog.Color);
             Color = dialog.Color;
             EndUpdate();
         }
     }
 }
コード例 #6
0
        public override object EditValue(
            ITypeDescriptorContext context, 
            IServiceProvider provider, 
            object value)
        {
            // Attempts to obtain an IWindowsFormsEditorService.
            IWindowsFormsEditorService edSvc = 
                (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc == null)
            {
                return null;
            }

            // Displays a StringInputDialog Form to get a user-adjustable  
            // string value. 
            using (ColorPickerDialog dialog = new ColorPickerDialog())
            {
                dialog.Color = (Color) value;
                if (edSvc.ShowDialog(dialog) == DialogResult.OK)
                {
                    return dialog.Color;
                }
            }

            // If OK was not pressed, return the original value 
            return (Color)value;
        }    
コード例 #7
0
        private void colorSwatchBackgroundColor_Click(object sender, EventArgs e)
        {
            var dialog = new ColorPickerDialog();
            dialog.Color = colorSwatchBackgroundColor.SelectedColor;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                colorSwatchBackgroundColor.SelectedColor = dialog.Color;
                if(BackgroundColorChanged != null)
                    BackgroundColorChanged(sender, new BackgroundColorChangedEventArgs(dialog.Color));

            }
        }
コード例 #8
0
 //Frame color button click
 private void btn_FrameColor_Click(object sender, EventArgs e)
 {
     ColorPickerDialog colorDialog = new ColorPickerDialog();
     DialogResult result = colorDialog.ShowDialog();
     switch (result)
     {
         case DialogResult.OK:
             ColorAction action = new ColorAction
             {
                 Name = "Frame color",
                 Drawable = FrameRectangleName,
                 Value = GameGraphics.ConvertSystemColorToXNA(colorDialog.Color)
             };
             textureManager.ExecuteAction(action);
             _textureGame.RunOneFrame();
             return;
         default:
             return;
     }
 }
コード例 #9
0
 private void btn_TransparentColor_Click(object sender, EventArgs e)
 {
     ColorPickerDialog colorDialog = new ColorPickerDialog();
     DialogResult result = colorDialog.ShowDialog();
     switch (result)
     {
         case DialogResult.OK:
             Texture2D newTexture = BinaryTexture.RemoveTransparentColor(selectedTexture, GameGraphics.ConvertSystemColorToXNA(colorDialog.Color));
             Game.gameGraphics.textureManager.Textures[newTexture.Name] = newTexture;
             selectedTexture = newTexture;
             return;
         default:
             return;
     }
 }