.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The Mistery Bag - Assigning an Extended Help File

2 REPLIES 2
Reply
Message 1 of 3
DouceDeux
487 Views, 2 Replies

The Mistery Bag - Assigning an Extended Help File

Hello,

 

I've been able to successfully add Extended help to my Toolbar by creating an .xalm and then manually assigning the .xalm file and then choosing one of the keys AutoCAD detects.

The extended help help displays as it should.

 

Now, I want to be able do make the toolbar button (or Menumacro to be more precise) have the property, for the extended help, from code. In other words, add the tag to .cui corresponding to the Extended help.

 

To do this I created a custom class derived from IPropertyBag and passed it as parameter but the MenuGroup.cui inside the .cuix did not change, I should add a <ExtendedContent UriSource="..." SourceKey=""> tag but it doesn't because the addition was not successful.

 

I'm trying:

 

public class CustomBag : IPropertyBag
{

  String UriSource;

  String SourceKey;

  //Methods

}

 

MenuMacro newMM1 = new MenuMacro();

CustomBag myBag = new CustomBag();

myBag.AddStuff(source, key);

newMM1.macro.addToolTipProperty((IPropertyBag) myBag);
newMM1.macro.addCommandProperty((IPropertyBag)myBag, false, false);
newMM1.macro.addProperties((IPropertyBag)myBag, false, false);

 

I don't know exactly which of those macro functions is the one that adds the tag but none of them worked with my bad custom class XD.

 

I read something about making property bags serializable but I don't know that, really, tried and failed.

 

The only other option I see is opening up the saved .cuix, unpacking it, opening MenuGroup.cui and then manually adding the text representing the <ExtendedContent> tag.

 

Help please @.@

 

Edit: I'm using Ac 2010 and .net 3.5

Tags (1)
2 REPLIES 2
Message 2 of 3
DouceDeux
in reply to: DouceDeux

I've tried the code below but it didn't work, it fails to cast StackPanel as IPropertyBag. Smiley Sad (no custom class this time)

 

[CommandMethod("test2")]
public void test2()
{
  ToolTipContent newTTC = new ToolTipContent();
  newTTC.UriSource = @"D:\User\Lev\Solutions\AutoCAD 2010\Rebars\Extended Help\RLEH.xaml";
  newTTC.SourceKey = "RLEH_CMD_001";
  CustomizationSection newCS = new CustomizationSection();
  newCS.MenuGroupName = "TESTCMD";
        
  MacroGroup newMG = new MacroGroup("TESTMacros", newCS.MenuGroup);
        
  MenuMacro newMM1 = new MenuMacro(newMG, "Test Command", "^C^CREGEN", "ID_Test");
        
  newMM1.macro.HelpString = "Anexar plano original bajo determinadas especificaciones";        
  newMM1.macro.CLICommand = "TESTCMD";
  newMM1.macro.SmallImage = "RCDATA_16_3D_ARRAY";
  newMM1.macro.SmallImage = "RCDATA_32_3D_ARRAY";

  Autodesk.Windows.RibbonToolTip rtt = new Autodesk.Windows.RibbonToolTip();
  System.Windows.Controls.StackPanel newSP = new System.Windows.Controls.StackPanel();
  System.Windows.Controls.TextBlock newTB = new System.Windows.Controls.TextBlock();
  newTB.Background = System.Windows.Media.Brushes.White;
  newTB.TextAlignment = System.Windows.TextAlignment.Justify;
  newTB.Text = "TEXT TEXT TEXT";
  System.Windows.Controls.Image newI = new System.Windows.Controls.Image();        
  BitmapImage bi3 = new BitmapImage();
  bi3.BeginInit();
  bi3.UriSource = new Uri(@"D:\User\Lev\Solutions\AutoCAD 2010\Rebars\Extended Help\Images\EH_RLXREF.png", UriKind.RelativeOrAbsolute);
  bi3.EndInit();
  newI.Stretch = System.Windows.Media.Stretch.Fill;
  newI.Source = bi3;
  newSP.Background = System.Windows.Media.Brushes.Black;
  newSP.Children.Add(newTB);
  newSP.Children.Add(newI);
  rtt.Content = newSP;
  rtt.ExpandedContent = newSP;
  newMM1.macro.addToolTipProperty((IPropertyBag)rtt.ExpandedContent);

  Toolbar newT = new Toolbar("Test Toolbar", newCS.MenuGroup);
  ToolbarButton newButton1 = new ToolbarButton("ID_Test", "Test", newT, 0);
  newT.ToolbarItems.Add(newButton1);
  newCS.SaveAs(@"C:\mycui.cuix");

        object oldCmdEcho = Application.GetSystemVariable("CMDECHO");
object oldFileDia = Application.GetSystemVariable("FILEDIA");
Application.SetSystemVariable("CMDECHO", 0);
Application.SetSystemVariable("FILEDIA", 0);

Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_.cuiload " + @"C:\mycui.cuix" + " ", false, false, false);
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("(setvar \"FILEDIA\" " + oldFileDia.ToString() + ")(princ) ", false, false, false);
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("(setvar \"CMDECHO\" " + oldCmdEcho.ToString() + ")(princ) ", false, false, false);
}

 

Message 3 of 3
fenton.webb
in reply to: DouceDeux

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost