コード例 #1
0
        public TripDisplayCard(Trip t, int index, ref Canvas c, MainWindow m)
        {
            FullTripData = t;
            window       = m;
            double baseLoc = (index * 215) + 100;

            BackGround = new Rectangle
            {
                Width           = 808,
                Height          = 210,
                Fill            = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                Stroke          = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                StrokeThickness = 3
            };
            Canvas.SetLeft(BackGround, 111);
            Canvas.SetTop(BackGround, baseLoc);
            c.Children.Add(BackGround);

            TripImage = new Image
            {
                MaxWidth  = 300,
                MaxHeight = 180,
                Source    = t.TripImage.GetImage().Source
            };
            TripImage.Loaded += TripImage_Loaded;
            Canvas.SetLeft(TripImage, 140);
            Canvas.SetTop(TripImage, baseLoc + 15);
            c.Children.Add(TripImage);

            DepartureAndDestination = new Label
            {
                FontSize            = 30,
                FontWeight          = FontWeights.Bold,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Content             = t.Departure + " - " + t.Destination
            };
            Canvas.SetTop(DepartureAndDestination, baseLoc + 10);
            c.Children.Add(DepartureAndDestination);

            FromStartToEndDate = new Label
            {
                FontSize            = 30,
                FontWeight          = FontWeights.Bold,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Content             = "From " + t.Start.ToShortDateString() + " to " + t.End.ToShortDateString()
            };
            Canvas.SetTop(FromStartToEndDate, baseLoc + 74);
            c.Children.Add(FromStartToEndDate);


            if (t.IsClosed)
            {
                Status_Label = new Label
                {
                    FontSize   = 30,
                    FontWeight = FontWeights.Bold,
                    Content    = "Status: closed"
                };
            }
            else
            {
                Status_Label = new Label
                {
                    FontSize   = 30,
                    FontWeight = FontWeights.Bold,
                    Content    = "Status: opened"
                };
            }
            Canvas.SetTop(Status_Label, baseLoc + 130);
            c.Children.Add(Status_Label);

            MoreInfo = new Button
            {
                Content    = "View More",
                Width      = 152,
                Height     = 48,
                Background = new SolidColorBrush(Color.FromRgb(232, 126, 49)),
                Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                FontSize   = 20,
                Cursor     = Cursors.Hand
            };
            MoreInfo.Click += MoreInfo_Click;
            Canvas.SetLeft(MoreInfo, 750);
            Canvas.SetTop(MoreInfo, baseLoc + 153);
            c.Children.Add(MoreInfo);

            c.Height = baseLoc + 230;
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            DataBase.Intialize();

            CurrentCanvas = CustomerFullDetails_Canvas;

            List <string> l = new List <string>();

            l.Add("Arabic");

            cus           = new Customer("1", "Ali Ahmed", "Egyption", l, "Male", "*****@*****.**", "0114849551");
            cus.UserImage = new CustomImage("E:/test.JPG");
            DataBase.Customers.Add(cus);

            CurrentCanvas = Main_Canvas;

            TourGuide t = new TourGuide("1", "ahmed", "egy", "male", "asa", "011");

            t.UserImage = new CustomImage("E:/test.JPG");
            DataBase.TourGuides.Add(t);

            Trip trip = new Trip("2", t, "family", "Cairo", "Alex", 0, new DateTime(2017, 5, 4), new DateTime(2017, 6, 4));

            trip.TripImage = new CustomImage("E:/test.JPG");  //Put a valid image just to test
            DataBase.Trips.Add(trip);


            Trip trip2 = new Trip("3", t, "test", "Rome", "Paris", 0, new DateTime(2017, 5, 4), new DateTime(2017, 6, 4));

            trip2.TripImage = new CustomImage("E:/test.JPG");  //Put a valid image just to test
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);


            int today = DateTime.Today.Day;

            if (DataBase.Trips.Count != 0)
            {
                TripOfTheDay = DataBase.Trips[today % DataBase.Trips.Count]; //generate trip based on today's date
            }
            if (DataBase.TourGuides.Count != 0)
            {
                TourGuideOfTheMonth = TourGuide.GetBestTourGuide(DateTime.Today.Month - 1); //returns tour guide with maximum salary in the past month
            }
            if (TripOfTheDay != null)
            {
                TripOfTheDay_IMG.Source    = TripOfTheDay.TripImage.GetImage().Source;
                TripOfTheDay_Label.Content = TripOfTheDay.Departure + " - " + TripOfTheDay.Destination;
            }

            if (TourGuideOfTheMonth == null)
            {
                ;
            }
            //Todo: add message
            //There is no tour guides or max existing haas 0 salary in the past month
        }