Пример #1
0
        public static object ShowPopUp(Route route)
        {
            PopUpTimeTable window = new PopUpTimeTable(route);
            window.ShowDialog();

            return window.Selected == null ? null : window.Selected;
        }
        public PageShowRoute(Route route)
        {
            this.Classes = new List<MVVMRouteClass>();

            this.Route = route;
            this.DataContext = this.Route;

            foreach (AirlinerClass.ClassType type in AirlinerClass.GetAirlinerTypes())
            {
                if (this.Route is PassengerRoute)
                {
                   RouteAirlinerClass rClass = ((PassengerRoute)this.Route).getRouteAirlinerClass(type);
                    MVVMRouteClass mClass = new MVVMRouteClass(type, rClass.Seating, rClass.FarePrice);

                    this.Classes.Add(mClass);
                }
            }

            this.Invoices = new List<MonthlyInvoice>();

            foreach (Invoice.InvoiceType type in this.Route.getRouteInvoiceTypes())
                this.Invoices.Add(new MonthlyInvoice(type, 1950, 1, this.Route.getRouteInvoiceAmount(type)));

            this.Legs = new List<Route>();
            this.Legs.Add(this.Route);
            this.Legs.AddRange(this.Route.Stopovers.SelectMany(s => s.Legs));

            InitializeComponent();

            Boolean inRoute = this.Route.getAirliners().Exists(a => a.Status != FleetAirliner.AirlinerStatus.Stopped);

            cbEdit.Visibility = inRoute ? Visibility.Collapsed : System.Windows.Visibility.Visible;

            this.Loaded += PageShowRoute_Loaded;
        }
Пример #3
0
        public SubsidiaryAirline(Airline airline,AirlineProfile profile, AirlineMentality mentality, AirlineFocus market, AirlineLicense license,Route.RouteType routefocus)
            : base(profile, mentality, market,license,routefocus)
        {
            this.Airline = airline;

            foreach (AirlineLogo logo in this.Airline.Profile.Logos)
                this.Profile.addLogo(logo);
        }
 public FutureSubsidiaryAirline(string name, string iata,Airport airport, Airline.AirlineMentality mentality, Airline.AirlineFocus market, Route.RouteType airlineRouteFocus, string logo)
 {
     this.Name = name;
     this.IATA = iata;
     this.PreferedAirport = airport;
     this.Mentality = mentality;
     this.Market = market;
     this.Logo = logo;
     this.AirlineRouteFocus = airlineRouteFocus;
 }
Пример #5
0
        public Airline(AirlineProfile profile, AirlineMentality mentality, AirlineFocus marketFocus, AirlineLicense license, Route.RouteType routeFocus)
        {
            this.Scores = new AirlineScores();
            this.Airports = new List<Airport>();
            this.Fleet = new List<FleetAirliner>();
            this._Routes = new List<Route>();
            this.FutureAirlines = new List<FutureSubsidiaryAirline>();
            this.Subsidiaries = new List<SubsidiaryAirline>();
            this.Advertisements = new Dictionary<AdvertisementType.AirlineAdvertisementType, AdvertisementType>();
            this.Statistics = new GeneralStatistics();
            this.Facilities = new List<AirlineFacility>();
            this.Invoices = new Invoices();
            this.Budget = new AirlineBudget();
            this.BudgetHistory = new Dictionary<DateTime, AirlineBudget>();
            this.TestBudget = new Dictionary<DateTime, AirlineBudget>();
            this.Profile = profile;
            this.AirlineRouteFocus = routeFocus;
            this.Loans = new List<Loan>();
            this.Reputation = 50;
            this.Alliances = new List<Alliance>();
            this.Mentality = mentality;
            this.MarketFocus = marketFocus;
            this.License = license;
            this.FlightCodes = new List<string>();
            this.Policies = new List<AirlinePolicy>();
            this.EventLog = new List<RandomEvent>();
            this.Ratings = new AirlineRatings();
            this.OverallScore = this.CountedScores = 0;
            this.GameScores = new Dictionary<DateTime, int>();
            this.InsuranceClaims = new List<InsuranceClaim>();
            this.InsurancePolicies = new List<AirlineInsurance>();
            for (int i = 1; i < 10000; i++)
                this.FlightCodes.Add(string.Format("{0}{1:0000}",this.Profile.IATACode, i));

            createStandardAdvertisement();

            this.Pilots = new List<Pilot>();
            this.FlightSchools = new List<FlightSchool>();
            this.Budget = new AirlineBudget();
        }
Пример #6
0
        public PageShowRoute(Route route)
        {
            this.Classes = new ObservableCollection<MVVMRouteClass>();

            this.Route = new HumanRouteMVVM(route);
            this.DataContext = this.Route;

             foreach (AirlinerClass.ClassType type in AirlinerClass.GetAirlinerTypes())
            {
                if (this.Route.Route is PassengerRoute)
                {
                   RouteAirlinerClass rClass = ((PassengerRoute)this.Route.Route).getRouteAirlinerClass(type);
                    MVVMRouteClass mClass = new MVVMRouteClass(type, rClass.Seating, rClass.FarePrice);

                    this.Classes.Add(mClass);
                }
            }

            InitializeComponent();

            this.Loaded += PageShowRoute_Loaded;
        }
Пример #7
0
        public PopUpTimeTable(Route route)
        {
            InitializeComponent();

            this.Uid = "1000";
            this.Route = route;

            this.Title = string.Format("{0} - {1}", this.Route.Destination1.Profile.IATACode, this.Route.Destination2.Profile.IATACode);

            this.Width = 800;

            this.Height = 450;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel panelMain = new StackPanel();
            panelMain.Margin = new Thickness(10, 10, 10, 10);

            Grid grdMain = UICreator.CreateGrid(2);

            StackPanel panelOutbound = createDestinationPanel(route.Destination1);
            Grid.SetColumn(panelOutbound, 0);
            grdMain.Children.Add(panelOutbound);

            StackPanel panelInbound = createDestinationPanel(route.Destination2);
            Grid.SetColumn(panelInbound, 1);
            grdMain.Children.Add(panelInbound);

            panelMain.Children.Add(grdMain);

            panelMain.Children.Add(createCPUButtonsPanel());

            this.Content = panelMain;

            showEntries();
        }
Пример #8
0
 //adds a route to the airliner
 public void addRoute(Route route)
 {
     this.Routes.Add(route);
 }
 public StartDataRoutes(string origin, int destinations, GeneralHelpers.Size minimumsize,Route.RouteType routetype)
 {
     this.Countries = new List<Country>();
     this.Origin = origin;
     this.Destinations = destinations;
     this.MinimumSize = minimumsize;
     this.RouteType = routetype;
 }
Пример #10
0
        //adds a route to the airline
        public void addRoute(Route route)
        {
            var routes = new List<Route>(this.Routes);

            lock (this._Routes)
            {
                this._Routes.Add(route);
                route.Airline = this;

                foreach (string flightCode in route.TimeTable.Entries.Select(e => e.Destination.FlightCode).Distinct())
                    this.FlightCodes.Remove(flightCode);
            }
        }
Пример #11
0
 //removes a route from the airline
 public void removeRoute(Route route)
 {
     lock (this._Routes)
     {
         this._Routes.Remove(route);
     }
 }
Пример #12
0
        //returns if two airports can have route between them and if the airline has license for the route
        private static Boolean CheckRouteOk(Airport airport1, Airport airport2, Route.RouteType routeType)
        {
            Boolean isCargoRouteOk = true;
            if (routeType == Route.RouteType.Cargo)
                isCargoRouteOk = AIHelpers.IsCargoRouteDestinationsCorrect(airport1, airport2, GameObject.GetInstance().HumanAirline);

            return isCargoRouteOk && AirlineHelpers.HasAirlineLicens(GameObject.GetInstance().HumanAirline, airport1, airport2) && AIHelpers.IsRouteInCorrectArea(airport1, airport2) && !FlightRestrictions.HasRestriction(airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) && !FlightRestrictions.HasRestriction(airport2.Profile.Country, airport1.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) && !FlightRestrictions.HasRestriction(GameObject.GetInstance().HumanAirline, airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime);
        }
Пример #13
0
        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();
        }
Пример #14
0
        //saves a route
        private static XmlElement SaveRoute(XmlDocument xmlDoc, Route route)
        {
            XmlElement routeNode = xmlDoc.CreateElement("route");
            routeNode.SetAttribute("id", route.Id);
            routeNode.SetAttribute("destination1", route.Destination1.Profile.IATACode);
            routeNode.SetAttribute("destination2", route.Destination2.Profile.IATACode);
            routeNode.SetAttribute("isbanned", route.Banned.ToString());
            routeNode.SetAttribute("type", route.Type.ToString());

            XmlElement routeStopoversNode = xmlDoc.CreateElement("stopovers");

            foreach (StopoverRoute stopover in route.Stopovers)
            {
                XmlElement routeStopoverNode = xmlDoc.CreateElement("stopover");
                routeStopoverNode.SetAttribute("airport", stopover.Stopover.Profile.ID);

                XmlElement stopoverLegsNode = xmlDoc.CreateElement("legs");
                foreach (Route leg in stopover.Legs)
                {
                    XmlElement stopoverLegNode = xmlDoc.CreateElement("leg");

                    stopoverLegNode.AppendChild(SaveRoute(xmlDoc, leg));

                    stopoverLegsNode.AppendChild(stopoverLegNode);
                }
                routeStopoverNode.AppendChild(stopoverLegsNode);
                routeStopoversNode.AppendChild(routeStopoverNode);
            }

            routeNode.AppendChild(routeStopoversNode);

            if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed)
            {

                XmlElement routeClassesNode = xmlDoc.CreateElement("routeclasses");

                foreach (RouteAirlinerClass aClass in ((PassengerRoute)route).Classes)
                {
                    XmlElement routeClassNode = xmlDoc.CreateElement("routeclass");
                    routeClassNode.SetAttribute("type", aClass.Type.ToString());
                    routeClassNode.SetAttribute("fareprice", aClass.FarePrice.ToString(new CultureInfo("de-DE", false)));

                    foreach (RouteFacility facility in aClass.getFacilities())
                        routeClassNode.SetAttribute(facility.Type.ToString(), facility.Uid);
                    // chs, 2011-18-10 added for saving of type of seating
                    routeClassNode.SetAttribute("seating", aClass.Seating.ToString());

                    routeClassesNode.AppendChild(routeClassNode);
                }
                routeNode.AppendChild(routeClassesNode);

            }

            if (route.Type == Route.RouteType.Mixed || route.Type == Route.RouteType.Cargo)
            {
                XmlElement routeCargoNode = xmlDoc.CreateElement("cargo");
                routeCargoNode.SetAttribute("priceperunit", ((CargoRoute)route).PricePerUnit.ToString(new CultureInfo("de-DE", false)));

                routeNode.AppendChild(routeCargoNode);
            }

            XmlElement timetableNode = xmlDoc.CreateElement("timetable");

            foreach (RouteTimeTableEntry entry in route.TimeTable.Entries)
            {
                XmlElement ttEntryNode = xmlDoc.CreateElement("timetableentry");
                ttEntryNode.SetAttribute("destination", entry.Destination.Airport.Profile.IATACode);
                ttEntryNode.SetAttribute("flightcode", entry.Destination.FlightCode);
                ttEntryNode.SetAttribute("day", entry.Day.ToString());
                ttEntryNode.SetAttribute("time", entry.Time.ToString());
                ttEntryNode.SetAttribute("airliner", entry.Airliner != null ? entry.Airliner.Airliner.ID : "-");
                ttEntryNode.SetAttribute("id", entry.ID);
                if (entry.MainEntry != null) ttEntryNode.SetAttribute("mainentry", entry.MainEntry.ID);

                timetableNode.AppendChild(ttEntryNode);
            }

            routeNode.AppendChild(timetableNode);

            XmlElement routeInvoicesNode = xmlDoc.CreateElement("invoices");
            foreach (MonthlyInvoice invoice in route.getInvoices().MonthlyInvoices)
            {
                XmlElement routeInvoiceNode = xmlDoc.CreateElement("invoice");
                routeInvoiceNode.SetAttribute("type", invoice.Type.ToString());
                routeInvoiceNode.SetAttribute("year", invoice.Year.ToString());
                routeInvoiceNode.SetAttribute("month", invoice.Month.ToString());
                routeInvoiceNode.SetAttribute("amount",invoice.Amount.ToString(new CultureInfo("de-DE", false)));

                routeInvoicesNode.AppendChild(routeInvoiceNode);
            }
            routeNode.AppendChild(routeInvoicesNode);

            return routeNode;
        }
Пример #15
0
        //loads a route
        private static Route LoadRoute(XmlElement routeNode, Airline airline, Route.RouteType routetype = Route.RouteType.Passenger)
        {
            string id = routeNode.Attributes["id"].Value;
            Airport dest1 = Airports.GetAirport(routeNode.Attributes["destination1"].Value);
            Airport dest2 = Airports.GetAirport(routeNode.Attributes["destination2"].Value);
            Boolean isBanned = Convert.ToBoolean(routeNode.Attributes["isbanned"].Value);

            if (routeNode.HasAttribute("type"))
                routetype = (Route.RouteType)Enum.Parse(typeof(Route.RouteType), routeNode.Attributes["type"].Value);

            Route route;

            if (routetype == Route.RouteType.Passenger || routetype == Route.RouteType.Mixed)
                route = new PassengerRoute(id, dest1, dest2, DateTime.Now,0);
            else
                route = new CargoRoute(id, dest1, dest2, DateTime.Now,0);

            route.Banned = isBanned;

            /* foreach (StopoverRoute stopover in route.Stopovers)
            {
                XmlElement routeStopoverNode = xmlDoc.CreateElement("stopover");
                routeStopoverNode.SetAttribute("airport", stopover.Stopover.Profile.ID);

                XmlElement stopoverLegsNode = xmlDoc.CreateElement("legs");
                foreach (Route leg in stopover.Legs)
                {
                    XmlElement stopoverLegNode = xmlDoc.CreateElement("leg");

                    stopoverLegNode.AppendChild(SaveRoute(xmlDoc, leg));

                    stopoverLegsNode.AppendChild(stopoverLegNode);
                }
                routeStopoverNode.AppendChild(stopoverLegsNode);
                routeStopoversNode.AppendChild(routeStopoverNode);*/

            XmlNodeList routeStopoverList = routeNode.SelectNodes("stopovers/stopover");

            foreach (XmlElement routeStopoverNode in routeStopoverList)
            {
                Airport stopoverAirport = Airports.GetAirportFromID(routeStopoverNode.Attributes["airport"].Value);

                StopoverRoute stopoverRoute = new StopoverRoute(stopoverAirport);

                XmlNodeList legsList = routeStopoverNode.SelectNodes("legs/leg");

                foreach (XmlElement legNode in legsList)
                {

                    stopoverRoute.addLeg(LoadRoute((XmlElement)legNode.SelectSingleNode("route"), airline, routetype));
                }

                route.addStopover(stopoverRoute);

            }

            if (routetype == Route.RouteType.Passenger || routetype == Route.RouteType.Mixed)
            {
                ((PassengerRoute)route).Classes.Clear();

                XmlNodeList routeClassList = routeNode.SelectNodes("routeclasses/routeclass");

                foreach (XmlElement routeClassNode in routeClassList)
                {
                    AirlinerClass.ClassType airlinerClassType = (AirlinerClass.ClassType)Enum.Parse(typeof(AirlinerClass.ClassType), routeClassNode.Attributes["type"].Value);
                    double fareprice = Convert.ToDouble(routeClassNode.Attributes["fareprice"].Value,new CultureInfo("de-DE", false));
                    RouteAirlinerClass.SeatingType seatingType = (RouteAirlinerClass.SeatingType)Enum.Parse(typeof(RouteAirlinerClass.SeatingType), routeClassNode.Attributes["seating"].Value);

                    RouteAirlinerClass rClass = new RouteAirlinerClass(airlinerClassType, RouteAirlinerClass.SeatingType.Reserved_Seating, fareprice);
                    rClass.Seating = seatingType;

                    foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof(RouteFacility.FacilityType)))
                    {
                        if (routeClassNode.HasAttribute(ftype.ToString()))
                        {
                            RouteFacility facility = RouteFacilities.GetFacility(routeClassNode.Attributes[ftype.ToString()].Value);
                            rClass.addFacility(facility);
                        }
                    }

                    ((PassengerRoute)route).addRouteAirlinerClass(rClass);

                }
            }
            if (routetype == Route.RouteType.Mixed || routetype == Route.RouteType.Cargo)
            {
                XmlElement routeCargoNode = (XmlElement)routeNode.SelectSingleNode("cargo");
                double unitPrice = Convert.ToDouble(routeCargoNode.Attributes["priceperunit"].Value,new CultureInfo("de-DE", false));

                ((CargoRoute)route).PricePerUnit = unitPrice;

            }

            RouteTimeTable timeTable = new RouteTimeTable(route);

            XmlNodeList timetableList = routeNode.SelectNodes("timetable/timetableentry");

            foreach (XmlElement entryNode in timetableList)
            {
                Airport entryDest = Airports.GetAirport(entryNode.Attributes["destination"].Value);
                string flightCode = entryNode.Attributes["flightcode"].Value;
                DayOfWeek day = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), entryNode.Attributes["day"].Value);
                TimeSpan time = TimeSpan.Parse(entryNode.Attributes["time"].Value);
                FleetAirliner airliner = entryNode.Attributes["airliner"].Value == "-" ? null : airline.Fleet.Find(a => a.Airliner.ID == entryNode.Attributes["airliner"].Value); ;

                RouteTimeTableEntry entry = new RouteTimeTableEntry(timeTable, day, time, new RouteEntryDestination(entryDest, flightCode,null),null);

                if (entryNode.HasAttribute("id"))
                    entry.ID = entryNode.Attributes["id"].Value;

                if (entryNode.HasAttribute("mainentry")) entry.MainEntry = airline.Routes.SelectMany(r => r.TimeTable.Entries).ToList().Find(e => e.ID == entryNode.Attributes["mainentry"].Value);

                entry.Airliner = airliner;

                if (airliner != null && !airliner.Routes.Contains(route))
                    airliner.Routes.Add(route);

                timeTable.addEntry(entry);
            }
            route.TimeTable = timeTable;

            XmlNodeList routeInvoiceList = routeNode.SelectNodes("invoices/invoice");

            foreach (XmlElement routeInvoiceNode in routeInvoiceList)
            {
                Invoice.InvoiceType type = (Invoice.InvoiceType)Enum.Parse(typeof(Invoice.InvoiceType), routeInvoiceNode.Attributes["type"].Value);
                int invoiceYear = Convert.ToInt16(routeInvoiceNode.Attributes["year"].Value);
                int invoiceMonth = Convert.ToInt16(routeInvoiceNode.Attributes["month"].Value);
                double invoiceAmount = Convert.ToDouble(routeInvoiceNode.Attributes["amount"].Value, new CultureInfo("de-DE", false));

                route.setRouteInvoice(type, invoiceYear, invoiceMonth, invoiceAmount);
            }

            return route;
        }
Пример #16
0
        //returns if a route can be created
        public static Boolean IsRouteDestinationsOk(Airline airline, Airport destination1, Airport destination2, Route.RouteType routeType, Airport stopover1 = null, Airport stopover2 = null)
        {
            var distances = new List<double>();

            Boolean stopoverOk = (stopover1 == null || routeType == Route.RouteType.Cargo ? true : AirportHelpers.HasFreeGates(stopover1, airline)) && (stopover2 == null || routeType == Route.RouteType.Cargo ? true : AirportHelpers.HasFreeGates(stopover2, airline));

            if ((AirportHelpers.HasFreeGates(destination1, airline) && AirportHelpers.HasFreeGates(destination2, airline) && stopoverOk) || routeType == Route.RouteType.Cargo)
            {
                RouteOkStatus routeOkStatus = RouteOkStatus.Ok;

                if (stopover1 == null && stopover2 == null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, destination2));
                    routeOkStatus = GetRouteStatus(destination1, destination2, routeType);
                }

                if (stopover1 == null && stopover2 != null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, stopover2));
                    distances.Add(MathHelpers.GetDistance(stopover2, destination2));
                    routeOkStatus = GetRouteStatus(destination1, stopover2, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover2, destination2, routeType);

                }

                if (stopover1 != null && stopover2 == null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, stopover1));
                    distances.Add(MathHelpers.GetDistance(stopover1, destination2));
                    routeOkStatus = GetRouteStatus(destination1, stopover1, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover1, destination2, routeType);
                }

                if (stopover1 != null && stopover2 != null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, stopover1));
                    distances.Add(MathHelpers.GetDistance(stopover1, stopover2));
                    distances.Add(MathHelpers.GetDistance(stopover2, destination2));
                    routeOkStatus = GetRouteStatus(destination1, stopover1, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover1, stopover2, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover2, destination2, routeType);
                }

                double maxDistance = distances.Max();
                double minDistance = distances.Min();

                var query = from a in AirlinerTypes.GetTypes(delegate(AirlinerType t) { return t.Produced.From < GameObject.GetInstance().GameTime; })
                            select a.Range;

                double maxFlightDistance = query.Max();
                
                if (minDistance <= Route.MinRouteDistance || maxDistance > maxFlightDistance)
                    routeOkStatus = RouteOkStatus.Wrong_Distance;

                if (routeOkStatus == RouteOkStatus.Ok)
                    return true;
                else
                {

                    if (routeOkStatus == RouteOkStatus.Appropriate_Type)
                        throw new Exception("3002");
                    else if (routeOkStatus == RouteOkStatus.Wrong_Distance)
                        throw new Exception("3001");
                    else if (routeOkStatus == RouteOkStatus.Missing_Cargo)
                        throw new Exception("3003");
                    else if (routeOkStatus == RouteOkStatus.Restrictions)
                        throw new Exception("3004");

                    throw new Exception("3000");

                }
            }
            else
                throw new Exception("3000");

        }
Пример #17
0
        //creates the panel for the statistics for a leg
        private StackPanel createLegStatistics(Route leg)
        {
            StackPanel panelLegStatistics = new StackPanel();
            panelLegStatistics.Margin = new Thickness(0, 5, 0, 0);

            TextBlock txtHeader = new TextBlock();
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text = string.Format("{0}-{1}", new AirportCodeConverter().Convert(leg.Destination1), new AirportCodeConverter().Convert(leg.Destination2));
            panelLegStatistics.Children.Add(txtHeader);

            ListBox lbLegStatistics = new ListBox();
            lbLegStatistics.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbLegStatistics.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            panelLegStatistics.Children.Add(lbLegStatistics);

            if (leg.Type == Route.RouteType.Mixed || leg.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Passenger)
            {
                RouteAirlinerClass raClass = ((PassengerRoute)leg).getRouteAirlinerClass(AirlinerClass.ClassType.Economy_Class);

                double passengers = leg.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers"));
                double avgPassengers = leg.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers%"));

                lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1009"), UICreator.CreateTextBlock(String.Format("{0:0,0}", passengers))));
                lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1010"), UICreator.CreateTextBlock(string.Format("{0:0.##}", avgPassengers))));
             }
            if (leg.Type == Route.RouteType.Mixed || leg.Type == Route.RouteType.Cargo)
            {
                double cargo = leg.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo"));
                double avgCargo = leg.Statistics.getStatisticsValue(StatisticsTypes.GetStatisticsType("Cargo%"));

                lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1013"), UICreator.CreateTextBlock(String.Format("{0:0,0}", cargo))));
                lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1014"), UICreator.CreateTextBlock(string.Format("{0:0.##}", avgCargo))));

            }
            lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1011"), UICreator.CreateTextBlock(string.Format("{0:0.##} %", leg.FillingDegree * 100))));

            lbLegStatistics.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelRoute", "1012"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(leg.Balance).ToString())));

            return panelLegStatistics;
        }
Пример #18
0
        private static RouteOkStatus GetRouteStatus(Airport airport1, Airport airport2, Route.RouteType routeType)
        {
            RouteOkStatus status = RouteOkStatus.Ok;

            if (routeType == Route.RouteType.Cargo || routeType == Route.RouteType.Mixed)
                if (!AIHelpers.IsCargoRouteDestinationsCorrect(airport1, airport2, GameObject.GetInstance().HumanAirline))
                    status = RouteOkStatus.Missing_Cargo;

            if (status == RouteOkStatus.Ok)
            {
                if (AirlineHelpers.HasAirlineLicens(GameObject.GetInstance().HumanAirline, airport1, airport2) && AIHelpers.IsRouteInCorrectArea(airport1, airport2))
                    if (!FlightRestrictions.HasRestriction(airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) && !FlightRestrictions.HasRestriction(airport2.Profile.Country, airport1.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) && !FlightRestrictions.HasRestriction(GameObject.GetInstance().HumanAirline, airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime))
                        status = RouteOkStatus.Ok;
                    else
                        status = RouteOkStatus.Restrictions;
                else
                    status = RouteOkStatus.Appropriate_Type;
            }

            return status;

        }
        public static void ShowPopUp(Route route)
        {
            List<Route> routes = new List<Route>();
            routes.Add(route);

            ShowPopUp(routes);
        }
Пример #20
0
 //adds a route to the airline
 public void addRoute(Route route)
 {
     lock (this._Routes)
     {
         this._Routes.Add(route);
         route.Airline = this;
     }
 }
        //shows a route
        private void showRoute(Route route, Panel panelMap, int zoom, Point margin, Boolean isStopoverRoute=false, Airline airline = null)
        {
            if (route.HasStopovers)
            {
                foreach (Route leg in route.Stopovers.SelectMany(s => s.Legs))
                    showRoute(leg, panelMap, zoom, margin,true,route.Airline);
            }
            else
            {
                Point pos = GraphicsHelpers.WorldToTilePos(route.Destination1.Profile.Coordinates, zoom);

                Point p = new Point(pos.X * ImageSize - margin.X * ImageSize, pos.Y * ImageSize - margin.Y * ImageSize);

                if (p.X < panelMap.Width)
                    panelMap.Children.Add(createPin(p, route.Destination1));

                pos = GraphicsHelpers.WorldToTilePos(route.Destination2.Profile.Coordinates, zoom);

                p = new Point(pos.X * ImageSize - margin.X * ImageSize, pos.Y * ImageSize - margin.Y * ImageSize);

                if (p.X < panelMap.Width)
                    panelMap.Children.Add(createPin(p, route.Destination2));

                if (airline == null)
                    airline = route.Airline;

                createRouteLine(route.Destination1, route.Destination2, panelMap, zoom, margin, airline,isStopoverRoute);
            }
        }
Пример #22
0
 //adds a leg to the stopover route
 public void addLeg(Route leg)
 {
     this.Legs.Add(leg);
 }
Пример #23
0
        //creates the stop over route based on the main route
        public static StopoverRoute CreateStopoverRoute(Airport dest1, Airport stopover, Airport dest2, Route mainroute, Boolean oneLegged,Route.RouteType type)
        {
            StopoverRoute stopoverRoute = new StopoverRoute(stopover);

            Guid id = Guid.NewGuid();

            if (!oneLegged)
            {
                if (mainroute.Type == Route.RouteType.Passenger || mainroute.Type == Route.RouteType.Mixed)
                {
                    PassengerRoute routeLegTwo = new PassengerRoute(id.ToString(), dest1, stopover, 0);

                    foreach (RouteAirlinerClass aClass in ((PassengerRoute)mainroute).Classes)
                    {
                        //routeLegTwo.getRouteAirlinerClass(aClass.Type).FarePrice = aClass.FarePrice;
                        routeLegTwo.getRouteAirlinerClass(aClass.Type).FarePrice = PassengerHelpers.GetPassengerPrice(dest1, stopover) * GeneralHelpers.ClassToPriceFactor(aClass.Type);

                        foreach (RouteFacility facility in aClass.getFacilities())
                            routeLegTwo.getRouteAirlinerClass(aClass.Type).addFacility(facility);

                        routeLegTwo.getRouteAirlinerClass(aClass.Type).Seating = aClass.Seating;

                    }


                    stopoverRoute.addLeg(routeLegTwo);
                }
                if (mainroute.Type == Route.RouteType.Cargo || mainroute.Type == Route.RouteType.Mixed)
                {
                    CargoRoute routeLegTwo = new CargoRoute(id.ToString(), dest1, stopover, ((CargoRoute)mainroute).PricePerUnit);

                    stopoverRoute.addLeg(routeLegTwo);
                }

            }

            if (mainroute.Type == Route.RouteType.Mixed || mainroute.Type == Route.RouteType.Passenger)
            {
                id = Guid.NewGuid();

                PassengerRoute routeLegOne = new PassengerRoute(id.ToString(), stopover, dest2, 0);

                foreach (RouteAirlinerClass aClass in ((PassengerRoute)mainroute).Classes)
                {
                    //routeLegOne.getRouteAirlinerClass(aClass.Type).FarePrice = aClass.FarePrice;

                    routeLegOne.getRouteAirlinerClass(aClass.Type).FarePrice = PassengerHelpers.GetPassengerPrice(stopover, dest2) * GeneralHelpers.ClassToPriceFactor(aClass.Type);


                    foreach (RouteFacility facility in aClass.getFacilities())
                        routeLegOne.getRouteAirlinerClass(aClass.Type).addFacility(facility);

                    routeLegOne.getRouteAirlinerClass(aClass.Type).Seating = aClass.Seating;

                }

                stopoverRoute.addLeg(routeLegOne);
            }
            if (mainroute.Type == Route.RouteType.Cargo || mainroute.Type == Route.RouteType.Mixed)
            {
                CargoRoute routeLegOne = new CargoRoute(id.ToString(), stopover, dest2, ((CargoRoute)mainroute).PricePerUnit);

                stopoverRoute.addLeg(routeLegOne);
              
            }
           

            return stopoverRoute;
        }
Пример #24
0
        //removes a route from the airline
        public void removeRoute(Route route)
        {
            lock (this._Routes)
            {
                this._Routes.Remove(route);

                foreach (string flightCode in route.TimeTable.Entries.Select(e => e.Destination.FlightCode).Distinct())
                    this.FlightCodes.Add(flightCode);

            }
        }
Пример #25
0
        public static void CreateStopoverRoute(Route route, Airport stopover1, Airport stopover2 = null)
        {

            if (stopover1 != null)
            {
                if (stopover2 != null)
                    route.addStopover(FleetAirlinerHelpers.CreateStopoverRoute(route.Destination1, route.Destination2, stopover2, route, false, route.Type));
                else
                    route.addStopover(FleetAirlinerHelpers.CreateStopoverRoute(route.Destination1, stopover1, route.Destination2, route, false, route.Type));
            }

            if (stopover2 != null && stopover1!=null)
            {
               route.addStopover(FleetAirlinerHelpers.CreateStopoverRoute(stopover1, stopover2, route.Destination2, route, true, route.Type));
              
            }
        }
 public StartDataRoute(string destination1, string destination2, int opened, int closed, Route.RouteType routetype)
 {
     this.Opened = opened;
     this.Closed = closed;
     this.Destination1 = destination1;
     this.Destination2 = destination2;
     this.RouteType = routetype;
 }
Пример #27
0
        public RouteProfitMVVM(Route route, double total)
        {
            this.Route = route;

            double balance = this.Route.Balance;

            this.Percent = balance / total * 100;
        }
 private void PopUpAirlinerAutoRoutes_RouteChanged(Route route)
 {
     this.SelectedRoute = route;
     showFlights();
 }
Пример #29
0
        //creates a subsidiary airline for an airline
        public static SubsidiaryAirline CreateSubsidiaryAirline(Airline airline, double money, string name, string iata, Airline.AirlineMentality mentality, Airline.AirlineFocus market, Route.RouteType routefocus, Airport homebase)
        {
            AirlineProfile profile = new AirlineProfile(name, iata, airline.Profile.Color, airline.Profile.CEO, true, GameObject.GetInstance().GameTime.Year, 2199);
            profile.Country = homebase.Profile.Country;

            SubsidiaryAirline sAirline = new SubsidiaryAirline(airline, profile, mentality, market, airline.License, routefocus);

            AddSubsidiaryAirline(airline, sAirline, money, homebase);

            return sAirline;
        }
Пример #30
0
        //removes a route from the airliner
        public void removeRoute(Route route)
        {
            this.Routes.Remove(route);

            route.TimeTable.Entries.RemoveAll(e => e.Airliner == this);
        }
Пример #31
0
 //adds a leg to the stopover route
 public void addLeg(Route leg)
 {
     this.Legs.Add(leg);
 }