// ---------------------------------------------------------------------------------------------------------------------------------------------------------
        public static OperationResult <VisualComplement> CreateComplement(Idea DestinationComposite, SimplePresentationElement Kind, View TargetView,
                                                                          VisualSymbol TargetSymbol, Point Position, double InitialWidth = 0.0)
        {
            General.ContractRequiresNotNull(DestinationComposite, Kind, TargetView);

            if (DestinationComposite.IdeaDefinitor.CompositeContentDomain == null)
            {
                return(OperationResult.Failure <VisualComplement>("Destination Container doest not accept Composite-Content.", DestinationComposite));
            }

            DestinationComposite.EditEngine.StartCommandVariation("Create Complement");

            VisualComplement NewComplement = null;

            var Owner = (Kind.TechName.IsOneOf(Domain.ComplementDefCallout.TechName, Domain.ComplementDefQuote.TechName,
                                               Domain.ComplementDefGroupRegion.TechName, Domain.ComplementDefGroupLine.TechName)
                         ? Ownership.Create <View, VisualSymbol>(TargetSymbol)
                         : Ownership.Create <View, VisualSymbol>(TargetView));

            NewComplement = new VisualComplement(Kind, Owner, Position, InitialWidth);

            if (!Owner.IsGlobal && TargetSymbol != null)
            {
                TargetSymbol.AddComplement(NewComplement);
            }

            TargetView.PutComplement(NewComplement);

            DestinationComposite.UpdateVersion();
            DestinationComposite.EditEngine.CompleteCommandVariation();

            return(OperationResult.Success(NewComplement));
        }
Example #2
0
        private static void ModelRev6_UpdateStorage(VisualComplement Target)
        {
            if (Target.IsComplementImage)
            {
                Target.SetPropertyField(VisualComplement.PROP_FIELD_IMAGE, Target.Content);
            }
            else
            if (Target.Kind.TechName.IsOneOf(Domain.ComplementDefText.TechName, Domain.ComplementDefNote.TechName, Domain.ComplementDefStamp.TechName))
            {
                var Register = Target.Content as Tuple <string, TextFormat, StoreBox <Brush>, StoreBox <Brush> >;
                if (Register != null)
                {
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_TEXT, Register.Item1);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_TEXTFORMAT, Register.Item2);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_FOREGROUND, Register.Item3.Value);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_BACKGROUND, Register.Item4.Value);
                }
            }
            else
            if (Target.IsComplementCallout || Target.IsComplementQuote)
            {
                var Register = Target.Content as Tuple <string, TextFormat, StoreBox <Brush>, StoreBox <Brush>, EVecinityQuadrant, double, double>;
                if (Register != null)
                {
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_TEXT, Register.Item1);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_TEXTFORMAT, Register.Item2);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_FOREGROUND, Register.Item3.Value);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_BACKGROUND, Register.Item4.Value);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_QUADRANT, Register.Item5);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_OFFSETX, Register.Item6);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_OFFSETY, Register.Item7);
                }
            }
            else
            if (Target.Kind.TechName.IsOneOf(Domain.ComplementDefInfoCard.TechName, Domain.ComplementDefLegend.TechName,
                                             Domain.ComplementDefGroupRegion.TechName))
            {
                var Register = Target.Content as Tuple <StoreBox <Brush>, StoreBox <Brush> >;
                if (Register != null)
                {
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_FOREGROUND, Register.Item1.Value);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_BACKGROUND, Register.Item2.Value);
                }
            }
            else
            if (Target.Kind.TechName == Domain.ComplementDefGroupLine.TechName)
            {
                var Register = Target.Content as Tuple <StoreBox <Brush>, StoreBox <Brush>, Orientation>;
                if (Register != null)
                {
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_FOREGROUND, Register.Item1.Value);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_BACKGROUND, Register.Item2.Value);
                    Target.SetPropertyField(VisualComplement.PROP_FIELD_ORIENTATION, Register.Item3);
                }
            }

            Target.Content = null;  // Field deprecated
        }
Example #3
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Creates and returns a Relationship Visual Representation shortcut (as Main Central/Main Symbol)
        /// to the target Relationship, for the specified target view, center position, symbol and connectors format,
        /// plus indication as a shortcut.
        /// </summary>
        public static RelationshipVisualRepresentation CreateRelationshipVisualRepresentation(Relationship Target,
                                                                                              View TargetView,
                                                                                              Point CenterPosition,
                                                                                              bool AsShortcut = false)
        {
            var Representator = new RelationshipVisualRepresentation(Target, TargetView)
            {
                IsShortcut = AsShortcut
            };

            var Width  = Target.RelationshipDefinitor.Value.DefaultSymbolFormat.InitialWidth.SubstituteFor(0, ProductDirector.DefaultRelationshipCentralSymbolSize.Width);
            var Height = Target.RelationshipDefinitor.Value.DefaultSymbolFormat.InitialHeight.SubstituteFor(0, ProductDirector.DefaultRelationshipCentralSymbolSize.Height);

            // Notice that "hidden" symbols are not adjusted/snapped to grid
            if (TargetView.SnapToGrid && !(Target.RelationshipDefinitor.Value.IsSimple && Target.RelationshipDefinitor.Value.HideCentralSymbolWhenSimple))
            {
                var SnappedArea = TargetView.GetGridSnappedArea(CenterPosition, Width, Height);

                if (!Target.RelationshipDefinitor.Value.DefaultSymbolFormat.HasFixedWidth)
                {
                    Width = SnappedArea.Width;
                }

                if (!Target.RelationshipDefinitor.Value.DefaultSymbolFormat.HasFixedWidth)
                {
                    Height = SnappedArea.Height;
                }

                CenterPosition = new Point(SnappedArea.X + SnappedArea.Width / 2.0, SnappedArea.Y + SnappedArea.Height / 2.0);
            }

            var Body = new VisualShape(Representator, EVisualRepresentationPart.RelationshipCentralSymbol, CenterPosition, Width, Height)
            {
                IsAutoPositionable = true // Very important (for users) to work more easily
            };

            Representator.AddVisualPart(Body);

            // Append possible Group Region Complement
            if (Target.IdeaDefinitor.HasGroupRegion)
            {
                var Params = VisualComplement.GetGroupRegionInitialParams(Body);

                ComplementCreationCommand.CreateComplement(TargetView.OwnerCompositeContainer, Domain.ComplementDefGroupRegion, TargetView, Body, Params.Item1, Params.Item2);
            }

            // Append possible Group Line Complement
            if (Target.IdeaDefinitor.HasGroupLine)
            {
                ComplementCreationCommand.CreateComplement(TargetView.OwnerCompositeContainer, Domain.ComplementDefGroupLine, TargetView, Body, VisualComplement.GetGroupLineInitialPosition(Body));
            }

            // NOTE: This does not render because the connectors are expected to be added later.

            return(Representator);
        }
        public VisualComplement AppendClone(View TargetView, VisualComplement OriginalComplement,
                                            double DeltaX, double DeltaY)
        {
            var NewPosition = new Point(OriginalComplement.BaseCenter.X + DeltaX,
                                        OriginalComplement.BaseCenter.Y + DeltaY);

            var Result = OriginalComplement.GenerateIndependentDuplicate(Ownership.Create <View, VisualSymbol>(TargetView));

            Result.BaseCenter = NewPosition;

            TargetView.PutComplement(Result);

            return(Result);
        }
Example #5
0
        public void CommandProperties_Executed(object sender, ExecutedRoutedEventArgs args)
        {
            var Eng = (CompositionEngine)WorkspaceDirector.ActiveDocumentEngine;

            if (Eng == null || Eng.CurrentView == null || !Eng.CurrentView.SelectedObjects.Any())
            {
                return;
            }

            var Selection = Eng.CurrentView.SelectedObjects.First();

            if (Selection is VisualElement)
            {
                Eng.CurrentView.EditPropertiesOfVisualRepresentation(((VisualElement)Selection).OwnerRepresentation);
            }
            else
            if (Selection is VisualComplement)
            {
                VisualComplement.Edit(Selection as VisualComplement);
            }
        }
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        private static void DefineContextMenuOptions()
        {
            // Views....................................................................................................
            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Go to Parent", "GoToParent", "Goes back to the parent Composite-Content View.", Display.GetAppImage("page_view_back.png")),
                                               (target, vexpo) => target.OwnerCompositeContainer.OwnerContainer != null,
                                               (target) => target.Engine.ShowCompositeAsView(target.OwnerCompositeContainer.OwnerContainer)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Go to View", "GoToView", "Goes to the pointed Composite-Content View.", Display.GetAppImage("page_view.png")),
                                               (target, vexpo) => (target == target.Engine.CurrentView ? (bool?)null : true),
                                               (target) => target.Engine.ShowView(target)));

            ContextMenuOptionsForViews.Add(null);   // Separator

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Paste", "Paste", "Paste Clipboard content.", Display.GetAppImage("paste_plain.png")),
                                               (target, vexpo) => (vexpo != target.Presenter) ? (bool?)null : target.Engine.ClipboardHasPasteableContent(),
                                               (target) => target.Engine.ClipboardPaste(target, false, CurrentMousePosition)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Paste Shortcut", "PasteShortcut", "Paste copied Ideas as Shortcut.", Display.GetAppImage("paste_shortcut.png")),
                                               (target, vexpo) => (vexpo != target.Presenter) ? (bool?)null : General.Execute(() => Clipboard.ContainsData(CompositionEngine.IdeaTransferFormat.Name),
                                                                                                                              "Cannot access Windows Clipboard!").Result,
                                               (target) => target.Engine.ClipboardPaste(target, true)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Select All", "SelectAll", "Sellect all visual objects of the View.", Display.GetAppImage("view_select_all.png")),
                                               (target, vexpo) => (vexpo != target.Presenter) ? (bool?)null : true,
                                               (target) => target.SelectMultipleObjects()));

            ContextMenuOptionsForViews.Add(null);   // Separator

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Remove", "RemoveView", "Removes the entire View.", Display.GetAppImage("delete.png")),
                                               (target, vexpo) => (!ProductDirector.DocumentVisualizerControl.GetAllViews(target.Engine.TargetComposition).CountsAtLeast(2)
                                                 ? (bool?)null : target.OwnerCompositeContainer != target.OwnerCompositeContainer.OwnerComposition),
                                               (target) => target.Engine.RemoveCompositeView(target)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("View Properties", "ViewProperties", "Edits the properties of the View.", Display.GetAppImage("page_white_edit.png")),
                                               (target, vexpo) => true,
                                               (target) => CompositionEngine.EditViewProperties(target)));

            // Symbols...................................................................................................
            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Show/Hide Details", "ShowHideDetails", "Open/Close the symbol Details poster.", Display.GetAppImage("detail_poster.png")),
                                                       (target, vexpo) => (vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.Manager.CommandSwitchDetails_Execution(null); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Convert", "Convert", "Converts the Idea, as based on other Idea Definition type.", Display.GetAppImage("wand_convert.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ConvertIdeasToAlternateDefinition(Eng.CurrentView.SelectedRepresentations.Select(vrep => vrep.RepresentedIdea)); }));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Expand/Collapse Related Origin Ideas", "ExpandCollapseRelatedOriginIdeas", "Expand/Collapse the Symbol supertree of Related Originating Ideas.", Display.GetAppImage("rel_sources.png")),
                                                       (target, vexpo) => ((vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.OriginRepresentations.Any()),
                                                       (target) => target.GetDisplayingView().Manipulator.SwitchRelated(target, false)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Expand/Collapse Related Target Ideas", "ExpandCollapseRelatedTargetIdeas", "Expand/Collapse the Symbol subtree of Related Targeted Ideas.", Display.GetAppImage("rel_targets.png")),
                                                       (target, vexpo) => ((vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.TargetRepresentations.Any()),
                                                       (target) => target.GetDisplayingView().Manipulator.SwitchRelated(target, true)));

            //- ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Show Composite-Content [F3]", "ShowCompositeContent", "Show the Idea Composite-Content as View.", Display.GetAppImage("show_composite.png")),
                                                       (target, vexpo) => (vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.IsComposable || target.OwnerRepresentation.RepresentedIdea.CompositeIdeas.Count > 0,
                                                       (target) => target.GetDisplayingView().Engine.ShowCompositeAsView(target)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Display/Hide Composite-Content as Detail", "ShowCompositeContentAsDetail", "Display/Hide the Composite-Content View instead of Details.", Display.GetAppImage("composite_view.png")),
                                                       (target, vexpo) => ((vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.RepresentedIdea.CompositeViews.Count > 0),
                                                       (target) => target.GetDisplayingView().Manipulator.ShowCompositeAsDetail(target)));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Add Attachment Detail", "AddAttachmentDetail", "Add an Attachment Detail to the Idea.", AttachmentDetailDesignator.KindPictogram),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().AppendDetailToVisualRepresentation(target.OwnerRepresentation, AttachmentDetailDesignator.KindName)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Add Link Detail", "AddLinkDetail", "Add a Link Detail to the Idea.", LinkDetailDesignator.KindPictogram),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().AppendDetailToVisualRepresentation(target.OwnerRepresentation, LinkDetailDesignator.KindName)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Add Table Detail", "AddTableDetail", "Add a Table Detail to the Idea.", TableDetailDesignator.KindPictogram),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().AppendDetailToVisualRepresentation(target.OwnerRepresentation, TableDetailDesignator.KindName)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Edit Details [F6]", "EditDetails", "Opens the tab for edit the details of this Idea", Display.GetAppImage("detail_edit.png")),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation, Display.TABKEY_DETAILS)));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Delete", "Delete", "Delete the selected objects.", Display.GetAppImage("lightbulb_delete.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.DeleteObjects(Eng.CurrentView.SelectedObjects); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Cut", "Cut", "Cut the selected objects and let a copy in the Clipboard.", Display.GetAppImage("cut.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCut(Eng.CurrentView); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Copy", "Copy", "Copy the selected objects to the Clipboard.", Display.GetAppImage("page_white_copy.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCopy(Eng.CurrentView); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Paste", "Paste", "Paste Clipboard content into current View.", Display.GetAppImage("paste_plain.png")),
                                                       (target, vexpo) => target.GetDisplayingView().Engine.ClipboardHasPasteableContent(),
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardPaste(Eng.CurrentView); }));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Edit Markers [F7]", "EditMarkers", "Opens the tab for edit the markers of this Idea", Display.GetAppImage("award_star_gold_1.png")),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation, Display.TABKEY_MARKINGS)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Properties [F4]", "IdeaProperties", "Edit the Properties of this Idea", Display.GetAppImage("page_white_edit.png")),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation)));

            // Connectors................................................................................................
            ContextMenuOptionsForVisualConnectors.Add(new Tuple <SimplePresentationElement, Func <VisualConnector, FrameworkElement, bool?>, Action <VisualConnector> >
                                                          (new SimplePresentationElement("Link Descriptor", "LinkDescriptor", "Edit the Descriptor of this Link", Display.GetAppImage("page_white_edit.png")),
                                                          (target, vexpo) => true,
                                                          (target) => target.DoEditDescriptor()));
            ContextMenuOptionsForVisualConnectors.Add(new Tuple <SimplePresentationElement, Func <VisualConnector, FrameworkElement, bool?>, Action <VisualConnector> >
                                                          (new SimplePresentationElement("Relationship Properties", "RelationshipProperties", "Edit the Descriptor of this Relationship", Display.GetAppImage("page_edit.png")),
                                                          (target, vexpo) => true,
                                                          (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation)));

            // Complements...............................................................................................
            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Delete", "Delete", "Delete the selected objects.", Display.GetAppImage("lightbulb_delete.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.DeleteObjects(Eng.CurrentView.SelectedObjects); },
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Cut", "Cut", "Cut the selected objects and let a copy in the Clipboard.", Display.GetAppImage("cut.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCut(Eng.CurrentView); },
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Copy", "Copy", "Copy the selected objects to the Clipboard.", Display.GetAppImage("page_white_copy.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCopy(Eng.CurrentView); },
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(null);   // Separator

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Edit Content", "EditContent", "Edits the Content of this Complement or its owner Idea.", Display.GetAppImage("image_edit.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => VisualComplement.Edit(target),
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(null);   // Separator

            /*? Superseded by appropriate controls in line/connector brush (now format) selector.
             * ContextMenuOptionsForVisualComplements.Add(new Tuple<SimplePresentationElement, Func<VisualComplement, bool>, Action<VisualComplement, SimplePresentationElement>, List<SimplePresentationElement>>
             *              (new SimplePresentationElement("Line Thickness", "LineThickness", "Changes the thickness of the Complement lines.", Display.GetAppImage("line_thickness.png")),
             *               (target) => true,
             *               (target, selection) => VisualComplement.ChangeLineThickness(target, double.Parse(selection.TechName)),
             *               General.CreateList(new SimplePresentationElement("0.5", "0.5"),
             *                                  new SimplePresentationElement("1.0", "1"),
             *                                  new SimplePresentationElement("1.5", "1.5"),
             *                                  new SimplePresentationElement("2.0", "2"),
             *                                  new SimplePresentationElement("3.0", "3"),
             *                                  new SimplePresentationElement("4.0", "4"),
             *                                  new SimplePresentationElement("5.0", "5"),
             *                                  new SimplePresentationElement("6.0", "6"),
             *                                  new SimplePresentationElement("7.0", "7"),
             *                                  new SimplePresentationElement("8.0", "8"),
             *                                  new SimplePresentationElement("9.0", "9"),
             *                                  new SimplePresentationElement("10.0", "10"))));
             *
             * ContextMenuOptionsForVisualComplements.Add(new Tuple<SimplePresentationElement, Func<VisualComplement, bool>, Action<VisualComplement, SimplePresentationElement>, List<SimplePresentationElement>>
             *              (new SimplePresentationElement("Line Dash-Style", "LineDashStyle", "Changes the dash-style of the Complement lines.", Display.GetAppImage("line_dashstyle.png")),
             *               (target) => true,
             *               (target, selection) => VisualComplement.ChangeLineDashStyle(target, Display.DeclaredDashStyles[int.Parse(selection.TechName)].Item1),
             *               Display.DeclaredDashStyles.Select(dds =>
             *                   new SimplePresentationElement(dds.Item2, Display.DeclaredDashStyles.IndexOfMatch(d => d.Item1.IsEqual(dds.Item1)).ToString())).ToList())); */

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Change Axis", "ChangeAxis", "Changes the axis (vertical/horizontal) of this Group Line Complement.", Display.GetAppImage("rod_change_axis.png")),
                                                           (target, vexpo) => target.IsComplementGroupLine,
                                                           (target, selection) => VisualComplement.ChangeAxis(target),
                                                           null));
        }
        public override bool Continue(MouseEventArgs Parameter, bool IsDefinitive = true)
        {
            var Go = base.Continue(Parameter, IsDefinitive);

            if (!Go)
            {
                return(false);
            }

            TargetLocation = Parameter.GetPosition(this.ContextEngine.CurrentView.PresenterControl);
            if (this.ContextEngine.CurrentView.SnapToGrid)
            {
                TargetLocation = this.ContextEngine.CurrentView.GetGridSnappedPosition(TargetLocation, true);
            }

            TargetSymbol = this.ContextEngine.GetPointedVisualObject(TargetLocation) as VisualSymbol;

            var InitialWidth = 0.0;

            if (IsDefinitive)
            {
                var CreationResult = new OperationResult <VisualComplement>();

                if (this.ComplementKind.TechName == Domain.ComplementDefCallout.TechName ||
                    this.ComplementKind.TechName == Domain.ComplementDefQuote.TechName)
                {
                    if (TargetSymbol == null)
                    {
                        Console.WriteLine(this.ComplementKind.Name + " must point to a Symbol");
                        return(true);
                    }

                    if (this.ComplementKind.TechName == Domain.ComplementDefCallout.TechName)
                    {
                        TargetLocation = new Point(TargetSymbol.BaseCenter.X + 20 + VisualComplement.CALLOUT_INI_WIDTH / 2.0,
                                                   TargetSymbol.BaseTop - 20 - VisualComplement.CALLOUT_INI_HEIGHT / 2.0);
                    }
                    else
                    {
                        TargetLocation = new Point(TargetSymbol.BaseCenter.X - 25 - VisualComplement.QUOTE_INI_WIDTH / 2.0,
                                                   TargetSymbol.BaseTop - 15 - VisualComplement.QUOTE_INI_HEIGHT / 2.0);
                    }

                    if (this.ContextEngine.CurrentView.SnapToGrid)
                    {
                        TargetLocation = this.ContextEngine.CurrentView.GetGridSnappedPosition(TargetLocation, true);
                    }
                }

                if (this.ComplementKind.TechName == Domain.ComplementDefGroupRegion.TechName ||
                    this.ComplementKind.TechName == Domain.ComplementDefGroupLine.TechName)
                {
                    if (TargetSymbol == null)
                    {
                        Console.WriteLine(this.ComplementKind.Name + " must belong to a Symbol");
                        return(true);
                    }

                    /*-
                     * if (this.ComplementKind.TechName == Domain.ComplementDefGroupRegion.TechName
                     *  && TargetSymbol.AttachedComplements.Count(comp => comp.IsComplementGroupRegion) > 0)
                     * {
                     *  Console.WriteLine("Symbol cannot have more than one Group Region.");
                     *  return true;
                     * } */

                    if (this.ComplementKind.TechName == Domain.ComplementDefGroupLine.TechName &&
                        TargetSymbol.AttachedComplements.Count(comp => comp.IsComplementGroupLine) > 1)
                    {
                        Console.WriteLine("Symbol cannot have more than two Group Lines.");
                        return(true);
                    }

                    if (this.ComplementKind.TechName == Domain.ComplementDefGroupRegion.TechName)
                    {
                        var Params = VisualComplement.GetGroupRegionInitialParams(TargetSymbol);
                        TargetLocation = Params.Item1;
                        InitialWidth   = Params.Item2;
                    }
                    else
                    {
                        TargetLocation = VisualComplement.GetGroupLineInitialPosition(TargetSymbol);
                    }
                }

                CreationResult = CreateComplement(this.ContextEngine.CurrentView.VisualizedCompositeIdea, this.ComplementKind, this.ContextEngine.CurrentView, TargetSymbol as VisualSymbol, TargetLocation, InitialWidth);

                if (CreationResult.WasSuccessful)
                {
                    this.ContextEngine.CurrentView.Manipulator.ApplySelection(CreationResult.Result);

                    this.ContextEngine.CurrentView.Presenter
                    .PostCall(pres => VisualComplement.Edit(CreationResult.Result, true));

                    if (this.ComplementKind.TechName == Domain.ComplementDefImage.TechName)
                    {
                        return(false);
                    }
                }
                else
                {
                    Console.WriteLine("Cannot create Complement: " + CreationResult.Message.AbsentDefault("?"));
                    this.Terminate();
                    return(false);
                }
            }

            // // Stop the command...
            // this.Terminate(true, Parameter);
            // return false;

            // Continue the command...
            return(true);
        }
Example #8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public ViewComplementManipulationAdorner(ViewManipulationManager OwnerManager, VisualComplement TargetComplement, AdornerLayer TargetLayer,
                                                 Action <ViewManipulationAdorner, bool, bool, bool, bool, bool, bool, bool, bool> ManipulationOperation)
            : base(OwnerManager, TargetComplement, TargetLayer)
        {
            this.DefaultAction_ = (byte)EComplementManipulationAction.Edit;

            this.ManipulatingHeadingRectangle = TargetComplement.BaseArea;
            this.ManipulationOperation        = ManipulationOperation;
        }