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() }); }
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; }
//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; }
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(); btnEditCargo.Margin = new Thickness(5, 0, 0, 0); btnEditCargo.Background = Brushes.Transparent; btnEditCargo.Click += new RoutedEventHandler(btnEditCargo_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); btnEditCargo.Content = imgEdit; panelCargo.Children.Add(btnEditCargo); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute","1015"),panelCargo)); } foreach (StopoverRoute stopover in this.Route.Stopovers) { foreach (Route leg in stopover.Legs) { lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1005"), UICreator.CreateTextBlock(string.Format("{0}-{1}", new AirportCodeConverter().Convert(leg.Destination1), new AirportCodeConverter().Convert(leg.Destination2))))); if (this.Route.Type == Route.RouteType.Passenger || this.Route.Type == Route.RouteType.Mixed) { this.Classes.Add(leg, new Dictionary<AirlinerClass.ClassType, RouteAirlinerClass>()); foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType))) { RouteAirlinerClass rClass = ((PassengerRoute)leg).getRouteAirlinerClass(type); this.Classes[leg].Add(type, rClass); WrapPanel panelClassButtons = new WrapPanel(); Button btnEdit = new Button(); btnEdit.Background = Brushes.Transparent; btnEdit.Tag = new KeyValuePair<Route, AirlinerClass.ClassType>(leg, 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; btnEdit.Visibility = this.Route.HasAirliner && (this.Route.getCurrentAirliner() != null && this.Route.getCurrentAirliner().Status != FleetAirliner.AirlinerStatus.Stopped) ? 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).ToString(), panelClassButtons)); } } } } int numberOfInboundFlights = this.Route.TimeTable.Entries.Count(e => e.DepartureAirport == this.Route.Destination2); int numberOfOutboundFlights = this.Route.TimeTable.Entries.Count(e => e.DepartureAirport == this.Route.Destination1); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1006"), UICreator.CreateTextBlock(string.Format("{0} / {1}", numberOfOutboundFlights, numberOfInboundFlights)))); WrapPanel buttonsPanel = new WrapPanel(); buttonsPanel.Margin = new Thickness(0, 5, 0, 0); this.Children.Add(buttonsPanel); buttonsPanel.Visibility = this.Route.HasAirliner && (this.Route.getCurrentAirliner() != null && this.Route.getCurrentAirliner().Status != FleetAirliner.AirlinerStatus.Stopped) ? Visibility.Collapsed : System.Windows.Visibility.Visible; Button btnOk = new Button(); btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnOk.Height = Double.NaN; btnOk.Width = Double.NaN; btnOk.Uid = "100"; btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid); btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnOk.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnOk.Click += new RoutedEventHandler(btnOk_Click); buttonsPanel.Children.Add(btnOk); Button btnLoad = new Button(); btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoad.Height = Double.NaN; btnLoad.Width = Double.NaN; btnLoad.Uid = "115"; btnLoad.Content = Translator.GetInstance().GetString("General", btnLoad.Uid); btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoad.Click += new RoutedEventHandler(btnLoad_Click); btnLoad.Margin = new Thickness(5, 0, 0, 0); btnLoad.Visibility = this.Route.Type == Route.RouteType.Cargo ? Visibility.Collapsed : System.Windows.Visibility.Visible; buttonsPanel.Children.Add(btnLoad); Button btnDelete = new Button(); btnDelete.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnDelete.Height = Double.NaN; btnDelete.Width = Double.NaN; btnDelete.Uid = "200"; btnDelete.Content = Translator.GetInstance().GetString("PanelRoute", btnDelete.Uid); btnDelete.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnDelete.Margin = new System.Windows.Thickness(5, 0, 0, 0); btnDelete.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; btnDelete.Click += new RoutedEventHandler(btnDelete_Click); buttonsPanel.Children.Add(btnDelete); //if (this.Route.HasStopovers) { this.Children.Add(createStopoverStatisticsPanel()); } //else { // this.Children.Add(createRouteFinancesPanel()); } showRouteFinances(); }
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); }
//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; imgInfo.ToolTip = brdToolTip; panelClassButtons.Children.Add(imgInfo); lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type, null, null, null).ToString(), panelClassButtons)); } } if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Cargo) { 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(); btnEditCargo.Margin = new Thickness(5, 0, 0, 0); btnEditCargo.Background = Brushes.Transparent; btnEditCargo.Click += new RoutedEventHandler(btnEditCargo_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); btnEditCargo.Content = imgEdit; panelCargo.Children.Add(btnEditCargo); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1007"), panelCargo)); } txtInvalidRoute = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PanelNewRoute", "1001")); txtInvalidRoute.Foreground = Brushes.DarkRed; txtInvalidRoute.Visibility = System.Windows.Visibility.Collapsed; panelRouteInfo.Children.Add(txtInvalidRoute); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelRouteInfo.Children.Add(panelButtons); btnSave = new Button(); btnSave.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnSave.Height = Double.NaN; btnSave.Width = Double.NaN; btnSave.Content = Translator.GetInstance().GetString("General", "113"); btnSave.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnSave.Click += new RoutedEventHandler(btnSave_Click); btnSave.IsEnabled = false; panelButtons.Children.Add(btnSave); btnLoad = new Button(); btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoad.Height = Double.NaN; btnLoad.Width = Double.NaN; btnLoad.Content = Translator.GetInstance().GetString("General", "115"); btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoad.IsEnabled = false; btnLoad.Click += new RoutedEventHandler(btnLoad_Click); btnLoad.Margin = new Thickness(5, 0, 0, 0); btnLoad.Visibility = this.RouteType == Route.RouteType.Cargo ? Visibility.Collapsed : Visibility.Visible; panelButtons.Children.Add(btnLoad); }
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; }
//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; }
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; } } } } }
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; } }
//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; }