public PageAirlineData(StartDataObject startData)
        {
            this.AllTimeZones = TimeZones.GetTimeZones();
            this.AllAirports  = new ObservableCollection <Airport>();
            this.StartData    = startData;

            InitializeComponent();

            var airlines = Airlines.GetAirlines(airline => (airline.Profile.Country.Region == this.StartData.Region || (this.StartData.Region.Uid == "100" && this.StartData.Continent.Uid == "100") || (this.StartData.Region.Uid == "100" && this.StartData.Continent.hasRegion(airline.Profile.Country.Region))) && airline.Profile.Founded <= this.StartData.Year && airline.Profile.Folded > this.StartData.Year).OrderBy(a => a.Profile.Name).ToList();

            cbAirline.ItemsSource = airlines;
        }
Beispiel #2
0
        public void GenerateUpdateScript()
        {
            string sql       = string.Empty;
            string sqlFormat =
                "UPDATE [<dbUser,varchar,dbo>].[subtext_Config] SET TimeZoneId = '{0}' WHERE TimeZone = {1}" +
                Environment.NewLine + "GO" + Environment.NewLine;

            foreach (TimeZoneInfo timezone in TimeZones.GetTimeZones())
            {
                sql += String.Format(sqlFormat, timezone.Id, timezone.Id.GetHashCode());
            }
            Console.Write(sql);
        }
Beispiel #3
0
        public void CanGetTimeZones()
        {
            // arrange, act
            ReadOnlyCollection <TimeZoneInfo> timeZones = TimeZones.GetTimeZones();

            foreach (TimeZoneInfo timeZone in timeZones)
            {
                Console.WriteLine(timeZone.Id.GetHashCode() + "\t" + timeZone.StandardName);
            }

            // assert
            Assert.Greater(timeZones.Count, 10);
        }
        public void FromUtc_ConvertsSpecifiedLocalTime_ToBlogTimeZoneFromUtc()
        {
            // arrange
            var          time            = new DateTime(2009, 08, 15, 18, 18, 0, DateTimeKind.Local);
            TimeZoneInfo blogTimeZone    = TimeZones.GetTimeZones().GetById("Fiji Standard Time");
            var          timeZoneWrapper = new TimeZoneWrapper(blogTimeZone, TimeZoneInfo.Local, () => DateTime.UtcNow);

            // act
            var fijiDateTime = timeZoneWrapper.FromUtc(time); // To Fiji Time Zone

            // assert
            DateTime expected = DateTime.ParseExact("2009/08/16 06:18 AM", "yyyy/MM/dd hh:mm tt",
                                                    CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);

            Assert.AreEqual(expected, fijiDateTime);
        }
        public void ToUtc_ConvertsSpecifiedTimeInTimeZone_ToUtcTime()
        {
            // arrange
            TimeZoneInfo blogTimeZone        = TimeZones.GetTimeZones().GetById("Tokyo Standard Time");
            var          timeZoneWrapper     = new TimeZoneWrapper(blogTimeZone, TimeZoneInfo.Local, () => DateTime.UtcNow);
            DateTime     expectedUtcDateTime = DateTime.ParseExact("2009/08/15 06:18 PM", "yyyy/MM/dd hh:mm tt",
                                                                   CultureInfo.InvariantCulture,
                                                                   DateTimeStyles.AdjustToUniversal);
            DateTime tokyoDateTime = TimeZoneInfo.ConvertTimeFromUtc(expectedUtcDateTime, blogTimeZone);

            // act
            DateTime utc = timeZoneWrapper.ToUtc(tokyoDateTime);

            // assert
            Assert.AreEqual(expectedUtcDateTime, utc);
        }
        public void Now_ReturnsTimeInLocalTimeZone()
        {
            // arrange
            DateTime utcNow = DateTime.ParseExact("2009/08/15 11:00 PM", "yyyy/MM/dd hh:mm tt",
                                                  CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
            TimeZoneInfo timeZone        = TimeZones.GetTimeZones().GetById("Mountain Standard Time");
            var          timeZoneWrapper = new TimeZoneWrapper(timeZone, TimeZoneInfo.Local, () => utcNow);

            // act
            DateTime now = timeZoneWrapper.Now;

            // assert
            DateTime expected = DateTime.ParseExact("2009/08/15 05:00 PM", "yyyy/MM/dd hh:mm tt",
                                                    CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);

            Assert.AreEqual(expected, now);
        }
        public void ctor_WhenServerAndLocalTimeZonesAreDifferent_ShowsDifferentTimes()
        {
            //arrange
            TimeZoneInfo pacificTimeZone = TimeZones.GetTimeZones().GetById("Tokyo Standard Time");
            TimeZoneInfo serverTimeZone  = TimeZones.GetTimeZones().GetById("Pacific Standard Time");
            DateTime     now             = DateTime.ParseExact("2009/08/12 12:03 AM", "yyyy/MM/dd hh:mm tt",
                                                               CultureInfo.InvariantCulture);
            DateTime utcNow = now.ToUniversalTime();

            //act
            var info = new ServerTimeZoneInfo(pacificTimeZone, serverTimeZone, now, utcNow);

            //assert
            Assert.AreEqual("2009/08/12 04:03 PM", info.CurrentTime);
            Assert.AreEqual("2009/08/12 12:03 AM", info.ServerTime);
            Assert.AreEqual("Pacific Standard Time (-07:00:00)", info.ServerTimeZone);
            Assert.AreEqual("2009/08/12 07:03 AM", info.ServerUtcTime);
        }
Beispiel #8
0
        public void ctor_WhenServerAndLocalTimeZonesAreSame_ShowsSameTime()
        {
            //arrange
            TimeZoneInfo pacificTimeZone = TimeZones.GetTimeZones().GetById("Pacific Standard Time");
            TimeZoneInfo serverTimeZone  = TimeZones.GetTimeZones().GetById("Pacific Standard Time");
            DateTime     now             = DateTime.ParseExact("2009/08/11 11:50 PM", "yyyy/MM/dd hh:mm tt",
                                                               CultureInfo.InvariantCulture);
            DateTime utcNow = TimeZoneInfo.ConvertTimeToUtc(now, serverTimeZone);

            //act
            var info = new ServerTimeZoneInfo(pacificTimeZone, serverTimeZone, now, utcNow);

            //assert
            Assert.AreEqual("2009/08/11 11:50 PM", info.CurrentTime);
            Assert.AreEqual("2009/08/11 11:50 PM", info.ServerTime);
            Assert.AreEqual("Pacific Standard Time (-07:00:00)", info.ServerTimeZone);
            Assert.AreEqual("2009/08/12 06:50 AM", info.ServerUtcTime);
        }
        public void IsInPast_WithDateInFuture_ReturnsFalse()
        {
            // arrange
            TimeZoneInfo blogTimeZone  = TimeZones.GetTimeZones().GetById("Fiji Standard Time");
            TimeZoneInfo tokyoTimeZone = TimeZones.GetTimeZones().GetById("Tokyo Standard Time");
            DateTime     utcDateTime   = DateTime.ParseExact("2009/08/15 06:18 PM", "yyyy/MM/dd hh:mm tt",
                                                             CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
            var      timeZoneWrapper = new TimeZoneWrapper(blogTimeZone, TimeZoneInfo.Local, () => utcDateTime);
            DateTime tokyoDateTime   = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, tokyoTimeZone).AddHours(1);

            // act
            bool isInPast   = timeZoneWrapper.IsInPast(tokyoDateTime, tokyoTimeZone);
            bool isInFuture = timeZoneWrapper.IsInFuture(tokyoDateTime, tokyoTimeZone);

            // assert
            Assert.IsFalse(isInPast);
            Assert.IsTrue(isInFuture);
        }
Beispiel #10
0
        public void FromTimeZone_ConvertsSpecifiedTime_ToBlogTimeZoneFromSpecifiedTimeZone()
        {
            // arrange
            TimeZoneInfo blogTimeZone    = TimeZones.GetTimeZones().GetById("Fiji Standard Time");
            TimeZoneInfo tokyoTimeZone   = TimeZones.GetTimeZones().GetById("Tokyo Standard Time");
            var          timeZoneWrapper = new TimeZoneWrapper(blogTimeZone, TimeZoneInfo.Local, () => DateTime.UtcNow);
            DateTime     utcDateTime     = DateTime.ParseExact("2009/08/15 06:18 PM", "yyyy/MM/dd hh:mm tt",
                                                               CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
            DateTime tokyoDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, tokyoTimeZone);

            // act
            DateTime fijiDateTime = timeZoneWrapper.FromTimeZone(tokyoDateTime, tokyoTimeZone); // To Fiji Time Zone

            // assert
            DateTime expected = DateTime.ParseExact("2009/08/16 06:18 AM", "yyyy/MM/dd hh:mm tt",
                                                    CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);

            Assert.AreEqual(expected, fijiDateTime);
        }
Beispiel #11
0
    private void populateTimeZoneList()
    {
        Win32TimeZone[] timezones;
        ListItem        newItem;

        timezones = TimeZones.GetTimeZones();

        foreach (Win32TimeZone currTimeZone in timezones)
        {
            newItem = new ListItem(currTimeZone.DisplayName, currTimeZone.Index.ToString());
            ddlTimezone.Items.Add(newItem);

            //Select the timezone from the profile
            if (currTimeZone.Index == Profile.TimeZoneIndex)
            {
                newItem.Selected = true;
            }
        }
    }
        public void TestIfModifiedSinceExtraction(string received, string expected)
        {
            var headers = new NameValueCollection {
                { "If-Modified-Since", received }
            };
            var httpRequest = new Mock <HttpRequestBase>();

            httpRequest.Setup(r => r.Headers).Returns(headers);

            DateTime expectedDate = DateTimeHelper.ParseUnknownFormatUtc(expected);

            Console.WriteLine("{0}\t{1}\t{2}", received, expected, expectedDate.ToUniversalTime());

            DateTime result = HttpHelper.GetIfModifiedSinceDateUtc(httpRequest.Object);
            //Convert to PST:
            TimeZoneInfo timeZone = TimeZones.GetTimeZones().GetById(TimeZonesTest.PacificTimeZoneId);

            result = TimeZoneInfo.ConvertTimeFromUtc(result, timeZone);

            Assert.AreEqual(expectedDate, result);
        }
Beispiel #13
0
 private void BindUserData()
 {
     SessionState.User = HyperCatalog.Business.User.GetByKey(SessionState.User.Id);
     currentUser       = SessionState.User;
     if (currentUser != null)
     {
         Win32TimeZone[] winTimeZones;
         winTimeZones = TimeZones.GetTimeZones();
         Array.Sort(winTimeZones, new Win32TimeZoneComparer());
         DDL_TimeZone.DataSource     = winTimeZones;
         DDL_TimeZone.DataTextField  = "DisplayName";
         DDL_TimeZone.DataValueField = "Index";
         Page.DataBind();
         DDL_TimeZone.SelectedValue  = currentUser.GMTTimeZone.Index.ToString();
         DDLFormatDate.SelectedValue = currentUser.FormatDate;
         DDLFormatTime.SelectedValue = currentUser.FormatTime;
     }
     else
     {
         Response.Write("An error occurred while retrieving User");
     }
 }
Beispiel #14
0
        public PageNewGame()
        {
            OpponentType = OpponentSelect.Random;

            InitializeComponent();

            popUpSplash = new Popup();

            popUpSplash.Child           = UICreator.CreateSplashWindow();
            popUpSplash.Placement       = PlacementMode.Center;
            popUpSplash.PlacementTarget = PageNavigator.MainWindow;
            popUpSplash.IsOpen          = false;

            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.Uid        = "1001";
            txtHeader.Text       = Translator.GetInstance().GetString("PageNewGame", txtHeader.Uid);
            panelContent.Children.Add(txtHeader);

            lbContentBasics = new ListBox();
            lbContentBasics.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbContentBasics.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
            lbContentBasics.MaxHeight = GraphicsHelpers.GetContentHeight() / 2;

            txtNarrative = new TextBox();
            txtNarrative.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            txtNarrative.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            txtNarrative.Background          = Brushes.Transparent;
            txtNarrative.TextWrapping        = TextWrapping.Wrap;
            txtNarrative.FontStyle           = FontStyles.Italic;
            txtNarrative.Width      = 500;
            txtNarrative.Height     = 100;
            txtNarrative.Uid        = "1015";
            txtNarrative.IsReadOnly = true;
            txtNarrative.Text       = Translator.GetInstance().GetString("PageNewGame", txtNarrative.Uid);
            txtNarrative.Visibility = System.Windows.Visibility.Collapsed;

            panelContent.Children.Add(txtNarrative);

            panelContent.Children.Add(lbContentBasics);

            lbContentHuman            = new ListBox();
            lbContentHuman.Visibility = System.Windows.Visibility.Collapsed;
            lbContentHuman.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
            lbContentHuman.MaxHeight  = GraphicsHelpers.GetContentHeight() / 2;
            lbContentHuman.Visibility = System.Windows.Visibility.Collapsed;

            panelContent.Children.Add(lbContentHuman);

            cbContinent = new ComboBox();
            cbContinent.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbContinent.Width             = 200;
            cbContinent.DisplayMemberPath = "Name";
            cbContinent.SelectedValuePath = "Name";

            cbContinent.Items.Add(new Continent("100", "All continents"));

            foreach (Continent continent in Continents.GetContinents().OrderBy(c => c.Name))
            {
                cbContinent.Items.Add(continent);
            }

            cbContinent.SelectionChanged += cbContinent_SelectionChanged;
            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1022"), cbContinent));

            cbRegion = new ComboBox();
            cbRegion.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbRegion.Width             = 200;
            cbRegion.DisplayMemberPath = "Name";
            cbRegion.SelectedValuePath = "Name";

            cbRegion.Items.Add(Regions.GetRegion("100"));
            foreach (Region region in Regions.GetRegions().FindAll(r => Airlines.GetAirlines(r).Count > 0).OrderBy(r => r.Name))
            {
                cbRegion.Items.Add(region);
            }

            cbRegion.SelectionChanged += new SelectionChangedEventHandler(cbRegion_SelectionChanged);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1012"), cbRegion));
            // chs, 2011-19-10 added for the possibility of creating a new airline
            WrapPanel panelAirline = new WrapPanel();

            cbAirline = new ComboBox();
            cbAirline.SetResourceReference(ComboBox.ItemTemplateProperty, "AirlineLogoItem");
            cbAirline.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirline.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbAirline.SelectionChanged   += new SelectionChangedEventHandler(cbAirline_SelectionChanged);
            cbAirline.Width = 200;

            List <Airline> airlines = Airlines.GetAllAirlines();

            airlines.Sort((delegate(Airline a1, Airline a2) { return(a1.Profile.Name.CompareTo(a2.Profile.Name)); }));

            cbAirline.ItemsSource = airlines;

            panelAirline.Children.Add(cbAirline);

            Button btnAddAirline = new Button();

            btnAddAirline.Margin     = new Thickness(5, 0, 0, 0);
            btnAddAirline.Background = Brushes.Transparent;
            btnAddAirline.Click     += new RoutedEventHandler(btnAddAirline_Click);

            Image imgAddAirline = new Image();

            imgAddAirline.Source = new BitmapImage(new Uri(@"/Data/images/add.png", UriKind.RelativeOrAbsolute));
            imgAddAirline.Height = 16;
            RenderOptions.SetBitmapScalingMode(imgAddAirline, BitmapScalingMode.HighQuality);

            btnAddAirline.Content = imgAddAirline;

            panelAirline.Children.Add(btnAddAirline);

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1002"), panelAirline));

            txtIATA = UICreator.CreateTextBlock("");
            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1003"), txtIATA));

            txtAirlineType = UICreator.CreateTextBlock("");
            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1021"), txtAirlineType));

            StackPanel panelCountry = new StackPanel();

            cbCountry = new ComboBox();
            cbCountry.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbCountry.SetResourceReference(ComboBox.ItemTemplateProperty, "CountryFlagLongItem");
            cbCountry.Width             = 150;
            cbCountry.SelectionChanged += cbCountry_SelectionChanged;

            panelCountry.Children.Add(cbCountry);

            cbLocalCurrency = new CheckBox();
            cbLocalCurrency.FlowDirection       = System.Windows.FlowDirection.RightToLeft;
            cbLocalCurrency.Content             = Translator.GetInstance().GetString("PageNewGame", "1014");
            cbLocalCurrency.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
            cbLocalCurrency.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            panelCountry.Children.Add(cbLocalCurrency);

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1004"), panelCountry));


            txtName             = new TextBox();
            txtName.Background  = Brushes.Transparent;
            txtName.BorderBrush = Brushes.Black;
            txtName.Width       = 200;


            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1005"), txtName));

            // chs, 2011-19-10 added to show the airline color
            airlineColorRect                 = new Rectangle();
            airlineColorRect.Width           = 40;
            airlineColorRect.Height          = 20;
            airlineColorRect.StrokeThickness = 1;
            airlineColorRect.Stroke          = Brushes.Black;
            airlineColorRect.Fill            = new AirlineBrushConverter().Convert(Airlines.GetAirline("ZA")) as Brush;
            airlineColorRect.Margin          = new Thickness(0, 2, 0, 2);

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1006"), airlineColorRect));

            cbAirport = new ComboBox();
            cbAirport.SetResourceReference(ComboBox.ItemTemplateProperty, "AirportCountryItem");
            cbAirport.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAirport.IsSynchronizedWithCurrentItem = true;
            cbAirport.HorizontalAlignment           = System.Windows.HorizontalAlignment.Left;
            cbAirport.SelectionChanged += new SelectionChangedEventHandler(cbAirports_SelectionChanged);

            List <Airport> airportsList = Airports.GetAllAirports();

            airportsView = CollectionViewSource.GetDefaultView(airportsList);
            airportsView.SortDescriptions.Add(new SortDescription("Profile.Name", ListSortDirection.Ascending));

            cbAirport.ItemsSource = airportsView;

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1007"), cbAirport));

            cbStartYear = new ComboBox();
            cbStartYear.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbStartYear.Width = 60;
            for (int i = GameObject.StartYear; i < DateTime.Now.Year + 2; i++)
            {
                cbStartYear.Items.Add(i);
            }

            cbStartYear.SelectionChanged += new SelectionChangedEventHandler(cbStartYear_SelectionChanged);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1008"), cbStartYear));

            cbTimeZone = new ComboBox();
            cbTimeZone.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbTimeZone.Width             = 300;
            cbTimeZone.DisplayMemberPath = "DisplayName";
            cbTimeZone.SelectedValuePath = "DisplayName";


            foreach (GameTimeZone gtz in TimeZones.GetTimeZones())
            {
                cbTimeZone.Items.Add(gtz);
            }

            cbTimeZone.SelectedItem = TimeZones.GetTimeZones().Find(delegate(GameTimeZone gtz) { return(gtz.UTCOffset == new TimeSpan(0, 0, 0)); });

            lbContentHuman.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1009"), cbTimeZone));

            cbFocus = new ComboBox();
            cbFocus.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbFocus.Width = 100;

            foreach (Airline.AirlineFocus focus in Enum.GetValues(typeof(Airline.AirlineFocus)))
            {
                cbFocus.Items.Add(focus);
            }

            cbFocus.SelectedIndex = 0;

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1013"), cbFocus));

            WrapPanel panelDifficulty = new WrapPanel();

            cbDifficulty = new ComboBox();
            cbDifficulty.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbDifficulty.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbDifficulty.Width             = 100;
            cbDifficulty.DisplayMemberPath = "Name";
            cbDifficulty.SelectedValuePath = "Name";

            foreach (DifficultyLevel difficulty in DifficultyLevels.GetDifficultyLevels())
            {
                cbDifficulty.Items.Add(difficulty);
            }

            cbDifficulty.SelectedIndex = 0;

            panelDifficulty.Children.Add(cbDifficulty);

            Button btnAddDifficulty = new Button();

            btnAddDifficulty.Margin     = new Thickness(5, 0, 0, 0);
            btnAddDifficulty.Background = Brushes.Transparent;
            btnAddDifficulty.Click     += new RoutedEventHandler(btnAddDifficulty_Click);

            Image imgAddDifficulty = new Image();

            imgAddDifficulty.Source = new BitmapImage(new Uri(@"/Data/images/add.png", UriKind.RelativeOrAbsolute));
            imgAddDifficulty.Height = 16;
            RenderOptions.SetBitmapScalingMode(imgAddDifficulty, BitmapScalingMode.HighQuality);

            btnAddDifficulty.Content = imgAddDifficulty;

            panelDifficulty.Children.Add(btnAddDifficulty);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1011"), panelDifficulty));

            WrapPanel panelOpponents = new WrapPanel();

            cbOpponents = new ComboBox();
            cbOpponents.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbOpponents.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbOpponents.Width = 50;
            cbOpponents.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
            for (int i = 0; i < Airlines.GetAllAirlines().Count; i++)
            {
                cbOpponents.Items.Add(i);
            }

            cbOpponents.SelectedIndex = 3;

            panelOpponents.Children.Add(cbOpponents);

            cbSameRegion = new CheckBox();
            cbSameRegion.FlowDirection     = System.Windows.FlowDirection.RightToLeft;
            cbSameRegion.Content           = Translator.GetInstance().GetString("PageNewGame", "1017");
            cbSameRegion.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            cbSameRegion.Margin            = new Thickness(5, 0, 0, 0);

            panelOpponents.Children.Add(cbSameRegion);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1010"), panelOpponents));

            WrapPanel panelOpponentSelect = new WrapPanel();

            RadioButton rbRandomOpponents = new RadioButton();

            rbRandomOpponents.IsChecked = true;
            rbRandomOpponents.GroupName = "Opponent";
            rbRandomOpponents.Content   = Translator.GetInstance().GetString("PageNewGame", "1018");
            rbRandomOpponents.Checked  += rbRandomOpponents_Checked;

            panelOpponentSelect.Children.Add(rbRandomOpponents);

            RadioButton rbSelectOpponents = new RadioButton();

            rbSelectOpponents.GroupName = "Opponent";
            rbSelectOpponents.Content   = Translator.GetInstance().GetString("PageNewGame", "1019");
            rbSelectOpponents.Checked  += rbSelectOpponents_Checked;
            rbSelectOpponents.Margin    = new Thickness(5, 0, 0, 0);

            panelOpponentSelect.Children.Add(rbSelectOpponents);

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1020"), panelOpponentSelect));

            cbDayTurnEnabled = new CheckBox();
            cbDayTurnEnabled.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            cbDayTurnEnabled.IsChecked         = true;

            lbContentBasics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageNewGame", "1016"), cbDayTurnEnabled));

            WrapPanel panelButtons = new WrapPanel();

            panelButtons.Margin = new Thickness(0, 5, 0, 0);
            panelContent.Children.Add(panelButtons);

            btnCreate = new Button();
            btnCreate.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnCreate.Click  += new RoutedEventHandler(btnCreate_Click);
            btnCreate.Height  = Double.NaN;
            btnCreate.Width   = Double.NaN;
            btnCreate.Uid     = "203";
            btnCreate.Content = Translator.GetInstance().GetString("PageNewGame", btnCreate.Uid);
            btnCreate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            panelButtons.Children.Add(btnCreate);

            btnBack = new Button();
            btnBack.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnBack.Height  = Double.NaN;
            btnBack.Width   = Double.NaN;
            btnBack.Uid     = "119";
            btnBack.Content = Translator.GetInstance().GetString("General", btnBack.Uid);
            btnBack.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnBack.Margin     = new Thickness(5, 0, 0, 0);
            btnBack.Click     += btnBack_Click;
            btnBack.Visibility = System.Windows.Visibility.Collapsed;
            panelButtons.Children.Add(btnBack);

            Button btnExit = new Button();

            btnExit.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnExit.Height  = double.NaN;
            btnExit.Width   = double.NaN;
            btnExit.Uid     = "202";
            btnExit.Content = Translator.GetInstance().GetString("PageNewGame", btnExit.Uid);
            btnExit.Margin  = new Thickness(5, 0, 0, 0);
            btnExit.Click  += new RoutedEventHandler(btnCancel_Click);
            btnExit.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            panelButtons.Children.Add(btnExit);

            base.setTopMenu(new PageTopMenu());

            base.hideNavigator();

            base.hideBottomMenu();

            base.setContent(panelContent);

            base.setHeaderContent(Translator.GetInstance().GetString("PageNewGame", "200"));

            cbStartYear.SelectedItem = DateTime.Now.Year;



            showPage(this);
        }
Beispiel #15
0
 public ServerTimeZoneInfo(string timeZoneText)
     : this(TimeZones.GetTimeZones().GetById(timeZoneText), TimeZoneInfo.Local, DateTime.Now, DateTime.UtcNow)
 {
 }
Beispiel #16
0
        //returns the time zone for the airport
        private GameTimeZone getTimeZone()
        {
            GameTimeZone zone = TimeZones.GetTimeZones().Find(delegate(GameTimeZone gtz) { return(gtz.UTCOffset == this.OffsetDST); });

            return(zone);
        }
Beispiel #17
0
    private void UpdateDataView()
    {
        #region Get all roles
        using (CollectionView rolesList = new CollectionView(SessionState.AppRoles))
        {
            rolesList.Sort("Name");
            ddlRoles.DataSource = rolesList;
            ddlRoles.DataBind();
        }
        #endregion
        #region Get all organizations
        using (CollectionView organizationsList = new CollectionView(SessionState.AppOrganizations))
        {
            organizationsList.Sort("Name");
            cbOrgs.DataSource = organizationsList;
            cbOrgs.DataBind();
        }
        #endregion
        #region Get all time zones
        Win32TimeZone[] winTimeZones = TimeZones.GetTimeZones();
        Array.Sort(winTimeZones, new Win32TimeZoneComparer());
        DDL_TimeZone.DataSource     = winTimeZones;
        DDL_TimeZone.DataTextField  = "DisplayName";
        DDL_TimeZone.DataValueField = "Index";
        DDL_TimeZone.DataBind();
        #endregion

        //resetPwdBtn.Visible = SessionState.EditedUser != null;
        //useDefaultPwd.Visible = SessionState.EditedUser == null;
        if (SessionState.EditedUser != null)
        {
            // Update field
            txtFirstName.Text = SessionState.EditedUser.FirstName;
            txtLastName.Text  = SessionState.EditedUser.LastName;
            txtEmail.Text     = SessionState.EditedUser.Email;
            txtPseudo.Text    = SessionState.EditedUser.Pseudo;
            //txtPassword.Text = SessionState.EditedUser.ClearPassword;
            cbIsActive.Checked          = SessionState.EditedUser.IsActive;
            ddlFormatDate.SelectedValue = SessionState.EditedUser.FormatDate;
            ddlFormatTime.SelectedValue = SessionState.EditedUser.FormatTime;
            cbIsReadOnly.Checked        = SessionState.EditedUser.IsReadOnly;
            if (DDL_TimeZone != null)
            {
                DDL_TimeZone.SelectedValue = SessionState.EditedUser.GMTTimeZoneIndex.ToString();
            }
            if (ddlRoles != null)
            {
                ddlRoles.SelectedValue = SessionState.EditedUser.Role.Id.ToString();
            }
            if (cbOrgs != null)
            {
                cbOrgs.SelectedValue = SessionState.EditedUser.OrgId.ToString();
            }
            // Hide 'Reactivate' button
            if (SessionState.EditedUser.AttemptsLeft > 0)
            {
                UITools.HideToolBarButton(uwToolbar, "Unlock");
                UITools.HideToolBarSeparator(uwToolbar, "UnlockSep");
            }

            // Hide 'Delete' button
            if (SessionState.EditedUser.Id == SessionState.User.Id)
            {
                UITools.HideToolBarButton(uwToolbar, "Delete");
                UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
            }
        }
        else
        {
            // Hide 'Delete' and 'Reactivate' buttons
            UITools.HideToolBarButton(uwToolbar, "Delete");
            UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
            UITools.HideToolBarButton(uwToolbar, "Unlock");
            UITools.HideToolBarSeparator(uwToolbar, "UnlockSep");
            UITools.HideToolBarButton(uwToolbar, "SendInfo");
            //UITools.HideToolBarSeparator(uwToolbar, "SendInfoSep");
        }

        if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly)
        {
            //txtFirstName.Enabled = txtLastName.Enabled = txtEmail.Enabled = cbIsActive.Enabled = cbIsReadOnly.Enabled =
            //  txtPseudo.Enabled = txtPassword.Enabled = resetPwdBtn.Enabled = useDefaultPwd.Enabled =
            //  cbOrgs.Enabled = DDL_TimeZone.Enabled = ddlRoles.Enabled = ddlFormatDate.Enabled = ddlFormatTime.Enabled = false;

            txtFirstName.Enabled   = txtLastName.Enabled = txtEmail.Enabled = cbIsActive.Enabled = cbIsReadOnly.Enabled =
                txtPseudo.Enabled  =
                    cbOrgs.Enabled = DDL_TimeZone.Enabled = ddlRoles.Enabled = ddlFormatDate.Enabled = ddlFormatTime.Enabled = false;
        }
    }
Beispiel #18
0
        protected override void BindLocalUI()
        {
            txbTitle.Text                 = Blog.Title;
            txbSubtitle.Text              = Blog.SubTitle;
            txbAuthor.Text                = Blog.Author;
            txbAuthorEmail.Text           = Blog.Email;
            txbUser.Text                  = Blog.UserName;
            txbNews.Text                  = Blog.News;
            ckbShowEmailonRssFeed.Checked = Blog.ShowEmailAddressInRss;
            txbGenericTrackingCode.Text   = Blog.TrackingCode;
            ckbAllowServiceAccess.Checked = Blog.AllowServiceAccess;
            chkAutoGenerate.Checked       = Blog.AutoFriendlyUrlEnabled;
            ddlTimezone.DataSource        = TimeZones.GetTimeZones();
            ddlTimezone.DataTextField     = "DisplayName";
            ddlTimezone.DataValueField    = "Id";
            ddlTimezone.DataBind();
            ListItem selectedItem = ddlTimezone.Items.FindByValue(Blog.TimeZoneId.ToString(CultureInfo.InvariantCulture));

            if (selectedItem != null)
            {
                selectedItem.Selected = true;
            }

            ListItem languageItem = ddlLangLocale.Items.FindByValue(Blog.Language);

            if (languageItem != null)
            {
                languageItem.Selected = true;
            }

            if (Blog.Skin.HasCustomCssText)
            {
                txbSecondaryCss.Text = Blog.Skin.CustomCssText;
            }

            //TODO: Move to a general DataBind() call.
            int count     = Config.Settings.ItemCount;
            int increment = 1;

            for (int i = 1; i <= count; i = i + increment)
            //starting with 25, the list items increment by 5. Example: 1,2,3,...24,25,30,35,...,45,50.
            {
                ddlItemCount.Items.Add(new ListItem(i.ToString(CultureInfo.InvariantCulture),
                                                    i.ToString(CultureInfo.InvariantCulture)));
                if (i == 25)
                {
                    increment = 5;
                }
            }

            if (Blog.ItemCount <= count)
            {
                ddlItemCount.Items.FindByValue(Blog.ItemCount.ToString(CultureInfo.InvariantCulture)).Selected = true;
            }

            //int 0 = "All" items
            int categoryListPostCount = Config.Settings.CategoryListPostCount;
            int maxDropDownItems      = categoryListPostCount;

            if (maxDropDownItems <= 0)
            {
                maxDropDownItems = 50; //since 0 represents "All", this provides some other options in the ddl.
            }
            ddlCategoryListPostCount.Items.Add(new ListItem("All".ToString(CultureInfo.InvariantCulture),
                                                            0.ToString(CultureInfo.InvariantCulture)));
            increment = 1;
            for (int j = 1; j <= maxDropDownItems; j = j + increment)
            //starting with 25, the list items increment by 5. Example: 1,2,3,...24,25,30,35,...,45,50.
            {
                ddlCategoryListPostCount.Items.Add(new ListItem(j.ToString(CultureInfo.InvariantCulture),
                                                                j.ToString(CultureInfo.InvariantCulture)));
                if (j == 25)
                {
                    increment = 5;
                }
            }

            if (Blog.CategoryListPostCount <= maxDropDownItems)
            {
                ddlCategoryListPostCount.Items.FindByValue(
                    Blog.CategoryListPostCount.ToString(CultureInfo.InvariantCulture)).Selected = true;
            }

            UpdateTime();

            base.BindLocalUI();
        }