Exemplo n.º 1
0
        public bool Apply()
        {
            if (this.AssociatedImportWidget != null)
            {
                var ImportData = this.AssociatedImportWidget.Tag as Tuple <TableDefinition, List <List <object> > >;

                if (ImportData != null)
                {
                    this.SourceDesignator.TableDefIsOwned          = true;
                    this.SourceDesignator.DeclaringTableDefinition = ImportData.Item1;

                    return(true);
                }
            }

            TableDefinition NewTableDef = null;

            // IMPORTANT: Do not evaluate [Any-Radio-Button].IsChecked because state changes at load/unload of the tab.
            if (this.SourceDesignator.TableDefIsOwned)
            {
                NewTableDef = this.OwnedTableDefinition;
            }
            else
            {
                NewTableDef = this.CbxReferencedTableStruct.SelectedItem as TableDefinition;
            }

            // No?
            this.RelatedDomain.TableDefinitions.AddNew(NewTableDef);

            bool Proceed = true;

            if (this.InitialTableDefinitionClone != null)
            {
                Proceed = TableDefinitionMaintainer.ApplyTableDefStructureAlter(NewTableDef,
                                                                                this.InitialTableDefinitionClone,
                                                                                true.IntoEnumerable().Cast <object>());
            }

            // Must be applied last
            if (Proceed)
            {
                this.SourceDesignator.DeclaringTableDefinition = NewTableDef;
            }

            return(Proceed);
        }
Exemplo n.º 2
0
        private void CbxCopySourceTableStruct_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var CloningSource = this.CbxCopySourceTableStruct.SelectedItem as TableDefinition;

            if (CloningSource == null)
            {
                return;
            }

            this.OwnedTableDefinition      = CloningSource.CreateClone(ECloneOperationScope.Deep, null);
            this.OwnedTableDefinition.Name = this.SourceDesignator.AssignerOwnerName + " - " + this.SourceDesignator.Name;
            // Old: "Clone of " + this.OwnedTableDefinition.Name + " - " + DateTime.Now.ToString("yyyyMMddhhmmss"); ;
            this.OwnedTableDefinition.TechName = this.OwnedTableDefinition.Name.TextToIdentifier();

            this.FrmTableStructEditor.SetSourceTableDef(this.OwnedTableDefinition);
            TableDefinitionMaintainer.SetFieldDefinitionsMaintainer(this.FrmTableStructEditor.FieldsMaintainer);    // Don't forget to assign the new maintainer
            this.FrmTableStructEditor.FieldsMaintainer.VisualControl.CanEditItemsDirectly = false;

            this.CbxCopySourceTableStruct.SetVisible(false, false);
            this.CbxCopySourceTableStruct.SelectedItem = null;
        }
Exemplo n.º 3
0
        public TableDetailDesignatorStructSubform(TableDetailDesignator SourceDesignator, FrameworkElement AssociatedImportWidget = null, bool DirectApply = false)
            : this()
        {
            this.SourceDesignator       = SourceDesignator;
            this.AssociatedImportWidget = AssociatedImportWidget;

            this.DirectApply = DirectApply;

            this.PnlButtons.SetVisible(DirectApply);

            // Clone for detect changes
            this.InitialTableDefinitionClone = (this.SourceDesignator.DeclaringTableDefinition == null ? null :
                                                this.SourceDesignator.DeclaringTableDefinition.CreateClone(ECloneOperationScope.DeepAndEquivalent, null));

            this.RelatedDomain = this.SourceDesignator.OwnerDomain;

            this.AvailabeTableStructures = this.RelatedDomain.TableDefinitions.Where(tdef => tdef.Alterability != EAlterability.System);;

            if (this.SourceDesignator.TableDefIsOwned)
            {
                this.OwnedTableDefinition = this.SourceDesignator.DeclaringTableDefinition;
            }

            if (this.OwnedTableDefinition == null)
            {
                var LocalName = this.SourceDesignator.AssignerOwnerName + " - " + this.SourceDesignator.Name;
                this.OwnedTableDefinition = new TableDefinition(this.RelatedDomain, LocalName, LocalName.TextToIdentifier());
                this.OwnedTableDefinition.Alterability = EAlterability.Definition;  // This prevents the table-def to be edited from the Domain.
            }

            this.FrmTableStructEditor.SetSourceTableDef(this.OwnedTableDefinition);
            TableDefinitionMaintainer.SetFieldDefinitionsMaintainer(this.FrmTableStructEditor.FieldsMaintainer);    // Don't forget to assign the new maintainer
            this.FrmTableStructEditor.FieldsMaintainer.VisualControl.CanEditItemsDirectly = false;

            this.CbxCopySourceTableStruct.ItemsSource = this.AvailabeTableStructures;

            if (this.AvailabeTableStructures != null && this.AvailabeTableStructures.Any())
            {
                this.CbxReferencedTableStruct.ItemsSource = this.AvailabeTableStructures;

                if (this.SourceDesignator.DeclaringTableDefinition != null &&
                    this.AvailabeTableStructures.Contains(this.SourceDesignator.DeclaringTableDefinition) &&
                    !this.SourceDesignator.TableDefIsOwned)
                {
                    this.CbxReferencedTableStruct.SelectedItem = this.SourceDesignator.DeclaringTableDefinition;
                }
                else
                {
                    this.CbxReferencedTableStruct.SelectedItem = this.AvailabeTableStructures.First();
                }
            }
            else
            {
                this.RbReferenced.IsEnabled             = false;
                this.TxbReferencedTableStruct.IsEnabled = false;
                this.CbxReferencedTableStruct.IsEnabled = false;
            }

            if (this.SourceDesignator.TableDefIsOwned || !this.RbReferenced.IsEnabled)
            {
                this.RbOwned.IsChecked = true;
            }
            else
            {
                this.RbReferenced.IsChecked = true;
            }
        }