예제 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var folder    = AppDomain.CurrentDomain.BaseDirectory;
            var direcFile = $"{folder}Trips.txt";
            int lineCount = File.ReadLines(direcFile).Count();
            var database  = File.ReadAllLines(direcFile);
            int count     = lineCount / 6;

            _trips = new ObservableCollection <Trips>();
            for (int i = 0; i < count; i++)
            {
                var line1 = database[i * 6];
                var line2 = database[i * 6 + 1];
                var line3 = database[i * 6 + 2];
                var trip  = new Trips()
                {
                    Name      = line1,
                    Introduce = line2,
                    Picture   = line3,
                };

                _trips.Add(trip);
            }
            var k = _rng.Next(_trips.Count);

            _trip = new ObservableCollection <Trips>();
            _trip.Add(_trips[k]);
            Title.Text = _trips[k].Name;
            sFile      = $"{folder}Images\\{_trips[k].Picture}";
            BackgoundImg.ImageSource  = new BitmapImage(new Uri(sFile));
            TripIntroduce.ItemsSource = _trip;
        }
 public TripDetailScreen(Trips t)
 {
     InitializeComponent();
     _data = t;
 }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = _data;

            if (_data.Type == 0)
            {
                Accomplished.Visibility = Visibility.Visible;
            }
            ;

            _listdetails      = new BindingList <Trips>();
            ReceivedMoneyData = new SeriesCollection()
            {
            };
            ExpensesData = new SeriesCollection()
            {
            };
            Photo.ItemsSource = _listdetails;
            RoutesItemsControl.ItemsSource = _listdetails;
            string folder = AppDomain.CurrentDomain.BaseDirectory;

            folder = folder + $"\\List\\{_data.Name}\\";
            var trip = new Trips()
            {
                ReceivedMoney = new ObservableCollection <Cash>(),
                Expenses      = new ObservableCollection <Cash>(),
                Routes        = new BindingList <string>(),
                Images        = new BindingList <string>()
            };

            //Images
            string fileImages     = folder + "Images.txt";
            var    dataFileImages = File.ReadAllLines(fileImages);

            for (int i = 0; i < dataFileImages.Length; i++)
            {
                trip.Images.Add(folder + dataFileImages[i]);
            }
            ;

            //Receive Money
            string fileReceivedMoney = folder + "Members.txt";
            var    dataFileMember    = File.ReadAllLines(fileReceivedMoney);
            int    fileMemberCount   = dataFileMember.Count() / 2;

            for (int i = 0; i < fileMemberCount; i++)
            {
                var line1     = dataFileMember[i * 2];
                int line2     = int.Parse(dataFileMember[i * 2 + 1]);
                var chartData = new PieSeries()
                {
                    Title  = line1,
                    Values = new ChartValues <int> {
                        line2
                    }
                };
                var cash = new Cash()
                {
                    Name  = line1,
                    Value = line2
                };
                trip.ReceivedMoney.Add(cash);
                ReceivedMoneyData.Add(chartData);
            }
            ;

            // Expenses
            string fileExpenses      = folder + "Expenses.txt";
            var    dataFileExpenses  = File.ReadAllLines(fileExpenses);
            int    fileExpensesCount = dataFileExpenses.Count() / 2;

            for (int i = 0; i < fileExpensesCount; i++)
            {
                var line1     = dataFileExpenses[i * 2];
                int line2     = int.Parse(dataFileExpenses[i * 2 + 1]);
                var chartData = new PieSeries()
                {
                    Title  = line1,
                    Values = new ChartValues <int> {
                        line2
                    }
                };
                var cash = new Cash()
                {
                    Name  = line1,
                    Value = line2
                };
                trip.Expenses.Add(cash);
                ExpensesData.Add(chartData);
            }

            //Routes
            string fileRoutes     = folder + "Location.txt";
            var    dataFileRoutes = File.ReadAllLines(fileRoutes);

            for (int i = 0; i < dataFileRoutes.Length; i++)
            {
                trip.Routes.Add(dataFileRoutes[i]);
            }
            ;
            _listdetails.Add(trip);

            RoutesPanel.Visibility         = Visibility.Visible;
            ButtonPanel.Visibility         = Visibility.Visible;
            ExpensesChart.DataContext      = ExpensesData;
            ReceivedMoneyChart.DataContext = ReceivedMoneyData;
            dataMembers.Visibility         = Visibility.Visible;
            dataMembers.ItemsSource        = _listdetails[0].ReceivedMoney;
        }
예제 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (Brush)converter.ConvertFromString("#2188fb");
            var fore      = (Brush)converter.ConvertFromString("white");
            var border    = (Brush)converter.ConvertFromString("Transparent");

            All.Background  = brush;
            All.Foreground  = fore;
            All.BorderBrush = border;

            string sMember   = "";
            int    j         = 0;
            int    k         = 1;
            var    folder    = AppDomain.CurrentDomain.BaseDirectory;
            var    direcFile = $"{folder}Trips.txt";
            var    memFile   = $"{folder}Trips-Members.txt";
            int    lineCount = File.ReadLines(direcFile).Count();
            var    database  = File.ReadAllLines(direcFile);
            var    dataFile  = File.ReadAllLines(memFile);
            int    count     = lineCount / 6;

            _trips = new ObservableCollection <Trips>();
            for (int i = 0; i < count; i++)
            {
                var      line1 = database[i * 6];
                var      line2 = database[i * 6 + 1];
                var      line3 = database[i * 6 + 2];
                int      line4 = int.Parse(database[i * 6 + 3]);
                DateTime line5 = DateTime.ParseExact(database[i * 6 + 4], "MM-dd-yyyy", CultureInfo.InvariantCulture);
                DateTime line6 = DateTime.ParseExact(database[i * 6 + 5], "MM-dd-yyyy", CultureInfo.InvariantCulture);
                var      trip  = new Trips()
                {
                    Name      = line1,
                    Introduce = line2,
                    Picture   = $"{folder}Images\\{line3}",
                    Type      = (Trips.TripType)line4,
                    StartDate = line5.ToShortDateString(),
                    EndDate   = line6.ToShortDateString(),
                    Members   = new BindingList <string>(),
                    sMembers  = "",
                };
                while (j < dataFile.Length - 1)
                {
                    if (dataFile[j].Contains("- " + line1))
                    {
                        while (k < dataFile.Length)
                        {
                            trip.Members.Add(dataFile[k]);
                            sMember += dataFile[k] + " ";
                            k++;
                            j++;
                            if (k == dataFile.Length)
                            {
                                trip.sMembers = sMember;
                                break;
                            }
                            if (dataFile[k].Contains("-"))
                            {
                                trip.sMembers = sMember;
                                j++;
                                k++;
                                break;
                            }
                            ;
                        }
                        ;
                        sMember = "";
                        break;
                    }
                    else
                    {
                        j++;
                        k++;
                    }
                }
                _trips.Add(trip);
            }
            dataListview.ItemsSource = _trips;
            SearchTextBox.Text       = "";
            CollectionView           view             = (CollectionView)CollectionViewSource.GetDefaultView(dataListview.ItemsSource);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("Type");

            view.GroupDescriptions.Add(groupDescription);
        }
 public TripDetailControl(Trips t)
 {
     InitializeComponent();
     _data = t;
 }