General Technical Discussions for Service

Get Involved. Join the Conversation.

Topic

    Cristian Nieva
    StatusBar Addin color schemaAnswered
    Topic posted December 13, 2017 by Cristian NievaRed Ribbon: 250+ Points 
    153 Views, 6 Comments
    Title:
    StatusBar Addin color schema
    Content:

    Hi All,

    I'm working in a status bar addin, and I'm able to set on it the image and text that we want, but I don't know how to set the right colors to it, so it looks in the same way as the other items in the status bar.

    As you can see on the screen shot that I added, the background of it is white and the font colors are black, and I would like to set the colors to it base on the selected color schema.

    Is there any way to set the right colors schema to the addin base on the option selected by the user?

    Thanks,

    Cristian

    Version:
    May 2017
    Image:

    Best Comment

    Bastiaan van der Kooij

    hey Christian,

    there is no so much wrong with your code, the issue is that since you're using WinForms for your control, RightNow uses an ElementHost to show your control in the WPF environment. This host has a white background which leaves you making your control as much transparent as you like without getting any results.

    By far the best way is to create your control in XAML since this solves all those problems. Since typically status bar controls are visually so simple I would not think making this transition will be that hard as it can be for more complex controls. Below some sample code, you would end up with a separate IStatusBarItem class, which returns the xaml file StatusBarControl;

     

        [AddIn("Status bar add-in", Version = "1.0.0.0")]
        public class AddIn : IStatusBarItem, IFrameworkElementAddIn
        {
            StatusBarControl UC;
    
            public System.Windows.Forms.Control GetControl()
            {
                return null;
            }
    
            public FrameworkElement GetFrameworkElement()
            {
                UC = new StatusBarControl();
                return UC;
            }
    
            public bool Initialize(IGlobalContext context)
            {
                return true;
            }
        }
    

     

    <UserControl x:Class="StatusBar.StatusBarControl"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:local="clr-namespace:StatusBar"
                 mc:Ignorable="d" 
                 d:DesignHeight="20" d:DesignWidth="300">
        <Grid>
            <Label VerticalAlignment="Center" Foreground="#FFB6D6F5" FontFamily="Segoe UI" Padding="5,0" FontSize="11">My StatusBar Addin!</Label>
        </Grid>
    </UserControl>
    

     

     

    Bastiaan

    Comment

     

    • Bastiaan van der Kooij
      Hey Christian, Why don't you just keep your addin background transparent? I have done it like that before with whitish text and that looks perfect. Bastiaan
    • Cristian Nieva

      Hi Bastiaan,

      I already have set the back color to transparent, in the add in class and in the control, but it is not working.

      Here part of my code, do you see anything wrong with it?

       

      [AddIn("Status bar add-in", Version = "1.0.0.0")]
      public partial class StatusBarAddIn : Panel, IStatusBarItem  {
          private IGlobalContext _context;
          private StatusBar _Campana;
      
          public StatusBarAddIn()  {
              this.SuspendLayout();
              this._Campana = new StatusBar();
              this.Controls.Add(_Campana);
              this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
              this.BackColor = System.Drawing.Color.Transparent;
      ....    
      public partial class StatusBar : UserControl  {
          public StatusBar()  {
              InitializeComponent();
              this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
              this.BackColor = System.Drawing.Color.Transparent;
      

       

      Thanks,

      Cristian

    • Bastiaan van der Kooij

      hey Christian,

      there is no so much wrong with your code, the issue is that since you're using WinForms for your control, RightNow uses an ElementHost to show your control in the WPF environment. This host has a white background which leaves you making your control as much transparent as you like without getting any results.

      By far the best way is to create your control in XAML since this solves all those problems. Since typically status bar controls are visually so simple I would not think making this transition will be that hard as it can be for more complex controls. Below some sample code, you would end up with a separate IStatusBarItem class, which returns the xaml file StatusBarControl;

       

          [AddIn("Status bar add-in", Version = "1.0.0.0")]
          public class AddIn : IStatusBarItem, IFrameworkElementAddIn
          {
              StatusBarControl UC;
      
              public System.Windows.Forms.Control GetControl()
              {
                  return null;
              }
      
              public FrameworkElement GetFrameworkElement()
              {
                  UC = new StatusBarControl();
                  return UC;
              }
      
              public bool Initialize(IGlobalContext context)
              {
                  return true;
              }
          }
      

       

      <UserControl x:Class="StatusBar.StatusBarControl"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                   xmlns:local="clr-namespace:StatusBar"
                   mc:Ignorable="d" 
                   d:DesignHeight="20" d:DesignWidth="300">
          <Grid>
              <Label VerticalAlignment="Center" Foreground="#FFB6D6F5" FontFamily="Segoe UI" Padding="5,0" FontSize="11">My StatusBar Addin!</Label>
          </Grid>
      </UserControl>
      

       

       

      Bastiaan

    • Cristian Nieva

      Hi Bastiaan,

      The use of XAML fixed the issue with the background, thanks a lot!

      Now I'm trying to get the label with an image.

      Regards,

      Cristian

    • Bastiaan van der Kooij

      Good to hear. You can use a StackPanel to stack items.

    • Noorshabah Ramjanee

      Hello Cristian,

      I am actually new to Oracle Service Cloud and addins.

      I am implementing Oracle Service Cloud and the Agent has to be notified in the status bar whenever there is a communique sent.

      Can you please share how to proceeded to code your status bar addin?

      Thanks a lot.