.NET

Reply
Active Contributor
DouceDeux
Posts: 46
Registered: ‎09-04-2012
Message 1 of 3 (261 Views)

The Mistery Bag - Assigning an Extended Help File

261 Views, 2 Replies
02-14-2013 12:18 PM

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

Active Contributor
DouceDeux
Posts: 46
Registered: ‎09-04-2012
Message 2 of 3 (238 Views)

Re: The Mistery Bag - Assigning an Extended Help File

02-14-2013 02:34 PM in reply to: DouceDeux

I've tried the code below but it didn't work, it fails to cast StackPanel as IPropertyBag. :smileysad: (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);
}

 

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 3 of 3 (199 Views)

Re: The Mistery Bag - Assigning an Extended Help File

02-27-2013 10:28 AM in reply to: DouceDeux
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.