本文整理汇总了C#中System.Windows.Controls.ToolBar类的典型用法代码示例。如果您正苦于以下问题:C# ToolBar类的具体用法?C# ToolBar怎么用?C# ToolBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToolBar类属于System.Windows.Controls命名空间,在下文中一共展示了ToolBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AbstractConsolePad
protected AbstractConsolePad()
{
this.panel = new Grid();
this.console = new ConsoleControl();
// creating the toolbar accesses the WordWrap property, so we must do this after creating the console
this.toolbar = BuildToolBar();
this.toolbar.SetValue(DockPanel.DockProperty, Dock.Top);
panel.Children.Add(toolbar);
panel.Children.Add(console);
panel.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
panel.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
Grid.SetRow(console, 1);
this.history = new List<string>();
this.console.editor.TextArea.PreviewKeyDown += (sender, e) => {
e.Handled = HandleInput(e.Key);
};
this.console.editor.TextArea.TextEntered += AbstractConsolePadTextEntered;
this.InitializeConsole();
}
示例2: AddFileToolBar
void AddFileToolBar(ToolBarTray tray, int band, int index)
{
ToolBar toolbar = new ToolBar();
toolbar.Band = band;
toolbar.BandIndex = index;
tray.ToolBars.Add(toolbar);
RoutedUICommand[] comm = {
ApplicationCommands.New, ApplicationCommands.Open, ApplicationCommands.Save
};
string[] strImages = {
"NewDocumentHS.png", "OpenHS.png", "SaveHS.png"
};
for (int i = 0; i < 3; i++)
{
Button btn = new Button();
btn.Command = comm[i];
toolbar.Items.Add(btn);
string fileName = Path.Combine(Directory.GetCurrentDirectory(), strImages[i]);
Image img = new Image();
img.Source = new BitmapImage(new Uri(fileName));
img.Stretch = Stretch.None;
btn.Content = img;
ToolTip tip = new ToolTip();
tip.Content = comm[i].Text;
btn.ToolTip = tip;
}
CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OnNew));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, OnOpen));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, OnSave));
}
示例3: TryArrangeChildren
private void TryArrangeChildren(IList<Region> children)
{
if (children.Count > 0)
{
var toolBar = new ToolBar();
toolBarContainer.Content = toolBar;
toolBarContainer.Visibility = Visibility.Visible;
for (int i = 0, c = children.Count; i < c; i++)
{
var child = children[i];
var btn = new Button()
{
Content = child.ChildrenLabel
};
btn.Click += (o, e) =>
{
var control = child.ControlResult.Control;
control.RemoveFromParent();
new Window()
{
WindowState = WindowState.Maximized,
Content = control
}.Show();
};
toolBar.Items.Add(btn);
}
}
}
示例4: ErrorListPad
public ErrorListPad()
{
instance = this;
properties = PropertyService.NestedProperties("ErrorListPad");
TaskService.Cleared += TaskServiceCleared;
TaskService.Added += TaskServiceAdded;
TaskService.Removed += TaskServiceRemoved;
TaskService.InUpdateChanged += delegate {
if (!TaskService.InUpdate)
InternalShowResults();
};
SD.BuildService.BuildFinished += ProjectServiceEndBuild;
SD.ProjectService.SolutionOpened += OnSolutionOpen;
SD.ProjectService.SolutionClosed += OnSolutionClosed;
errors = new ObservableCollection<SDTask>(TaskService.Tasks.Where(t => t.TaskType != TaskType.Comment));
toolBar = ToolBarService.CreateToolBar(contentPanel, this, "/SharpDevelop/Pads/ErrorList/Toolbar");
contentPanel.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
contentPanel.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
contentPanel.Children.Add(toolBar);
contentPanel.Children.Add(errorView);
Grid.SetRow(errorView, 1);
errorView.ItemsSource = errors;
errorView.MouseDoubleClick += ErrorViewMouseDoubleClick;
errorView.Style = (Style)new TaskViewResources()["TaskListView"];
errorView.ContextMenu = MenuService.CreateContextMenu(errorView, DefaultContextMenuAddInTreeEntry);
errorView.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, ExecuteCopy, CanExecuteCopy));
errorView.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll));
InternalShowResults();
}
示例5: AddToolBar
private void AddToolBar(IMenu toolbarModel)
{
var toolBar = new ToolBar();
toolBar.SetResourceReference(ToolBar.StyleProperty, Resources.ToolBarStyleKey);
toolBar.DataContext = toolbarModel;
m_toolBarTray.ToolBars.Add(toolBar);
}
示例6: RemoveToolBarOverflow
public static void RemoveToolBarOverflow(ToolBar toolBar)
{
FrameworkElement overflowGrid = toolBar.Template.FindName("OverflowGrid", toolBar) as FrameworkElement;
if (overflowGrid != null)
{
overflowGrid.Visibility = Visibility.Collapsed;
}
}
示例7: AddSeparator
public void AddSeparator(double width,ToolBar location)
{
Separator sp = new Separator();
sp.Width = width;
BrushConverter bc = new BrushConverter();
sp.Background = (Brush)bc.ConvertFrom("Transparent");
location.Items.Add(sp);
}
示例8: ResizeToolbar
public static void ResizeToolbar(ToolBar toolStrip, FrameworkElement resizingItem)
{
var w = (from FrameworkElement t in toolStrip.Items where t != resizingItem select t.ActualWidth).Sum();
if (((toolStrip.ActualWidth - w) - 50) > 50)
resizingItem.Width = (toolStrip.ActualWidth - w) - 50;
else
resizingItem.Width = 50;
}
示例9: CraftTheToolbar
public CraftTheToolbar()
{
Title = "Craft the Toolbar";
RoutedUICommand[] comm =
{
ApplicationCommands.New, ApplicationCommands.Open,
ApplicationCommands.Save, ApplicationCommands.Print,
ApplicationCommands.Cut, ApplicationCommands.Copy,
ApplicationCommands.Paste, ApplicationCommands.Delete
};
string[] strImages =
{
"NewDocumentHS.png", "openHS.png", "saveHS.png",
"PrintHS.png", "CutHS.png", "CopyHS.png",
"PasteHS.png", "DeleteHS.png"
};
// Create DockPanel as content of window.
DockPanel dock = new DockPanel();
dock.LastChildFill = false;
Content = dock;
// Create Toolbar docked at top of window.
ToolBar toolbar = new ToolBar();
dock.Children.Add(toolbar);
DockPanel.SetDock(toolbar, Dock.Top);
// Create the Toolbar buttons.
for (int i = 0; i < 8; i++)
{
if (i == 4)
toolbar.Items.Add(new Separator());
// Create the Button.
Button btn = new Button();
btn.Command = comm[i];
toolbar.Items.Add(btn);
// Create an Image as content of the Button.
Image img = new Image();
img.Source = new BitmapImage(
new Uri("pack://application:,,/Images/" + strImages[i]));
img.Stretch = Stretch.None;
btn.Content = img;
// Create a ToolTip based on the UICommand text.
ToolTip tip = new ToolTip();
tip.Content = comm[i].Text;
btn.ToolTip = tip;
// Add the UICommand to the window command bindings.
CommandBindings.Add(
new CommandBinding(comm[i], ToolBarButtonOnClick));
}
}
示例10: AddTool
//Add new tool to toolsbox
public void AddTool(BaseUMLMode Mode, Uri icon1, Uri icon2, ToolBar location)
{
ToolButton UIButton = new Controls.ToolButton(Mode, icon1, icon2);
UIButton.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(ToolsButton_MouseLeftButtonDown), true);
UIButton.AddHandler(MouseEnterEvent, new MouseEventHandler(ToolsButton_MouseEnter), true);
UIButton.AddHandler(MouseLeaveEvent, new MouseEventHandler(ToolsPanel_MouseEnter), true);
location.Items.Add(UIButton);
Buttons.Add(UIButton);
}
示例11: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.toolBar1 = ((System.Windows.Controls.ToolBar)(target));
return;
}
this._contentLoaded = true;
}
示例12: MeetTheDockers
public MeetTheDockers()
{
Title = "Meet the Dockers";
DockPanel dock = new DockPanel();
Content = dock;
// Create menu.
Menu menu = new Menu();
MenuItem item = new MenuItem();
item.Header = "Menu";
menu.Items.Add(item);
// Dock menu at top of panel.
DockPanel.SetDock(menu, Dock.Top);
dock.Children.Add(menu);
// Create tool bar.
ToolBar tool = new ToolBar();
tool.Header = "Toolbar";
// Dock tool bar at top of panel.
DockPanel.SetDock(tool, Dock.Top);
dock.Children.Add(tool);
// Create status bar.
StatusBar status = new StatusBar();
StatusBarItem statitem = new StatusBarItem();
statitem.Content = "Status";
status.Items.Add(statitem);
// Dock status bar at bottom of panel.
DockPanel.SetDock(status, Dock.Bottom);
dock.Children.Add(status);
// Create list box.
ListBox lstbox = new ListBox();
lstbox.Items.Add("List Box Item");
// Dock list box at left of panel.
DockPanel.SetDock(lstbox, Dock.Left);
dock.Children.Add(lstbox);
// Create text box.
TextBox txtbox = new TextBox();
txtbox.AcceptsReturn = true;
// Add text box to panel & give it input focus.
dock.Children.Add(txtbox);
txtbox.Focus();
}
示例13: AddEditToolBar
void AddEditToolBar(ToolBarTray tray, int band, int index)
{
// Create Toolbar.
ToolBar toolbar = new ToolBar();
toolbar.Band = band;
toolbar.BandIndex = index;
tray.ToolBars.Add(toolbar);
RoutedUICommand[] comm =
{
ApplicationCommands.Cut, ApplicationCommands.Copy,
ApplicationCommands.Paste, ApplicationCommands.Delete,
ApplicationCommands.Undo, ApplicationCommands.Redo
};
string[] strImages =
{
"CutHS.png", "CopyHS.png",
"PasteHS.png", "DeleteHS.png",
"Edit_UndoHS.png", "Edit_RedoHS.png"
};
for (int i = 0; i < 6; i++)
{
if (i == 4)
toolbar.Items.Add(new Separator());
Button btn = new Button();
btn.Command = comm[i];
toolbar.Items.Add(btn);
Image img = new Image();
img.Source = new BitmapImage(
new Uri("pack://application:,,/Images/" + strImages[i]));
img.Stretch = Stretch.None;
btn.Content = img;
ToolTip tip = new ToolTip();
tip.Content = comm[i].Text;
btn.ToolTip = tip;
}
CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste));
CommandBindings.Add(new CommandBinding(
ApplicationCommands.Delete, OnDelete, CanDelete));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo));
}
示例14: CraftTheToolbar
public CraftTheToolbar()
{
Title = "Craft the Toolbar";
RoutedUICommand[] comm = {
ApplicationCommands.New,
ApplicationCommands.Open,
ApplicationCommands.Save,
ApplicationCommands.Print,
ApplicationCommands.Cut,
ApplicationCommands.Copy,
ApplicationCommands.Paste,
ApplicationCommands.Delete
};
string[] strImages = {
"NewDocumentHS.png", "OpenHS.png", "SaveHS.png", "PrintHS.png",
"CutHS.png", "CopyHS.png", "PasteHS.png", "DeleteHS.png"
};
DockPanel dock = new DockPanel();
dock.LastChildFill = false;
Content = dock;
ToolBar toolbar = new ToolBar();
dock.Children.Add(toolbar);
DockPanel.SetDock(toolbar, Dock.Top);
for (int i = 0; i < 8; i++)
{
if (i == 4)
toolbar.Items.Add(new Separator());
Button btn = new Button();
btn.Command = comm[i];
toolbar.Items.Add(btn);
Image img = new Image();
string fileName = Path.Combine(Directory.GetCurrentDirectory(), strImages[i]);
img.Source = new BitmapImage(new Uri(fileName));
img.Stretch = Stretch.None;
btn.Content = img;
ToolTip tip = new ToolTip();
tip.Content = comm[i].Text;
btn.ToolTip = tip;
CommandBindings.Add(new CommandBinding(comm[i], ToolBarButtonOnClick));
}
}
示例15: AddParaToolBar
void AddParaToolBar(ToolBarTray tray, int band, int index)
{
ToolBar toolbar = new ToolBar();
toolbar.Band = band;
toolbar.BandIndex = index;
tray.ToolBars.Add(toolbar);
toolbar.Items.Add(btnAlignment[0] = CreateButton(TextAlignment.Left, "Align Left", 0, 4));
toolbar.Items.Add(btnAlignment[1] = CreateButton(TextAlignment.Center, "Center", 2, 2));
toolbar.Items.Add(btnAlignment[2] = CreateButton(TextAlignment.Right, "Align Right", 4, 0));
toolbar.Items.Add(btnAlignment[3] = CreateButton(TextAlignment.Justify, "Justify", 0, 0));
txtbox.SelectionChanged += TextBoxOnSelectionChanged2;
}