Colore - C# Library for Chroma

Discussion in 'Razer Chroma' started by BrandonJCScott, Mar 8, 2015.

Thread Status:
Not open for further replies.
  1. Sharparam

    Sharparam Member

    This is a good suggestion for a feature. We'll look into seeing if there's an easy way to convert between Razer's key enum and the ones found in .NET (manual dictionary mapping always works but is also the most tedious).

    Tracking issue for this feature.
     
    KeithM likes this.
  2. bytePruneventure855

    bytePruneventure855 New Member

    Hey just received my Blackwidow Chroma and instantly tried your library.
    I`m running into a problem and I´m not exactly sure whats going wrong...

    This is my current testing code:
    Code:
            public Form1()
            {
                InitializeComponent();
            }  
            private void button1_Click(object sender, EventArgs e)
            {
                Keyboard.Instance.Clear();
                Keyboard.Instance.SetAll(Corale.Colore.Core.Color.Blue);
            }
    It is throwing a "Corale.Colore.Razer.NativeCallException" at the "Keyboard.Instance.Clear();" line with this description:
    Code:
    Call to native Chroma SDK function CreateKeyboardEffect failed with error: RzResourceDisabled: Resource not available or disabled. (4309)
    It does however turn the standard wave animation off and sets all LEDs to the off state while debugging so there seems to be a working connection to the Keyboard.

    I have installed the Chroma SDK & restarted after the Installation
    Razer Synapse is closed
    Using .Net 4.5
    Using Colore 2.2.2

    It´s probably something extremely obvious...

    Full Detail Crash log: (Parts in German sry)
    Corale.Colore.Razer.NativeCallException wurde nicht behandelt.
    HResult=-2146233088
    Message=Call to native Chroma SDK function CreateKeyboardEffect failed with error: RzResourceDisabled: Resource not available or disabled. (4309)
    Source=Corale.Colore
    Function=CreateKeyboardEffect
    StackTrace:
    bei Corale.Colore.Core.NativeWrapper.CreateKeyboardEffect(Effect effect, IntPtr param)
    bei Corale.Colore.Core.NativeWrapper.CreateKeyboardEffect[T](Effect effect, T struct)
    bei Corale.Colore.Core.NativeWrapper.CreateKeyboardEffect(Custom effect)
    bei Corale.Colore.Core.Keyboard.SetAll(Color color)
    bei Corale.Colore.Core.Device.Clear()
    bei ColoreTest.Form1.button1_Click(Object sender, EventArgs e) in e:\Dev\C#\Projects\ColoreTest\ColoreTest\Form1.cs:Zeile 24.
    bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    bei System.Windows.Forms.Control.WndProc(Message& m)
    bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
    bei System.Windows.Forms.Button.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    bei ColoreTest.Program.Main() in e:\Dev\C#\Projects\ColoreTest\ColoreTest\Program.cs:Zeile 19.
    bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    bei System.Threading.ThreadHelper.ThreadStart()
    InnerException: System.ComponentModel.Win32Exception
    HResult=-2147467259
    Message=Eine für diesen Vorgang benötigte Ressource ist deaktiviert
    ErrorCode=-2147467259
    NativeErrorCode=4309
    InnerException:

    This Library looks great would love to be able to try it ;)
     
  3. njbmartin

    njbmartin Developer of Awesome

    This normally indicated that the SDK is available but you may need to restart your PC first so it's enabled.
     
  4. Sharparam

    Sharparam Member

    @TP_ Did you run the reg file included with the SDK?
     
  5. bytePruneventure855

    bytePruneventure855 New Member

    That was it! Thx for the fast answer
     
  6. BrandonJCScott

    BrandonJCScott Active Member

    Let us know if we can answer any other questions about Chroma or Colore.
     
  7. njbmartin

    njbmartin Developer of Awesome

  8. njbmartin

    njbmartin Developer of Awesome

    Colore 2.3.0 has been released with lots of improvements and new helper methods (eg. setting all devices to the same colour).

    Get it from the GitHub release page or from NuGet!

    Any issues or suggestions, please raise them in the issue tracker, or get in touch. We're friendly!
     
  9. hjilp

    hjilp Member

    This is really helpful, thanks so much!
     
    BrandonJCScott likes this.
  10. BrandonJCScott

    BrandonJCScott Active Member

    Glad you're liking Colore, let us know if you want any help or advice.
     
  11. Ergonyx

    Ergonyx Member

    Can we get some documentation for dummies in here? I can't figure out how to set a color using 0-255 as values
     
    Austin Clark likes this.
  12. Sharparam

    Sharparam Member


    Documentation is available online for the entirety of Colore.


    I'd suggest looking at the documentation for Core.Color and the various device interfaces for setting colors (every device supports SetAll).

    Constructing a color using RGB byte values can be done like this:

    Code:
    byte r, g, b; // 0-255 byte values
    var color = new Color(r, g, b);
    
     
  13. Ergonyx

    Ergonyx Member

    I was reading the documentation for the last hour and a half or so. Made zero sense to me. Hence the request for some documentation for dummies. Because right now, looking at the documentation you already have, I feel like a moron.

    And I was more interested in using variables that I can change on the fly or on certain key presses and not setting a bunch of my own custom colors.

    Like Color(Var1, Var2, Var3) and so on.
     
    Austin Clark likes this.
  14. Sharparam

    Sharparam Member

    Short example showing changing values on variables and passing them to methods:

    Code:
    // class fields:
    private byte _r;
    private byte _g;
    private byte _b;
    
    private void KeyHandler(object s, KeyEventArgs e) // Customize to whatever framework is in use
    {
      switch (e.Key)
      {
        case KeyEnum.A:
          _r = 255;
          _g = 0;
          _b = 0;
          break;
        case KeyEnum.B:
          _r = 0;
          _g = 0;
          _b = 255;
          break;
        // et.c. ad infinitum
      }
    
      UpdateColors();
    }
    
    // Method called whenever colors need updating
    private void UpdateColors()
    {
      // Saved instance of IKeyboard, alternatively access
      // directly with Keyboard.Instance or some other
      // device entirely
      _keyboard.SetAll(new Color(_r, _g, _b));
    }
    
     
  15. BrandonJCScott

    BrandonJCScott Active Member

    Hopefully the code Adam posted above can get you started, it assumes that you know how to add a Key handler. If you need any further assistance feel free to jump into: https://gitter.im/CoraleStudios/Colore

    We can help you out in real time.
     
Thread Status:
Not open for further replies.
Sign In with Razer ID >


Don't have a Razer ID yet?
Get Razer ID >