Exemplo n.º 1
0
 // ###############################################################################################
 // Add/Edit purchase dialog
 private void AddPurchase_click(object sender, RoutedEventArgs e)
 {
     NewPurchase = new ObservableCollection <PurchaseClass>()
     {
         new PurchaseClass()
     };
     TestRepeater.ItemsSource         = NewPurchase;
     PurchaseDialog.Title             = "💵 New purchase";
     PurchaseDialog.PrimaryButtonText = "Add";
     PurchaseDialog.ShowAsync();
 }
Exemplo n.º 2
0
        private void EditPurchase_Click(object sender, RoutedEventArgs e)
        {
            var purchase = ((PurchaseClass)((FrameworkElement)sender).DataContext);

            EditingPurchaseId = PurchaseList.IndexOf(purchase);
            NewPurchase       = new ObservableCollection <PurchaseClass>()
            {
                purchase
            };
            TestRepeater.ItemsSource         = NewPurchase;
            PurchaseDialog.Title             = "💵 Edit purchase";
            PurchaseDialog.PrimaryButtonText = "Save";
            PurchaseDialog.ShowAsync();
        }
Exemplo n.º 3
0
    private void OnPurchase(object o, EventArgs args)
    {
        TreeIter      iter;
        TreeModel     model;
        TreeSelection sel = songtv.Selection;

        if (!sel.GetSelected(out model, out iter))
        {
            return;
        }

        bool      Purchase = true;
        int       index    = (int)model.GetValue(iter, 5);
        Hashtable song     = (Hashtable)this.songs[index];

        if (song["downloadKey"] == null)
        {
            Hashtable meta;

            PurchaseDialog dlg = new PurchaseDialog(MainWindow);

            if (song["metaData"] != null)
            {
                meta = (Hashtable)song["metaData"];
            }
            else if (song["metadata"] != null)
            {
                meta = (Hashtable)song["metadata"];
            }
            else
            {
                meta = song;
            }

            if (song["isAlbum"] != null && (bool)song["isAlbum"] == true)
            {
                dlg.Title  = "*";
                dlg.Artist = "*";
            }
            else
            {
                dlg.Title  = (string)meta["itemName"];
                dlg.Artist = (string)meta["artistName"];
            }
            dlg.Album = (string)meta["playlistName"];
            dlg.Price = GetSongPrice(meta);

            if ((ResponseType)dlg.Run() != ResponseType.Accept)
            {
                Purchase = false;
            }

            dlg.Destroy();
        }

        if (!Purchase)
        {
            return;
        }

        if (song["downloadKey"] == null)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(PurchaseThread),
                                         song);
        }
        else
        {
            ArrayList songs = new ArrayList();
            songs.Add(song);
            ThreadPool.QueueUserWorkItem(new WaitCallback(DownloadThread),
                                         songs);
        }
    }
Exemplo n.º 4
0
 void Awake()
 {
     instance = this;
 }
Exemplo n.º 5
0
    private void OnPurchase( object o, EventArgs args )
    {
        TreeIter iter;
        TreeModel model;
        TreeSelection sel = songtv.Selection;

        if( !sel.GetSelected( out model, out iter ) )
            return;

        bool Purchase = true;
        int index = (int)model.GetValue( iter, 5 );
        Hashtable song = (Hashtable)this.songs[ index ];

        if( song[ "downloadKey" ] == null )
        {
            Hashtable meta;

            PurchaseDialog dlg = new PurchaseDialog( MainWindow );

        if( song[ "metaData" ] != null ) {
            meta = (Hashtable)song[ "metaData" ];
        } else if( song[ "metadata" ] != null ) {
            meta = (Hashtable)song[ "metadata" ];
        } else {
            meta = song;
        }

            if( song[ "isAlbum" ] != null && (bool)song[ "isAlbum" ] == true )
            {
                dlg.Title = "*";
                dlg.Artist = "*";
            }
            else
            {
                dlg.Title = (string)meta[ "itemName" ];
                dlg.Artist = (string)meta[ "artistName" ];
            }
            dlg.Album = (string)meta[ "playlistName" ];
            dlg.Price = GetSongPrice( meta );

            if( (ResponseType)dlg.Run() != ResponseType.Accept )
            {
                Purchase = false;
            }

            dlg.Destroy();
        }

        if( !Purchase )
            return;

        if( song[ "downloadKey" ] == null )
        {
            ThreadPool.QueueUserWorkItem( new WaitCallback(PurchaseThread),
                                          song );
        }
        else
        {
            ArrayList songs = new ArrayList();
            songs.Add( song );
            ThreadPool.QueueUserWorkItem( new WaitCallback(DownloadThread),
                                          songs );
        }
    }