Пример #1
0
        /// <summary>
        /// Add a <see cref="UIElement"/> that contains information (e.g. the name of the object), and display it with a given object (e.g. the object to interact with).
        /// </summary>
        /// <param name="name">The element taht displays information about the elment being displayed (e.g. descriptive name).</param>
        /// <param name="displayer">The element that displays the object in the cell (normally the same as <see ref="visualiser"/>).</param>
        /// <param name="visualiser">The object that is responsible for the link with a variable (normally the same as <see ref="displayer"/>).</param>
        /// <param name="registry">The registry which contains the value that should be displayed. May or may not be <c>null</c> (depending on the visualiser).</param>
        /// <param name="key">The key to access the exact value required. May or may not be <c>null</c> (depending on the visualiser).</param>
        public void Add([CanBeNull] UIElement name, [CanBeNull] UIElement displayer, [CanBeNull] IParameterVisualiser visualiser, IRegistry registry, string key)
        {
            Content.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            if (visualiser != null)
            {
                visualiser.SynchronisationHandler = SynchronisationHandler;
                visualiser.Registry = registry;
                visualiser.Key      = key;
                visualiser.Read();
            }

            // add the name to the left
            if (name != null)
            {
                Grid.SetColumn(name, 0);
                Grid.SetRow(name, RowPos);
                Content.Children.Add(name);
            }

            if (displayer != null)
            {
                Grid.SetColumn(displayer, 1);
                Grid.SetRow(displayer, RowPos);
                Content.Children.Add(displayer);
            }

            RowPos++;
        }
Пример #2
0
        public void Add(UIElement name, object visualiserAndDisplayer, IRegistry registry, string key)
        {
            UIElement            displayer  = visualiserAndDisplayer as UIElement;
            IParameterVisualiser visualiser = visualiserAndDisplayer as IParameterVisualiser;

            if (displayer != null && visualiser != null)
            {
                Add(name, displayer, visualiser, registry, key);
            }
            else
            {
                _log.Warn($"The passed visualiser and displayer {visualiserAndDisplayer} is either not a {typeof(UIElement)} or not a {typeof(IParameterVisualiser)}. Use other Add overloads if you want to add something.");
            }
        }
Пример #3
0
        public IParameterVisualiser Add(UIElement name, Type visualiserType, IRegistry registry, string key)
        {
            //UIElement displayer = (UIElement) Activator.CreateInstance(Manager.VisualiserType(visualiserType));
            UIElement            displayer  = (UIElement)Manager.InstantiateVisualiser(visualiserType);
            IParameterVisualiser visualiser = displayer as IParameterVisualiser;

            if (visualiser == null)
            {
                _log.Warn($"{Manager.VisualiserType(visualiserType).Name} is not an {nameof(IParameterVisualiser)} and can therefore not be linked to a value.");
            }

            Add(name, displayer, visualiser, registry, key);

            return(visualiser);
        }
Пример #4
0
 /// <summary>
 /// Create a hook with a certain time step
 /// </summary>
 /// <param name="timestep">The time step.</param>
 /// <param name="visualiser">The visualisers that will be updated.</param>
 public PollParameterHook(ITimeStep timestep, IParameterVisualiser visualiser) : base(timestep)
 {
     ParameterRegistry[VisualiserIdentifier] = visualiser;
 }
Пример #5
0
 /// <summary>
 /// Set the state of a visualiser to success (i.e. don't care anymore).
 /// </summary>
 /// <param name="visualiser">The visualiser that has changed its state.</param>
 public virtual void Success(IParameterVisualiser visualiser)
 {
     PendingItems.Remove(visualiser);
     ErroredItems.Remove(visualiser);
 }
Пример #6
0
 /// <summary>
 /// Set the state of a visualiser to errored.
 /// </summary>
 /// <param name="visualiser">The visualiser that has changed its state.</param>
 public virtual void Errored(IParameterVisualiser visualiser)
 {
     PendingItems.Remove(visualiser);
     ErroredItems.Add(visualiser);
 }
Пример #7
0
 /// <summary>
 /// Set the state of a visualiser to pending.
 /// </summary>
 /// <param name="visualiser">The visualiser that has changed its state.</param>
 public virtual void Pending(IParameterVisualiser visualiser)
 {
     PendingItems.Add(visualiser);
 }