0

Using AvalonDock I created the ToolBoxControl and now I am planning to disable certain top level activities (want it visible just greyed out). I wanted to know the ways I can do it.

The image below, the activities circled in red, I want either to grey them out or change font colour. This way I can differentiate the users using the software. ToolBox

The code used for this in XAML is

<xcad:DockingManager Grid.Row="1"
                       AllowMixedOrientation="True"
                       BorderBrush="Black"
                       BorderThickness="1">
        <xcad:LayoutRoot x:Name="LayoutRoot">
            <xcad:LayoutPanel Orientation="Horizontal">

                <xcad:LayoutAnchorablePane DockWidth="200">
                    <xcad:LayoutAnchorable Title="Toolbox" CanClose="False" CanFloat="False" CanHide="False" ContentId="toolbox" x:Name="CtrlToolbox">
                    </xcad:LayoutAnchorable>

                    <xcad:LayoutAnchorable Title="Outline" CanClose="False" CanFloat="False" CanHide="False" ContentId="outline" x:Name="CtrlOutline">
                    </xcad:LayoutAnchorable>
                </xcad:LayoutAnchorablePane>

The .cs version of this is :

private void AddToolBox()
{
    ToolboxControl tc = GetToolboxControl(); //CreateToolboxControls();
    CtrlToolbox.Content = tc;
}


private ToolboxControl GetToolboxControl()
{

// Create the ToolBoxControl.
ToolboxControl ctrl = new ToolboxControl();

ToolboxCategory categoryFlowChart = new ToolboxCategory("Flow Chart");
ToolboxCategory categoryStateMachine = new ToolboxCategory("State Machine");
ToolboxCategory categoryExport = new ToolboxCategory("File System");
ToolboxCategory categoryWindowsApp = new ToolboxCategory("Windows App");
ToolboxCategory categorySSH = new ToolboxCategory("SSH");
ToolboxCategory categoryVBScript = new ToolboxCategory("VB Script");
ToolboxCategory categoryCommunication = new ToolboxCategory("Communication");
ToolboxCategory categoryDatabase = new ToolboxCategory("Database");



// Add the category to the ToolBox control.
ctrl.Categories.Add(categoryFlowChart);
ctrl.Categories.Add(categoryDatabase);
ctrl.Categories.Add(categoryStateMachine);
ctrl.Categories.Add(categoryWindowsApp);
ctrl.Categories.Add(categorySSH);
ctrl.Categories.Add(categoryCommunication);
ctrl.Categories.Add(categoryVBScript);

return ctrl

}

Any other information I need to provide please let me know. Just need to be able to disable the top level activity.

Vivian Lobo
  • 583
  • 10
  • 29

1 Answers1

0

Take a look at this example, its not exactly what your after. But it explains how to customize the ToolboxControl style and alter the icons. The idea can be applied to alter the style of the ToolboxItems to your own means. (review step 3 specifically). If you need further assistance I can work on an example.

DotNetHitMan
  • 931
  • 8
  • 20
  • Thank you for the link, but I do change the icons and also style like shown in this pic : http://i60.tinypic.com/5mbbid.jpg I was thinking more in terms of disabling/greying out the top level of the tree as circled form the above post. So literally "State Machine" and "Windows App" and "SSH". I hope to have explained it better. I appreciate the help. – Vivian Lobo May 08 '15 at 09:10
  • ok well i am not 100% sure you can control the Toolbox control in this manner. http://blogs.msdn.com/b/tilovell/archive/2011/08/12/wf4-toolbox-updating-the-wf4-toolbox-icon-faq-for-rehosting-and-custom-activities.aspx explains how you can create events off of your own toolbox. So you might be better off writing your own tool box and implementing the event to drag / drop activities onto the design surface yourself. Look for the question "Can I create my own toolbox, instead of using ToolboxControl, and still drag-drop stuff into the designer?" – DotNetHitMan May 08 '15 at 12:34
  • Thanks DotNetHitman, I think I will have to implement my own. However, if I may throw in another question. I am looking for the dragdrop activity. I want to run a function, when this drag and drop is happening and possibly cancel the drag and drop depending on the return value. Is this possible? I saw this in google, Type type = ((AvailableActivity)(((ListBox)sender).SelectedItem)).Type; DataObject data = new DataObject(DragDropHelper.WorkflowItemTypeNameFormat, type.AssemblyQualifiedName); DragDrop.DoDragDrop(this.box1, data, DragDropEffects.Move); I am not sure yet. – Vivian Lobo May 12 '15 at 09:20
  • Hi @VivianLobo if you create a new question related to your drag drop issue. I will assist where i can :) – DotNetHitMan May 12 '15 at 15:13
  • :) Sorry. I will do it. Thanks DotNetHitMan. – Vivian Lobo May 13 '15 at 10:23