コード例 #1
0
        /// <summary>
        /// Standard post-interceptor for update view.
        /// </summary>
        public static bool UpdateViewPropertyPostInterceptor(IMModelClass Instance, MModelPropertyDefinitor PropDefinitor, object Value)
        {
            var Source = Instance as VisualObject;

            if (Source != null)
            {
                Source.GetDisplayingView().Show(Source);
            }

            return(true);    // Indicates to continue with the property change
        }
コード例 #2
0
        /// <summary>
        /// Sets the Symbol-Format Property/Text-Format Value for the specified Instance and Key.
        /// </summary>
        public static void SetValue(VisualElement Instance, string PropertyKey, object Value)
        {
            object GlobalValue              = null;
            bool   ValuesAreDifferent       = false;
            MModelPropertyDefinitor PropDef = null;
            var StorageKey = PropertyKey;

            if (PropertyKey.StartsWith(TEXTFORMAT_PREFIX))
            {
                var TxtFormat = Instance.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.DefaultSymbolFormat
                                .GetTextFormat((ETextPurpose)Enum.Parse(typeof(ETextPurpose), PropertyKey.Substring(1)));
                GlobalValue        = TxtFormat;
                ValuesAreDifferent = !TxtFormat.IsEquivalentTo((TextFormat)Value);
            }
            else
            {
                VisualElementFormat DefaultFormat = null;

                if (Instance is VisualSymbol)
                {
                    PropDef       = VisualSymbolFormat.__ClassDefinitor.GetPropertyDef(PropertyKey);
                    DefaultFormat = Instance.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.DefaultSymbolFormat;
                }
                else
                {
                    PropDef       = VisualConnectorsFormat.__ClassDefinitor.GetPropertyDef(PropertyKey);
                    DefaultFormat = ((RelationshipVisualRepresentation)Instance.OwnerRepresentation).RepresentedRelationship
                                    .RelationshipDefinitor.Value.DefaultConnectorsFormat;
                }

                GlobalValue        = PropDef.Read(DefaultFormat);
                ValuesAreDifferent = (GlobalValue != Value);
            }

            // Do not do this concatenation for Visual-Symbol to not loose users' (stock) already stored formatting.
            if (Instance is VisualConnector)
            {
                StorageKey = VisualConnector.__ClassDefinitor.TechName + "." + PropertyKey; // Avoids ambiguity between VisualElementFormat descendants
            }
            if (ValuesAreDifferent)
            {
                if (Value != null && PropDef != null && PropDef.IsStoreBoxBased)
                {
                    Value = StoreBox.CreateStoreBoxForType(PropDef.DataType, Value);
                }

                Instance.OwnerRepresentation.CustomFormatValues.AddOrReplace(StorageKey, Value);
            }
            else
            {
                Instance.OwnerRepresentation.CustomFormatValues.Remove(StorageKey);
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the Element-Format Property/Text-Format value for the specified Instance and Key.
        /// </summary>
        public static object GetValue(VisualElement Instance, string PropertyKey)
        {
            object Result = null;
            MModelPropertyDefinitor PropDef       = null;
            VisualElementFormat     DefaultFormat = null;
            var StorageKey = PropertyKey;

            if (!PropertyKey.StartsWith(TEXTFORMAT_PREFIX))
            {
                if (Instance is VisualSymbol)
                {
                    PropDef       = VisualSymbolFormat.__ClassDefinitor.GetPropertyDef(PropertyKey);
                    DefaultFormat = Instance.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.DefaultSymbolFormat;
                }
                else
                {
                    PropDef       = VisualConnectorsFormat.__ClassDefinitor.GetPropertyDef(PropertyKey);
                    DefaultFormat = ((RelationshipVisualRepresentation)Instance.OwnerRepresentation).RepresentedRelationship
                                    .RelationshipDefinitor.Value.DefaultConnectorsFormat;
                }

                // Do not do this concatenation for Visual-Symbol to not loose users' (stock) already stored formatting.
                if (Instance is VisualConnector)
                {
                    StorageKey = VisualConnector.__ClassDefinitor.TechName + "." + PropertyKey; // Avoids ambiguity between VisualElementFormat descendants
                }
            }

            if (Instance.OwnerRepresentation.CustomFormatValues.ContainsKey(StorageKey))
            {
                Result = Instance.OwnerRepresentation.CustomFormatValues[StorageKey];

                if (Result != null && PropDef != null && PropDef.IsStoreBoxBased)
                {
                    Result = ((StoreBoxBase)Result).StoredObject;
                }
            }
            else
            if (PropertyKey.StartsWith(TEXTFORMAT_PREFIX))
            {
                Result = Instance.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.DefaultSymbolFormat
                         .GetTextFormat((ETextPurpose)Enum.Parse(typeof(ETextPurpose), PropertyKey.Substring(1)));
            }
            else
            {
                Result = PropDef.Read(DefaultFormat);
            }

            return(Result);
        }
コード例 #4
0
        /// <summary>
        /// Registers the new supplied model class property definitor.
        /// </summary>
        public void DeclareProperty(MModelPropertyDefinitor PropertyDefinitor)
        {
            if (this.Properties_.ContainsKey(PropertyDefinitor.TechName))
            {
                throw new UsageAnomaly("Property definitor is already registered for the model class.", PropertyDefinitor);
            }

            // Attach this declarator to its owner/class, and for generate qualified-names, plus maybe assemble interceptors.
            PropertyDefinitor.AssignDeclarator(this);

            // Register property
            this.Properties_.Add(PropertyDefinitor.TechName, PropertyDefinitor);
            MModelClassDefinitor.DeclaredMemberDefinitors_.Add(PropertyDefinitor.QualifiedTechName, PropertyDefinitor);
        }
コード例 #5
0
        // -----------------------------------------------------------------------------------------
        public static void Edit(DocumentEngine Engine, MModelPropertyDefinitor Property, Idea TargetIdea)
        {
            Engine.StartCommandVariation("Edit Internal Property");
            DialogOptionsWindow EditingWindow = null;
            var Editor  = new DetailInternalPropertyEditor("Edit internal property...", Property, TargetIdea);
            var Changed = Display.OpenContentDialogWindow <DetailInternalPropertyEditor>(ref EditingWindow, "Edit Property", Editor);

            if (Changed.IsTrue())
            {
                TargetIdea.UpdateVersion();
                Engine.CompleteCommandVariation();
            }
            else
            {
                Engine.DiscardCommandVariation();
            }
        }
コード例 #6
0
 /// <summary>
 /// Notifies all entity subscriptors that a property, identified by the supplied definitor, has changed.
 /// </summary>
 public void NotifyPropertyChange(MModelPropertyDefinitor PropertyDefinitor)
 {
     this.NotifyPropertyChange(PropertyDefinitor.TechName);
 }
コード例 #7
0
        public void AddComparisonRow(MModelPropertyDefinitor PropertyDef, string MergeActionCode,
                                     object SourceValue, object TargetValue, bool IsSymmetric)
        {
            var RowDef = new RowDefinition();

            RowDef.MaxHeight = 24;
            this.PropertiesGrid.RowDefinitions.Add(RowDef);
            var RowIndex = this.PropertiesGrid.RowDefinitions.Count - 1;

            var ExpoProperty = new TextBlock();

            ExpoProperty.Text    = PropertyDef.Name;
            ExpoProperty.Margin  = new Thickness(1);
            ExpoProperty.ToolTip = PropertyDef.Summary;
            Grid.SetRow(ExpoProperty, RowIndex);
            Grid.SetColumn(ExpoProperty, 0);
            this.PropertiesGrid.Children.Add(ExpoProperty);

            if (SourceValue != null)
            {
                var ExpoSourceValue = new TextBlock();
                ExpoSourceValue.Text       = SourceValue.ToStringAlways();
                ExpoSourceValue.Margin     = new Thickness(1);
                ExpoSourceValue.Foreground = Brushes.Blue;
                ExpoSourceValue.Background = Brushes.White;
                Grid.SetRow(ExpoSourceValue, RowIndex);
                Grid.SetColumn(ExpoSourceValue, 1);
                this.PropertiesGrid.Children.Add(ExpoSourceValue);
            }

            /* Cancelled: No property level merge will be provided yet
             * if (MergeActionCode != MergingManager.MERGE_ACTION_NONE
             *  && IsSymmetric)
             * {
             *  var ExpoAction = new Image();
             *  ExpoAction.Source = MergingManager.MergeActions.GetByTechName(MergeActionCode).Get(mac => mac.Pictogram);
             *  ExpoAction.HorizontalAlignment = HorizontalAlignment.Center;
             *  ExpoAction.VerticalAlignment = VerticalAlignment.Top;
             *  Grid.SetRow(ExpoAction, RowIndex);
             *  Grid.SetColumn(ExpoAction, 2);
             *  this.PropertiesGrid.Children.Add(ExpoAction);
             *
             *  var ExpoCheck = new CheckBox();
             *  ExpoCheck.IsChecked = (MergeActionCode == MergingManager.MERGE_ACTION_UPDATE);
             *  ExpoCheck.HorizontalAlignment = HorizontalAlignment.Center;
             *  Grid.SetRow(ExpoCheck, RowIndex);
             *  Grid.SetColumn(ExpoCheck, 3);
             *  this.PropertiesGrid.Children.Add(ExpoCheck);
             * } */

            if (TargetValue != null)
            {
                var ExpoTargetValue = new TextBlock();
                ExpoTargetValue.Text       = TargetValue.ToStringAlways();
                ExpoTargetValue.Margin     = new Thickness(1);
                ExpoTargetValue.Foreground = Brushes.Blue;
                ExpoTargetValue.Background = Brushes.White;
                Grid.SetRow(ExpoTargetValue, RowIndex);
                Grid.SetColumn(ExpoTargetValue, 2);
                this.PropertiesGrid.Children.Add(ExpoTargetValue);
            }
        }
コード例 #8
0
        /// <summary>
        /// Creates and returns a data-grid-column for the supplied model property definitor.
        /// </summary>
        public static DataGridColumn CreateGridColumn(IModelEntity Context, MModelPropertyDefinitor Definitor)
        {
            DataGridColumn Result = null;

            if (Definitor.DeclaringType == typeof(bool))
            {
                var Column = new DataGridCheckBoxColumn();
                var Binder = new Binding(Definitor.TechName);
                Binder.Mode    = BindingMode.TwoWay;
                Column.Binding = Binder;
                Result         = Column;
            }
            else
            if (Definitor.DeclaringType == typeof(ImageSource))
            {
                var Column        = new DataGridTemplateColumn();
                var EditorFactory = new FrameworkElementFactory(typeof(Image));
                var Binder        = new Binding(Definitor.TechName);
                Binder.Mode = BindingMode.TwoWay;
                EditorFactory.SetValue(Image.SourceProperty, Binder);
                var CellTemplate = new DataTemplate();
                CellTemplate.VisualTree = EditorFactory;
                Column.CellTemplate     = CellTemplate;
                Result = Column;
            }
            else
            if (Definitor.ItemsSourceGetter != null)
            {
                var Column = new DataGridComboBoxColumn();
                Column.ItemsSource = Definitor.ItemsSourceGetter(Context);
                if (!Definitor.ItemsSourceSelectedValuePath.IsAbsent())
                {
                    Column.SelectedValuePath = Definitor.ItemsSourceSelectedValuePath;
                }
                if (!Definitor.ItemsSourceDisplayMemberPath.IsAbsent())
                {
                    Column.DisplayMemberPath = Definitor.ItemsSourceDisplayMemberPath;
                }
                var Binder = new Binding(Definitor.TechName);
                Binder.Mode = BindingMode.TwoWay;
                Column.SelectedItemBinding = Binder;
                var ComboStyle = new Style(typeof(ComboBox));
                ComboStyle.Setters.Add(new Setter(ComboBox.FontSizeProperty, DEF_FONT_SIZE));

                /*T This may crash? for edit value (as text)
                 * ComboStyle.Setters.Add(new Setter(ComboBox.IsEditableProperty, true));
                 * ComboStyle.Setters.Add(new Setter(ComboBox.IsReadOnlyProperty, false)); */
                Column.EditingElementStyle = ComboStyle;
                Column.ElementStyle        = ComboStyle;
                Result = Column;
            }
            else
            {
                var Column = new DataGridTextColumn();
                var Binder = new Binding(Definitor.TechName);
                Binder.Mode = (Definitor.DataType == typeof(string) || Definitor.BindingValueConverter != null
                                       ? BindingMode.TwoWay : BindingMode.OneWay);
                Column.Binding             = Binder;
                Column.EditingElementStyle = new Style(typeof(TextBox));
                Column.EditingElementStyle.Setters.Add(new Setter(TextBox.PaddingProperty, new Thickness(0, -1, 0, 0)));
                Column.FontSize = DEF_FONT_SIZE;
                Result          = Column;
            }

            var Entitler = new TextBlock();

            Entitler.Text    = Definitor.Name;
            Entitler.ToolTip = Definitor.Summary;
            Entitler.Tag     = Definitor;

            Result.Header     = Entitler;
            Result.IsReadOnly = !Definitor.IsEditControlled;
            Result.MinWidth   = Math.Max(Definitor.Name.Length, Definitor.DisplayMinLength) * Display.CHAR_PXWIDTH_DEFAULT;

            return(Result);
        }
コード例 #9
0
 public DetailInternalPropertyEditor(string Title, MModelPropertyDefinitor Property, Idea TargetIdea)
     : this()
 {
     this.Property   = Property;
     this.TargetIdea = TargetIdea;
 }
コード例 #10
0
        public static bool FieldDefinitionEdit(TableDefinition OwnerTableDef, IList <FieldDefinition> EditedList, FieldDefinition FieldDef)
        {
            var InstanceController = EntityInstanceController.AssignInstanceController(FieldDef);

            InstanceController.StartEdit();

            var ExtraControls = new List <UIElement>();
            MModelPropertyDefinitor ExposedProperty = null;

            // Declare expositor for hidden field
            var HideInDiagramExpositor = new EntityPropertyExpositor(FieldDefinition.__HideInDiagram.TechName);

            HideInDiagramExpositor.LabelMinWidth = 90;

            // Declare expositor for available values-sources
            var AvailableValuesSourcesExpositor = new EntityPropertyExpositor();

            ExposedProperty = FieldDefinition.__ValuesSource;

            AvailableValuesSourcesExpositor.ExposedProperty = ExposedProperty.TechName;
            AvailableValuesSourcesExpositor.LabelMinWidth   = 90;
            AvailableValuesSourcesExpositor.IsEnabled       = (FieldDef.FieldType is NumberType ||
                                                               FieldDef.FieldType.IsOneOf(DataType.DataTypeTableRecordRef, DataType.DataTypeText)); // Initial setting

            // Declare expositor for available Ideas
            var IdeaReferencingPropertyExpositor = new EntityPropertyExpositor();

            ExposedProperty = FieldDefinition.__IdeaReferencingProperty;

            IdeaReferencingPropertyExpositor.ExposedProperty = ExposedProperty.TechName;
            IdeaReferencingPropertyExpositor.LabelMinWidth   = 90;
            IdeaReferencingPropertyExpositor.SetAvailable(FieldDef.FieldType.IsOneOf(DataType.DataTypeIdeaRef, DataType.DataTypeText));  // Initial setting

            // Declare button for table-definition assignation button
            var TableDefAssignationPanel = new StackPanel();
            // TableDefAssignationPanel.Orientation = Orientation.Horizontal;

            var TableDefAssignSingleRecordCbx = new EntityPropertyExpositor(FieldDefinition.__ContainedTableIsSingleRecord.TechName);

            TableDefAssignSingleRecordCbx.LabelMinWidth = 90;

            /* var TableDefAssignSingleRecordCbx = new CheckBox();
             * TableDefAssignSingleRecordCbx.Content = FieldDefinition.__ContainedTableIsSingleRecord.Name; //  "Is Single-Record";
             * TableDefAssignSingleRecordCbx.ToolTip = FieldDefinition.__ContainedTableIsSingleRecord.Summary;
             * TableDefAssignSingleRecordCbx.FontSize = 8;
             * TableDefAssignSingleRecordCbx.Margin = new Thickness(2); */
            TableDefAssignSingleRecordCbx.IsEnabled = FieldDef.FieldType.IsEqual(DataType.DataTypeTable);

            var TableDefAssignationButtonArea = new StackPanel();

            TableDefAssignationButtonArea.Orientation = Orientation.Horizontal;

            var TableDefAssignationButtonPrefix = new TextBlock();

            TableDefAssignationButtonPrefix.Text          = "Table-Structure";
            TableDefAssignationButtonPrefix.TextAlignment = TextAlignment.Right;
            TableDefAssignationButtonPrefix.FontSize      = 10;
            TableDefAssignationButtonPrefix.Width         = 90;
            TableDefAssignationButtonPrefix.Margin        = new Thickness(0, 6, 2, 2);
            TableDefAssignationButtonPrefix.SetAvailable(FieldDef.FieldType == DataType.DataTypeTable);  // Initial setting

            var TableDefAssignationButton = new PaletteButton("Definition...", Display.GetAppImage("table.png"));

            TableDefAssignationButton.Margin    = new Thickness(2 /*45*/, 2, 2, 2);
            TableDefAssignationButton.IsEnabled = FieldDef.FieldType.IsEqual(DataType.DataTypeTable);

            TableDefAssignationButtonArea.Children.Add(TableDefAssignationButtonPrefix);
            TableDefAssignationButtonArea.Children.Add(TableDefAssignationButton);

            TableDefAssignationButton.Click +=
                ((sender, args) =>
            {
                var DsnName = OwnerTableDef.Name + " - " + FieldDef.Name;

                if (FieldDef.ContainedTableDesignator == null)
                {
                    var ContainedTableDef = new TableDefinition(OwnerTableDef.OwnerDomain, DsnName, DsnName.TextToIdentifier());
                    FieldDef.ContainedTableDesignator = new TableDetailDesignator(Ownership.Create <IdeaDefinition, Idea>(OwnerTableDef.OwnerDomain),
                                                                                  ContainedTableDef, true /* Very important! */,
                                                                                  DsnName, DsnName.TextToIdentifier(), "", null, FieldDef);
                }
                else
                if (FieldDef.ContainedTableDesignator.Name != DsnName)
                {
                    FieldDef.ContainedTableDesignator.Name = DsnName;
                    FieldDef.ContainedTableDesignator.TechName = DsnName.TextToIdentifier();
                }

                var TableDefAssigner = new TableDetailDesignatorStructSubform(FieldDef.ContainedTableDesignator, null, true);

                DialogOptionsWindow TableDesfAssignationWindow = null;          // Do not move outside this lambda

                OwnerTableDef.EditEngine.StartCommandVariation("Edit Field-Definition type assignment of Table-Structure Definition");

                var Response = Display.OpenContentDialogWindow(ref TableDesfAssignationWindow,
                                                               "Table-Structure for Field '" + FieldDef.Name + "'",
                                                               TableDefAssigner);
                OwnerTableDef.EditEngine.CompleteCommandVariation();

                if (Response.IsTrue())
                {
                    FieldDef.ContainedTableDesignator.DeclaringTableDefinition.AlterStructure();
                }
                else
                {
                    OwnerTableDef.EditEngine.Undo();
                }
            });

            // Declare expositor for field-type
            var FieldTypeExpositor = new EntityPropertyExpositor();

            ExposedProperty = FieldDefinition.__FieldType;

            FieldDef.PropertyChanged +=
                ((sender, args) =>
            {
                if (args.PropertyName != FieldDefinition.__FieldType.TechName ||
                    FieldDef.FieldType == null)
                {
                    return;
                }

                // Postcalls to be applied after the load initialization.

                var CanSelectValues = (FieldDef.FieldType is NumberType ||
                                       FieldDef.FieldType.IsOneOf(DataType.DataTypeTableRecordRef, DataType.DataTypeText));
                AvailableValuesSourcesExpositor.PostCall(
                    expo =>
                {
                    expo.SetAvailable(CanSelectValues);

                    if (!CanSelectValues)
                    {
                        FieldDef.ValuesSource = null;
                    }
                });

                var CanSelectIdeas = FieldDef.FieldType.IsOneOf(DataType.DataTypeIdeaRef, DataType.DataTypeText);
                IdeaReferencingPropertyExpositor.PostCall(
                    expo =>
                {
                    expo.SetAvailable(CanSelectIdeas);

                    if (!CanSelectIdeas)
                    {
                        FieldDef.IdeaReferencingProperty = null;
                    }
                });

                var CanAssignTableDef = FieldDef.FieldType.IsEqual(DataType.DataTypeTable);
                TableDefAssignationButton.PostCall(
                    ctrl =>
                {
                    // ctrl.SetAvailable(CanAssignTableDef);
                    ctrl.IsEnabled = CanAssignTableDef;

                    /* Cancelled (better is to save user's data)...
                     * if (!CanAssignTableDef)
                     * {
                     *  FieldDef.DeclaringTableDefinition = null;
                     *  FieldDef.DeclaringTableDefIsOwned = false;
                     * } */
                });
                TableDefAssignSingleRecordCbx.PostCall(ctrl => ctrl.IsEnabled = CanAssignTableDef);
            });

            FieldTypeExpositor.ExposedProperty = ExposedProperty.TechName;
            FieldTypeExpositor.LabelMinWidth   = 90;

            // Add the just created extra controls
            ExtraControls.Add(HideInDiagramExpositor);
            ExtraControls.Add(FieldTypeExpositor);
            ExtraControls.Add(AvailableValuesSourcesExpositor);
            ExtraControls.Add(IdeaReferencingPropertyExpositor);

            TableDefAssignationPanel.Children.Add(TableDefAssignationButtonArea);
            // POSTPONED: TableDefAssignationPanel.Children.Add(TableDefAssignSingleRecordCbx);
            ExtraControls.Add(TableDefAssignationPanel);

            var Result = InstanceController.Edit(Display.CreateEditPanel(FieldDef, null, true, null, null, true, false, false, true, ExtraControls.ToArray()),
                                                 "Edit Field Definition - " + FieldDef.ToString(), InitialWidth: 700).IsTrue();

            return(Result);
        }
コード例 #11
0
 public RichTextEditor(IModelEntity SourceEntity, MModelPropertyDefinitor SourceProperty)
     : this()
 {
     this.SourceEntity   = SourceEntity;
     this.SourceProperty = SourceProperty;
 }
コード例 #12
0
        public static FrameworkElement CreateRichTextBoxPresenter(IModelEntity SourceEntity, MModelPropertyDefinitor SourceProperty)
        {
            if (SourceEntity == null || SourceProperty.DataType != typeof(string))
            {
                throw new UsageAnomaly("A valid source-entity and a string source-property must be provided to create a Rich-Text Editor.");
            }

            var RichEditor = new RichTextEditor(SourceEntity, SourceProperty);

            return(RichEditor);
        }