Exemplo n.º 1
0
 public SnippetListViewItem(SnippetToolboxDataItem item)
     : base(item.InternalDisplayName)
 {
     if (base.Text.Length == 0)
     {
         base.Text = "(Unnamed Snippet) " + item.DisplayName;
     }
     this._item = item;
 }
Exemplo n.º 2
0
 public void AddSnippet(SnippetToolboxDataItem item)
 {
     ListViewItem item2 = new SnippetListViewItem(item);
     item2.Checked = true;
     this._snippetListView.Items.Add(item2);
 }
Exemplo n.º 3
0
 protected internal override bool OnNext()
 {
     string text = this._fileNameTextBox.Text;
     if (text.IndexOfAny(Path.InvalidPathChars) != -1)
     {
         MessageBox.Show(base.WizardForm, "The specified filename contains invalid characters.", "Import Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return false;
     }
     if (!File.Exists(text))
     {
         MessageBox.Show(base.WizardForm, "The file '" + text + "' does not exist", "Import Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return false;
     }
     bool flag = false;
     if (string.Compare(this._filename, text, true, CultureInfo.InvariantCulture) != 0)
     {
         ListSnippetsWizardPanel snippetList = ((ImportSnippetsWizard) base.WizardForm).SnippetList;
         snippetList.ClearSnippets();
         FileStream input = null;
         try
         {
             input = new FileStream(this._fileNameTextBox.Text, FileMode.Open, FileAccess.Read, FileShare.Read);
             XmlTextReader reader = new XmlTextReader(input);
             reader.MoveToContent();
             if (reader.Name == "Snippets")
             {
                 while (reader.Read())
                 {
                     if (reader.Name == "Snippet")
                     {
                         string displayName = string.Empty;
                         if (reader.HasAttributes)
                         {
                             displayName = reader.GetAttribute("name");
                         }
                         SnippetToolboxDataItem item = new SnippetToolboxDataItem(reader.ReadString(), displayName);
                         snippetList.AddSnippet(item);
                     }
                 }
                 this._filename = text;
             }
             else
             {
                 MessageBox.Show(base.WizardForm, "The specified file is not in a valid format.", "Import Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                 flag = true;
             }
         }
         catch
         {
             MessageBox.Show(base.WizardForm, "The specified file could not be read.", "Import Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
             flag = true;
         }
         finally
         {
             if (input != null)
             {
                 input.Close();
             }
         }
     }
     return !flag;
 }