本文整理汇总了C#中System.Windows.Controls.Button.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetResourceReference方法的具体用法?C# Button.SetResourceReference怎么用?C# Button.SetResourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Button
的用法示例。
在下文中一共展示了Button.SetResourceReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageAirlineSubsidiaries
public PageAirlineSubsidiaries(Airline airline, StandardPage parent)
{
this.PageParent = parent;
this.Airline = airline;
InitializeComponent();
StackPanel panelSubsidiaries = new StackPanel();
panelSubsidiaries.Margin = new Thickness(0, 10, 50, 0);
TextBlock txtSubsidiariesHeader = new TextBlock();
txtSubsidiariesHeader.Uid = "1001";
txtSubsidiariesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtSubsidiariesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtSubsidiariesHeader.FontWeight = FontWeights.Bold;
txtSubsidiariesHeader.Text = Translator.GetInstance().GetString("PageAirlineSubsidiaries", txtSubsidiariesHeader.Uid);
panelSubsidiaries.Children.Add(txtSubsidiariesHeader);
lbSubsidiaryAirline = new ListBox();
lbSubsidiaryAirline.ItemTemplate = this.Resources["SubsidiaryItem"] as DataTemplate;
lbSubsidiaryAirline.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbSubsidiaryAirline.MaxHeight = GraphicsHelpers.GetContentHeight() - 100;
showSubsidiaries();
panelSubsidiaries.Children.Add(lbSubsidiaryAirline);
WrapPanel panelButtons = new WrapPanel();
panelButtons.Visibility = this.Airline.IsHuman && !(this.Airline is SubsidiaryAirline) && this.Airline.Money>100000 ? Visibility.Visible : Visibility.Collapsed;
panelButtons.Margin = new Thickness(0,5,0,0);
panelSubsidiaries.Children.Add(panelButtons);
Button btnCreate = new Button();
btnCreate.Uid = "200";
btnCreate.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnCreate.Height = Double.NaN;
btnCreate.Width = Double.NaN;
btnCreate.Content = Translator.GetInstance().GetString("PageAirlineSubsidiaries",btnCreate.Uid);
btnCreate.Click+=new RoutedEventHandler(btnCreate_Click);
btnCreate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelButtons.Children.Add(btnCreate);
if (this.Airline.IsHuman)
panelSubsidiaries.Children.Add(createTransferFundsPanel());
this.Content = panelSubsidiaries;
}
示例2: createButtonsPanel
//creates the buttons panel
private WrapPanel createButtonsPanel()
{
WrapPanel buttonsPanel = new WrapPanel();
buttonsPanel.Margin = new Thickness(0, 10, 0, 0);
Button btnOk = new Button();
btnOk.Uid = "100";
btnOk.SetResourceReference(StyleProperty, "StandardButtonStyle");
btnOk.Height = Double.NaN;
btnOk.Width = Double.NaN;
btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid);
btnOk.Click += new RoutedEventHandler(btnOk_Click);
btnOk.IsDefault = true;
buttonsPanel.Children.Add(btnOk);
Button btnCancel = new Button();
btnCancel.Uid = "101";
btnCancel.SetResourceReference(StyleProperty, "StandardButtonStyle");
btnCancel.Height = Double.NaN;
btnCancel.Margin = new Thickness(5, 0, 0, 0);
btnCancel.Width = Double.NaN;
btnCancel.IsCancel = true;
btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
btnCancel.Content = Translator.GetInstance().GetString("General", btnCancel.Uid);
buttonsPanel.Children.Add(btnCancel);
return buttonsPanel;
}
示例3: AddButton
/// <summary>
/// Creates a button.
/// </summary>
public static void AddButton(this ISmartTextOutput output, string text, RoutedEventHandler click)
{
output.AddUIElement(() => {
var button = new Button();
button.SetResourceReference(FrameworkElement.StyleProperty, "TextEditorButton");
button.Content = text;
button.Click += click;
return button;
});
}
示例4: loadCart
public void loadCart(){
LinkedList<VarCart> sc = UIMain.Instance.uicartedit.varCart;
this.stackCarts.Children.Clear();
Console.WriteLine("yoyo");
foreach (VarCart s in sc)
{
Button b = new Button();
b.Content = s.name;
b.Tag = s;
b.Foreground = Brushes.White;
b.SetResourceReference(BackgroundProperty, "BlackBtn");
b.Click += new RoutedEventHandler(VarCart_Click);
b.MouseRightButtonDown += new MouseButtonEventHandler(b_MouseRightButtonDown);
this.stackCarts.Children.Add(b);
}
}
示例5: engine_onChangeCart
void engine_onChangeCart(List<string> slides)
{
this.stack.Children.Clear();
foreach (String s in slides)
{
Button b = new Button();
b.Content = s;
b.Tag = s;
b.SetResourceReference(BackgroundProperty, "BlackBtn");
b.Foreground = Brushes.White;
b.Click+=new RoutedEventHandler(Slide_Click);
b.MouseRightButtonDown += new MouseButtonEventHandler(b_MouseRightButtonDown);
this.stack.Children.Add(b);
}
HighlightSlideOnair();
}
示例6: PageNewAirline
public PageNewAirline()
{
InitializeComponent();
StackPanel panelContent = new StackPanel();
panelContent.Margin = new Thickness(10, 0, 10, 0);
panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
Panel panelLogo = UICreator.CreateGameLogo();
panelLogo.Margin = new Thickness(0, 0, 0, 20);
panelContent.Children.Add(panelLogo);
TextBlock txtHeader = new TextBlock();
txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtHeader.FontWeight = FontWeights.Bold;
txtHeader.Text = "Airline Profile";
panelContent.Children.Add(txtHeader);
ListBox lbContent = new ListBox();
lbContent.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbContent.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
panelContent.Children.Add(lbContent);
txtAirlineName = new TextBox();
txtAirlineName.Background = Brushes.Transparent;
txtAirlineName.BorderBrush = Brushes.Black;
txtAirlineName.Width = 200;
txtAirlineName.TextChanged+=new TextChangedEventHandler(txtIATA_TextChanged);
lbContent.Items.Add(new QuickInfoValue("Airline Name", txtAirlineName));
txtIATA = new TextBox();
txtIATA.Background = Brushes.Transparent;
txtIATA.BorderBrush = Brushes.Black;
txtIATA.MaxLength = 2;
txtIATA.Width = 25;
txtIATA.TextChanged += new TextChangedEventHandler(txtIATA_TextChanged);
lbContent.Items.Add(new QuickInfoValue("IATA Code", txtIATA));
// chs, 2011-20-10 changed to enable loading of logo
WrapPanel panelAirlinerType = new WrapPanel();
RadioButton rbPassenger = new RadioButton();
rbPassenger.Content = "Passenger";
rbPassenger.GroupName = "AirlineFocus";
rbPassenger.IsChecked = true;
rbPassenger.Tag = Route.RouteType.Passenger;
rbPassenger.Checked += rbAirlineType_Checked;
rbPassenger.Margin = new Thickness(5, 0, 0, 0);
panelAirlinerType.Children.Add(rbPassenger);
RadioButton rbCargo = new RadioButton();
rbCargo.Content = "Cargo";
rbCargo.GroupName = "AirlineFocus";
rbCargo.Tag = Route.RouteType.Cargo;
rbCargo.Checked += rbAirlineType_Checked;
panelAirlinerType.Children.Add(rbCargo);
lbContent.Items.Add(new QuickInfoValue("Airline type", panelAirlinerType));
WrapPanel panelAirlineLogo = new WrapPanel();
imgLogo = new Image();
imgLogo.Source = new BitmapImage(new Uri(logoPath, UriKind.RelativeOrAbsolute));
imgLogo.Width = 32;
imgLogo.Margin = new Thickness(0, 0, 5, 0);
imgLogo.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
RenderOptions.SetBitmapScalingMode(imgLogo, BitmapScalingMode.HighQuality);
panelAirlineLogo.Children.Add(imgLogo);
Button btnLogo = new Button();
btnLogo.Content = "...";
btnLogo.Background = Brushes.Transparent;
btnLogo.Click += new RoutedEventHandler(btnLogo_Click);
btnLogo.Margin = new Thickness(5, 0, 0, 0);
panelAirlineLogo.Children.Add(btnLogo);
lbContent.Items.Add(new QuickInfoValue("Airline Logo", panelAirlineLogo));
cbColor = new ComboBox();
cbColor.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
cbColor.Width = 250;
cbColor.ItemTemplate = this.Resources["ColorItem"] as DataTemplate;
foreach (PropertyInfo c in typeof(Colors).GetProperties())
cbColor.Items.Add(c);
cbColor.SelectedIndex = 0;
lbContent.Items.Add(new QuickInfoValue("Airline Color", cbColor));
cbCountry = new ComboBox();
//.........这里部分代码省略.........
示例7: createButtonsPanel
//creates the buttons panel
private WrapPanel createButtonsPanel()
{
WrapPanel panelButtons = new WrapPanel();
panelButtons.Margin = new Thickness(0, 5, 0, 0);
Button btnOk = new Button();
btnOk.Uid = "100";
btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnOk.Height = Double.NaN;
btnOk.Width = Double.NaN;
btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid);
btnOk.Click += new RoutedEventHandler(btnOk_Click);
btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelButtons.Children.Add(btnOk);
Button btnCancel = new Button();
btnCancel.Uid = "101";
btnCancel.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnCancel.Height = Double.NaN;
btnCancel.Margin = new Thickness(5, 0, 0, 0);
btnCancel.Width = Double.NaN;
btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
btnCancel.Content = Translator.GetInstance().GetString("General", btnCancel.Uid);
btnCancel.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelButtons.Children.Add(btnCancel);
return panelButtons;
}
示例8: createButtonsPanel
//creates the buttons panel
private WrapPanel createButtonsPanel()
{
WrapPanel buttonsPanel = new WrapPanel();
buttonsPanel.Margin = new Thickness(0, 10, 0, 0);
Button btnOk = new Button();
btnOk.Uid = "100";
btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnOk.Height = Double.NaN;
btnOk.Width = Double.NaN;
btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid);
btnOk.Click += new RoutedEventHandler(btnOk_Click);
btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
buttonsPanel.Children.Add(btnOk);
Button btnCancel = new Button();
btnCancel.Uid = "101";
btnCancel.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnCancel.Height = Double.NaN;
btnCancel.Margin = new Thickness(5, 0, 0, 0);
btnCancel.Width = Double.NaN;
btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
btnCancel.Content = Translator.GetInstance().GetString("General", btnCancel.Uid);
btnCancel.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
buttonsPanel.Children.Add(btnCancel);
Button btnUndo = new Button();
btnUndo.Uid = "103";
btnUndo.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnUndo.Height = Double.NaN;
btnUndo.Width = Double.NaN;
btnUndo.Margin = new Thickness(5, 0, 0, 0);
btnUndo.Content = Translator.GetInstance().GetString("General", btnUndo.Uid);
btnUndo.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnUndo.Click += new RoutedEventHandler(btnUndo_Click);
buttonsPanel.Children.Add(btnUndo);
Button btnClear = new Button();
btnClear.Uid = "108";
btnClear.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnClear.Height = Double.NaN;
btnClear.Width = Double.NaN;
btnClear.Margin = new Thickness(5, 0, 0, 0);
btnClear.Content = Translator.GetInstance().GetString("General", btnClear.Uid);
btnClear.Click += new RoutedEventHandler(btnClear_Click);
btnClear.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
buttonsPanel.Children.Add(btnClear);
Button btnTransfer = new Button();
btnTransfer.Uid = "202";
btnTransfer.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnTransfer.Height = Double.NaN;
btnTransfer.Width = Double.NaN;
btnTransfer.Visibility = getTransferAirliners().Count > 0 && this.Airliner.Routes.Count == 0 ? Visibility.Visible : System.Windows.Visibility.Collapsed;
btnTransfer.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnTransfer.Content = Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", btnTransfer.Uid);
btnTransfer.Click += new RoutedEventHandler(btnTransfer_Click);
btnTransfer.Margin = new Thickness(5, 0, 0, 0);
buttonsPanel.Children.Add(btnTransfer);
btnAdvanced = new Button();
btnAdvanced.Uid = "201";
btnAdvanced.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnAdvanced.Height = Double.NaN;
btnAdvanced.Width = Double.NaN;
btnAdvanced.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnAdvanced.Content = Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", btnAdvanced.Uid);
btnAdvanced.Margin = new Thickness(5, 0, 0, 0);
btnAdvanced.Click += btnAdvanced_Click;
buttonsPanel.Children.Add(btnAdvanced);
btnRegular = new Button();
btnRegular.Uid = "203";
btnRegular.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnRegular.Height = Double.NaN;
btnRegular.Width = Double.NaN;
btnRegular.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnRegular.Content = Translator.GetInstance().GetString("PopUpAirlinerAutoRoutes", btnRegular.Uid);
btnRegular.Margin = new Thickness(5, 0, 0, 0);
btnRegular.Visibility = System.Windows.Visibility.Collapsed;
btnRegular.Click += btnRegular_Click;
buttonsPanel.Children.Add(btnRegular);
return buttonsPanel;
}
示例9: PopUpSelectOpponents
public PopUpSelectOpponents(Airline human, int opponents, int startyear, Region region, Continent continent)
{
this.Human = human;
this.Opponents = opponents;
this.StartYear = startyear;
InitializeComponent();
this.Uid = "1000";
this.Title = Translator.GetInstance().GetString("PopUpSelectOpponents", this.Uid);
this.Width = 500;
this.Height = 500;
this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
StackPanel panelMain = new StackPanel();
Grid grdMain = UICreator.CreateGrid(2);
panelMain.Children.Add(grdMain);
StackPanel panelSelectAirlines = new StackPanel();
panelSelectAirlines.Margin = new Thickness(5, 0, 5, 0);
TextBlock txtSelectedHeader = new TextBlock();
txtSelectedHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtSelectedHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
txtSelectedHeader.FontWeight = FontWeights.Bold;
txtSelectedHeader.Uid = "1001";
txtSelectedHeader.Text = string.Format(Translator.GetInstance().GetString("PopUpSelectOpponents", txtSelectedHeader.Uid),this.Opponents);
panelSelectAirlines.Children.Add(txtSelectedHeader);
lbSelectedAirlines = new ListBox();
lbSelectedAirlines.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbSelectedAirlines.SetResourceReference(ListBox.ItemTemplateProperty, "AirlineLogoItem");
lbSelectedAirlines.MaxHeight = 400;
lbSelectedAirlines.SelectionChanged += lbSelectedAirlines_SelectionChanged;
panelSelectAirlines.Children.Add(lbSelectedAirlines);
Grid.SetColumn(panelSelectAirlines, 0);
grdMain.Children.Add(panelSelectAirlines);
StackPanel panelOpponents = new StackPanel();
panelOpponents.Margin = new Thickness(5, 0, 5, 0);
TextBlock txtOpponentsHeader = new TextBlock();
txtOpponentsHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtOpponentsHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
txtOpponentsHeader.FontWeight = FontWeights.Bold;
txtOpponentsHeader.Uid = "1002";
txtOpponentsHeader.Text = Translator.GetInstance().GetString("PopUpSelectOpponents", txtOpponentsHeader.Uid);
panelOpponents.Children.Add(txtOpponentsHeader);
lbOpponentAirlines = new ListBox();
lbOpponentAirlines.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbOpponentAirlines.SetResourceReference(ListBox.ItemTemplateProperty, "AirlineLogoItem");
lbOpponentAirlines.MaxHeight = 400;
lbOpponentAirlines.SelectionChanged += lbOpponentAirlines_SelectionChanged;
panelOpponents.Children.Add(lbOpponentAirlines);
foreach (Airline airline in Airlines.GetAirlines(a => a.Profile.Founded <= startyear && a.Profile.Folded > startyear && a != this.Human && (a.Profile.Country.Region == region || (continent != null && (continent.Uid == "100" || continent.hasRegion(a.Profile.Country.Region))))))
lbOpponentAirlines.Items.Add(airline);
Grid.SetColumn(panelOpponents, 1);
grdMain.Children.Add(panelOpponents);
Button btnOk = new Button();
btnOk.Uid = "100";
btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnOk.Height = Double.NaN;
btnOk.Width = Double.NaN;
btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid);
btnOk.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnOk.Margin = new Thickness(5, 5, 0, 0);
btnOk.Click += btnOk_Click;
btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelMain.Children.Add(btnOk);
this.Content = panelMain;
}
示例10: createHumanControllingPanel
//creates the panel for the human controlling airline
private StackPanel createHumanControllingPanel()
{
StackPanel panelMain = new StackPanel();
panelMain.Margin = new Thickness(5, 5, 10, 0);
TextBlock txtHeader = new TextBlock();
txtHeader.Uid = "1020";
txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
txtHeader.TextAlignment = TextAlignment.Left;
txtHeader.FontWeight = FontWeights.Bold;
txtHeader.Text = Translator.GetInstance().GetString("PageAirline", txtHeader.Uid);
panelMain.Children.Add(txtHeader);
WrapPanel panelChangeControl = new WrapPanel();
panelMain.Children.Add(panelChangeControl);
cbControlling = new ComboBox();
cbControlling.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
cbControlling.SetResourceReference(ComboBox.ItemTemplateProperty, "AirlineLogoItem");
cbControlling.Width = 250;
cbControlling.Items.Add(GameObject.GetInstance().MainAirline);
foreach (Airline airline in GameObject.GetInstance().MainAirline.Subsidiaries)
cbControlling.Items.Add(airline);
cbControlling.SelectedItem = GameObject.GetInstance().HumanAirline;
panelChangeControl.Children.Add(cbControlling);
btnOk = new Button();
btnOk.Uid = "116";
btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnOk.Height = Double.NaN;
btnOk.Width = Double.NaN;
btnOk.Content = Translator.GetInstance().GetString("General", btnOk.Uid);
btnOk.IsEnabled = cbControlling.Items.Count > 1;
btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnOk.Margin = new Thickness(5, 0, 0, 0);
btnOk.Click += new RoutedEventHandler(btnOk_Click);
panelChangeControl.Children.Add(btnOk);
return panelMain;
}
示例11: createInflightServicesPanel
//creates the inflight services panel
private ScrollViewer createInflightServicesPanel()
{
this.Facilities = new Dictionary<AirlinerClass.ClassType, List<RouteFacility>>();
this.cbFacilities = new Dictionary<AirlinerClass.ClassType, List<ComboBox>>();
ScrollViewer scroller = new ScrollViewer();
scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
scroller.MaxHeight = GraphicsHelpers.GetContentHeight() - 100;
StackPanel panelServices = new StackPanel();
/*
TextBlock txtServicesHeader = new TextBlock();
txtServicesHeader.Uid = "1007";
txtServicesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtServicesHeader.FontWeight = FontWeights.Bold;
txtServicesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtServicesHeader.Text = Translator.GetInstance().GetString("PageAirlineWages", txtServicesHeader.Uid);
panelServices.Children.Add(txtServicesHeader);
*/
foreach (AirlinerClass.ClassType classType in Enum.GetValues(typeof(AirlinerClass.ClassType)))
{
this.cbFacilities.Add(classType, new List<ComboBox>());
TextBlock txtClassHeader = new TextBlock();
txtClassHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtClassHeader.FontWeight = FontWeights.Bold;
txtClassHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtClassHeader.Text = new TextUnderscoreConverter().Convert(classType).ToString();
txtClassHeader.Margin = new Thickness(0, 5, 0, 0);
panelServices.Children.Add(txtClassHeader);
ListBox lbServices = new ListBox();
lbServices.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbServices.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
panelServices.Children.Add(lbServices);
foreach (RouteFacility.FacilityType facilityType in Enum.GetValues(typeof(RouteFacility.FacilityType)))
{
if (GameObject.GetInstance().GameTime.Year >= (int)facilityType)
{
ComboBox cbFacility = new ComboBox();
cbFacility.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
cbFacility.Width = 200;
cbFacility.DisplayMemberPath = "Name";
cbFacility.SelectedValuePath = "Name";
cbFacility.Tag = classType;
cbFacility.SelectionChanged += new SelectionChangedEventHandler(cbFacility_SelectionChanged);
AirlineHelpers.GetRouteFacilities(GameObject.GetInstance().HumanAirline,facilityType).ForEach(f => cbFacility.Items.Add(f));
lbServices.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(facilityType).ToString(), cbFacility));
cbFacility.SelectedIndex = 0;
this.cbFacilities[classType].Add(cbFacility);
}
}
}
WrapPanel panelButtons = new WrapPanel();
panelButtons.Margin = new Thickness(0, 5, 0, 0);
panelServices.Children.Add(panelButtons);
Button btnSave = new Button();
btnSave.Uid = "113";
btnSave.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnSave.Height = Double.NaN;
btnSave.Width = Double.NaN;
btnSave.Content = Translator.GetInstance().GetString("General", btnSave.Uid);
btnSave.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnSave.Click += new RoutedEventHandler(btnSave_Click);
panelButtons.Children.Add(btnSave);
Button btnLoad = new Button();
btnLoad.Uid = "114";
btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnLoad.Height = Double.NaN;
btnLoad.Width = Double.NaN;
btnLoad.Content = Translator.GetInstance().GetString("General", btnLoad.Uid);
btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnLoad.Click += new RoutedEventHandler(btnLoad_Click);
panelButtons.Children.Add(btnLoad);
scroller.Content = panelServices;
return scroller;
}
示例12: createAdvertisementPanel
//creates the for the panel advertisement
private StackPanel createAdvertisementPanel()
{
cbAdvertisements = new Dictionary<AdvertisementType.AirlineAdvertisementType, ComboBox>();
StackPanel panelAdvertisement = new StackPanel();
TextBlock txtHeaderAdvertisement = new TextBlock();
txtHeaderAdvertisement.Uid = "1003";
txtHeaderAdvertisement.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtHeaderAdvertisement.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtHeaderAdvertisement.FontWeight = FontWeights.Bold;
txtHeaderAdvertisement.Text = Translator.GetInstance().GetString("PageAirlineFacilities", txtHeaderAdvertisement.Uid);
panelAdvertisement.Children.Add(txtHeaderAdvertisement);
lbAdvertisement = new ListBox();
lbAdvertisement.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbAdvertisement.MaxHeight = (GraphicsHelpers.GetContentHeight() - 100) / 3;
lbAdvertisement.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
panelAdvertisement.Children.Add(lbAdvertisement);
// chs, 2011-17-10 changed so it is only advertisement types which has been invented which are shown
foreach (AdvertisementType.AirlineAdvertisementType type in Enum.GetValues(typeof(AdvertisementType.AirlineAdvertisementType)))
{
if (GameObject.GetInstance().GameTime.Year >= (int)type)
lbAdvertisement.Items.Add(new QuickInfoValue(type.ToString(), createAdvertisementTypeItem(type)));
}
Button btnSave = new Button();
btnSave.Uid = "113";
btnSave.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnSave.Height = 16;
btnSave.Width = Double.NaN;
btnSave.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnSave.Margin = new Thickness(0, 5, 0, 0);
btnSave.Content = Translator.GetInstance().GetString("General", btnSave.Uid);
btnSave.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnSave.Click+=new RoutedEventHandler(btnSaveAdvertisement_Click);
btnSave.Visibility = this.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed;
panelAdvertisement.Children.Add(btnSave);
return panelAdvertisement;
}
示例13: PageFleetTimeslot
public PageFleetTimeslot(FleetAirliner airliner)
{
this.Airliner = airliner;
this.Day = GameObject.GetInstance().GameTime.DayOfWeek;
InitializeComponent();
StackPanel panelTimeSlot = new StackPanel();
panelTimeSlot.Margin = new Thickness(0, 10, 50, 0);
WrapPanel panelDayNavigator = new WrapPanel();
Button btnPrevious = new Button();
btnPrevious.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnPrevious.Height = 24;
btnPrevious.Width = 32;
btnPrevious.Content = "<";
btnPrevious.Margin = new Thickness(2, 0, 0, 0);
btnPrevious.Click += new RoutedEventHandler(btnPrevious_Click);
btnPrevious.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelDayNavigator.Children.Add(btnPrevious);
Button btnNext = new Button();
btnNext.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnNext.Height = 24;
btnNext.Margin = new Thickness(2, 0, 0, 0);
btnNext.Width = 32;
btnNext.Content = ">";
btnNext.Click += new RoutedEventHandler(btnNext_Click);
btnNext.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelDayNavigator.Children.Add(btnNext);
txtDay = new TextBlock();
txtDay.FontSize = 14;
txtDay.FontWeight = FontWeights.Bold;
txtDay.Margin = new Thickness(5, 0, 0, 0);
txtDay.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
panelDayNavigator.Children.Add(txtDay);
panelTimeSlot.Children.Add(panelDayNavigator);
lbTimeSlot = new ListBox();
lbTimeSlot.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
panelTimeSlot.Children.Add(lbTimeSlot);
ScrollViewer scroller = new ScrollViewer();
scroller.Height = GraphicsHelpers.GetContentHeight() - 100;
panelTimeSlot.Children.Add(scroller);
WrapPanel panelHours = new WrapPanel();
scroller.Content = panelHours;
ListBox lbHours = new ListBox();
lbHours.ItemTemplate = this.Resources["HourItem"] as DataTemplate;
lbHours.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbHours.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
panelHours.Children.Add(lbHours);
for (int i = 0; i < 24; i++)
lbHours.Items.Add(new TimeSpan(i, 0, 0));
Canvas cnvFlights = new Canvas();
panelHours.Children.Add(cnvFlights);
foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
{
var list = (from e in this.Airliner.Routes.SelectMany(r=>r.TimeTable.Entries.FindAll(te=>te.Airliner==this.Airliner)) select e);
foreach (RouteTimeTableEntry e in list)
{
TimeSpan flightTime = MathHelpers.GetFlightTime(e.TimeTable.Route.Destination1.Profile.Coordinates, e.TimeTable.Route.Destination2.Profile.Coordinates, this.Airliner.Airliner.Type);
ContentControl ccFlight = new ContentControl();
ccFlight.ContentTemplate = this.Resources["FlightItem"] as DataTemplate;
ccFlight.Content = new KeyValuePair<double, RouteTimeTableEntry>(flightTime.TotalMinutes, e);
int minutes = 15 * (e.Time.Minutes / 15);
Canvas.SetTop(ccFlight, 60 * e.Time.Hours + e.Time.Minutes);
Canvas.SetLeft(ccFlight, 100 * (int)day);
cnvFlights.Children.Add(ccFlight);
}
}
this.Content = panelTimeSlot;
showDayTimeSlot();
}
示例14: PageAirportGates
public PageAirportGates(Airport airport)
{
Stopwatch sw = new Stopwatch();
sw.Start();
this.Airport = airport;
InitializeComponent();
// chs, 2011-27-10 added for the possibility of purchasing a terminal
StackPanel panelGatesTerminals = new StackPanel();
panelGatesTerminals.Margin = new Thickness(0, 10, 50, 0);
panelGates = new StackPanel();
panelGatesTerminals.Children.Add(panelGates);
ScrollViewer svTerminals = new ScrollViewer();
svTerminals.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
svTerminals.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
svTerminals.MaxHeight = (GraphicsHelpers.GetContentHeight()-100) / 4;
StackPanel panelAirlineGates = new StackPanel();
panelAirlineGates.Margin = new Thickness(0, 0, 10, 0);
TextBlock txtGatesHeader = new TextBlock();
txtGatesHeader.Uid = "1007";
txtGatesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
txtGatesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
txtGatesHeader.FontWeight = FontWeights.Bold;
txtGatesHeader.Text = Translator.GetInstance().GetString("PageAirportGates", txtGatesHeader.Uid);
panelAirlineGates.Children.Add(txtGatesHeader);
lbAirlineContracts = new ListBox();
lbAirlineContracts.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
lbAirlineContracts.ItemTemplate = this.Resources["AirlineContractItem"] as DataTemplate;
lbAirlineContracts.MaxHeight = GraphicsHelpers.GetContentHeight() / 4;
panelAirlineGates.Children.Add(lbAirlineContracts);
//List<Airline> airlines = (from a in Airlines.GetAllAirlines() where this.Airport.Terminals.getNumberOfGates(a) > 0 orderby a.Profile.Name select a).ToList();
//foreach (Airline airline in airlines)
//lbAirlineContracts.Items.Add(new AirlineGates(airline, this.Airport.Terminals.getNumberOfGates(airline), this.Airport.Terminals.getNumberOfGates(airline) - this.Airport.Terminals.getNumberOfFreeGates(airline)));
var contracts = (from c in this.Airport.AirlineContracts orderby c.Airline.Profile.Name select c);
foreach (AirportContract contract in contracts)
lbAirlineContracts.Items.Add(contract);
svTerminals.Content = panelAirlineGates;
panelGatesTerminals.Children.Add(svTerminals);
WrapPanel panelButtons = new WrapPanel();
panelButtons.Margin = new Thickness(0, 5, 0, 0);
panelGatesTerminals.Children.Add(panelButtons);
Button btnTerminal = new Button();
btnTerminal.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnTerminal.Uid = "201";
btnTerminal.Height = Double.NaN;
btnTerminal.Width = Double.NaN;
btnTerminal.Content = Translator.GetInstance().GetString("PageAirportGates", btnTerminal.Uid);
btnTerminal.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnTerminal.Click += new RoutedEventHandler(btnTerminal_Click);
btnTerminal.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
//btnTerminal.Visibility = this.Airport.AirlineContract == null || this.Airport.AirlineContract.Airline.IsHuman ? Visibility.Visible : System.Windows.Visibility.Collapsed;
panelButtons.Children.Add(btnTerminal);
btnHub = new Button();
btnHub.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnHub.Uid = "204";
btnHub.Width = Double.NaN;
btnHub.Height = Double.NaN;
btnHub.Content = Translator.GetInstance().GetString("PageAirportGates", btnHub.Uid);
btnHub.Click += new RoutedEventHandler(btnHub_Click);
btnHub.Margin = new Thickness(5, 0, 0, 0);
btnHub.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelButtons.Children.Add(btnHub);
btnContract = new Button();
btnContract.Margin = new Thickness(5, 0, 0, 0);
btnContract.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnContract.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
btnContract.Width = Double.NaN;
btnContract.Height = Double.NaN;
btnContract.Uid = "206";
btnContract.Click += btnContract_Click;
btnContract.Content = Translator.GetInstance().GetString("PageAirportGates", btnContract.Uid);
panelButtons.Children.Add(btnContract);
btnContract.ToolTip = UICreator.CreateToolTip("1017");
Airport allocateToAirport = Airports.GetAirports(a => a.Profile.Town == airport.Profile.Town && airport != a && a.Profile.Period.From.AddDays(30) > GameObject.GetInstance().GameTime).FirstOrDefault();
Button btnReallocate = new Button();
btnReallocate.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnReallocate.Uid = "205";
btnReallocate.Width = Double.NaN;
//.........这里部分代码省略.........
示例15: createButtonsPanel
//creates the buttons menu
private WrapPanel createButtonsPanel()
{
WrapPanel panelButtons = new WrapPanel();
panelButtons.Margin = new Thickness(0, 5, 0, 0);
Button btnOk = new Button();
btnOk.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnOk.Height = 16;
btnOk.Width = Double.NaN;
btnOk.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnOk.Click += new RoutedEventHandler(btnOk_Click);
btnOk.Content = "OK";
btnOk.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelButtons.Children.Add(btnOk);
Button btnCancel = new Button();
btnCancel.SetResourceReference(Button.StyleProperty, "RoundedButton");
btnCancel.Height = 16;
btnCancel.Width = Double.NaN;
btnCancel.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
btnCancel.Margin = new Thickness(5, 0, 0, 0);
btnCancel.Visibility = System.Windows.Visibility.Collapsed;
btnCancel.Content = "Cancel";
btnCancel.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
panelButtons.Children.Add(btnCancel);
return panelButtons;
}