public ButtonTag(ICommandTarget target, IToolBarComponent owner, IPoderosaCommand command) : base(owner) { _target = target; _associatedCommand = command; _generalCommand = (IGeneralCommand)command.GetAdapter(typeof(IGeneralCommand)); //取得できなきゃnull }
private void CreateToolBarComponent(IToolBarComponent comp, Point pt) { //この中でIToolBarの各メソッドが呼ばれ、モロモロの登録が行われる _currentToolStrip = new ToolStrip(); IToolBarElement[] elements = comp.ToolBarElements; foreach (IToolBarElement e in elements) { if (e is IToolBarCommandButton) { DefineCommandButton(comp, (IToolBarCommandButton)e); } else if (e is IToolBarLabel) { DefineLabel(comp, (IToolBarLabel)e); } else if (e is IToolBarComboBox) { DefineComboBox(comp, (IToolBarComboBox)e); } else if (e is IToolBarToggleButton) { DefineToggleButton(comp, (IToolBarToggleButton)e); } else { throw new ArgumentException("Unexpected IToolBarElement type"); } } _currentToolStrip.Location = pt; _toolStrips.Add(_currentToolStrip); Debug.WriteLineIf(DebugOpt.BuildToolBar, "toolbar " + comp.GetType().Name + " location=" + _currentToolStrip.Location.ToString()); }
private void DefineCommandButton(IToolBarComponent comp, IToolBarCommandButton element) { ToolStripButton button = new ToolStripButton(); button.Image = element.Icon; button.Tag = new ButtonTag(GetCommandTarget(), comp, element.Command); button.Size = new Size(24, 23); button.Click += delegate(object sender, EventArgs args) { DoCommand(element.Command); }; IGeneralCommand gc = (IGeneralCommand)element.Command.GetAdapter(typeof(IGeneralCommand)); if (gc != null) { if (!String.IsNullOrEmpty(gc.Description)) { button.ToolTipText = gc.Description; } } else if (!String.IsNullOrEmpty(element.ToolTipText)) { button.ToolTipText = element.ToolTipText; } _currentToolStrip.Items.Add(button); }
private void DefineLabel(IToolBarComponent comp, IToolBarLabel element) { ToolStripLabel label = new ToolStripLabel(); label.Width = element.Width; label.Text = element.Text; label.Tag = new LabelTag(comp, element); label.TextAlign = ContentAlignment.MiddleRight; _currentToolStrip.Items.Add(label); }
private void DefineToggleButton(IToolBarComponent comp, IToolBarToggleButton element) { ToolStripButton tb = new ToolStripButton(); tb.Image = element.Icon; ToggleButtonTag tag = new ToggleButtonTag(GetCommandTarget(), comp, element); tb.Tag = tag; tb.Click += new EventHandler(tag.OnClick); if (!String.IsNullOrEmpty(element.ToolTipText)) { tb.ToolTipText = element.ToolTipText; } _currentToolStrip.Items.Add(tb); }
public override void InitializePlugin(IPoderosaWorld poderosa) { base.InitializePlugin(poderosa); _instance = this; IPluginManager pm = poderosa.PluginManager; _commandManager = (ICommandManager)pm.FindPlugin("org.poderosa.core.commands", typeof(ICommandManager)); _loginDialogCommand = new CygwinLoginDialogCommand(); _commandManager.Register(_loginDialogCommand); IExtensionPoint ep = poderosa.PluginManager.FindExtensionPoint("org.poderosa.menu.file"); _cygwinMenuGroup = new CygwinMenuGroup(); ep.RegisterExtension(_cygwinMenuGroup); _cygwinToolBarComponent = new CygwinToolBarComponent(); poderosa.PluginManager.FindExtensionPoint("org.poderosa.core.window.toolbar").RegisterExtension(_cygwinToolBarComponent); }
//UIのAdjustment public void RefreshComponent(IToolBarComponent component) { ICommandTarget target = (ICommandTarget)_parent.GetAdapter(typeof(ICommandTarget)); foreach (ToolStrip st in GetContents()) { //TODO タグの関連付け工夫できる foreach (ToolStripItem c in st.Items) { ControlTagBase tag = c.Tag as ControlTagBase; if (tag != null && tag.OwnerComponent == component) { RefreshElement(c, tag, target); } } } }
private void DefineComboBox(IToolBarComponent comp, IToolBarComboBox element) { ToolStripComboBox cb = new ToolStripComboBox(); cb.Items.AddRange(element.Items); cb.Size = new Size(element.Width, cb.Height); //Widthを直接設定してもいかんらしい。なんじゃいな cb.DropDownStyle = ComboBoxStyle.DropDownList; ComboBoxTag tag = new ComboBoxTag(GetCommandTarget(), comp, element); cb.Tag = tag; cb.SelectedIndexChanged += new EventHandler(tag.OnSelectedIndexChanged); if (!String.IsNullOrEmpty(element.ToolTipText)) { cb.ToolTipText = element.ToolTipText; } _currentToolStrip.Items.Add(cb); }
public LabelTag(IToolBarComponent owner, IToolBarLabel label) : base(owner) { _label = label; }
public ToggleButtonTag(ICommandTarget target, IToolBarComponent component, IToolBarToggleButton handler) : base(component) { _target = target; _handler = handler; }
public ComboBoxTag(ICommandTarget target, IToolBarComponent component, IToolBarComboBox handler) : base(component) { _target = target; _handler = handler; }
public ControlTagBase(IToolBarComponent component) { _ownerComponent = component; }
private void DefineToggleButton(IToolBarComponent comp, IToolBarToggleButton element) { ToolStripButton tb = new ToolStripButton(); tb.Image = element.Icon; ToggleButtonTag tag = new ToggleButtonTag(GetCommandTarget(), comp, element); tb.Tag = tag; tb.Click += new EventHandler(tag.OnClick); if (!String.IsNullOrEmpty(element.ToolTipText)) tb.ToolTipText = element.ToolTipText; _currentToolStrip.Items.Add(tb); }
private void DefineCommandButton(IToolBarComponent comp, IToolBarCommandButton element) { ToolStripButton button = new ToolStripButton(); button.Image = element.Icon; button.Tag = new ButtonTag(GetCommandTarget(), comp, element.Command); button.Size = new Size(24, 23); button.Click += delegate(object sender, EventArgs args) { DoCommand(element.Command); }; IGeneralCommand gc = (IGeneralCommand)element.Command.GetAdapter(typeof(IGeneralCommand)); if (gc != null) { if (!String.IsNullOrEmpty(gc.Description)) button.ToolTipText = gc.Description; } else if (!String.IsNullOrEmpty(element.ToolTipText)) { button.ToolTipText = element.ToolTipText; } _currentToolStrip.Items.Add(button); }
private void CreateToolBarComponent(IToolBarComponent comp, Point pt) { //この中でIToolBarの各メソッドが呼ばれ、モロモロの登録が行われる _currentToolStrip = new ToolStrip(); IToolBarElement[] elements = comp.ToolBarElements; foreach (IToolBarElement e in elements) { if (e is IToolBarCommandButton) DefineCommandButton(comp, (IToolBarCommandButton)e); else if (e is IToolBarLabel) DefineLabel(comp, (IToolBarLabel)e); else if (e is IToolBarComboBox) DefineComboBox(comp, (IToolBarComboBox)e); else if (e is IToolBarToggleButton) DefineToggleButton(comp, (IToolBarToggleButton)e); else throw new ArgumentException("Unexpected IToolBarElement type"); } _currentToolStrip.Location = pt; _toolStrips.Add(_currentToolStrip); Debug.WriteLineIf(DebugOpt.BuildToolBar, "toolbar " + comp.GetType().Name + " location=" + _currentToolStrip.Location.ToString()); }
private void DefineComboBox(IToolBarComponent comp, IToolBarComboBox element) { ToolStripComboBox cb = new ToolStripComboBox(); cb.Items.AddRange(element.Items); cb.Size = new Size(element.Width, cb.Height); //Widthを直接設定してもいかんらしい。なんじゃいな cb.DropDownStyle = ComboBoxStyle.DropDownList; ComboBoxTag tag = new ComboBoxTag(GetCommandTarget(), comp, element); cb.Tag = tag; cb.SelectedIndexChanged += new EventHandler(tag.OnSelectedIndexChanged); if (!String.IsNullOrEmpty(element.ToolTipText)) cb.ToolTipText = element.ToolTipText; _currentToolStrip.Items.Add(cb); }