Ejemplo n.º 1
0
        //DROPPING TO listDGV
        private void listDGV_DragDrop(object sender, DragEventArgs e)
        {
            // The mouse locations are relative to the screen, so they must be
            // converted to client coordinates.
            Point    clientPoint = listDGV.PointToClient(new Point(e.X, e.Y));
            XElement newElement  = null;

            // If the drag operation was a copy then add the row to the other control.
            if (e.Effect == DragDropEffects.Copy)
            {
                string cellvalue = e.Data.GetData(typeof(string)) as string;
                var    hittest   = listDGV.HitTest(clientPoint.X, clientPoint.Y);
                if (hittest.ColumnIndex != -1 && hittest.RowIndex != -1)
                {
                    string searchParam = listDGV[hittest.ColumnIndex, hittest.RowIndex].Value.ToString();
                    //searchparem ==
                    Console.WriteLine(cellvalue + "sear parem is this" + searchParam);
                    Boolean   heyy     = false;
                    string    filePath = @"Resources\ListOfMovies.xml";
                    XDocument xDoc2    = null;
                    xDoc2 = XDocument.Load(filePath);
                    var titleQuery2 = from x in xDoc2.Descendants("list")

                                      select x;

                    foreach (XElement m in titleQuery2)
                    {
                        if (m.Element("listTitle") != null && m.Element("title") != null && m.Element("listTitle").Value == searchParam && m.Element("title").Value == cellvalue)
                        {
                            heyy = true;
                        }
                    }

                    if (!heyy)
                    {
                        DialogResult dialogResult = MessageBox.Show("Save changes to list?", "Save Changes", MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            XElement y = new XElement("list", new XElement("listTitle", searchParam), new XElement("title", cellvalue));
                            xDoc2.Root.Add(y);
                            xDoc2.Save(filePath);
                            //xDoc2.Root.Add(cellvalue);


                            //  xDoc2.Save(filePath);
                        }
                        else if (dialogResult == DialogResult.No)
                        {
                            ListPage newPage = new ListPage();
                            newPage.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Duplicate title found in list.");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (movieDGV.SelectedCells.Count > 0)
            {
                string    filePath = @"Resources\ListOfMovies.xml";
                XDocument xDoc     = null;
                xDoc = XDocument.Load(filePath);
                var titleQuery = from x in xDoc.Descendants("list")
                                 select x;
                DataTable temp = new DataTable("newTable");
                temp.Columns.Add("Movies");
                Boolean removed = false;

                for (int i = titleQuery.Count() - 1; i >= 0; i--)
                {
                    XElement y = titleQuery.ElementAt(i);
                    if (y.Element("listTitle") != null && y.Element("listTitle").Value.CompareTo(listDGV.SelectedCells[0].Value) == 0)
                    {
                        if (y.Element("title") != null)
                        {
                            if ((y.Element("title").Value.ToString()).CompareTo(movieDGV.SelectedCells[0].Value.ToString()) == 0)
                            {
                                //Console.WriteLine(y.Element("title").Value.ToString());
                                XElement newList = new XElement("list");
                                newList.Add(new XElement("listTitle", y.Element("listTitle").Value.ToString()));
                                xDoc.Root.Add(newList);
                                y.Remove();
                                removed = true;
                            }
                            else
                            {
                                temp.Rows.Add(y.Element("title").Value.ToString());
                            }
                        }
                    }
                }
                movieDGV.DataSource = temp;
                DialogResult dialogResult = MessageBox.Show("Save removal from list?", "Save Changes", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    xDoc.Save(filePath);
                }
                else if (dialogResult == DialogResult.No)
                {
                    ListPage newPage = new ListPage();
                    newPage.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Error: No movie selected to delete.");
            }
        }
Ejemplo n.º 3
0
 private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         ListPage lp = new ListPage();
         lp.Show();
         if (this.GetType() != typeof(Form1))
         {
             this.Hide();
         }
     }
 }
Ejemplo n.º 4
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     if (this.GetType() != typeof(ListPage))
     {
         ListPage lp = new ListPage();
         lp.Show();
         if (this.GetType() != typeof(Form1))
         {
             this.Close();
         }
     }
 }
Ejemplo n.º 5
0
 private void fileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.GetType() != typeof(ListPage))
     {
         ListPage lp = new ListPage();
         lp.Show();
         if (this.GetType() != typeof(Form1))
         {
             this.Hide();
         }
     }
 }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            listMessageBox x = new listMessageBox();

            x.ShowDialog();
            //OnActivated (x.Close)

            if (x.get)
            {
                listDGV.Update();

                ListPage newPage = new ListPage();
                newPage.Show();
                this.Close();
            }
        }
Ejemplo n.º 7
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (listDGV.SelectedCells.Count > 0)
            {
                string    filePath = @"Resources\ListOfMovies.xml";
                string    toDelete = listDGV.SelectedCells[0].Value.ToString();
                Boolean   removed  = false;
                XDocument xDoc     = null;
                xDoc = XDocument.Load(filePath);
                var titleQuery = from x in xDoc.Descendants("list")
                                 select x;

                for (int i = titleQuery.Count() - 1; i >= 0 && !removed; i--)
                {
                    if ((titleQuery.ElementAt(i).Element("listTitle").Value.ToString()).CompareTo(toDelete) == 0)
                    {
                        titleQuery.ElementAt(i).Remove();
                    }
                }

                DialogResult dialogResult = MessageBox.Show("WARNING: This list will be removed permanently.\nContinue?", "Save Changes", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    xDoc.Save(filePath);
                    ListPage newPage = new ListPage();
                    newPage.Show();
                    this.Hide();
                }
                else if (dialogResult == DialogResult.No)
                {
                    ListPage newPage = new ListPage();
                    newPage.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Error: No list selected to delete.");
            }
        }