コード例 #1
0
        public bool LoadAasxRepoFile(string fn = null, AasxFileRepository repo = null)
        {
            try
            {
                this.TheAasxRepo = null;

                if (fn != null)
                {
                    // from file
                    this.TheAasxRepo = AasxFileRepository.Load(fn);
                }

                if (repo != null)
                {
                    // from RAM
                    this.TheAasxRepo = repo;
                }

                if (this.TheAasxRepo == null)
                {
                    return(false);
                }

                // rework buttons
                this.StackPanelTags.Children.Clear();
                foreach (var fm in this.TheAasxRepo.FileMap)
                {
                    var tag = fm.Tag.Trim();
                    if (tag != "")
                    {
                        var b = new Button();
                        b.Style      = (Style)FindResource("TranspRoundCorner");
                        b.Content    = "" + tag;
                        b.Height     = 40;
                        b.Width      = 40;
                        b.Margin     = new Thickness(5, 0, 5, 0);
                        b.Foreground = Brushes.White;
                        b.Click     += TagButton_Click;
                        this.StackPanelTags.Children.Add(b);
                        b.Tag = fm;
                    }
                }
            }
            catch (Exception ex)
            {
                AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                this.TheAasxRepo = null;
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public static bool PrintRepositoryCodeSheet(
            string repoFn = null, AasxFileRepository repoDirect = null, string title = "Asset repository")
        {
            List <CodeSheetItem> codeSheetItems = new List <CodeSheetItem>();

            try
            {
                AasxFileRepository repo = null;

                // load the data
                if (repoFn != null)
                {
                    // from file
                    repo = AasxFileRepository.Load(repoFn);
                }

                if (repoDirect != null)
                {
                    // from RAM
                    repo = repoDirect;
                }

                // got something
                if (repo == null)
                {
                    return(false);
                }

                // all assets
                foreach (var fmi in repo.FileMap)
                {
                    var csi = new CodeSheetItem();
                    csi.id          = fmi.AssetId;
                    csi.code        = fmi.CodeType2D;
                    csi.description = fmi.Description;
                    csi.normSize    = 1.0; // do not vary
                    codeSheetItems.Add(csi);
                }

                // print
                PrintCodeSheet(codeSheetItems.ToArray(), title);
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message, "Print AASX file repository");
                return(false);
            }
            return(true);
        }