private static ExtensionPanel CreatePastingExtraOptions(ExtensionPanel ExtraOptions, VisualRepresentation TargetRep, IEnumerable <string> FilePaths)
        {
            ExtraOptions = ExtensionPanel.Create()
                           .AddGroupPanel("Pasting options...")
                           .AddSelectableOption(PASTE_AS_MAINCONTENT, "As main content", true,
                                                "The pasted object is intended as Summary (when text) or Pictogram (if image).")
                           .AddSelectableOption(PASTE_AS_DETAIL, "As detail", false,
                                                "The pasted object must be appended as detail.");

            if (TargetRep == null && FilePaths.CountsAtLeast(2))
            {
                ExtraOptions.AddSwitchOption(PASTE_MULTI_TARGETS, "Create multiple targets", true, "Create multiple targets (Concepts or Complements), one per each source file.");
            }

            var ButtonPasteAsComplement = new PaletteButton("As Text/Image Complement", Domain.ComplementDefImage.Pictogram);

            ButtonPasteAsComplement.MinHeight = 32;
            ButtonPasteAsComplement.Summary   = "Paste as a Text/Image Complement in the background";
            ButtonPasteAsComplement.Click    +=
                ((sender, args) =>
            {
                var OwnerWindow = ButtonPasteAsComplement.GetNearestVisualDominantOfType <Window>();
                if (OwnerWindow == null)
                {
                    return;
                }

                Display.SelectedOptionText = VisualComplement.__ClassDefinitor.TechName;
                OwnerWindow.Close();
            });
            ExtraOptions.Children.Add(ButtonPasteAsComplement);
            return(ExtraOptions);
        }
Exemple #2
0
        /// <summary>
        /// The on mouse down event handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        private void onMouseDownMoveEventHandler(object sender, MouseEventArgs e)
        {
            if (!e.IsArrowClick())
            {
                return;
            }
            IObjectLabel lab = Label;

            if (lab == null)
            {
                return;
            }
            PanelDesktop  desktop = Parent as PanelDesktop;
            PaletteButton active  = desktop.Tools.Active;

            if (active != null)
            {
                if (active.IsArrow & !(active.ReflectionType == null))
                {
                    try
                    {
                        ICategoryArrow arrow = desktop.Tools.Factory.CreateArrow(active);
                        arrow.Source              = lab.Object;
                        desktop.ActiveArrow       = arrow;
                        desktop.ActiveObjectLabel = lab;
                        return;
                    }
                    catch (Exception ex)
                    {
                        ex.ShowError(10);
                    }
                }
            }
        }
Exemple #3
0
 public void CopyButton()
 {
     if (buttonSelector.activeSelf)
     {
         if (0 <= buttonIndex && buttonIndex < getCurrentPaletteButtonCount() && getCurrentPaletteButtonCount() > 0)
         {
             GameObject paletteButton = Instantiate(palettes[paletteIndex].buttons[buttonIndex].button, Vector3.zero, Quaternion.identity);
             paletteButton.transform.SetParent(buttonInstantiator.transform.parent, true);
             paletteButton.transform.localScale = new Vector3(1, 1, 1);
             paletteButton.GetComponent <RectTransform>().anchoredPosition = getButtonPositionByIndex(getCurrentPaletteButtonCount());
             paletteButton.SetActive(true);
             palettes[paletteIndex].buttons.Add(new PaletteButton(paletteButton));
             PaletteButton copiedPalette = palettes[paletteIndex].buttons[buttonIndex];
             selectButton(getCurrentPaletteButtonCount() - 1);
             setButtonTitle(copiedPalette.title);
             setButtonColor(copiedPalette.color);
             setButtonEmotion(copiedPalette.emotion);
             setSpeechSynthesis(copiedPalette.speech);
             setSpeechRate(copiedPalette.rate);
             setSpeechPitch(copiedPalette.pitch);
             setShortcutKey(copiedPalette.shortcut);
         }
         else
         {
             Debug.LogWarning("Bad button index! Nothing copied.");
         }
     }
     else
     {
         Debug.LogWarning("No button selected! Nothing copied.");
     }
 }
Exemple #4
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        public void SetValueEditorAsTableEditorLauncher()
        {
            var Launcher = new PaletteButton();

            Launcher.ButtonText      = "...";
            Launcher.ButtonShowImage = false;   // Launcher.ButtonImage = Display.GetAppImage("table_edit.png");
            Launcher.ToolTip         = "Edit data values";
            Launcher.Cursor          = Cursors.Hand;

            SetValueEditorControl(Launcher, Button.TagProperty,
                                  (exp) => (exp.ValueEditor as PaletteButton).Tag,
                                  (exp, val) => (exp.ValueEditor as PaletteButton).Tag = (Table)val,
                                  (exp) =>
            {
                var Ctl      = exp.ValueEditor as PaletteButton;
                Ctl.FontSize = FONT_SIZE;

                if (exp.SourceFieldDefinitor == null)
                {
                    Ctl.IsEnabled = false;
                    return;
                }

                var StoredTable = exp.InstanceSource.GetStoredValue(exp.SourceFieldDefinitor) as Table;
                if (StoredTable != null)
                {
                    Ctl.ButtonText = StoredTable.RecordsLabel;
                }

                // This must be set for explicit change. Databinding didn't work.
                Ctl.Click += ((sender, args) =>
                {
                    exp.InstanceSource.OwnerTable.OwnerIdea.EditEngine.StartCommandVariation("Edit Field contained Table");

                    if (StoredTable == null)
                    {
                        StoredTable = new Table(exp.InstanceSource.OwnerTable.OwnerIdea,
                                                exp.SourceFieldDefinitor.ContainedTableDesignator.Assign <DetailDesignator>(false));

                        // This must be set for explicit change. Databinding didn't work.
                        exp.InstanceSource.SetStoredValue(exp.SourceFieldDefinitor, StoredTable);
                        Ctl.ButtonText = StoredTable.RecordsLabel;
                    }

                    var Changed = DetailTableEditor.Edit(StoredTable, exp.SourceFieldDefinitor.ContainedTableDesignator);
                    exp.InstanceSource.OwnerTable.OwnerIdea.EditEngine.CompleteCommandVariation();

                    if (Changed)
                    {
                        Ctl.ButtonText = StoredTable.RecordsLabel;
                    }
                    else
                    {
                        exp.InstanceSource.OwnerTable.OwnerIdea.EditEngine.Undo();
                    }
                });
            },
                                  null);
        }
Exemple #5
0
 public void selectButton(int index, bool autoSend = false)
 {
     //Select Button
     if (paletteIndex > -1)
     {
         if (0 <= index && index < getCurrentPaletteButtonCount() && getCurrentPaletteButtonCount() > 0)
         {
             PaletteButton button = palettes[paletteIndex].buttons[index];
             buttonIndex          = index;
             buttonTitle.text     = button.title;
             buttonColor.value    = button.color;
             buttonEmotion.value  = button.emotion;
             speechSynthesis.text = button.speech;
             speechRate.value     = button.rate;
             speechPitch.value    = button.pitch;
             if (shortcutDropdown)
             {
                 shortcutDropdown.value = button.shortcut;
             }
             revert = new PaletteButton(buttonInstantiator, button.title, button.color, button.emotion, button.speech, button.rate, button.pitch);
             buttonSelector.GetComponent <RectTransform>().anchoredPosition = getButtonPositionByIndex(index) + new Vector2(-3, 3);
             buttonSelector.SetActive(true);
             if (autoSend)
             {
                 if (autoSendUDPIP != null && autoSendUDPIP.isOn)
                 {
                     sendUDPMessage();
                 }
                 if (autoSendBluetooth != null && autoSendBluetooth.isOn)
                 {
                     sendBluetoothMessage();
                 }
                 if (autoSendMisty != null && autoSendMisty.isOn)
                 {
                     sendMistyMessage();
                 }
             }
         }
         //Deselect Button
         else
         {
             buttonIndex          = -1;
             buttonTitle.text     = "";
             buttonColor.value    = 0;
             buttonEmotion.value  = 0;
             speechSynthesis.text = "";
             speechRate.value     = 1;
             speechPitch.value    = 1;
             if (shortcutDropdown)
             {
                 shortcutDropdown.value = 0;
             }
             buttonSelector.SetActive(false);
         }
     }
 }
        private void MouseDown(object sender, MouseEventArgs e)
        {
            if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
            {
                label.Selected = !label.Selected;
                return;
            }
            if (e.Button == MouseButtons.Right)
            {
                if (label is IShowForm)
                {
                    IShowForm sf = label as IShowForm;
                    sf.Show();
                    return;
                }
            }

            /*  if (EditorRectangle.Contains(e.X, e.Y))
             * {
             *    return;
             * }*/
            PaletteButton active = pDesktop.Tools.Active;

            if (active != null)
            {
                if (active.IsArrow & (active.ReflectionType != null))
                {
                    try
                    {
                        ICategoryArrow arrow = pDesktop.Tools.Factory.CreateArrow(active);
                        arrow.Source               = label.Object;
                        pDesktop.ActiveArrow       = arrow;
                        pDesktop.ActiveObjectLabel = label;
                        return;
                    }
                    catch (Exception ex)
                    {
                        ex.ShowError(10);
                        return;
                    }
                }
            }
            IsMoved = true;
            pDesktop.SetBlocking(true);
            mouseX = e.X;
            mouseY = e.Y;
        }
Exemple #7
0
        /// <summary>
        /// Creates Arrow Control
        /// </summary>
        /// <param name="control">Base Control</param>
        /// <param name="tools">Tools</param>
        public static void CreateArrowControl(Control control, ToolsDiagram tools)
        {
            PaletteToolBar toolBar   = new PaletteToolBar(tools);
            ImageList      imageList = new ImageList();

            imageList.ImageSize = new Size(25, 25);
            imageList.Images.Add(ResourceImage._object);
            imageList.Images.Add(ResourceImage.Arrow);
            toolBar.ImageList = imageList;
            toolBar.ImageList = imageList;

            PaletteButton p = new PaletteButton(toolBar, null, null, "", "Selection arrow", imageList.Images[0], 0, true);

            p.Visible = false;

            new PaletteButton(toolBar, null, null, "", "Selection arrow", imageList.Images[1], 1, true);
            control.Controls.Add(toolBar);
        }
Exemple #8
0
        /// <summary>
        /// The on mouse down event handler
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        protected void onMouseDownMoveEventHandler(object sender, MouseEventArgs e)
        {
            if ((ModifierKeys & Keys.Shift) == Keys.Shift)
            {
                return;
            }
            if (!StaticExtensionDiagramUIForms.IsArrowClick(e))
            {
                return;
            }
            if (EditorRectangle.Contains(e.X, e.Y))
            {
                return;
            }
            PaletteButton active = Desktop.Tools.Active;

            if (active != null)
            {
                if (active.IsArrow & active.ReflectionType != null)
                {
                    try
                    {
                        ICategoryArrow arrow = Desktop.Tools.Factory.CreateArrow(active);
                        arrow.Source              = Object;
                        Desktop.ActiveArrow       = arrow;
                        Desktop.ActiveObjectLabel = this;
                        return;
                    }
                    catch (Exception ex)
                    {
                        ex.ShowError(10);
                        return;
                    }
                }
            }
            isMoved         = true;
            Desktop.IsMoved = true;
            Desktop.SetBlocking(true);
            mouseX = e.X;
            mouseY = e.Y;
        }
Exemple #9
0
        //------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes user-interface components over the provided shell.
        /// </summary>
        public static void InitializeUserInterface()
        {
            PaletteProject = new WidgetPalette("PaletteProject", "Project", EShellVisualContentType.PaletteContent, "book_open.png");
            //PaletteProject.PaletteTab.Width = 300;
            // Ugly: PaletteProject.PaletteTab.FlowDirection = FlowDirection.RightToLeft;    // To let space for the quickbar on the left.

            PaletteEdition = new WidgetPalette("PaletteEdition", "Compose", EShellVisualContentType.PaletteContent, "wand.png");

            PaletteGeneral = new WidgetPalette("PaletteGeneral", "General", EShellVisualContentType.PaletteContent, "world.png");

            PopulateMenuPalette(PaletteProject, CompositionDirector, EShellCommandCategory.Document, EShellCommandCategory.Global);
            PopulateMenuPalette(PaletteProject, DomainDirector, EShellCommandCategory.Document, EShellCommandCategory.Global);

            PopulateMenuPalette(PaletteEdition, CompositionDirector, EShellCommandCategory.Edition);

            PopulateMenuPalette(PaletteGeneral, CompositionDirector, EShellCommandCategory.Extra);

            // Let the "Recent" tab at end
            var Tabs = new List <object>();

            foreach (var Tab in PaletteProject.PaletteTab.Items)
            {
                Tabs.Add(Tab);
            }

            Tabs.SwapItemsAt(1, 2);

            PaletteProject.PaletteTab.Items.Clear();
            Tabs.ForEach(tab => PaletteProject.PaletteTab.Items.Add(tab));

            // ----------------------------------------------------------------------------------------------------------------------------------------
            EditorPropertiesControl = new WidgetPropertyPanel();
            EditorProperties        = new EntitledPanel("EditorProperties", "Properties", EShellVisualContentType.NavigationContent, EditorPropertiesControl);

            //POSTPONED: NavigatorMapControl = new WidgetNavMap();
            //POSTPONED: NavigatorMap = new EntitledPanel("NavigatorMap", "Map", EShellVisualContentType.NavigationContent, NavigatorMapControl);

            // ----------------------------------------------------------------------------------------------------------------------------------------
            ContentTreeControl = new WidgetNavTree(WorkspaceDirector);
            ContentTree        = new EntitledPanel("ContentTree", "Content", EShellVisualContentType.NavigationContent, ContentTreeControl);

            // ----------------------------------------------------------------------------------------------------------------------------------------
            DocumentArea        = new DocumentPanel("DocumentVisualizer", DocumentVisualizerControl);
            DocumentArea.Height = double.NaN;
            DocumentArea.Width  = double.NaN;

            // ----------------------------------------------------------------------------------------------------------------------------------------
            var MessengerConsole = new WidgetMessenger();

            MessengerConsolePublisher = new ConsoleRollPublisher(MessengerConsole.MessagePublisher,
                                                                 AppExec.GetConfiguration <int>("Application", "ConsoleOutputMaxLines",
                                                                                                ConsoleRollPublisher.DEF_MAXLINES));
            Console.SetOut(MessengerConsolePublisher);

            /* Messages and Results...
             * var TabItemConsole = new TabItem();
             * TabItemConsole.Header = "Console";
             * TabItemConsole.Content = MessengerConsole;
             *
             * var MessengerResults = new WidgetMessenger();
             * var TabItemResults = new TabItem();
             * TabItemResults.Header = "Results";
             * TabItemResults.Content = MessengerResults;
             *
             * var TabMessenger = new TabControl();
             * TabMessenger.TabStripPlacement = Dock.Bottom;
             * TabMessenger.Items.Add(TabItemConsole);
             * TabMessenger.Items.Add(TabItemResults);
             * TabMessenger.Height = double.NaN;
             * TabMessenger.Width = double.NaN; */

            Messenger           = new EntitledPanel("Messenger", "Messaging", EShellVisualContentType.MessagingContent, MessengerConsole /* TabMessenger */);
            Messenger.ShowTitle = false;

            // ----------------------------------------------------------------------------------------------------------------------------------------
            var IdeaScroller = new ScrollViewer();

            IdeaScroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            IdeaScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;  // For nice wrapping
            IdeaScroller.Content = IdeaPaletteControl;

            EditorIdeaPalette = new EntitledPanel("EditorIdeaPalette", "Ideas", EShellVisualContentType.EditingContent, IdeaScroller);

            // ----------------------------------------------------------------------------------------------------------------------------------------
            var ComplementScroller = new ScrollViewer();

            ComplementScroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            ComplementScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;  // For nice wrapping
            ComplementScroller.Content = ComplementPaletteControl;

            EditorComplementPalette = new EntitledPanel("EditorComplementPalette", "Complements", EShellVisualContentType.EditingContent, ComplementScroller);

            // ----------------------------------------------------------------------------------------------------------------------------------------
            var MarkerScroller = new ScrollViewer();

            MarkerScroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            MarkerScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;  // For nice wrapping
            MarkerScroller.Content = MarkerPaletteControl;

            EditorMarkerPalette = new EntitledPanel("EditorMarkerPalette", "Markers", EShellVisualContentType.EditingContent, MarkerScroller);

            // ----------------------------------------------------------------------------------------------------------------------------------------
            StatusBarControl      = new WidgetStatusBar();
            StatusArea            = new EntitledPanel("StatusMessage", "Status", EShellVisualContentType.StatusContent, StatusBarControl, false);
            StatusArea.Background = Brushes.Transparent;

            ShellHost.MainSelector = StatusBarControl.DocumentSelector;

            // ----------------------------------------------------------------------------------------------------------------------------------------
            ShellHost.PutVisualContent(PaletteProject);
            ShellHost.PutVisualContent(PaletteEdition);
            //POSTPONED: ShellHost.PutVisualContent(PaletteGeneral);

            ShellHost.PutVisualContent(EShellVisualContentType.QuickPaletteContent,
                                       CompositionDirector.QuickExposedCommands.Select(
                                           (expo) =>
            {
                var NewButton        = new PaletteButton(expo);
                NewButton.ButtonText = "";                                  // Only show the icon
                NewButton.ToolTip    = expo.Name;
                return(NewButton);
            }));

            ShellHost.PutVisualContent(ContentTree);

            ShellHost.PutVisualContent(EditorProperties);

            //POSTPONED: ShellHost.PutVisualContent(NavigatorMap);

            ShellHost.PutVisualContent(DocumentArea);

            ShellHost.PutVisualContent(Messenger);

            ShellHost.PutVisualContent(EditorIdeaPalette, 0);

            ShellHost.PutVisualContent(EditorMarkerPalette, 1);

            ShellHost.PutVisualContent(EditorComplementPalette, 2);

            ShellHost.PutVisualContent(StatusArea);

            ShellHost.MainSelector.ItemsSource       = WorkspaceDirector.Documents;
            ShellHost.MainSelector.SelectionChanged += new SelectionChangedEventHandler(MainDocumentSelector_SelectionChanged);

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // VERY IMPORTANT!
            // Do not mess with the next Action<T> nor Lambdas.
            // They are entangled into serialized content (Still don't know from where)
            WorkspaceDirector.PreDocumentDeactivation =
                (workspace, document) =>
            {
                OnDocumentDiscard(workspace, document);
                document.DocumentEditEngine.LastOpenedViews = DocumentVisualizerControl.GetAllViews(document).ToList();
                document.DocumentEditEngine.Visualizer.DiscardAllViews();
            };

            WorkspaceDirector.PostDocumentActivation =
                (workspace, document) =>
            {
                if (ShellHost.MainSelector.SelectedItem != document)
                {
                    ShellHost.RefreshSelection(document);
                }

                OnDocumentChange(workspace, document);

                document.DocumentEditEngine.Show();
                document.DocumentEditEngine.LastOpenedViews = null;
            };

            WorkspaceDirector.PostDocumentStatusChange =
                (workspace, document) =>
            {
                OnDocumentChange(workspace, document);
            };
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            EntitleApplication();

            ShowAssistance();
        }
Exemple #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);
        }
        // -------------------------------------------------------------------------------------------------------------

        /*********************************************************************************
        *  //! CRITICAL CODE: Do not rename nor move.
        *  // This part is entangled with predefined Domains, thru some
        *  // serialized event-handlers with Action<T>, Func<T> and lambdas.
        *********************************************************************************/
        public static void PopulateMenuPalette(WidgetPalette Palette, WorkSphere Sphere, params EShellCommandCategory[] AssignableCommandCategories)
        {
            var GroupingHeaderBrush = Display.GetResource <Brush, EntitledPanel>("HeaderBrush"); // PanelTextBrush also looks good
            var GroupingBodyBrush   = new SolidColorBrush(Color.FromRgb(242, 246, 248));         // Display.GetGradientBrush(Color.FromRgb(252, 252, 252), Color.FromRgb(247, 247, 247)); //Display.GetResource<Brush, EntitledPanel>("PanelBrush");

            // Adds the required tab items if these already does not exists in the palette's tab control.
            foreach (var Area in Sphere.CommandAreas)
            {
                Panel TargetAreaPanel = null;
                bool  TabExists       = false;
                bool  MenuItemExposed = false;

                // Determines whether the current Area is already exposed as a TabItem.
                foreach (TabItem Item in Palette.PaletteTab.Items)
                {
                    if (Item.Name == Area.TechName)
                    {
                        TargetAreaPanel = Item.Content as Panel;
                        TabExists       = true;
                        break;
                    }
                }

                // Creates a new Panel if no TabItem was found.
                if (!TabExists)
                {
                    var WrappingPanel = new WrapPanel();
                    WrappingPanel.Orientation = Orientation.Horizontal;
                    TargetAreaPanel           = WrappingPanel;
                }

                // Create Groups
                foreach (var Group in Sphere.CommandGroups[Area.TechName])
                {
                    StackPanel TargetGroupContainer = null;
                    WrapPanel  TargetGroupingPanel  = null;

                    // Determines whether the current Group is already exposed as a GroupBox.
                    foreach (var Element in TargetAreaPanel.Children)
                    {
                        if (Element is GroupBox &&
                            ((StackPanel)Element).Tag.ToString() == Group.TechName)
                        {
                            TargetGroupContainer = Element as StackPanel;
                            var Body = (Border)TargetGroupContainer.Children[1];  // Children[0] is the Header
                            TargetGroupingPanel = (WrapPanel)Body.Child;
                            break;
                        }
                    }

                    // Creates a new Panel if no TabItem was found.
                    if (TargetGroupContainer == null)
                    {
                        TargetGroupContainer                   = new StackPanel();
                        TargetGroupContainer.Tag               = Group.TechName;
                        TargetGroupContainer.Orientation       = Orientation.Horizontal;
                        TargetGroupContainer.VerticalAlignment = VerticalAlignment.Stretch;
                        TargetGroupContainer.Margin            = new Thickness(1, 0, 1, 0);

                        var GroupingHeader = new Border();
                        GroupingHeader.CornerRadius = new CornerRadius(3.0, 0, 0, 3.0);
                        GroupingHeader.Background   = GroupingHeaderBrush;
                        GroupingHeader.Padding      = new Thickness(0, 4, 1, 4);
                        GroupingHeader.ToolTip      = Group.Name;

                        var GroupingTitle = new TextBlock();
                        GroupingTitle.Text       = Group.Name;
                        GroupingTitle.FontFamily = new FontFamily("Arial"); // new FontFamily("Verdana");
                        GroupingTitle.FontSize   = 11;
                        // GroupingTitle.FontWeight = FontWeights.Thin;
                        GroupingTitle.Foreground          = Brushes.White;
                        GroupingTitle.TextAlignment       = TextAlignment.Right;
                        GroupingTitle.HorizontalAlignment = HorizontalAlignment.Stretch;
                        GroupingTitle.LayoutTransform     = new RotateTransform(-90.0);
                        GroupingHeader.Child = GroupingTitle;
                        TargetGroupContainer.Children.Add(GroupingHeader);

                        var GroupingBody = new Border();
                        GroupingBody.CornerRadius    = new CornerRadius(0, 3.0, 3.0, 0);
                        GroupingBody.Background      = GroupingBodyBrush;
                        GroupingBody.BorderThickness = new Thickness(0);
                        // GroupingBody.BorderBrush = Brushes.LightGray;
                        // GroupingBody.BorderThickness = new Thickness(0,1,1,1);

                        /* Rarely needed
                         * GroupingHeader.MouseLeftButtonDown +=
                         *  ((sender, mevargs) => GroupingBody.SetVisible(!GroupingBody.IsVisible.IsTrue())); */

                        TargetGroupContainer.Children.Add(GroupingBody);

                        TargetGroupingPanel             = new WrapPanel();
                        TargetGroupingPanel.Orientation = Orientation.Vertical;
                        GroupingBody.Child = TargetGroupingPanel;
                    }

                    TargetAreaPanel.Children.Add(TargetGroupContainer);

                    // Populates the GroupBox with the associated Command Expositors.
                    foreach (KeyValuePair <string, WorkCommandExpositor> ExpositorReg in Sphere.CommandExpositors)
                    {
                        var Expositor = ExpositorReg;

                        if (Expositor.Value.AreaKey == Area.TechName && Expositor.Value.GroupKey == Group.TechName &&
                            AssignableCommandCategories.Contains(Expositor.Value.Category))
                        {
                            Control NewControl = null;

                            var Options = (Expositor.Value.OptionsGetter == null ? null : Expositor.Value.OptionsGetter());

                            if (Expositor.Value.SwitchInitializer != null)
                            {
                                var SwitchChecker = new CheckBox();
                                SwitchChecker.Content  = Expositor.Value.Name;
                                SwitchChecker.ToolTip  = Expositor.Value.Summary;
                                SwitchChecker.Margin   = new Thickness(2, 4, 2, 4);
                                SwitchChecker.FontSize = 10.0;

                                /* WPF still has minor problems with fonts over shadow
                                 * var Shadow = new DropShadowEffect();
                                 * Shadow.Color = Colors.Gray;
                                 * Shadow.Opacity = 0.2;
                                 * SwitchChecker.Effect = Shadow; */
                                SwitchChecker.Command = ExpositorReg.Value.Command;

                                // Important to pass as parameter instead of negating model property
                                // (which, after undos/redos, can be incoherent with the check-box state shown)
                                Expositor.Value.CommandParameterExtractor = (() => SwitchChecker.IsChecked);

                                /* var Switcher = new RoutedEventHandler((sender, evargs) =>
                                 *  {
                                 *      var CanExec = Expositor.Value.Command.CanExecute(null);
                                 *      if (CanExec)
                                 *          Expositor.Value.Command.Execute(SwitchChecker.IsChecked);
                                 *  });
                                 *
                                 * SwitchChecker.Checked += Switcher;
                                 * SwitchChecker.Unchecked += Switcher; */

                                NewControl = SwitchChecker;
                                MenuToolbarControlsUpdater.AddOrReplace(Area.TechName + "." + Group.TechName + "." + ExpositorReg.Key,
                                                                        () =>
                                {
                                    SwitchChecker.IsChecked = Expositor.Value.SwitchInitializer(WorkspaceDirector.ActiveDocumentEngine);
                                });
                            }
                            else
                            if (Expositor.Value.OptionsGetter == null)
                            {
                                NewControl = new PaletteButton(Expositor.Value);
                            }
                            else
                            if (Expositor.Value.ShowOptionsAsComboBox)
                            {
                                var SelectorButton = new ComboBox();
                                SelectorButton.ToolTip = Expositor.Value.Name;
                                SelectorButton.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                                //? SelectorCombo.MaxWidth = ApplicationShell.MainWindow.PREDEF_INITIAL_TOOLTAB_WIDTH - 48;
                                SelectorButton.BorderBrush = Brushes.Transparent;
                                SelectorButton.Background  = Brushes.Transparent;
                                SelectorButton.Height      = 22;
                                SelectorButton.Padding     = new Thickness(1, 1, 1, 1);
                                ScrollViewer.SetVerticalScrollBarVisibility(SelectorButton, ScrollBarVisibility.Visible);
                                ScrollViewer.SetHorizontalScrollBarVisibility(SelectorButton, ScrollBarVisibility.Disabled);

                                var FirstOption = Options.FirstOrDefault();
                                if (FirstOption == null || typeof(FormalPresentationElement).IsAssignableFrom(FirstOption.GetType()))
                                {
                                    SelectorButton.ItemTemplate = Display.GetResource <DataTemplate>("TplFormalPresentationElement");
                                }
                                else
                                if (typeof(SimplePresentationElement).IsAssignableFrom(FirstOption.GetType()))
                                {
                                    SelectorButton.ItemTemplate = Display.GetResource <DataTemplate>("TplSimplePresentationElement");
                                }

                                SelectorButton.Loaded +=
                                    ((sender, args) =>
                                {
                                    var Items = Expositor.Value.OptionsGetter();
                                    SelectorButton.ItemsSource = Items;
                                    if (Items.Length > 0)
                                    {
                                        SelectorButton.SelectedItem = Items[0];
                                    }
                                    SelectorButton.Tag = true;               // Indicates ready for selection
                                });

                                SelectorButton.SelectionChanged +=
                                    ((sender, selargs) =>
                                {
                                    if (Expositor.Value.Command.CanExecute(null) && SelectorButton.Tag != null)
                                    {
                                        Expositor.Value.Command.Execute(selargs.AddedItems != null && selargs.AddedItems.Count > 0
                                                                                    ? selargs.AddedItems[0] : null);
                                    }
                                });

                                NewControl = SelectorButton;
                            }
                            else
                            {
                                var SelectorList = new ListBox();
                                SelectorList.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                                SelectorList.Width       = ApplicationShell.MainWindow.PREDEF_INITIAL_TOOLTAB_WIDTH - 48;
                                SelectorList.BorderBrush = Brushes.Transparent;
                                SelectorList.FontSize    = 11;
                                SelectorList.Margin      = new Thickness(0, -2, 0, 0);
                                SelectorList.Cursor      = Cursors.Hand;
                                ScrollViewer.SetVerticalScrollBarVisibility(SelectorList, ScrollBarVisibility.Visible);
                                ScrollViewer.SetHorizontalScrollBarVisibility(SelectorList, ScrollBarVisibility.Disabled);

                                SelectorList.Loaded +=
                                    ((sender, args) =>
                                {
                                    SelectorList.ItemsSource = Expositor.Value.OptionsGetter();
                                });

                                SelectorList.SelectionChanged +=
                                    ((sender, selargs) =>
                                {
                                    if ((Mouse.LeftButton == MouseButtonState.Pressed || Keyboard.IsKeyDown(Key.Enter)) &&
                                        Expositor.Value.Command.CanExecute(null))
                                    {
                                        Expositor.Value.Command.Execute(selargs.AddedItems != null && selargs.AddedItems.Count > 0
                                                                                    ? selargs.AddedItems[0] : null);
                                        if (Expositor.Value.GoesToRootAfterExecute)
                                        {
                                            Palette.PaletteTab.PostCall(ptab => ptab.SelectedIndex = 0);
                                        }
                                    }
                                });

                                SelectorList.KeyDown +=
                                    ((sender, keyargs) =>
                                {
                                    if (Keyboard.IsKeyDown(Key.Enter) &&
                                        Expositor.Value.Command.CanExecute(null))
                                    {
                                        Expositor.Value.Command.Execute(SelectorList.SelectedItem);
                                    }
                                });

                                /* Looks bad (hides some lines)
                                 * SelectorList.MouseMove +=
                                 *  ((sender, args) =>
                                 *      {
                                 *          // var Position = Mouse.GetPosition(sender as IInputElement);
                                 *          var Container = Display.GetNearestVisualDominantOfType<ListBoxItem>(args.OriginalSource as DependencyObject);
                                 *          if (Container == LastRecentDocContainer)
                                 *              return;
                                 *
                                 *          LastRecentDocContainer = Container;
                                 *          if (LastRecentDocContainer == null)
                                 *              ToolTipService.SetToolTip(SelectorList, null);
                                 *          else
                                 *          {
                                 *              // PENDING: Make this work as supposed to be.
                                 *              ToolTipService.SetToolTip(SelectorList, LastRecentDocContainer.Content);
                                 *              ToolTipService.SetPlacementTarget(SelectorList, LastRecentDocContainer);
                                 *              ToolTipService.SetPlacement(SelectorList, PlacementMode.Relative);
                                 *              ToolTipService.SetVerticalOffset(SelectorList, 0);
                                 *              ToolTipService.SetHorizontalOffset(SelectorList, 0);
                                 *              ToolTipService.SetInitialShowDelay(SelectorList, 1);
                                 *              ToolTipService.SetBetweenShowDelay(SelectorList, 1);
                                 *              ToolTipService.SetShowDuration(SelectorList, 30000);
                                 *          }
                                 *      }); */

                                NewControl = SelectorList;
                            }

                            TargetGroupingPanel.Children.Add(NewControl);
                            MenuItemExposed = true;
                        }
                    }
                }

                // For possible assigned commands invocators creates a new TabItem, if no one was found related to the current Area.
                if (!TabExists && MenuItemExposed)
                {
                    var NewTab = new TabItem();
                    NewTab.Name    = Area.TechName;
                    NewTab.Header  = Area.Name;
                    NewTab.Content = TargetAreaPanel;
                    Palette.PaletteTab.Items.Add(NewTab);
                }
            }
        }
Exemple #12
0
 /// <summary>
 /// Adds a palette button to the list of palette buttons from a given IControl
 /// </summary>
 /// <param name="control"></param>
 private void AddPaletteButtonFromControl(IControl control)
 {
     PaletteButton button = new PaletteButton(c_buttonWidth, c_buttonHeight, control, _controller);
     this.PaletteButtons.Add(button);
 }
Exemple #13
0
    public void selectButton(int index, bool autoSend = false, bool save = false)
    {
        //Save previous palette if autosave is enabled.
        if (save && autoSaveLoadPalettes && 0 <= paletteIndex && paletteIndex < getPaletteCount() && getPaletteCount() > 0 && palettes[paletteIndex].buttons.Count > 0)
        {
            SaveCSVPalette();
        }
        //Select Button
        if (paletteIndex > -1)
        {
            if (0 <= index && index < getCurrentPaletteButtonCount() && getCurrentPaletteButtonCount() > 0)
            {
                PaletteButton button = palettes[paletteIndex].buttons[index];
                buttonIndex      = index;
                buttonTitle.text = button.title;

                buttonColor.value   = button.color;
                buttonEmotion.value = button.emotion;

                buttonAnimation.text = button.animation;
                buttonGaze.text      = button.gaze;

                speechSynthesis.text = button.speech;
                speechRate.value     = button.rate;
                speechPitch.value    = button.pitch;
                if (shortcutDropdown)
                {
                    shortcutDropdown.value = button.shortcut;
                }
                revert = new PaletteButton(buttonInstantiator, button.title, button.color, button.emotion, button.speech, button.rate, button.pitch);
                buttonSelector.GetComponent <RectTransform>().anchoredPosition = getButtonPositionByIndex(index) + new Vector2(-3, 3);
                buttonSelector.SetActive(true);
                if (autoSend && autoSendToggle != null && autoSendToggle.isOn)
                {
                    buttonPresses.Add(new ButtonPress(getSpeechSynthesis()));
                    sendMessage();
                }
                buttonDuration = 0;
            }
            //Deselect Button
            else
            {
                buttonIndex      = -1;
                buttonTitle.text = "";

                buttonColor.value   = 0;
                buttonEmotion.value = 0;
                speechRate.value    = 1;
                speechPitch.value   = 1;

                speechSynthesis.text = "";
                buttonAnimation.text = "";
                buttonGaze.text      = "";

                if (shortcutDropdown)
                {
                    shortcutDropdown.value = 0;
                }
                buttonSelector.SetActive(false);
            }
        }
    }