private void SetSelectedState(VisualElementGeneric ve, bool newState)
        {
            // ok?
            if (ve == null)
            {
                return;
            }

            // new state?
            if (newState)
            {
                ve.IsSelected = true;
                if (!_selectedItems.Contains(ve))
                {
                    _selectedItems.Add(ve);
                }
            }
            else
            {
                ve.IsSelected = false;
                if (_selectedItems.Contains(ve))
                {
                    _selectedItems.Remove(ve);
                }
            }
        }
Beispiel #2
0
        public int RefreshAllChildsFromMainData(VisualElementGeneric root)
        {
            /* TODO (MIHO, 2021-01-04): check to replace all occurences of RefreshFromMainData() by
             * making the tree-items ObservableCollection and INotifyPropertyChanged */

            // access
            if (root == null)
            {
                return(0);
            }

            // self
            var sum = 1;

            root.RefreshFromMainData();

            // children?
            if (root.Members != null)
            {
                foreach (var child in root.Members)
                {
                    sum += RefreshAllChildsFromMainData(child);
                }
            }

            // ok
            return(sum);
        }
Beispiel #3
0
        public void PrepareDispEditEntity(AdminShell.PackageEnv package, VisualElementGeneric entity, bool editMode, bool hintMode)
        {
            // make UI visible settings ..
            // panels
            if (!editMode)
            {
                ContentPanelNoEdit.Visibility = Visibility.Visible;
                ContentPanelEdit.Visibility   = Visibility.Hidden;
            }
            else
            {
                ContentPanelNoEdit.Visibility = Visibility.Hidden;
                ContentPanelEdit.Visibility   = Visibility.Visible;
            }
            // further
            ShowContent.IsEnabled      = false;
            DragSource.Foreground      = Brushes.DarkGray;
            DownloadContent.IsEnabled  = false;
            this.showContentPackageUri = null;

            // update element view
            DispEditEntityPanel.DisplayOrEditVisualAasxElement(package, entity, editMode, hintMode, (thePackageAux == null) ? null : new AdminShell.PackageEnv[] { thePackageAux }, flyoutProvider: this);

            // show it
            Dispatcher.BeginInvoke((Action)(() => ElementTabControl.SelectedIndex = 0));

            // some entities require special handling
            if (entity is VisualElementSubmodelElement && (entity as VisualElementSubmodelElement).theWrapper.submodelElement is AdminShell.File)
            {
                var elem = (entity as VisualElementSubmodelElement).theWrapper.submodelElement;
                ShowContent.IsEnabled      = true;
                this.showContentPackageUri = (elem as AdminShell.File).value;
                DragSource.Foreground      = Brushes.Black;
            }
        }
        public VisualElementPluginExtension(
            VisualElementGeneric parent,
            TreeViewLineCache cache,
            AdminShellPackageEnv package,
            AdminShell.Referable referable,
            Plugins.PluginInstance plugin,
            AasxIntegrationBase.AasxPluginResultVisualExtension ext)
            : base()
        {
            this.Parent       = parent;
            this.Cache        = cache;
            this.thePackage   = package;
            this.theReferable = referable;
            this.thePlugin    = plugin;
            this.theExt       = ext;

            this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#A0A0A0"));
            this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070"));
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "" + ext?.Tag;

            RefreshFromMainData();
            RestoreFromCache();
        }
Beispiel #5
0
 public VisualElementEnvironmentItem(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.PackageEnv package, AdminShell.AdministrationShellEnv env, ItemType itemType)
     : base()
 {
     this.Parent      = parent;
     this.Cache       = cache;
     this.thePackage  = package;
     this.theEnv      = env;
     this.theItemType = itemType;
     this.Background  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#B0B0B0"));
     this.Border      = (SolidColorBrush)(new BrushConverter().ConvertFrom("#404040"));
     this.Caption     = $"\"{ItemTypeNames[(int)itemType]}\"";
     this.Info        = "";
     this.IsTopLevel  = true;
     this.TagString   = "Env";
     if (theItemType == ItemType.EmptySet)
     {
         this.TagString = "\u2205";
         this.Caption   = "No information available";
     }
     if (theItemType == ItemType.Package && thePackage != null)
     {
         this.TagString = "\u25a2";
         this.Info     += "" + thePackage.Filename;
     }
     this.TagBg = this.Border;
     this.TagFg = Brushes.White;
     RestoreFromCache();
 }
 public VisualElementHistoryItem(VisualElementGeneric VisualElement,
                                 AdminShell.Identification ReferableAasId = null, AdminShell.Reference ReferableReference = null)
 {
     this.VisualElement      = VisualElement;
     this.ReferableAasId     = ReferableAasId;
     this.ReferableReference = ReferableReference;
 }
        public void Push(VisualElementGeneric ve)
        {
            // access
            if (ve == null)
            {
                return;
            }

            // for ve, try to find the AAS (in the parent hierarchy)
            var veAas = ve.FindAllParents((v) => { return(v is VisualElementAdminShell); },
                                          includeThis: true).FirstOrDefault();

            // for ve, find the Referable to be ve or superordinate ..
            var veRef = ve.FindAllParents((v) =>
            {
                var derefdo = v?.GetDereferencedMainDataObject();
                // success implies AdminShell.IGetReference as well
                return(derefdo is AdminShell.Referable);
            }, includeThis: true).FirstOrDefault();

            // check, if ve can identify a Referable, to which a symbolic link can be done ..
            AdminShell.Identification aasid  = null;
            AdminShell.Reference      refref = null;

            if (veAas != null && veRef != null)
            {
                aasid = (veAas as VisualElementAdminShell)?.theAas?.identification;

                var derefdo = veRef.GetDereferencedMainDataObject();
                refref = (derefdo as AdminShell.IGetReference)?.GetReference();
            }

            // some more special cases
            if (refref == null && ve is VisualElementConceptDescription vecd)
            {
                refref = vecd.theCD?.GetReference();
            }

            // found some referable Reference?
            if (refref == null)
            {
                return;
            }

            // in case of plug in, make it more specific
            if (ve is VisualElementPluginExtension vepe && vepe.theExt?.Tag != null)
            {
                refref += new AdminShell.Key(AdminShell.Key.FragmentReference, false,
                                             AdminShell.Key.Custom, "Plugin:" + vepe.theExt.Tag);
            }

            // add, only if not already there
            if (history.Count < 1 || history[history.Count - 1].VisualElement != ve)
            {
                history.Add(new VisualElementHistoryItem(ve, aasid, refref));
            }

            // is enabled
            buttonBack.IsEnabled = true;
        }
Beispiel #8
0
        public bool TrySelectVisualElement(VisualElementGeneric ve, bool wishExpanded)
        {
            // access?
            if (ve == null)
            {
                return(false);
            }

            // select
            ve.IsSelected = true;
            if (wishExpanded)
            {
                // go upward the tree in order to expand, as well
                var sii = ve;
                while (sii != null)
                {
                    sii.IsExpanded = true;
                    sii            = sii.Parent;
                }
            }
            if (wishExpanded == false)
            {
                ve.IsExpanded = false;
            }
            Woodoo(ve);

            // OK
            return(true);
        }
        public bool TrySelectVisualElement(VisualElementGeneric ve, bool?wishExpanded)
        {
            // access?
            if (ve == null)
            {
                return(false);
            }

            // select (but no callback!)
            SelectSingleVisualElement(ve, preventFireItem: true);

            if (wishExpanded == true)
            {
                // go upward the tree in order to expand, as well
                var sii = ve;
                while (sii != null)
                {
                    sii.IsExpanded = true;
                    sii            = sii.Parent;
                }
            }
            if (wishExpanded == false)
            {
                ve.IsExpanded = false;
            }
            Woodoo(ve);

            // OK
            return(true);
        }
        public VisualElementOperationVariable(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env,
            AdminShell.Referable parentContainer, AdminShell.OperationVariable opvar,
            AdminShell.OperationVariable.Direction dir)
            : base()
        {
            this.Parent       = parent;
            this.Cache        = cache;
            this.theEnv       = env;
            this.theContainer = parentContainer;
            this.theOpVar     = opvar;
            this.theDir       = dir;

            this.Background = Brushes.White;
            this.Border     = Brushes.White;
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "In";
            if (this.theDir == AdminShell.OperationVariable.Direction.Out)
            {
                this.TagString = "Out";
            }
            if (this.theDir == AdminShell.OperationVariable.Direction.InOut)
            {
                this.TagString = "InOut";
            }

            this.TagBg = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070"));;
            this.TagFg = Brushes.White;
            RefreshFromMainData();
            RestoreFromCache();
        }
        public VisualElementEnvironmentItem(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShellPackageEnv package,
            AdminShell.AdministrationShellEnv env, ItemType itemType)
            : base()
        {
            this.Parent      = parent;
            this.Cache       = cache;
            this.thePackage  = package;
            this.theEnv      = env;
            this.theItemType = itemType;

            this.Background = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkAccentColor"];
            this.Border     = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.Caption    = $"\"{ItemTypeNames[(int)itemType]}\"";
            this.Info       = "";
            this.IsTopLevel = true;
            this.TagString  = "Env";
            if (theItemType == ItemType.EmptySet)
            {
                this.TagString = "\u2205";
                this.Caption   = "No information available";
            }
            if (theItemType == ItemType.Package && thePackage != null)
            {
                this.TagString = "\u25a2";
                this.Info     += "" + thePackage.Filename;
            }
            RestoreFromCache();
        }
 public bool Contains(VisualElementGeneric ve)
 {
     if (displayedTreeViewLines != null)
     {
         return(displayedTreeViewLines.ContainsDeep(ve));
     }
     return(false);
 }
        /// <summary>
        /// Return true, if <code>mem</code> has to be deleted, because not in filter.
        /// </summary>
        /// <param name="mem"></param>
        /// <param name="fullFilterElementName"></param>
        /// <returns></returns>
        public bool FilterLeavesOfVisualElements(VisualElementGeneric mem, string fullFilterElementName)
        {
            if (fullFilterElementName == null)
            {
                return(false);
            }
            fullFilterElementName = fullFilterElementName.Trim().ToLower();
            if (fullFilterElementName == "")
            {
                return(false);
            }

            // has Members -> is not leaf!
            if (mem.Members != null && mem.Members.Count > 0)
            {
                // go into non-leafs mode -> simply go over list
                var todel = new List <VisualElementGeneric>();
                foreach (var x in mem.Members)
                {
                    if (FilterLeavesOfVisualElements(x, fullFilterElementName))
                    {
                        todel.Add(x);
                    }
                }
                // delete items on list
                foreach (var td in todel)
                {
                    mem.Members.Remove(td);
                }
            }
            else
            {
                // consider lazy loading
                if (mem is VisualElementEnvironmentItem memei &&
                    memei.theItemType == VisualElementEnvironmentItem.ItemType.DummyNode)
                {
                    return(false);
                }

                // this member is a leaf!!
                var isIn = false;
                var mdo  = mem.GetMainDataObject();
                if (mdo != null && mdo is AdminShell.Referable)
                {
                    var mdoen = (mdo as AdminShell.Referable).GetElementName().Trim().ToLower();
                    isIn = fullFilterElementName.IndexOf(mdoen, StringComparison.Ordinal) >= 0;
                }
                if (mdo != null && mdo is AdminShell.Reference)
                {
                    var mdoen = (mdo as AdminShell.Reference).GetElementName().Trim().ToLower();
                    isIn = fullFilterElementName.IndexOf(mdoen, StringComparison.Ordinal) >= 0;
                }
                return(!isIn);
            }
            return(false);
        }
Beispiel #14
0
 public bool Contains(VisualElementGeneric ve)
 {
     // ReSharper disable UnusedVariable
     foreach (var e in FindAllVisualElement((o) => { return(ve == o); }))
     {
         return(true);
     }
     // ReSharper enable UnusedVariable
     return(false);
 }
        public void Push(VisualElementGeneric ve)
        {
            // add, only if not already there
            if (history.Count < 1 || history[history.Count - 1] != ve)
            {
                history.Add(ve);
            }

            // is enabled
            buttonBack.IsEnabled = true;
        }
 public void SelectSingleVisualElement(VisualElementGeneric ve, bool preventFireItem = false)
 {
     if (ve == null)
     {
         return;
     }
     ve.IsSelected = true;
     _selectedItems.Clear();
     _selectedItems.Add(ve);
     if (!preventFireItem)
     {
         FireSelectedItem();
     }
 }
Beispiel #17
0
 public VisualElementConceptDescription(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.ConceptDescription cd)
     : base()
 {
     this.Parent     = parent;
     this.Cache      = cache;
     this.theEnv     = env;
     this.theCD      = cd;
     this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0D0D0"));
     this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#606060"));
     this.TagString  = "CD";
     this.TagBg      = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070"));;
     this.TagFg      = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Beispiel #18
0
 public VisualElementView(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.View vw)
     : base()
 {
     this.Parent     = parent;
     this.Cache      = cache;
     this.theEnv     = env;
     this.theView    = vw;
     this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#C0C0C0"));
     this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#404040"));
     this.TagString  = "View";
     this.TagBg      = this.Border;
     this.TagFg      = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Beispiel #19
0
 public VisualElementSupplementalFile(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.PackageEnv package, AdminShell.PackageSupplementaryFile sf)
     : base()
 {
     this.Parent     = parent;
     this.Cache      = cache;
     this.thePackage = package;
     this.theFile    = sf;
     this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0D0D0"));
     this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#606060"));
     this.TagString  = "\u25a4";
     this.TagBg      = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070"));;
     this.TagFg      = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Beispiel #20
0
 public VisualElementAdminShell(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.AdministrationShell aas)
     : base()
 {
     this.Parent     = parent;
     this.Cache      = cache;
     this.theEnv     = env;
     this.theAas     = aas;
     this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#88A6D2"));
     this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4370B3"));
     this.TagString  = "AAS";
     this.TagBg      = this.Border;
     this.TagFg      = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Beispiel #21
0
 public VisualElementReference(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.Reference rf)
     : base()
 {
     this.Parent       = parent;
     this.Cache        = cache;
     this.theEnv       = env;
     this.theReference = rf;
     this.Background   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0D0D0"));
     this.Border       = (SolidColorBrush)(new BrushConverter().ConvertFrom("#606060"));
     this.TagString    = "\u2b95";
     this.TagBg        = this.Border;
     this.TagFg        = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Beispiel #22
0
        //
        // Element management
        //

        private IEnumerable <VisualElementGeneric> FindAllVisualElementInternal(VisualElementGeneric root)
        {
            yield return(root);

            if (root?.Members != null)
            {
                foreach (var m in root.Members)
                {
                    foreach (var e in FindAllVisualElementInternal(m))
                    {
                        yield return(e);
                    }
                }
            }
        }
Beispiel #23
0
 public VisualElementSubmodelRef(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.SubmodelRef smr, AdminShell.Submodel sm)
     : base()
 {
     this.Parent         = parent;
     this.Cache          = cache;
     this.theEnv         = env;
     this.theSubmodelRef = smr;
     this.theSubmodel    = sm;
     this.Background     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#CBD8EB"));
     this.Border         = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4370B3"));
     this.TagString      = "Sub";
     this.TagBg          = this.Border;
     this.TagFg          = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
Beispiel #24
0
        private VisualElementGeneric SearchInListOfVisualElements(VisualElementGeneric tvl, object dataObject,
                                                                  bool alsoDereferenceObjects = false)
        {
            if (tvl == null || dataObject == null)
            {
                return(null);
            }

            // Test for VirtualEntities. Allow a string comparison
            var mdo = tvl.GetMainDataObject();

            if (mdo == null)
            {
                return(null);
            }
            var s1 = mdo as string;
            var s2 = dataObject as string;

            if (s1 != null && s1 == s2)
            {
                return(tvl);
            }

            // normal comparison
            if (tvl.GetMainDataObject() == dataObject)
            {
                return(tvl);
            }

            // extended?
            if (alsoDereferenceObjects && tvl.GetDereferencedMainDataObject() == dataObject)
            {
                return(tvl);
            }

            // recursion
            foreach (var mem in tvl.Members)
            {
                var x = SearchInListOfVisualElements(mem, dataObject, alsoDereferenceObjects);
                if (x != null)
                {
                    return(x);
                }
            }
            return(null);
        }
Beispiel #25
0
        public VisualElementSubmodelElement(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper wrap)
            : base()
        {
            this.Parent       = parent;
            this.Cache        = cache;
            this.theEnv       = env;
            this.theContainer = parentContainer;
            this.theWrapper   = wrap;
            this.Background   = Brushes.White;
            this.Border       = Brushes.White;

            this.TagString = "Elem";
            if (wrap != null && wrap.submodelElement != null)
            {
                if (wrap.submodelElement is AdminShell.Property)
                {
                    this.TagString = "Prop";
                }
                if (wrap.submodelElement is AdminShell.File)
                {
                    this.TagString = "File";
                }
                if (wrap.submodelElement is AdminShell.Blob)
                {
                    this.TagString = "Blob";
                }
                if (wrap.submodelElement is AdminShell.ReferenceElement)
                {
                    this.TagString = "Ref";
                }
                if (wrap.submodelElement is AdminShell.RelationshipElement)
                {
                    this.TagString = "Rel";
                }
                if (wrap.submodelElement is AdminShell.SubmodelElementCollection)
                {
                    this.TagString = "Coll";
                }
            }

            this.TagBg = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070"));;
            this.TagFg = Brushes.White;
            RefreshFromMainData();
            RestoreFromCache();
        }
        public VisualElementReference(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env,
            AdminShell.Reference rf)
            : base()
        {
            this.Parent       = parent;
            this.Cache        = cache;
            this.theEnv       = env;
            this.theReference = rf;

            this.Background = Brushes.White;
            this.Border     = Brushes.White;
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "\u2b95";
            RefreshFromMainData();
            RestoreFromCache();
        }
        public VisualElementAdminShell(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShellPackageEnv package,
            AdminShell.AdministrationShellEnv env, AdminShell.AdministrationShell aas)
            : base()
        {
            this.Parent     = parent;
            this.Cache      = cache;
            this.thePackage = package;
            this.theEnv     = env;
            this.theAas     = aas;

            this.Background = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkAccentColor"];
            this.Border     = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "AAS";
            RefreshFromMainData();
            RestoreFromCache();
        }
        public VisualElementSubmodelRef(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env,
            AdminShell.SubmodelRef smr, AdminShell.Submodel sm)
            : base()
        {
            this.Parent         = parent;
            this.Cache          = cache;
            this.theEnv         = env;
            this.theSubmodelRef = smr;
            this.theSubmodel    = sm;

            this.Background = (SolidColorBrush)System.Windows.Application.Current.Resources["LightAccentColor"];
            this.Border     = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "SM";
            RefreshFromMainData();
            RestoreFromCache();
        }
        //
        // Element View Drawing
        //

        private VisualElementGeneric SearchInListOfVisualElements(VisualElementGeneric tvl, object dataObject)
        {
            if (tvl == null || dataObject == null)
            {
                return(null);
            }
            if (tvl.GetMainDataObject() == dataObject)
            {
                return(tvl);
            }
            foreach (var mem in tvl.Members)
            {
                var x = SearchInListOfVisualElements(mem, dataObject);
                if (x != null)
                {
                    return(x);
                }
            }
            return(null);
        }
        public VisualElementSubmodelElement(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env,
            AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper wrap)
            : base()
        {
            this.Parent       = parent;
            this.Cache        = cache;
            this.theEnv       = env;
            this.theContainer = parentContainer;
            this.theWrapper   = wrap;

            this.Background = Brushes.White;
            this.Border     = Brushes.White;
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = wrap.GetElementAbbreviation();

            RefreshFromMainData();
            RestoreFromCache();
        }