Exemplo n.º 1
0
        public void initialize(Band[] bands, Reviewer[] reviewers)
        {
            if(bands != null && reviewers != null)
            {
                this.bands = new List<Band>();
                foreach(Band b in bands)
                    this.bands.Add(b);

                this.reviewers = new List<Reviewer>();
                foreach(Reviewer r in reviewers)
                    this.reviewers.Add(r);

                this._ISSET = true;
            }
        }
Exemplo n.º 2
0
        public OpenBand(Controller c, Band[] bands)
        {
            _controller = c;
            _bands = bands;
            InitializeComponent();

            this.nameBox.Items.AddRange(bands);

            albums = new List<Album>();
            shows = new List<Show>();
            foreach (Band b in bands)
            {
                albums.AddRange(b.getAlbums());
                shows.AddRange(b.getShows());
            }

            this.albumBox.Items.AddRange(albums.ToArray());

            foreach (Show s in shows)
                this.showBox.Items.AddRange(s.getDates());
        }
Exemplo n.º 3
0
        public BandRow(Band b, Controller controller, Form parent, bool canEditMembers)
        {
            InitializeComponent();
            this._controller = controller;
            this._model = b;
            this._parent = parent;

            this.band.Text = b.getName();
            int i = 0;
            foreach (Member member in b.getMembers())
            {
                MemberRow row = new MemberRow(member, _controller, _parent, canEditMembers);
                row.Top = row.Height * i + this.Height;
                this.Controls.Add(row);
                i++;
            }

            //update the height

            MemberRow temp = new MemberRow(new Member("temp", "temp") , _controller, _parent, canEditMembers);
            this.Height += i * temp.Height;
        }
Exemplo n.º 4
0
        internal void saveBand(string name, Member[] members, AddBand view, bool isEdit)
        {
            if (name.Length == 0)
                {
                    showMessage(true, "Must enter a band name");
                    return;
                }
            else if (members.Length == 0)
                {
                    showMessage(true, "Must add at least one member");
                    return;
                }

            if (isEdit)
            {
                //get index and remove
                //int index = bands.IndexOf(bandHighlight);
                //bands.RemoveAt(index);

                //Change the band info
                bandHighlight.setName(name);

                //remove and re-add members
                bandHighlight.removeMembers();
                foreach (Member m in members)
                    bandHighlight.addMember(m);

                //remove all rows
                ((MainView)_current_view).removeAllRows();

                //Reintialize the window
                ((MainView)_current_view).initialize(bands.ToArray(), reviewers.ToArray());
                //Close the add band view
                close(view);

                //disable edit / delete buttons
                ((MainView)_current_view).disableDelete(MainView.BANDS_TAB);
                ((MainView)_current_view).disableEdit(MainView.BANDS_TAB);
            }
            else
            {
                //Create a temp band
                Band b = new Band(name, members.Length.ToString());
                //Add the member
                foreach (Member m in members)
                    b.addMember(m);
                //Add Band
                bands.Add(b);
                //Reintialize the window
                ((MainView)_current_view).initialize(bands.ToArray(), reviewers.ToArray());
                //Close the add band view
                close(view);
            }
            saveXML();
        }
Exemplo n.º 5
0
 internal void openBandResult(object p)
 {
     bandHighlight = (Band)p;
     ((MainView)_current_view).setBandTabName(bandHighlight.getName());
     ((MainView)_current_view).switchToBandtab(bandHighlight);
 }
Exemplo n.º 6
0
        internal void removeBand()
        {
            //Remove the band from controller
            bands.Remove(bandHighlight);
            //Remove band from view
            ((MainView)_current_view).removeAllRows();
            ((MainView)_current_view).initialize(bands.ToArray(), reviewers.ToArray());

            //We have no highighted band now
            bandHighlight = null;
            //Disable edit and delete buttons
            ((MainView)_current_view).disableEdit(MainView.BANDS_TAB);
            ((MainView)_current_view).disableDelete(MainView.BANDS_TAB);

            //Change the band tab name
            ((MainView)_current_view).setBandTabName("Select a band");

            saveXML();
        }
Exemplo n.º 7
0
        internal void highlightBand(BandRow row)
        {
            //Set highlighted one green
            row.setGreen();
            //Set all others normal
            foreach (BandRow r in ((MainView)_current_view).getBandRows())
                if (!r.Equals(row))
                    r.setNormal();

            //Set it to our "focus"
            bandHighlight = row.getModel();

            //Set up "Edit" and "Delete" Buttons
            ((MainView)_current_view).enableEdit(MainView.BANDS_TAB);
            ((MainView)_current_view).enableDelete(MainView.BANDS_TAB);

            //Change the band tab name
            ((MainView)_current_view).setBandTabName(bandHighlight.getName());
        }
Exemplo n.º 8
0
        public void writeXML(Band[] bands, Reviewer[] reviewers)
        {
            if (!File.Exists(filePath))
                using(File.Create(filePath));

            using (XmlWriter writer = XmlWriter.Create(filePath))
            {
                writer.WriteStartDocument(); // start document
                writer.WriteStartElement("root", "http://www.w3.org/2001/XMLSchema-instance"); //start root
                foreach (Band b in bands)
                {
                    writer.WriteStartElement("band"); // start band
                    writer.WriteAttributeString("name", b.getName());
                    writer.WriteAttributeString("size", b.getSize());
                    foreach (Member m in b.getMembers())
                    {
                        writer.WriteStartElement("member"); //start member
                        writer.WriteAttributeString("name", m.getName());
                        writer.WriteAttributeString("instrument", m.getInstrument());
                        writer.WriteElementString("join-date", m.getJoinDate());
                        writer.WriteEndElement(); // end memeber
                    }
                    foreach (Album a in b.getAlbums())
                    {
                        writer.WriteStartElement("album"); //start album
                        writer.WriteAttributeString("name", a.getName());
                        foreach (Song s in a.getSongs())
                        {
                            writer.WriteStartElement("song"); //start song
                            writer.WriteElementString("name", s.getName());
                            writer.WriteElementString("tracklength", s.getlength());
                            writer.WriteEndElement(); //end song
                        }
                        foreach (Review r in a.getReviews())
                        {
                            writer.WriteStartElement("reviewer"); // start review
                            writer.WriteAttributeString("ref", r.getReviewerId());
                            writer.WriteString(r.getReview());
                            writer.WriteEndElement(); // end review
                        }
                        writer.WriteEndElement(); // end album
                    }
                    foreach (Show s in b.getShows())
                    {
                        writer.WriteStartElement("show");
                        for (int i = 0; i < s.getDates().Length; i++)
                        {
                            writer.WriteElementString("date", s.getDates()[i]);
                            writer.WriteElementString("venue", s.getVenues()[i]);
                        }
                        writer.WriteEndElement(); //end show
                    }
                    writer.WriteEndElement(); //end band
                }

                foreach (Reviewer r in reviewers)
                {
                    writer.WriteStartElement("reviewer"); // start reviewer
                    writer.WriteAttributeString("id", r.getId());
                    if (r.getName().Length > 0)
                        writer.WriteElementString("name", r.getName());
                    if (r.getCompany().Length > 0)
                        writer.WriteElementString("company", r.getCompany());
                    writer.WriteEndElement(); //end reviewer
                }

                writer.WriteEndElement();   //end root
                writer.WriteEndDocument(); //end document
            }
        }
Exemplo n.º 9
0
 public void switchToBandtab(Band b)
 {
     initializeBandTab(b);
     this.tabs.SelectedTab = this.bandTab;
 }
Exemplo n.º 10
0
        public void initializeBandTab(Band b)
        {
            //remove exist rows
            foreach (AlbumRow row in albumRows)
            {
                this.bandTab.Controls.Remove(row);
                foreach (ShowRow srow in showRows)
                    row.Controls.Remove(srow);
            }
            foreach (ShowRow row in showRows)
                this.bandTab.Controls.Remove(row);
            if (this.showLabel != null)
                this.bandTab.Controls.Remove(showLabel);

            this.albumRows = new List<AlbumRow>();
            this.showRows = new List<ShowRow>();
            this.reviewRows = new List<ReviewRow>();
            this.songRows = new List<SongRow>();

            int i = 0;
            Control lastControl = null;
            foreach (Album a in b.getAlbums())
            {
                AlbumRow row = new AlbumRow(_controller, a);
                //match parent's width
                row.Width = bandsTab.Width;
                //add the row
                this.bandTab.Controls.Add(row);
                //adjust the height
                row.initialize();
                //move it down
                if (lastControl != null)
                   row.Top = lastControl.Top + lastControl.Height + 5;
                else
                    row.Top = 0;
                //Store the "last control"
                lastControl = row;
                lastControl.Show();
                //Add it to the row list
                albumRows.Add((AlbumRow)lastControl);
                //increment placement
                i++;

                Control lastSongControl = null;
                //Add songs to it
                foreach (Song s in a.getSongs())
                {
                    SongRow srow = new SongRow(_controller, s, a, null);

                    srow.Width = bandsTab.Width;
                    lastControl.Controls.Add(srow);

                    srow.initialize();
                    srow.Top = lastControl.Height;

                    lastSongControl = srow;
                    songRows.Add(srow);
                    srow.Visible = true;
                    lastControl.Height += srow.Height;
                }

                Control lastReviewControl = null;
                int k = 0;
                //Add songs to it
                foreach (Review r in a.getReviews())
                {
                    ReviewRow rrow = new ReviewRow(_controller, r, a, row);

                    rrow.Width = bandsTab.Width;
                    lastControl.Controls.Add(rrow);
                    rrow.initialize();

                    rrow.Top = row.Height ;

                    lastReviewControl = rrow;
                    reviewRows.Add(rrow);
                    row.Height += rrow.Height;

                    k++;

                }
            }
            showLabel = new Label();
            showLabel.Text = "Shows";
            showLabel.Font = new Font(showLabel.Font.FontFamily, 15);
            if(lastControl != null)
                showLabel.Top = lastControl.Top + lastControl.Height + 5;

            this.bandTab.Controls.Add(showLabel);

            Control lastShowControl = null;
            showRows = new List<ShowRow>();
            int l = 0;
            //Add songs to it
            foreach (Show s in b.getShows())
            {
                for (int m = 0; m < s.getDates().Length; m++)
                {
                    ShowRow srow = new ShowRow(_controller, s, s.getVenues()[m], s.getDates()[m]);
                    showRows.Add(srow);
                    srow.Width = bandsTab.Width;
                    this.bandTab.Controls.Add(srow);
                    srow.initialize();
                    if (lastShowControl != null)
                        srow.Top = lastShowControl.Top + lastShowControl.Height;
                    else
                    {
                        srow.Top = showLabel.Top + showLabel.Height + 5;
                    }

                    lastShowControl = srow;

                    l++;
                }
            }
        }
Exemplo n.º 11
0
        public void initialize(Band[] bandsSource, Reviewer[] reviewersSource)
        {
            //Bands Tab
            int i = 0;
            Control lastControl = null;
            foreach (Band band in bandsSource)
            {
                BandRow row = new BandRow(band, _controller, this, false);
                //match parent's width
                row.Width = bandsTab.Width;
                //add the row
                this.bandsTab.Controls.Add(row);
                //adjust the height
                row.initialize();
                //move it down
                if (lastControl != null)
                    row.Top = lastControl.Top + lastControl.Height;
                else
                    row.Top = 0;
                //Store the "last control"
                lastControl = row;
                //Add it to the row list
                bandRows.Add((BandRow)lastControl);
                //increment placement
                i++;
            }

            //Reviewer Tab
            i = 0;
            lastControl = null;
            foreach (Reviewer reviewer in reviewersSource)
            {
                ReviewerRow row = new ReviewerRow(reviewer, _controller, this);
                //match parent's width
                row.Width = bandsTab.Width;
                //add the row
                this.reviewersTab.Controls.Add(row);
                //adjust the height
                row.initialize();
                //move it down
                if (lastControl != null)
                    row.Top = lastControl.Top + lastControl.Height;
                else
                    row.Top = 0;
                //Store the "last control"
                lastControl = row;
                //Add it to the row list
                reviewerRows.Add((ReviewerRow)lastControl);
                //increment placement
                i++;
            }
        }