Ejemplo n.º 1
0
        private void ChangeSettingsxmlLoctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var wizard = new Wizard();

            wizard.ShowDialog();
            var xmlLoction =
                (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Update_Settings", "xmlLoction", null);

            listView1.BeginUpdate();
            listView1.Items.Clear();
            UpdadtListView(xmlLoction);
            listView1.EndUpdate();
        }
Ejemplo n.º 2
0
        private static void FirstRun()
        {
            var wizard = new Wizard();

            wizard.ShowDialog();
        }
Ejemplo n.º 3
0
        private void UpdadtListView(string xmlLoction)
        {
            try
            {
                var doc = XDocument.Load(xmlLoction);
                var i   = 1;
                foreach (var dm in doc.Descendants("tv_item"))
                {
                    var index    = i++;
                    var xElement = dm.Element(@"file_name");
                    if (xElement == null)
                    {
                        continue;
                    }
                    var element = dm.Element(@"destination");
                    if (element == null)
                    {
                        continue;
                    }
                    var item = new ListViewItem(new[]
                    {
                        index.ToString(),
                        xElement.Value,
                        element.Value
                    });
                    listView1.Items.Add(item);
                }
                listView1.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.HeaderSize);
                listView1.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.HeaderSize);
                listView1.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.ColumnContent);
                //listView1.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            catch (Exception exception)
            {
                if (exception.Message.Contains("Could not find file"))
                {
                    var dialogResult = MessageBox.Show(@"Could not find settings file" + Environment.NewLine + @"Create New One?", @"Error", MessageBoxButtons.YesNo);
                    switch (dialogResult)
                    {
                    case DialogResult.Yes:
                    {
                        var refrash =
                            (string)
                            Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Update_Settings", "xmlLoction", null);
                        ExportListViewlToXml(listView1, refrash);
                    }
                    break;

                    case DialogResult.No:
                    {
                        var wizard = new Wizard();
                        wizard.ShowDialog();
                        var refrash =
                            (string)
                            Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Update_Settings", "xmlLoction", null);
                        UpdadtListView(refrash);
                    }
                    break;

                    case DialogResult.None:
                        break;

                    case DialogResult.OK:
                        break;

                    case DialogResult.Cancel:
                        break;

                    case DialogResult.Abort:
                        break;

                    case DialogResult.Retry:
                        break;

                    case DialogResult.Ignore:
                        break;

                    default:
                        Application.Exit();
                        break;
                    }
                }
                else
                {
                    var refrash = (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Update_Settings", "xmlLoction", null);
                    File.Delete(refrash);
                    ExportListViewlToXml(listView1, refrash);
                    UpdadtListView(refrash);
                }
            }
        }