本文整理汇总了C#中System.Windows.Controls.Border.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# Border.SetResourceReference方法的具体用法?C# Border.SetResourceReference怎么用?C# Border.SetResourceReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Border
的用法示例。
在下文中一共展示了Border.SetResourceReference方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopupButton
public PopupButton()
{
var content = new ContentPresenter();
content.SetBinding(ContentPresenter.ContentProperty, new Binding("PopupContent") { Source = this });
var border = new Border()
{
CornerRadius = new CornerRadius(5),
BorderThickness = new Thickness(1),
Child = content
};
border.SetResourceReference(Border.BackgroundProperty, "BaseWindowBackgroundBrush");
border.SetResourceReference(Border.BorderBrushProperty, "WindowBorderBrush");
_popup = new Popup()
{
AllowsTransparency = true,
StaysOpen = false,
Placement = PlacementMode.Bottom,
PlacementTarget = this,
DataContext = this,
Child = border,
};
_popup.SetBinding(Popup.IsOpenProperty, "IsChecked");
_popup.SetBinding(Popup.WidthProperty, "Width");
SetBinding(PopupButton.IsHitTestVisibleProperty, new Binding("IsOpen") { Source = _popup, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter() });
}
示例2: ThemedWindow
public ThemedWindow()
{
this.ShouldBeThemed();
WindowStyle = WindowStyle.None;
ResizeMode = ResizeMode.CanResizeWithGrip;
Background = Brushes.Transparent;
AllowsTransparency = true;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
ShowInTaskbar = false;
Grid host = new Grid();
//Header
host.RowDefinitions.Add(new RowDefinition
{
Height = GridLength.Auto
});
//Body
host.RowDefinitions.Add(new RowDefinition());
FrameworkElement header = BuildHeaderArea();
header.SetValue(Grid.RowProperty, 0);
host.Children.Add(header);
ContentPresenter contentPresenter = new ContentPresenter();
contentPresenter.SetValue(Grid.RowProperty, 1);
contentPresenter.SetBinding(ContentPresenter.ContentProperty, new Binding
{
Mode = BindingMode.OneWay,
RelativeSource = new RelativeSource
{
Mode = RelativeSourceMode.FindAncestor,
AncestorType = typeof(ThemedWindow)
},
Path = new PropertyPath("Content")
});
contentPresenter.Resources = Resources;
host.Children.Add(contentPresenter);
host.SetResourceReference(BackgroundProperty, EnvironmentColors.ToolWindowBackgroundBrushKey);
Border hostContainer = new Border
{
Child = host,
//Margin = new Thickness(1, 1, 5, 5),
BorderThickness = new Thickness(1)
};
hostContainer.SetResourceReference(BorderBrushProperty, EnvironmentColors.MainWindowActiveDefaultBorderBrushKey);
//hostContainer.Effect = new DropShadowEffect
//{
// Direction = -75,
// ShadowDepth = 2,
// BlurRadius = 2,
// Color = Colors.Azure
//};
base.Content = hostContainer;
}
示例3: createPin
//creates the pin at a position with airport
private UIElement createPin(Point position, Airport airport)
{
Ellipse imgPin = new Ellipse();
imgPin.Tag = airport;
imgPin.Fill = new SolidColorBrush(getSizeColor(airport.Profile.Size));
imgPin.Height = 8;
imgPin.Width = imgPin.Height;
imgPin.Stroke = Brushes.Black;
imgPin.StrokeThickness = 1;
imgPin.MouseDown += new MouseButtonEventHandler(imgPin_MouseDown);
Border brdToolTip = new Border();
brdToolTip.Margin = new Thickness(-4, 0, -4, -3);
brdToolTip.Padding = new Thickness(5);
brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2");
ContentControl lblAirport = new ContentControl();
lblAirport.SetResourceReference(ContentControl.ContentTemplateProperty, "AirportCountryItemNormal");
lblAirport.Content = airport;
brdToolTip.Child = lblAirport;
imgPin.ToolTip = brdToolTip;
Canvas.SetTop(imgPin, position.Y - imgPin.Height + 5);
Canvas.SetLeft(imgPin, position.X - imgPin.Height / 2);
return imgPin;
}
示例4: PanelRoute
public PanelRoute(PageRoutes parent, Route route)
{
this.Classes = new Dictionary<Route, Dictionary<AirlinerClass.ClassType, RouteAirlinerClass>>();
this.ParentPage = parent;
this.Route = route;
this.Margin = new Thickness(0, 0, 50, 0);
TextBlock txtHeader = new TextBlock();
txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtHeader.FontWeight = FontWeights.Bold;
txtHeader.Uid = "1000";
txtHeader.Text = Translator.GetInstance().GetString("PanelRoute", txtHeader.Uid);
this.Children.Add(txtHeader);
ListBox lbRouteInfo = new ListBox();
lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
this.Children.Add(lbRouteInfo);
double distance = MathHelpers.GetDistance(this.Route.Destination1.Profile.Coordinates, this.Route.Destination2.Profile.Coordinates);
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1016"),UICreator.CreateTextBlock(this.Route.Type.ToString())));
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1001"), UICreator.CreateTextBlock(this.Route.Destination1.Profile.Name)));
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1002"), UICreator.CreateTextBlock(this.Route.Destination2.Profile.Name)));
if (this.Route.HasStopovers)
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1003"), UICreator.CreateTextBlock(string.Join(", ", from s in this.Route.Stopovers select new AirportCodeConverter().Convert(s.Stopover).ToString()))));
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1004"), UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(distance), new StringToLanguageConverter().Convert("km.")))));
if (this.Route.Type == Route.RouteType.Passenger || this.Route.Type == Route.RouteType.Mixed)
{
this.Classes.Add(route, new Dictionary<AirlinerClass.ClassType, RouteAirlinerClass>());
foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType)))
{
RouteAirlinerClass rClass = ((PassengerRoute)this.Route).getRouteAirlinerClass(type);
this.Classes[route].Add(type, rClass);
WrapPanel panelClassButtons = new WrapPanel();
Button btnEdit = new Button();
btnEdit.Background = Brushes.Transparent;
btnEdit.Tag = new KeyValuePair<Route, AirlinerClass.ClassType>(this.Route, type);
btnEdit.Click += new RoutedEventHandler(btnEdit_Click);
Image imgEdit = new Image();
imgEdit.Width = 16;
imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute));
RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality);
btnEdit.Content = imgEdit;
Boolean inRoute = route.getAirliners().Exists(a => a.Status != FleetAirliner.AirlinerStatus.Stopped);
//btnEdit.Visibility = this.Route.HasAirliner && (this.Route.getCurrentAirliner() != null && this.Route.getCurrentAirliner().Status != FleetAirliner.AirlinerStatus.Stopped) ? Visibility.Collapsed : System.Windows.Visibility.Visible;
btnEdit.Visibility = inRoute ? Visibility.Collapsed : System.Windows.Visibility.Visible;
panelClassButtons.Children.Add(btnEdit);
Image imgInfo = new Image();
imgInfo.Width = 16;
imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute));
imgInfo.Margin = new Thickness(5, 0, 0, 0);
imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality);
Border brdToolTip = new Border();
brdToolTip.Margin = new Thickness(-4, 0, -4, -3);
brdToolTip.Padding = new Thickness(5);
brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2");
ContentControl lblClass = new ContentControl();
lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem");
lblClass.Content = rClass;
brdToolTip.Child = lblClass;
imgInfo.ToolTip = brdToolTip;
panelClassButtons.Children.Add(imgInfo);
lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type, null, null, null).ToString(), panelClassButtons));
}
}
if (this.Route.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Mixed || this.Route.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Cargo)
{
this.CargoPrice = ((CargoRoute)this.Route).PricePerUnit;
WrapPanel panelCargo = new WrapPanel();
txtCargo = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.CargoPrice).ToString());
txtCargo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
panelCargo.Children.Add(txtCargo);
Button btnEditCargo = new Button();
//.........这里部分代码省略.........
示例5: AddUITabShowList
private void AddUITabShowList(TabItem tabItem)
{
if (_TabContent == null)
return;
Border border = new Border();
border.Name = tabItem.DisplayName;
border.SetResourceReference(Border.StyleProperty, "TabItemBorderWhite");
TextBlock textBlock = new TextBlock();
textBlock.Text = tabItem.DisplayName;
textBlock.SetResourceReference(TextBlock.StyleProperty, "TabItemWhite");
border.Child = textBlock;
//设置显示事件
if (tabItem.PopType == TabPopType.POP_CLICK)
{//点击显示,选择列表show,失去焦点hide
border.MouseUp -= ShowTabContent;
border.MouseUp += ShowTabContent;
_TabContent.LostFocus -= HideTabContent;
_TabContent.LostFocus += HideTabContent;
}
else if (tabItem.PopType == TabPopType.POP_MOUSE_OVER)
{
border.MouseEnter -= ShowTabContent;
border.MouseEnter += ShowTabContent;
_TabContent.MouseLeave -= HideTabContent;
_TabContent.MouseLeave += HideTabContent;
}
_TabList.Items.Add(border);
}
示例6: createRoutePanel
//creates the panel for a new route
private void createRoutePanel()
{
panelRouteInfo.Children.Clear();
ListBox lbRouteInfo = new ListBox();
lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
panelRouteInfo.Children.Add(lbRouteInfo);
WrapPanel panelDestination1 = new WrapPanel();
cbDestination1 = createDestinationComboBox();
panelDestination1.Children.Add(cbDestination1);
txtDestination1Gates = new TextBlock();
txtDestination1Gates.Margin = new Thickness(5, 0, 0, 0);
txtDestination1Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
panelDestination1.Children.Add(txtDestination1Gates);
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "202"), panelDestination1));
WrapPanel panelDestination2 = new WrapPanel();
cbDestination2 = createDestinationComboBox();
panelDestination2.Children.Add(cbDestination2);
txtDestination2Gates = new TextBlock();
txtDestination2Gates.Margin = new Thickness(5, 0, 0, 0);
txtDestination2Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
panelDestination2.Children.Add(txtDestination2Gates);
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "203"), panelDestination2));
ucStopover1 = new ucStopover();
ucStopover1.ValueChanged += ucStopover_OnValueChanged;
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover1));
ucStopover2 = new ucStopover();
ucStopover2.ValueChanged += ucStopover_OnValueChanged;
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover2));
txtRoute = UICreator.CreateTextBlock("");
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1004"), txtRoute));
txtDistance = UICreator.CreateTextBlock("-");
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "204"), txtDistance));
lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "205"), UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(this.MaxDistance), new StringToLanguageConverter().Convert("km.")))));
if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Passenger)
{
this.Classes.Clear();
foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType)))
{
RouteAirlinerClass rClass = new RouteAirlinerClass(type, RouteAirlinerClass.SeatingType.Reserved_Seating, 1);
foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof(RouteFacility.FacilityType)))
{
if (GameObject.GetInstance().GameTime.Year >= (int)ftype)
rClass.addFacility(RouteFacilities.GetBasicFacility(ftype));
}
this.Classes.Add(type, rClass);
WrapPanel panelClassButtons = new WrapPanel();
Button btnEdit = new Button();
btnEdit.Background = Brushes.Transparent;
btnEdit.Tag = type;
btnEdit.Click += new RoutedEventHandler(btnEdit_Click);
Image imgEdit = new Image();
imgEdit.Width = 16;
imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute));
RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality);
btnEdit.Content = imgEdit;
panelClassButtons.Children.Add(btnEdit);
Image imgInfo = new Image();
imgInfo.Width = 16;
imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute));
imgInfo.Margin = new Thickness(5, 0, 0, 0);
imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality);
Border brdToolTip = new Border();
brdToolTip.Margin = new Thickness(-4, 0, -4, -3);
brdToolTip.Padding = new Thickness(5);
brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2");
ContentControl lblClass = new ContentControl();
lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem");
lblClass.Content = rClass;
brdToolTip.Child = lblClass;
//.........这里部分代码省略.........
示例7: CreateUIElement
UIElement CreateUIElement(string s) {
var border = new Border {
Child = new TextBlock {
Text = s,
Padding = new Thickness(1),
},
BorderThickness = new Thickness(1),
};
border.SetResourceReference(Control.BackgroundProperty, "ToolTipBackground");
border.SetResourceReference(Control.ForegroundProperty, "ToolTipForeground");
border.SetResourceReference(Border.BorderBrushProperty, "ToolTipBorderBrush");
return border;
}
示例8: createRoutesInfo
//creates the routes details
private StackPanel createRoutesInfo()
{
StackPanel panelRoutesInfo = new StackPanel();
TextBlock txtHeader = new TextBlock();
txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtHeader.FontWeight = FontWeights.Bold;
txtHeader.Text = "Routes Information";
panelRoutesInfo.Children.Add(txtHeader);
ScrollViewer svRoutes = new ScrollViewer();
svRoutes.MaxHeight = GraphicsHelpers.GetContentHeight()/2;
svRoutes.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
svRoutes.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
panelRoutesInfo.Children.Add(svRoutes);
StackPanel panelRoutes = new StackPanel();
svRoutes.Content = panelRoutes;
foreach (Route route in this.Airliner.Routes)
{
ListBox lbRouteInfo = new ListBox();
lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
lbRouteInfo.Margin = new Thickness(0, 0, 0, 5);
panelRoutes.Children.Add(lbRouteInfo);
double distance = MathHelpers.GetDistance(route.Destination1.Profile.Coordinates, route.Destination2.Profile.Coordinates);
lbRouteInfo.Items.Add(new QuickInfoValue("Route", UICreator.CreateTextBlock(string.Format("{0} <-> {1}",route.Destination1.Profile.Name,route.Destination2.Profile.Name))));
// chs, 2011-10-10 added missing conversion
lbRouteInfo.Items.Add(new QuickInfoValue("Distance", UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(distance), new StringToLanguageConverter().Convert("km.")))));
if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed)
{
foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
{
RouteAirlinerClass rClass = ((PassengerRoute)route).getRouteAirlinerClass(aClass.Type);
Image imgInfo = new Image();
imgInfo.Width = 16;
imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute));
imgInfo.Margin = new Thickness(5, 0, 0, 0);
RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality);
Border brdToolTip = new Border();
brdToolTip.Margin = new Thickness(-4, 0, -4, -3);
brdToolTip.Padding = new Thickness(5);
brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2");
ContentControl lblClass = new ContentControl();
lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem");
lblClass.Content = rClass;
brdToolTip.Child = lblClass;
imgInfo.ToolTip = brdToolTip;
lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(aClass.Type, null, null, null).ToString(), imgInfo));
}
}
}
WrapPanel buttonsPanel = new WrapPanel();
buttonsPanel.Margin = new Thickness(0, 5, 0, 0);
Button btnTimeTable = new Button();
btnTimeTable.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnTimeTable.Height = Double.NaN;
btnTimeTable.Width = Double.NaN;
btnTimeTable.Content = "Timetable";
btnTimeTable.Visibility = Visibility.Visible;// Visibility.Collapsed;//this.Airliner.Airliner.Airline.IsHuman ? Visibility.Collapsed : Visibility.Visible;
btnTimeTable.Click += new RoutedEventHandler(btnTimeTable_Click);
btnTimeTable.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnTimeTable.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
buttonsPanel.Children.Add(btnTimeTable);
Button btnMap = new Button();
btnMap.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnMap.Width = Double.NaN;
btnMap.Height = Double.NaN;
btnMap.Content = "Routes map";
btnMap.Margin = new Thickness(2, 0, 0, 0);
btnMap.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnMap.Click += new RoutedEventHandler(btnMap_Click);
buttonsPanel.Children.Add(btnMap);
panelRoutesInfo.Children.Add(buttonsPanel);
return panelRoutesInfo;
}
示例9: HoverAtPoint
private void HoverAtPoint(Point point)
{
if (_mouseHoverTimer != null && _mouseHoverTimer.IsEnabled && _margin.Enabled)
{
ITextViewLine textViewLineContainingYCoordinate = _textViewHost.TextView.TextViewLines.GetTextViewLineContainingYCoordinate(point.Y + _textViewHost.TextView.ViewportTop);
if (textViewLineContainingYCoordinate != this._lastHoverPosition)
{
this._lastHoverPosition = textViewLineContainingYCoordinate;
if (textViewLineContainingYCoordinate != null)
{
string str = null;
foreach (InheritanceTag tag in GetInheritanceGlyphTagsStartingOnLine(textViewLineContainingYCoordinate))
{
if (!string.IsNullOrEmpty(tag.ToolTip))
str = tag.ToolTip;
}
if (!string.IsNullOrEmpty(str))
{
this._popup.Child = null;
TextBlock block = new TextBlock
{
Text = str,
Name = "InheritanceGlyphToolTip"
};
Border border = new Border
{
Padding = new Thickness(1.0),
BorderThickness = new Thickness(1.0),
Child = block
};
block.SetResourceReference(TextBlock.ForegroundProperty, VsBrushes.ScreenTipTextKey);
border.SetResourceReference(Border.BorderBrushProperty, VsBrushes.ScreenTipBorderKey);
border.SetResourceReference(Border.BackgroundProperty, VsBrushes.ScreenTipBackgroundKey);
_popup.Child = border;
_popup.Placement = PlacementMode.Relative;
_popup.PlacementTarget = _margin.VisualElement;
_popup.HorizontalOffset = 0.0;
_popup.VerticalOffset = textViewLineContainingYCoordinate.Bottom - _textViewHost.TextView.ViewportTop;
_popup.IsOpen = true;
_popup.Visibility = Visibility.Visible;
_currentlyHoveringLine = textViewLineContainingYCoordinate;
}
}
}
}
}
示例10: ShowToolTip
private void ShowToolTip(object sender, EventArgs e)
{
if (_mouseHoverTimer == null || _textViewHost.IsClosed || !_mouseHoverTimer.IsEnabled || !_margin.Enabled)
{
return;
}
var point = Mouse.GetPosition(_margin.VisualElement);
var textViewLine = _textViewHost.TextView.TextViewLines.GetTextViewLineContainingYCoordinate(point.Y + _textViewHost.TextView.ViewportTop);
if (textViewLine == _lastHoverPosition)
{
return;
}
_lastHoverPosition = textViewLine;
if (_lastHoverPosition == null)
{
return;
}
string toolTip = null;
foreach (var tag in GetTagsForLine(textViewLine))
{
if (!string.IsNullOrEmpty(tag.ToolTip))
{
toolTip = tag.ToolTip;
}
}
if (!string.IsNullOrEmpty(toolTip))
{
var block = new TextBlock
{
Text = toolTip,
Name = "MarkerToolTip"
};
block.SetResourceReference(TextBlock.ForegroundProperty, VsBrushes.ScreenTipTextKey);
var border = new Border
{
Padding = new Thickness(1.0),
BorderThickness = new Thickness(1.0),
Child = block
};
border.SetResourceReference(Border.BorderBrushProperty, VsBrushes.ScreenTipBorderKey);
border.SetResourceReference(Border.BackgroundProperty, VsBrushes.ScreenTipBackgroundKey);
_popup.Child = border;
_popup.Placement = PlacementMode.Relative;
_popup.PlacementTarget = _margin.VisualElement;
_popup.HorizontalOffset = 0.0;
_popup.VerticalOffset = textViewLine.Bottom - _textViewHost.TextView.ViewportTop;
_popup.IsOpen = true;
_popup.Visibility = Visibility.Visible;
_currentlyHoveringLine = textViewLine;
}
}
示例11: createToolTip
//creates the tool tip for an entry
private Border createToolTip(KeyValuePair<TimeSpan, KeyValuePair<int,int>> value)
{
double maxFlightsPerSlot = 10 * this.Airport.Runways.Count;
double slotValue = Convert.ToDouble(value.Value.Value + value.Value.Key) / maxFlightsPerSlot;
Border brdToolTip = new Border();
brdToolTip.Margin = new Thickness(-4, 0, -4, -3);
brdToolTip.Padding = new Thickness(5);
brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2");
StackPanel panelToolTip = new StackPanel();
TextBlock txtTime = UICreator.CreateTextBlock(new TimeSpanConverter().Convert(value.Key).ToString());
txtTime.FontWeight = FontWeights.Bold;
txtTime.TextDecorations = TextDecorations.Underline;
panelToolTip.Children.Add(txtTime);
panelToolTip.Children.Add(UICreator.CreateTextBlock(string.Format("Departures: {0}",value.Value.Key)));
panelToolTip.Children.Add(UICreator.CreateTextBlock(string.Format("Arrivals: {0}", value.Value.Value)));
panelToolTip.Children.Add(UICreator.CreateTextBlock(string.Format("Percent of capacity: {0:P}",slotValue)));
brdToolTip.Child = panelToolTip;
return brdToolTip;
}