2using System.Collections.Generic;
3using System.Threading.Tasks;
6using System.Windows.Controls;
7using System.Windows.Input;
8using System.Windows.Media;
9using System.Windows.Media.Imaging;
27 protected SortedDictionary<string, TreeNode> children =
null;
28 private object tag =
null;
29 private bool expanded =
false;
43 public abstract string Key
56 if (this.children is
null)
62 return this.children.Count > 0;
75 if (this.children is
null)
83 this.children.Values.CopyTo(
Children, 0);
100 return this.children.TryGetValue(ChildKey, out Child);
115 set => this.tag = value;
137 public abstract void Write(XmlWriter Output);
152 get {
return Visibility.Visible; }
168 get {
return Visibility.Hidden; }
192 public virtual string this[
string DisplayableParameter]
196 if (!(this.parameters is
null))
197 return this.parameters[DisplayableParameter];
205 if (this.parameters is
null)
208 this.parameters.AddRange(Parameters);
226 this.Raise(this.Updated);
234 get => this.expanded;
237 if (this.expanded != value)
239 this.expanded = value;
265 this.Raise(this.Expanded);
277 protected virtual bool IsLoaded
281 if (this.children is
null)
286 return this.children.Count != 1 || !this.children.ContainsKey(
string.Empty);
312 if (!(this.children is
null))
314 foreach (
TreeNode Node
in this.children.Values)
324 this.parent?.LoadChildren();
333 this.Raise(this.Collapsed);
350 throw new NotSupportedException();
374 OnDeleted.Raise(
this, EventArgs.Empty);
375 return Task.CompletedTask;
392 throw new NotSupportedException();
409 throw new NotSupportedException();
426 throw new NotSupportedException();
444 throw new NotSupportedException();
454 if (!(this.children is
null))
458 return this.children.Remove(Node.
Key);
465 internal void RenameChild(
string OldKey,
string NewKey,
TreeNode Node)
467 if (!(this.children is
null))
471 this.children.Remove(OldKey);
472 this.children[NewKey] = Node;
482 get {
return false; }
492 throw new NotSupportedException();
503 throw new NotSupportedException();
520 MainWindow.ErrorBox(
"You are not allowed to chat with this entity.");
521 return Task.CompletedTask;
556 throw new NotSupportedException();
565 throw new NotSupportedException();
575 throw new NotSupportedException();
588 Mouse.OverrideCursor = Cursors.Wait;
591 if (e2.Ok && !(e2.Form is
null))
596 return Task.CompletedTask;
608 throw new NotSupportedException();
616 get {
return false; }
624 throw new NotSupportedException();
636 CurrentGroup =
"Edit";
637 Menu.Items.Add(
new MenuItem()
644 Source =
new BitmapImage(
new Uri(
"../Graphics/Add.png", UriKind.Relative)),
651 if (!(this.Parent is
null) && this.Parent.
CanDelete)
653 CurrentGroup =
"Edit";
654 Menu.Items.Add(
new MenuItem()
661 Source =
new BitmapImage(
new Uri(
"../Graphics/delete_32_h.png", UriKind.Relative)),
670 CurrentGroup =
"Edit";
671 Menu.Items.Add(
new MenuItem()
678 Source =
new BitmapImage(
new Uri(
"../Graphics/Amitjakhu-Drip-Copy.16.png", UriKind.Relative)),
686 CurrentGroup =
"Edit";
687 Menu.Items.Add(
new MenuItem()
694 Source =
new BitmapImage(
new Uri(
"../Graphics/Amitjakhu-Drip-Clipboard.16.png", UriKind.Relative)),
703 this.GroupSeparator(ref CurrentGroup,
"Connection", Menu);
704 Menu.Items.Add(
new MenuItem()
711 Source =
new BitmapImage(
new Uri(
"../Graphics/refresh_document_16_h.png", UriKind.Relative)),
720 this.GroupSeparator(ref CurrentGroup,
"Connection", Menu);
721 Menu.Items.Add(
new MenuItem()
728 Source =
new BitmapImage(
new Uri(
"../Graphics/Spy-icon.png", UriKind.Relative)),
737 this.GroupSeparator(ref CurrentGroup,
"Communication", Menu);
738 Menu.Items.Add(
new MenuItem()
752 if (this.CanReadSensorData)
754 this.GroupSeparator(ref CurrentGroup,
"Communication", Menu);
755 Menu.Items.Add(
new MenuItem()
757 Header =
"Read _Momentary Values...",
762 Source =
new BitmapImage(
new Uri(
"../Graphics/history_16_h.png", UriKind.Relative)),
768 Menu.Items.Add(
new MenuItem()
770 Header =
"Read _Detailed Values...",
775 Source =
new BitmapImage(
new Uri(
"../Graphics/print_preview_lined_16_h.png", UriKind.Relative)),
782 if (this.CanSubscribeToSensorData)
784 this.GroupSeparator(ref CurrentGroup,
"Communication", Menu);
785 Menu.Items.Add(
new MenuItem()
787 Header =
"Su_bscribe to Momentary Values...",
792 Source =
new BitmapImage(
new Uri(
"../Graphics/rss-feed-icon_16.png", UriKind.Relative)),
799 if (this.CanConfigure)
801 this.GroupSeparator(ref CurrentGroup,
"Communication", Menu);
802 Menu.Items.Add(
new MenuItem()
804 Header =
"Configure _Parameters...",
809 Source =
new BitmapImage(
new Uri(
"../Graphics/Settings-icon_16.png", UriKind.Relative)),
818 this.GroupSeparator(ref CurrentGroup,
"Database", Menu);
819 Menu.Items.Add(
new MenuItem()
826 Source =
new BitmapImage(
new Uri(
"../Graphics/search_16_h.png", UriKind.Relative)),
834 while (!(Loop is
null))
843 protected void GroupSeparator(ref
string CurrentGroup,
string Group, ContextMenu Menu)
845 if (CurrentGroup != Group)
847 if (!
string.IsNullOrEmpty(CurrentGroup))
848 Menu.Items.Add(
new MenuItem());
850 CurrentGroup = Group;
Interaction logic for xaml
Abstract base class for selectable items.
Abstract base class for tree nodes in the connection view.
virtual void OnCollapsed()
Raises the Collapsed event.
virtual void UnloadChildren()
Method is called to notify children can be unloaded.
virtual void UnloadGrandchildren()
Method is called to notify grandchildren can be unloaded.
virtual bool CanCopy
If node can be copied to clipboard.
TreeNode[] Children
Children of the node. If null, children are not loaded.
virtual void Added(MainWindow Window)
Is called when the node has been added to the main window.
virtual Visibility ImageResource2Visibility
If the second image resource is visible or not.
virtual Task GetConfigurationForm(EventHandlerAsync< DataFormEventArgs > Callback, object State)
Gets the configuration form for the node.
virtual void Copy()
Is called when the user wants to copy the node to the clipboard.
abstract ImageSource ImageResource
Image resource for the node.
virtual void Removed(MainWindow Window)
Is called when the node has been removed from the main window.
virtual void Add()
Is called when the user wants to add a node to the current node.
object Tag
Object tagged to the node.
virtual void Edit()
Is called when the user wants to edit a node.
virtual void AddContexMenuItems(ref string CurrentGroup, ContextMenu Menu)
Adds context sensitive menu items to a context menu.
virtual bool CanChat
If it's possible to chat with the node.
virtual Task< SensorDataSubscriptionRequest > SubscribeSensorDataMomentaryReadout(FieldSubscriptionRule[] Rules)
Starts subscription of momentary sensor data values.
virtual bool CanConfigure
If it's possible to configure control parameters on the node.
abstract bool CanRecycle
If the node can be recycled.
virtual DisplayableParameters DisplayableParameters
Gets available displayable parameters.
abstract bool CanDelete
If the node can be deleted.
virtual void LoadSiblings()
Method is called to make sure siblings are loaded.
virtual Task< SensorDataClientRequest > StartSensorDataMomentaryReadout()
Starts readout of momentary sensor data values.
virtual void Search()
Performs a search on the node.
abstract bool CanAddChildren
If children can be added to the node.
virtual void SelectionChanged()
Method called when selection has been changed.
virtual Task SendChatMessage(string Message, string ThreadId, MarkdownDocument Markdown)
Sends a chat message.
EventHandler Collapsed
Event raised when the node has been collapsed.
abstract string Key
Key in parent child collection.
virtual bool CanPaste
If node can be pasted to, from the clipboard.
TreeNode Parent
Parent node. May be null if a root node.
bool? HasChildren
If the node has child nodes or not. If null, the state is undefined, and might need to be checked by ...
virtual ImageSource ImageResource2
Secondary image resource for the node.
bool TryGetChild(string ChildKey, out TreeNode Child)
Tries to get the child node corresponding to a given key.
virtual void AddSniffer(ISniffer Sniffer)
Adds a sniffer to the node.
EventHandler Expanded
Event raised when the node has been expanded.
virtual bool CanSearch
If it's possible to search for data on the node.
virtual Task< SensorDataClientRequest > StartSensorDataFullReadout()
Starts readout of all sensor data values.
virtual void Paste()
Is called when the user wants to paste data from the clipboard to the node.
virtual void OnExpanded()
Raises the Expanded event.
abstract string Header
Tree Node header text.
virtual bool IsSniffable
If the node can be sniffed.
virtual Task Recycle(MainWindow Window)
Is called when the user wants to recycle the node.
virtual void ViewClosed()
Method called when the view has been closed.
abstract string TypeName
Node Type Name.
abstract string ToolTip
Tool Tip for node.
TreeNode(TreeNode Parent)
Abstract base class for tree nodes in the connection view.
virtual void OnUpdated()
Raises the Updated event.
virtual bool CustomDeleteQuestion
If the node provides a custom delete question.
virtual Visibility ImageResourceVisibility
If the second image resource is visible or not.
override void OnSelected()
Raises the Selected event.
EventHandler Updated
Raised when the node has been updated. The sender argument will contain a reference to the node.
virtual bool CanSubscribeToSensorData
If it's possible to subscribe to sensor data from the node.
virtual void LoadChildren()
Method is called to make sure children are loaded.
virtual bool CanReadSensorData
If it's possible to read sensor data from the node.
abstract void Write(XmlWriter Output)
Saves the object to a file.
virtual bool RemoveChild(TreeNode Node)
Removes a child node.
bool IsExpanded
If the node is expanded.
abstract bool CanEdit
If the node can be edited.
virtual Task< bool > RemoveSniffer(ISniffer Sniffer)
Removes a sniffer from the node.
virtual void Dispose()
Disposes of the node and its resources.
virtual void Configure()
Starts configuration of the node.
virtual Task Delete(TreeNode Parent, EventHandler OnDeleted)
Method called when a node is to be deleted.
Class representing a normal XMPP account.
Contains a markdown document. This markdown document class supports original markdown,...
Maintains the status of a field subscription rule.
Contains information about a message logged on a node.
Base class for all node parameters.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...