~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/Main/ICSharpCode.Core.Presentation/ToolBar/ToolBarSplitButton.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections;
 
6
using System.Windows;
 
7
using System.Windows.Controls;
 
8
 
 
9
namespace ICSharpCode.Core.Presentation
 
10
{
 
11
        /// <summary>
 
12
        /// A tool bar button based on the AddIn-tree.
 
13
        /// </summary>
 
14
        sealed class ToolBarSplitButton : SplitButton, IStatusUpdate
 
15
        {
 
16
                ICommand menuCommand;
 
17
                object caller;
 
18
                Codon codon;
 
19
                
 
20
                public ToolBarSplitButton(Codon codon, object caller, IList submenu)
 
21
                {
 
22
                        ToolTipService.SetShowOnDisabled(this, true);
 
23
                        
 
24
                        this.codon = codon;
 
25
                        this.caller = caller;
 
26
 
 
27
                        this.Content = ToolBarService.CreateToolBarItemContent(codon);
 
28
                        if (codon.Properties.Contains("name")) {
 
29
                                this.Name = codon.Properties["name"];
 
30
                        }
 
31
                        
 
32
                        menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
 
33
                        menuCommand.Owner = this;
 
34
                        
 
35
                        this.Command = new CommandWrapper(codon, caller, menuCommand);
 
36
                        this.DropDownMenu = MenuService.CreateContextMenu(submenu);
 
37
                        
 
38
                        UpdateText();
 
39
                }
 
40
                
 
41
                public void UpdateText()
 
42
                {
 
43
                        if (codon.Properties.Contains("tooltip")) {
 
44
                                this.ToolTip = StringParser.Parse(codon.Properties["tooltip"]);
 
45
                        }
 
46
                }
 
47
                
 
48
                public void UpdateStatus()
 
49
                {
 
50
                        if (codon.GetFailedAction(caller) == ConditionFailedAction.Exclude)
 
51
                                this.Visibility = Visibility.Collapsed;
 
52
                        else
 
53
                                this.Visibility = Visibility.Visible;
 
54
                }
 
55
        }
 
56
}