Exemple #1
0
        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            // get text
            var aid = TextBoxAssetId.Text.Trim().ToLower();

            // first compare against tags
            if (this.TheAasxRepo != null && this.TheAasxRepo.FileMap != null)
            {
                foreach (var fm in this.TheAasxRepo.FileMap)
                {
                    if (aid == fm.Tag.Trim().ToLower())
                    {
                        this.ResultItem = fm;
                        ControlClosed?.Invoke();
                        return;
                    }
                }
            }

            // if not, compare asset ids
            if (this.TheAasxRepo != null && this.TheAasxRepo.FileMap != null)
            {
                foreach (var fm in this.TheAasxRepo.FileMap)
                {
                    if (aid == fm.AssetId.Trim().ToLower())
                    {
                        this.ResultItem = fm;
                        ControlClosed?.Invoke();
                        return;
                    }
                }
            }
        }
Exemple #2
0
 private void UserControl_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         // quit
         ResultItem = null;
         ControlClosed?.Invoke();
     }
 }
        public static bool GenerateRepositoryFromFileNames(string[] inputFns, string outputFn)
        {
            var res = true;

            // new repo
            var repo = new AasxFileRepository();

            // make records
            foreach (var ifn in inputFns)
            {
                // get one or multiple asset ids
                var assetIds = new List <string>();
                try
                {
                    var pkg = new AdminShellPackageEnv();
                    pkg.Load(ifn);
                    if (pkg.AasEnv != null && pkg.AasEnv.Assets != null)
                    {
                        foreach (var asset in pkg.AasEnv.Assets)
                        {
                            if (asset.identification != null)
                            {
                                assetIds.Add(asset.identification.id);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                    res = false;
                }

                // make the record(s)
                foreach (var assetid in assetIds)
                {
                    var fmi = new AasxFileRepository.FileItem();
                    fmi.Filename    = ifn;
                    fmi.CodeType2D  = "DMC";
                    fmi.AssetId     = assetid;
                    fmi.Description = "TODO";
                    fmi.Tag         = "TODO";

                    // add it
                    repo.FileMap.Add(fmi);
                }
            }

            // save
            using (var s = new StreamWriter(outputFn))
            {
                var json = JsonConvert.SerializeObject(repo, Formatting.Indented);
                s.WriteLine(json);
            }

            return(res);
        }
Exemple #4
0
        private void TagButton_Click(object sender, RoutedEventArgs e)
        {
            var b = sender as Button;

            if (b?.Tag != null && this.TheAasxRepo?.FileMap != null && this.TheAasxRepo.FileMap.Contains(b.Tag))
            {
                this.ResultItem = b.Tag as AasxFileRepository.FileItem;
                ControlClosed?.Invoke();
            }
        }
Exemple #5
0
        private void RepoList_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (sender == this.RepoList && e.ChangedButton == MouseButton.Right)
            {
                // store selected item for later (when context menu selection is done)
                var fi = this.RepoList.SelectedItem as AasxFileRepository.FileItem;
                this.rightClickSelectedItem = fi;

                // find context menu
                ContextMenu cm = this.FindResource("ContextMenuFileItem") as ContextMenu;
                if (cm == null)
                {
                    return;
                }

                // set some fields in context menu
                var x = AasxWpfBaseUtils.FindChildLogicalTree <TextBox>(cm, "TextBoxTag");
                if (x != null && fi != null)
                {
                    x.Text = "" + fi.Tag;
                }

                x = AasxWpfBaseUtils.FindChildLogicalTree <TextBox>(cm, "TextBoxDescription");
                if (x != null && fi != null)
                {
                    x.Text = "" + fi.Description;
                }

                x = AasxWpfBaseUtils.FindChildLogicalTree <TextBox>(cm, "TextBoxCode");
                if (x != null && fi != null)
                {
                    x.Text = "" + fi.CodeType2D;
                }

                // show context menu
                cm.PlacementTarget = sender as Button;
                cm.IsOpen          = true;
            }
        }
Exemple #6
0
        //
        // Mechanics
        //

        private void ButtonClose_Click(object sender, RoutedEventArgs e)
        {
            ResultItem = null;
            ControlClosed?.Invoke();
        }