Esempio n. 1
0
        /// <summary>
        /// Called to create our custom view
        /// </summary>
        /// <param name="parent">Parent visual</param>
        /// <returns>newly created view</returns>
        public override PlatformVisual CreateView(PlatformVisual parent)
        {
            var view = new VIReferenceNodeView();

            view.DataContext = this;
            return(view);
        }
Esempio n. 2
0
        public override void Attach(ICommandEx command, PlatformVisual visual, ICommandAttachContext context)
        {
            var listBoxItem = (ListBoxItem)GetCommandSourceForVisual(visual);

            listBoxItem.Command          = command;
            listBoxItem.CommandParameter = new ChoiceCommandParameter(command);
            base.Attach(command, visual, context);
        }
Esempio n. 3
0
 private static void FanSpeedHighAttach(PlatformVisual visual, ICommandParameter parameter, IEnumerable <IViewModel> selection, ICompositionHost host, DocumentEditSite site)
 {
     if (!parameter.QueryService <ControlCommandParameter>().Any())
     {
         parameter.AttachService(new ControlCommandParameter()
         {
             Parameter = FanSpeed.High
         });
     }
 }
Esempio n. 4
0
 private static void FanSpeedLowAttach(PlatformVisual visual, ICommandParameter parameter, IEnumerable <IViewModel> selection, ICompositionHost host, DocumentEditSite site)
 {
     // This allows us to pass specific information to a common handler used by multiple commands. Otherwise, we would have redundant code for
     // three different commands
     if (!parameter.QueryService <ControlCommandParameter>().Any())
     {
         parameter.AttachService(new ControlCommandParameter()
         {
             Parameter = FanSpeed.Low
         });
     }
 }
        /// <summary>
        /// Constructs a new instance of the TwoChannelAdorner class
        /// </summary>
        /// <param name="adornedElement">The visual element this adorner is attached to.</param>
        public TwoChannelAdorner(PlatformVisual adornedElement)
        {
            InitializeComponent();
            // set the data context for the control to itself. This lets us bind to the commands by name instead of having to use a more advanced binding
            DataContext = this;
            Model       = DesignerNodeHelpers.GetModelForVisual(adornedElement) as VisualModel;
            // set up the commands which are used by the adorner buttonsf
            LoadFirstPopupCommand  = new RelayCommand(ExecuteLoadFirstPopup);
            LoadSecondPopupCommand = new RelayCommand(ExecuteLoadSecondPopup);
            // Hook up event handlers.  We set up event handlers for when keys are pressed on the adorner as well as when the properties change on either of the channel
            // selection popups
            WeakEventManager <UIElement, KeyEventArgs> .AddHandler(this, "KeyDown", HandleKeyDown);

            WeakEventManager <UIElement, KeyEventArgs> .AddHandler(this, "KeyUp", HandleKeyUp);

            WeakEventManager <ChannelPopup, PropertyChangedEventArgs> .AddHandler(FirstUiSdfPopup, "PropertyChanged", FirstChannelPropertyChanged);

            WeakEventManager <ChannelPopup, PropertyChangedEventArgs> .AddHandler(SecondUiSdfPopup, "PropertyChanged", SecondChannelPropertyChanged);

            // add this adorner as an observer of the model
            Model.AddObserver(this);
            FirstTextControl.Text  = ((PulseWidthModulationControlModel)Model).FrequencyChannel;
            SecondTextControl.Text = ((PulseWidthModulationControlModel)Model).DutyCycleChannel;
        }
        public override void CreateContextMenuContent(ICommandPresentationContext context, PlatformVisual sourceVisual)
        {
            var projectItem = sourceVisual.DataContext as ProjectItemViewModel;

            if (projectItem != null && projectItem.Envoy != null)
            {
                try
                {
                    if (projectItem.Envoy.ReferenceDefinition != null)
                    {
                        var textDocument = projectItem.Envoy.ReferenceDefinition as TextDocumentDefinition;
                        if (textDocument != null)
                        {
                            context.Add(OpenInNotepadCommand);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            base.CreateContextMenuContent(context, sourceVisual);
        }
Esempio n. 7
0
 protected override PlatformVisual CreateVisualControl(PlatformVisual parent)
 {
     return(new OptionPatternStructureControl());
 }
        public override void CreateContextMenuContent(ICommandPresentationContext context, PlatformVisual sourceVisual)
        {
            var projectItem = sourceVisual.DataContext as ProjectItemViewModel;

            if (projectItem != null && projectItem.Envoy != null)
            {
                try
                {
                    var loadedEnvoy = projectItem.Envoy.Project.GetLinkedEnvoys(projectItem.Envoy).Where(e => e.ReferenceDefinition != null).FirstOrDefault();
                    if (loadedEnvoy != null)
                    {
                        var viDocument = loadedEnvoy.ReferenceDefinition as VirtualInstrument;
                        if (loadedEnvoy.ReferenceDefinition != null)
                        {
                            context.Add(OpenInNotepadCommand);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            var terminal = sourceVisual.DataContext as NodeTerminalViewModel;

            if (terminal != null)
            {
                context.Add(new ShellCommandInstance(TerminalCommand, terminal));
            }
            base.CreateContextMenuContent(context, sourceVisual);
        }
Esempio n. 9
0
        public override void CreateContextMenuContent(ICommandPresentationContext context, PlatformVisual sourceVisual)
        {
            var projectItem = sourceVisual.DataContext as ProjectItemViewModel;

            if (projectItem?.Envoy != null)
            {
                try
                {
                    var envoy = projectItem.Envoy;
                    if (envoy != null)
                    {
                        var svnManager = Host.GetSharedExportedValue <SvnManagerPlugin>();
                        var status     = svnManager.Status(projectItem.FullPathForced);

                        if (status.Exists && status.IsVersionable)
                        {
                            context.Add(new ShellCommandInstance(SvnCommands.SvnSubMenuCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }

                        if (status.IsVersionable && !status.IsVersioned)
                        {
                            context.Add(new ShellCommandInstance(AddCommand.ShellSelectionRelayCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }
                        if (status.IsVersioned && status.IsModified)
                        {
                            context.Add(new ShellCommandInstance(CommitCommand.ShellSelectionRelayCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }
                        if (status.IsVersioned && !status.IsAdded)
                        {
                            context.Add(new ShellCommandInstance(HistoryCommand.ShellSelectionRelayCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }
                        if (status.IsVersioned && !status.IsLocked && !status.IsAdded)
                        {
                            context.Add(new ShellCommandInstance(LockCommand.ShellSelectionRelayCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }
                        if (status.IsVersioned && status.IsLocked)
                        {
                            context.Add(new ShellCommandInstance(ReleaseLockCommand.ShellSelectionRelayCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }
                        if (status.IsVersioned && status.IsModified && !status.IsAdded)
                        {
                            context.Add(new ShellCommandInstance(RevertCommand.ShellSelectionRelayCommand)
                            {
                                CommandParameter = projectItem.Envoy
                            });
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            base.CreateContextMenuContent(context, sourceVisual);
        }
Esempio n. 10
0
        public override PlatformVisual CreateView(PlatformVisual parent)
        {
            var view = new InteractiveNodeView();

            return(view);
        }
Esempio n. 11
0
 /// <summary>
 /// Selects this wire
 /// </summary>
 public override bool Select(DesignerSelectionMode mode, PlatformVisual source, ElementSelection elementSelection, UIPosition position)
 {
     ((SplineWireControl)this.View.AsFrameworkElement).Stroke = Brushes.Orange;
     return(base.Select(mode, source, elementSelection, position));
 }
Esempio n. 12
0
 /// <inheritdoc />
 protected override PlatformVisual CreateVisualControl(PlatformVisual parent)
 {
     return(new SplineWireControl());
 }
Esempio n. 13
0
        public override IVisualCollectionProvider GetVisualCollectionProvider(PlatformVisual visual)
        {
            var listBox = (ListBox)GetCommandSourceForVisual(visual);

            return(new CollectionOrderVisualCollectionProvider(listBox.Items));
        }
Esempio n. 14
0
 /// <inheritdoc />
 public override void CreateContextMenuContent(ICommandPresentationContext context, PlatformVisual sourceVisual)
 {
     base.CreateContextMenuContent(context, sourceVisual);
     context.Add(ContextMenuCommand);
 }
Esempio n. 15
0
        public override void CreateContextMenuContent(ICommandPresentationContext context, PlatformVisual sourceVisual)
        {
            var projectItem = sourceVisual.DataContext as ProjectItemViewModel;

            if (projectItem != null && projectItem.Envoy != null)
            {
                try
                {
                    var path = projectItem.Envoy?.QueryService <IReferencedFileService>().FirstOrDefault()?.StoragePath ?? string.Empty;
                    if (!string.IsNullOrEmpty(path))
                    {
                        context.Add(new ShellCommandInstance(LoadBetterCommmandCommand, path));
                        context.Add(new ShellCommandInstance(SaveBetterCommmandCommand, path));
                    }
                }
                catch (Exception)
                {
                }
            }
            base.CreateContextMenuContent(context, sourceVisual);
        }
 /// <inheritdoc />
 protected override PlatformVisual CreateVisualControl(PlatformVisual parent) => new VariantMatchStructureControl();