Ejemplo n.º 1
0
            protected override void OnClick(DataGridViewCellEventArgs e)
            {
                DataGridViewRow row      = this.OwningRow;
                DataGridView    view     = row.DataGridView;
                string          filename = row.Cells[2].Value as string;

                if (!string.IsNullOrEmpty(filename))
                {
                    Uri uri = new Uri(filename);
                    if (uri.IsFile)
                    {
                        var path = uri.LocalPath;
                        fd.InitialDirectory = System.IO.Path.GetDirectoryName(path);
                        fd.FileName         = System.IO.Path.GetFileName(path);
                    }
                }
                else
                {
                    fd.FileName = "";
                }
                fd.Multiselect = false;
                if (fd.ShowDialog(this.DataGridView.FindForm()) == DialogResult.OK)
                {
                    if (SchemaDialogCommand.ValidateSchema(row, fd.FileName) != null)
                    {
                        row.Cells[2].Value = fd.FileName;
                    }
                }
            }
Ejemplo n.º 2
0
 public static XmlSchema ValidateSchema(DataGridViewRow row, string filename)
 {
     try {
         XmlSchema schema = SchemaDialogCommand.LoadSchema(filename); // make sure we can load it!
         return(schema);
     } catch (Exception ex) {
         MessageBox.Show(string.Format(SR.SchemaLoadError, filename, ex.Message),
                         SR.SchemaError, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
 }
Ejemplo n.º 3
0
 void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (e.ColumnIndex == 2)
     {
         DataGridViewRow row      = this.dataGridView1.Rows[e.RowIndex];
         string          filename = e.FormattedValue as string;
         if (string.IsNullOrEmpty(filename))
         {
             return;
         }
         if (SchemaDialogCommand.ValidateSchema(row, filename) == null)
         {
             e.Cancel = true;
         }
     }
 }
Ejemplo n.º 4
0
        public SchemaDialogEditCommand(DataGridView view, List <SchemaItem> items, DataGridViewRow row, string newSchema)
            : base(view, items)
        {
            this.newSchema = newSchema;
            this.row       = row;
            SchemaItem item = row.Tag as SchemaItem;

            if (item != null)
            {
                oldSchema    = item.Filename;
                oldNamespace = item.TargetNamespace;
                schema       = item.Schema;
            }
            // should succeed because previous code already validated the filename.
            schema       = SchemaDialogCommand.LoadSchema(newSchema);
            newNamespace = schema == null ? "" : schema.TargetNamespace;
            index        = row.Index;
        }