Ejemplo n.º 1
0
        private void OnWorkerMethodComplete(string message)
        {
            pbw.Dispatcher.BeginInvoke(
            new Action(
            delegate()
            {
                    if (!message.Contains(":"))
                    {
                        pbw.Close();
                        NewForm nf = CenterContent.Children[0] as NewForm;
                        nf.tbxVideo.Text = string.Empty;
                        nf.tbFilename.Text = string.Empty;
                        nf.tbxDestination.Text = string.Empty;
                        foreach (var item in nf.stackContent.Children)
                        {
                            StackPanel spMain = item as StackPanel;
                            XmlNodeFormatter childTag = new XmlNodeFormatter(((TextBox)spMain.Children[0]).Text);
                            int count = spMain.Children.Count;
                            WrapPanel wpFirst = spMain.Children[1] as WrapPanel;
                            WrapPanel wpSecond = spMain.Children[2] as WrapPanel;
                            WrapPanel wpThird = spMain.Children[3] as WrapPanel;

                            foreach (var content in wpFirst.Children)
                            {
                                if (content.GetType().Name == "StackPanel")
                                {
                                    StackPanel sp = content as StackPanel;
                                    TextBox tb = sp.Children[1] as TextBox;
                                    tb.Text = "";
                                }
                            }

                            foreach (var content in wpSecond.Children)
                            {
                                Border brd = content as Border;
                                ScrollViewer sv = brd.Child as ScrollViewer;
                                StackPanel spVertical = sv.Content as StackPanel;
                                StackPanel spHorizontal = spVertical.Children[0] as StackPanel;
                                TextBlock tbl = spHorizontal.Children[0] as TextBlock;
                                if (spVertical.Children.Count >= 2)
                                {
                                    for (int i = 1; i < spVertical.Children.Count; i++)
                                    {
                                        StackPanel hStack = spVertical.Children[i] as StackPanel;
                                        TextBox tbItem = hStack.Children[0] as TextBox;
                                        tbItem.Text = "";
                                    }
                                }
                            }

                            if (wpThird.Children.Count > 0)
                            {
                                foreach (var content in wpThird.Children)
                                {
                                    if (content.GetType().Name == "StackPanel")
                                    {
                                        StackPanel sp = content as StackPanel;
                                        ComboBox tb = sp.Children[1] as ComboBox;
                                        tb.SelectedItem = null;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        pbw.Close();
                        MessageBox.Show(message, "File Exits", MessageBoxButton.OKCancel);
                    }
            }
            ));
        }
Ejemplo n.º 2
0
 public void AddChildNode(XmlNodeFormatter childNode)
 {
     childNodes.Add(childNode);
 }
Ejemplo n.º 3
0
        void controlheader_SaveForm(object sender, EventArgs e)
        {
            XmlNodeFormatter xmlTag = new XmlNodeFormatter("?xml", "", new List<string>(new string[] { "version=\"1.0\"", "encoding=\"utf-8\"" }));

            XmlNodeFormatter parentTag = new XmlNodeFormatter("Metadata");
            NewForm nf = CenterContent.Children[0] as NewForm;
            if (string.IsNullOrEmpty(nf.tbxVideo.Text) || string.IsNullOrEmpty(nf.tbxDestination.Text))
            {
                MessageBox.Show("All Form fields need to be filled", "Invalid Form", MessageBoxButton.OK);
                return;
            }

            foreach (var item in nf.stackContent.Children)
            {
                StackPanel spMain = item as StackPanel;
                XmlNodeFormatter childTag = new XmlNodeFormatter(((TextBox)spMain.Children[0]).Text);
                int count = spMain.Children.Count;
                WrapPanel wpFirst = spMain.Children[1] as WrapPanel;
                WrapPanel wpSecond = spMain.Children[2] as WrapPanel;
                WrapPanel wpThird = spMain.Children[3] as WrapPanel;

                XmlNodeFormatter uidTag = new XmlNodeFormatter("UUID", Guid.NewGuid().ToString(), new List<string>());
                XmlNodeFormatter fileTag = new XmlNodeFormatter("Filename", nf.tbxVideo.Text, new List<string>());
                childTag.AddChildNode(uidTag);
                childTag.AddChildNode(fileTag);
                foreach (var content in wpFirst.Children)
                {
                    if (content.GetType().Name == "StackPanel")
                    {
                        StackPanel sp = content as StackPanel;
                        TextBlock tbl = sp.Children[0] as TextBlock;
                        TextBox tb = sp.Children[1] as TextBox;
                        if (string.IsNullOrEmpty(tb.Text))
                        {
                            MessageBox.Show("All Form fields need to be filled", "Invalid Form", MessageBoxButton.OK);
                            return;

                        }
                        else
                        {
                            string element = tbl.Text.Replace(" ", "_");
                            XmlNodeFormatter elementdTag = new XmlNodeFormatter(element, tb.Text, new List<string>());
                            childTag.AddChildNode(elementdTag);
                        }
                    }
                }

                foreach (var content in wpSecond.Children)
                {
                    Border brd = content as Border;
                    ScrollViewer sv = brd.Child as ScrollViewer;
                    StackPanel spVertical = sv.Content as StackPanel;
                    StackPanel spHorizontal = spVertical.Children[0] as StackPanel;
                    TextBlock tbl = spHorizontal.Children[0] as TextBlock;
                    if (spVertical.Children.Count < 2)
                    {
                        MessageBox.Show("Need atleast one item in list", "Invalid Form", MessageBoxButton.OKCancel);
                        return;
                    }
                    else
                    {
                        string listName = tbl.Text.Replace(" ", "_"); ;
                        XmlNodeFormatter listTag = new XmlNodeFormatter(listName + "_List");
                        for (int i = 1; i < spVertical.Children.Count; i++)
                        {
                            StackPanel hStack = spVertical.Children[i] as StackPanel;
                            TextBox tbItem = hStack.Children[0] as TextBox;
                            if (string.IsNullOrEmpty(tbItem.Text))
                            {
                                MessageBox.Show("All Form fields need to be filled", "Invalid Form", MessageBoxButton.OKCancel);
                                return;
                            }
                            else
                            {
                                XmlNodeFormatter listChildTag = new XmlNodeFormatter(listName, tbItem.Text, new List<string>());
                                listTag.AddChildNode(listChildTag);
                            }
                        }
                        childTag.AddChildNode(listTag);
                    }
                }

                //**************************************************************************
                if (wpThird.Children.Count > 0)
                {
                    foreach (var content in wpThird.Children)
                    {
                        if (content.GetType().Name == "StackPanel")
                        {
                            StackPanel sp = content as StackPanel;
                            TextBlock tbl = sp.Children[0] as TextBlock;
                            ComboBox tb = sp.Children[1] as ComboBox;
                            if (tb.SelectedItem == null)
                            {
                                MessageBox.Show("All Form fields need to be filled", "Invalid Form", MessageBoxButton.OK);
                                return;

                            }
                            else
                            {
                                string element = tbl.Text.Replace(" ", "_");
                                XmlNodeFormatter elementdTag = new XmlNodeFormatter(element, tb.SelectedValue.ToString(), new List<string>());
                                childTag.AddChildNode(elementdTag);
                            }
                        }
                    }
                }
                //******************************************************************************************
                parentTag.AddChildNode(childTag);
                xmlTag.AddChildNode(parentTag);
            }

            XDocument doc = XDocument.Parse(xmlTag.ToString());
            try
            {
                OnWorkerMethodStart(nf, doc);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception Occured", MessageBoxButton.OKCancel);
                return;
            }
        }