Answers for "ribbon panel color revit api"

0

ribbon panel color revit api

public Result OnStartup( UIControlledApplication a )
{
  try
  {
    adWin.RibbonControl ribbon 
      = adWin.ComponentManager.Ribbon;
 
    ImageSource imgbg = new BitmapImage( 
      new Uri( Path.Combine( 
        Path.GetDirectoryName( 
          Assembly.GetExecutingAssembly().Location ), 
        "yourBackGroundPicture.jpg" ),
        UriKind.Relative ) );
 
    // define an image brush
 
    ImageBrush picBrush = new ImageBrush(); 
    picBrush.ImageSource = imgbg;
    picBrush.AlignmentX = AlignmentX.Left;
    picBrush.AlignmentY = AlignmentY.Top;
    picBrush.Stretch = Stretch.None;
    picBrush.TileMode = TileMode.FlipXY;
 
    // define a linear brush from top to bottom
 
    LinearGradientBrush gradientBrush 
      = new LinearGradientBrush(); 
 
    gradientBrush.StartPoint 
      = new System.Windows.Point( 0, 0 );
 
    gradientBrush.EndPoint 
      = new System.Windows.Point( 0, 1 );
 
    gradientBrush.GradientStops.Add( 
      new GradientStop( Colors.White, 0.0 ) );
 
    gradientBrush.GradientStops.Add( 
      new GradientStop( Colors.Blue, 1 ) );
 
    // change the tab header font
 
    ribbon.FontFamily = new System.Windows.Media
      .FontFamily( "Bauhaus 93" ); 
 
    ribbon.FontSize = 10;
 
    // iterate through the tabs and their panels
 
    foreach( adWin.RibbonTab tab in ribbon.Tabs )
    {
      foreach( adWin.RibbonPanel panel in tab.Panels )
      {
        panel.CustomPanelTitleBarBackground 
          = gradientBrush;
 
        panel.CustomPanelBackground 
          = picBrush; // use your picture
 
        //panel.CustomPanelBackground 
        //  = gradientBrush; // use your gradient fill
      }
    }
    adWin.ComponentManager.UIElementActivated += new 
      EventHandler<adWin.UIElementActivatedEventArgs>( 
        ComponentManager_UIElementActivated );
  }
  catch( Exception ex )
  {
    winform.MessageBox.Show( 
      ex.StackTrace + "\r\n" + ex.InnerException, 
      "Error", winform.MessageBoxButtons.OK );
 
    return Result.Failed;
  }
  return Result.Succeeded;
}
Posted by: Guest on July-29-2021

Browse Popular Code Answers by Language