This class saves and restores data in isolated storage.
Ejemplo n.º 1
0
 public Mobile()
 {
     //SMSProvider = SMSProviderFactory.GetSMSProvider("SMSProviderWithTread");
     SMSProvider              = SMSProviderFactory.GetSMSProvider("SMSProviderWithTasks");
     Storage                  = new MyStorage();
     SMSProvider.SMSReceived += (message) => Storage.Add(message);
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if ((Tbx_Name.Text != null) && (Tbx_Age.Text != null) && (Date.SelectedDate != null) &&
                (Cbx_Concession.SelectedValue != null) &&
                (Cbx_Ticket_Type.SelectedValue != null) && (Tbx_Total.Text != null))
            {
                var t = new Tickets
                {
                    Name       = Tbx_Name.Text,
                    Age        = int.Parse(Tbx_Age.Text),
                    Concession = Cbx_Concession.SelectedItem.ToString(),
                    TicketType = Cbx_Ticket_Type.SelectedItem.ToString(),
                    Total      = Tbx_Total.Text.ToString(),
                    Path       = theRoute,
                    Date       = (DateTime)Date.SelectedDate
                };

                tickets.Add(t);

                MyStorage.SaveXML <ObservableCollection <Tickets> >(tickets, "TicketsNew.xml");
                MessageBox.Show("Ticket Booked successfully");
            }
            else
            {
                MessageBox.Show("Please enter all the details first!", "Alert");
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Train_Image.Visibility = Visibility.Visible;
            HidePath();

            tickets = MyStorage.ReadXML <ObservableCollection <Tickets> >("TicketsNew.xml");

            List <string> cities = Cities("Cities.xml", "Source");

            foreach (string s in cities)
            {
                Cbx_Source.Items.Add(s);
                Cbx_Destination.Items.Add(s);
            }
            List <string> concession = Cities("Cities.xml", "Concession");

            foreach (string s in concession)
            {
                Cbx_Concession.Items.Add(s);
            }
            List <string> tickettype = Cities("Cities.xml", "TicketType");

            foreach (string s in tickettype)
            {
                Cbx_Ticket_Type.Items.Add(s);
            }
        }
Ejemplo n.º 4
0
 public static void Show(MyStorage storage)
 {
     foreach (Product item in storage)
     {
         Console.WriteLine(String.Format("{0}\t{1}\t{2}\t{3}"
                                         , item.Name, item.Price, item.Category.Name, item.Id));
     }
     Console.Write("\n\n");
 }
Ejemplo n.º 5
0
        private void Button_Click_Clear(object sender, RoutedEventArgs e)
        {
            Cbx_df.SelectedIndex    = -1;
            Cbx_price.SelectedIndex = -1;
            Cbx_sf.SelectedIndex    = -1;
            Cbx_sp.SelectedIndex    = -1;

            rooms = MyStorage.ReadXml <ObservableCollection <Room> >("RoomData.xml");
            Lbx_rooms.ItemsSource = rooms;
        }
Ejemplo n.º 6
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (changed)
     {
         MyStorage.WriteXml <ObservableCollection <Tenant> >(tt, "TenantData.xml");
     }
     MyStorage.WriteXml <ObservableCollection <Bookings> >(bookings, "BookingData.xml");
     MyStorage.WriteXml <ObservableCollection <Room> >(rooms, "RoomData.xml");
     MyStorage.WriteXml <ObservableCollection <CheckoutList> >(checkoutLists, "CheckoutData.xml");
 }
Ejemplo n.º 7
0
 private void readfromXML()
 {
     info.Add(MyStorage.ReadXML <ObservableCollection <Module> >("modules.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <Module> >("modules.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <CourseOverview> >("courseOverview.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <Professor> >("profs.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <AdmissionRequirement> >("admissionRequirements.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <Prospect> >("prospects.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <AdmissionDocuments> >("admissionDocuments.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <StudentReviews> >("studentReviews.xml"));
     info.Add(MyStorage.ReadXML <ObservableCollection <Contact> >("contact.xml"));
 }
Ejemplo n.º 8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            rooms = MyStorage.ReadXml <ObservableCollection <Room> >("RoomData.xml");
            Lbx_rooms.ItemsSource = rooms;

            tt = MyStorage.ReadXml <ObservableCollection <Tenant> >("TenantData.xml");
            Lbx_tenants.ItemsSource = tt;

            bookings             = MyStorage.ReadXml <ObservableCollection <Bookings> >("BookingData.xml");
            Grd_book.ItemsSource = bookings;

            checkoutLists           = MyStorage.ReadXml <ObservableCollection <CheckoutList> >("CheckoutData.xml");
            Grd_history.ItemsSource = checkoutLists;
        }
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //Get the needed data

            //_members = GenerateMembers(20);

            _members = MyStorage.ReadXML <ObservableCollection <Member> >("ClubMembers.xml");

            if (_members == null)
            {
                _members = new ObservableCollection <Member>();
            }

            timer.Interval = TimeSpan.FromSeconds(3);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
Ejemplo n.º 10
0
        public void addShape(shape shape)
        {
            int s = _shapes.getCount();

            shape[] _shapes1;
            _shapes1 = new shape[++s];
            for (int i = 0; i < s - 1; i++)
            {
                _shapes1[i] = _shapes.GetObject(i);
            }
            _shapes1[s - 1] = shape;
            _shapes         = new MyStorage(s);
            for (int i = 0; i < s; i++)
            {
                _shapes.SetObject(i, _shapes1[i]);
            }
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            MyStorage storage = new MyStorage
            {
                Products   = Exemple.Products,              // підключаєм базу продуктів
                Categories = Exemple.Categories             // підключаєм базу категорій
            };

            View.Show(storage);                             // відображаєм
            storage.Products.Sort(Product.CompareByName);   // сортуєм по імені
            View.Show(storage);                             // знаву відображаєм
            storage.Products.Sort(Product.CompareByPrise);  // сортуєм по ціні
            View.Show(storage);                             // як завжди відображаєм
            storage.Products.Sort();                        // сортування по замовчуванню відбувається по Id
            View.Show(storage);                             // як здогадалися, відображаєм

            View.Show(storage.Categories);                  // ах, да, про категорії забули

            Console.ReadLine();
        }
Ejemplo n.º 12
0
    /// <summary>
    /// This constructor will automatically save and restore the passed
    /// window's position in isolated storage.
    /// </summary>
    /// <remarks>
    /// Yes, we could use subclasses, but banana-monkey-jungle problem.
    /// </remarks>
    /// <param name="w">window whose position is to be saved and restored</param>
    /// <param name="tag">unique name for isolated storage</param>
    public WindowPosition(Window w, string tag)
    {
        _tag = tag;

        // Read the current position from storage
        XElement?position = MyStorage.ReadXElement(_tag);

        if (position is null)
        {
            _bounds     = w.RestoreBounds;
            _bMinimized = (w.WindowState == WindowState.Minimized);
            _bMaximized = (w.WindowState == WindowState.Maximized);
        }
        else
        {
            FromXML(position);
        }

        SetWindow(w);
    }
Ejemplo n.º 13
0
    public void SetWindow(Window w)
    {
        _window = w;

        _window.Loaded += (object sender, RoutedEventArgs e) =>
        {
            System.Diagnostics.Debug.Assert(sender as Window == _window);

            SetWindowPosition();
        };

        _window.Closing += (object?sender, CancelEventArgs e) =>
        {
            System.Diagnostics.Debug.Assert(sender as Window == _window);

            _bounds     = _window.RestoreBounds;
            _bMinimized = (_window.WindowState == WindowState.Minimized);
            _bMaximized = (_window.WindowState == WindowState.Maximized);

            MyStorage.WriteXElement(_tag, new XElement(nameof(WindowPosition), ToXML()));
        };
    }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     tenants      = MyStorage.ReadXml <ObservableCollection <Tenant> >("TenantData.xml");
     storebooking = MyStorage.ReadXml <ObservableCollection <Bookings> >("BookingData.xml");
 }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     Owner.Visibility = Visibility.Visible;
     MyStorage.WriteXml <ObservableCollection <Tenant> >(tenants, "TenantData.xml");
     MyStorage.WriteXml <ObservableCollection <Bookings> >(storebooking, "BookingData.xml");
 }
Ejemplo n.º 16
0
 public Mobile()
 {
     SMSProvider              = new SMSProvider();
     Storage                  = new MyStorage();
     SMSProvider.SMSReceived += (message) => Storage.Add(message);
 }
 private void Application_Exit(object sender, ExitEventArgs e)
 {
     MyStorage.WriteXml <ObservableCollection <Member> >(_members, "ClubMembers.xml");
 }
 public MainWindow()
 {
     InitializeComponent();
     tickets = new ObservableCollection <Tickets>();
     routes  = MyStorage.ReadXML <ObservableCollection <Routes> >("NewRoutes.xml");
 }
Ejemplo n.º 19
0
 public CGroup(int _count)
 {
     MyStorage _shapes = new MyStorage(_count);
 }