private void RebindDataSource(ApplicationRoleSchemaList newSource)
        {
            this.applicationRoleSchemaListBindingSource.RaiseListChangedEvents = false;
            this.applicationRoleSchemaListBindingSource.EndEdit();
            this.applicationRoleSchemaListBindingSource.DataSource = null;

            _currentSource = newSource;

            this.applicationRoleSchemaListBindingSource.DataSource             = _currentSource;
            this.applicationRoleSchemaListBindingSource.RaiseListChangedEvents = true;
            this.applicationRoleSchemaListBindingSource.ResetBindings(false);

            this.EditableDataListView.Select();
        }
        public void Create()
        {
            if (!SaveCurrentSource())
            {
                return;
            }

            var result = new ApplicationRoleSchemaList();

            RebindDataSource(result);

            _currentFilePath = string.Empty;

            this.Text = "New Role Schema";
        }
        private void ApplicationRoleSchemaListForm_Load(object sender, EventArgs e)
        {
            if (_currentSource == null)
            {
                _currentSource = new ApplicationRoleSchemaList();
                this.Text      = "New Role Schema";
            }
            else
            {
                this.Text = "Role Schema: " + _currentFilePath;
            }

            this.applicationRoleSchemaListBindingSource.DataSource = _currentSource;

            ((SimpleDropSink)this.EditableDataListView.DropSink).AcceptExternal      = false;
            ((SimpleDropSink)this.EditableDataListView.DropSink).CanDropOnBackground = false;
            ((SimpleDropSink)this.EditableDataListView.DropSink).CanDropOnItem       = false;
            ((SimpleDropSink)this.EditableDataListView.DropSink).CanDropOnSubItem    = false;
            ((SimpleDropSink)this.EditableDataListView.DropSink).EnableFeedback      = true;
            ((SimpleDropSink)this.EditableDataListView.DropSink).CanDropBetween      = true;
        }
 public ApplicationRoleSchemaListForm(ApplicationRoleSchemaList objectToEdit, string filePath)
 {
     InitializeComponent();
     _currentSource   = objectToEdit;
     _currentFilePath = filePath;
 }
Exemple #5
0
        private void OpenFile(object sender, EventArgs e)
        {
            string filePath = string.Empty;

            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                openFileDialog.Filter           = string.Format("{0} (*.{1})|*.{1}|All Files (*.*)|*.*",
                                                                "xml files", "xml");
                if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    filePath = openFileDialog.FileName;
                }
            }

            if (filePath.IsNullOrWhiteSpace())
            {
                return;
            }

            foreach (var child in MdiChildren)
            {
                if (child is IStandardActionForm && ((IStandardActionForm)child).CurrentFilePath.Trim().ToLower()
                    == filePath.Trim().ToLower())
                {
                    child.Activate();
                    return;
                }
            }

            Form childForm = null;

            try
            {
                var result = new ApplicationRoleSchemaList();
                result.LoadXmlFile(filePath);
                childForm = new ApplicationRoleSchemaListForm(result, filePath);
            }
            catch (Exception) { }

            if (childForm == null)
            {
                try
                {
                    var result = new DbSchema();
                    result.LoadXmlFile(filePath);
                    childForm = new DbSchemaForm(filePath, result);
                }
                catch (Exception) { }
            }

            if (childForm == null)
            {
                try
                {
                    var result = new SqlRepository();
                    result.LoadFile(filePath);
                    childForm = new SqlDictionaryForm(result, filePath);
                }
                catch (Exception) { }
            }

            if (childForm == null)
            {
                MessageBox.Show("File is not recognized as any Apskaita5 cofig file.", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            childForm.MdiParent = this;
            childForm.Show();
        }