Esempio n. 1
0
        public IList <ImageIdentifier> ImageQuery(ImageIdentifier queryCriteria)
        {
            CheckMinimumPermission();

            Dictionary <string, ImageIdentifier> combinedResults = new Dictionary <string, ImageIdentifier>();

            foreach (ImageServerQuery query in _partitionQueryList)
            {
                IList <ImageIdentifier> list = Query(queryCriteria, query.InstanceQuery);
                foreach (ImageIdentifier i in list)
                {
                    //TODO (CR May 2010): should this be keyed on the RetrieveAE/UID as well?
                    // There's a bug in InstanceServerQuery which causes results only to be returned
                    // from one partition.  This bug should be fixed also.
                    if (!combinedResults.ContainsKey(i.SopInstanceUid))
                    {
                        if (!query.Partition.Enabled)
                        {
                            i.InstanceAvailability = "OFFLINE";
                        }
                        combinedResults.Add(i.SopInstanceUid, i);
                    }
                }
            }

            return(new List <ImageIdentifier>(combinedResults.Values));
        }
Esempio n. 2
0
 public InquiryElement(object identifier, string title, ImageIdentifier imageIdentifier)
 {
     this.Identifier      = identifier;
     this.Title           = title;
     this.ImageIdentifier = imageIdentifier;
     this.IsEnabled       = true;
     this.Hint            = (string)null;
 }
Esempio n. 3
0
        /// <summary>
        /// Performs an IMAGE level query.
        /// </summary>
        /// <exception cref="FaultException{DataValidationFault}">Thrown when some part of the data in the request is poorly formatted.</exception>
        /// <exception cref="FaultException{QueryFailedFault}">Thrown when the query fails.</exception>
        public IList <ImageIdentifier> ImageQuery(ImageIdentifier queryCriteria)
        {
            var results = _real.ImageQuery(queryCriteria);

            AuditHelper.LogQueryIssued(_remoteServer.AETitle, _remoteServer.ScpParameters.HostName, EventSource.CurrentUser,
                                       EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid,
                                       queryCriteria.ToDicomAttributeCollection());

            return(results);
        }
Esempio n. 4
0
        public System.Collections.Generic.IList <ImageIdentifier> ImageQuery(ImageIdentifier queryCriteria)
        {
            var criteria = new ImageEntry {
                Image = queryCriteria
            };
            var result = Real.GetImageEntries(new GetImageEntriesRequest {
                Criteria = criteria
            });

            return(result.ImageEntries.Select(e => e.Image).ToList());
        }
Esempio n. 5
0
 public static extern int DismMountImage(
     [MarshalAs(UnmanagedType.LPWStr)] string ImagePath,
     [MarshalAs(UnmanagedType.LPWStr)] string MountPath,
     uint ImageIndex,
     [MarshalAs(UnmanagedType.LPWStr)] string ImageName,
     ImageIdentifier ImageIdentifier,
     uint MountFlags,
     SafeWaitHandle CancelHandle,
     DismInterop.ProgressCallback Progress,
     IntPtr UserData
     );
Esempio n. 6
0
        public System.Drawing.Image GetImage(System.Int32 Zoom, System.Int32 X, System.Int32 Y)
        {
            var ImageIdentifier = new ImageIdentifier(Zoom, X, Y);

            if (_Cache.ContainsKey(ImageIdentifier) == true)
            {
                return(_Cache[ImageIdentifier]);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
 public InquiryElement(
     object identifier,
     string title,
     ImageIdentifier imageIdentifier,
     bool isEnabled,
     string hint)
 {
     this.Identifier      = identifier;
     this.Title           = title;
     this.ImageIdentifier = imageIdentifier;
     this.IsEnabled       = isEnabled;
     this.Hint            = hint;
 }
        private void ExecuteRangedCavalryTypeSelection()
        {
            if (!Game.Current.IsDevelopmentMode)
            {
                return;
            }
            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            foreach (BasicCharacterObject rangedCavalryType in this._rangedCavalryTypes)
            {
                ImageIdentifier imageIdentifier = new ImageIdentifier(CharacterCode.CreateFrom(rangedCavalryType));
                inquiryElements.Add(new InquiryElement((object)rangedCavalryType, rangedCavalryType.Name.ToString(), imageIdentifier));
            }
            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("Ranged Cavalry Troop Types", string.Empty, inquiryElements, true, -1, "Done", "", new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver), new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver)));
        }
Esempio n. 9
0
        public IList <ImageIdentifier> LocateImagesBySeries(string studyInstanceUid, string seriesInstanceUid, out LocateFailureInfo[] failures)
        {
            Platform.CheckForEmptyString(studyInstanceUid, "studyInstanceUid");
            Platform.CheckForEmptyString(seriesInstanceUid, "seriesInstanceUid");

            var criteria = new ImageIdentifier {
                StudyInstanceUid = studyInstanceUid, SeriesInstanceUid = seriesInstanceUid
            };
            var result = LocateImages(new LocateImagesRequest {
                Criteria = criteria
            });

            failures = result.Failures.ToArray();
            return(result.Images);
        }
        internal override void ValidateResults(Eyes eyes, TestResults results)
        {
            SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results);

            ActualAppOutput[] actualAppOutputs = sessionResults.ActualAppOutput;
            Assert.AreEqual(2, actualAppOutputs.Length);

            ImageIdentifier image1 = actualAppOutputs[0].Image;

            Assert.IsTrue(image1.HasDom);
            Assert.AreEqual(1024, image1.Size.Width);
            Assert.AreEqual(768, image1.Size.Height);

            ImageIdentifier image2 = actualAppOutputs[1].Image;

            Assert.IsTrue(image2.HasDom);
        }
Esempio n. 11
0
        private static InquiryElement CreateInquiryElementFromItem(MBItemObject item)
        {
            var itemModifier =
                string.IsNullOrWhiteSpace(item.StringId) ? null : MBMBObjectManager.GetObjectById <ItemModifier>(item.StringId);
            var equipmentElement = new EquipmentElement(item, itemModifier);
            var imageIdentifier  = new ImageIdentifier(
                equipmentElement.Item.StringId,
                ImageIdentifierType.Item,
                equipmentElement.GetModifiedItemName().ToString());

            return(new InquiryElement(
                       equipmentElement.Item.StringId,
                       equipmentElement.GetModifiedItemName().ToString(),
                       imageIdentifier,
                       true,
                       equipmentElement.ToString()
                       ));
        }
Esempio n. 12
0
        private void ExecuteRangedCavalryTypeSelection()
        {
            if (!Game.Current.IsDevelopmentMode)
            {
                return;
            }
            List <InquiryElement> inquiryElementList = new List <InquiryElement>();

            using (List <BasicCharacterObject> .Enumerator enumerator = this._rangedCavalryTypes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BasicCharacterObject current         = enumerator.Current;
                    ImageIdentifier      imageIdentifier = new ImageIdentifier(CharacterCode.CreateFrom(current));
                    inquiryElementList.Add(new InquiryElement((object)current, ((object)current.Name).ToString(), imageIdentifier));
                }
            }
            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("Ranged Cavalry Troop Types", string.Empty, inquiryElementList, true, false, "Done", "", new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver), new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver), ""), false);
        }
        private static void ShowChildrenToAdopt()
        {
            var currentSettlement = Hero.MainHero.CurrentSettlement;
            var lostChildren      = OrphanAdoptionHelper.ChildrenForAdoptionAtSettlement(currentSettlement);

            var inquiryElements = new List <InquiryElement>();

            foreach (var hero in lostChildren)
            {
                var identifier = new ImageIdentifier(CharacterCode.CreateFrom(hero.CharacterObject));
                inquiryElements.Add(new InquiryElement(hero,
                                                       hero.Name + " - " + Math.Floor(hero.BirthDay.ElapsedYearsUntilNow),
                                                       identifier));
            }

            if (inquiryElements.Count < 1)
            {
                InformationManager.ShowInquiry(
                    new InquiryData("No child",
                                    "Empty orphanage", true, false, "OK", "", null, null),
                    true);
                GameMenu.SwitchToMenu("town");
            }
            else
            {
                InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData(
                                                                 "Children you may adopt", "", inquiryElements, true, 1, "Continue", null, args =>
                {
                    if (args == null)
                    {
                        return;
                    }
                    if (!args.Any())
                    {
                        return;
                    }
                    InformationManager.HideInquiry();
                    ConfirmAdoption(args.Select(element => element.Identifier as Hero).First());
                }, null));
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Validates this image detail for Image Details
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var validationBuilder = new ValidationBuilder(path, messages);

            if (SeriesIdentifier != null)
            {
                SeriesIdentifier.Validate(validationBuilder.Path + "ImageIdentifier", messages);
            }

            if (ImageIdentifier != null)
            {
                ImageIdentifier.Validate(validationBuilder.Path + "ImageIdentifier", messages);
            }

            if (ImageViewName != null)
            {
                ImageViewName.Validate(validationBuilder.Path + "ImageViewName", messages);
            }

            if (Image != null)
            {
                Image.Validate(validationBuilder.Path + "Image", messages);
            }
        }
Esempio n. 15
0
        public IList <ImageIdentifier> ImageQuery(ImageIdentifier criteria)
        {
            var entries = GetSopInstances(criteria);

            return(entries.Select(e => e.ToStoreEntry().Image).ToList());
        }
Esempio n. 16
0
        public static void PrizeSelectConsequence(MenuCallbackArgs args)
        {
            try
            {
                List <InquiryElement> prizeElements  = new List <InquiryElement>();
                TournamentGame        tournamentGame = Campaign.Current.TournamentManager.GetTournamentGame(Settlement.CurrentSettlement.Town);
                TournamentPrizePool   currentPool    = GetTournamentPrizePool(Settlement.CurrentSettlement);

                if (currentPool.Prizes.Count < TournamentXPSettings.Instance.NumberOfPrizeOptions)
                {
                    ItemObject prize = GenerateTournamentPrize(tournamentGame, currentPool, true);
                }

                //  InformationManager.Clear();
                foreach (ItemRosterElement ire in currentPool.Prizes)
                {
                    var p = ire.EquipmentElement;
                    try
                    {
                        var ii = new ImageIdentifier(p.Item.StringId, ImageIdentifierType.Item, p.GetModifiedItemName().ToString());
                        // prizeElements.Add(new InquiryElement(p.Item.StringId, ii, true, p.Item.ToToolTipTextObject().ToString()));
                        prizeElements.Add(new InquiryElement(
                                              p.Item.StringId,
                                              p.GetModifiedItemName().ToString(),
                                              ii,
                                              true,
                                              p.ToToolTipTextObject().ToString()
                                              ));
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Log("ERROR: Tournament Prize System\nFailed to add prize element to display" + p.Item.StringId);
                        ErrorLog.Log(ex.ToStringFull());
                    }
                }
                if (prizeElements.Count > 0)
                {
                    string     info  = "{=tourn012}You can choose an item from the list below as your reward if you win the tournament!";
                    TextObject descr = new TextObject(info);

                    if (TournamentXPSettings.Instance.DebugMode)
                    {
                        info  = "Town:{TOWN}\nMin:{MIN}\nMax:{MAX}\nProsperity:{PROSPERITY}\nTypes:{TYPES}";
                        descr = new TextObject(info);
                        descr.SetTextVariable("TOWN", currentPool.Town.Name);
                        descr.SetTextVariable("MIN", TournamentPrizePoolBehavior.GetMinPrizeValue().ToString());
                        descr.SetTextVariable("MAX", TournamentPrizePoolBehavior.GetMaxPrizeValue().ToString());
                        descr.SetTextVariable("PROSPERITY", currentPool.Town.GetProsperityLevel().ToString());
                        var types = "";
                        foreach (var t in TournamentPrizePoolBehavior.GetActivePrizeTypes())
                        {
                            types += t.ToString() + ", ";
                        }
                        types = types.Substring(0, types.Length - 2);
                        descr.SetTextVariable("TYPES", types);
                    }

                    InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData(
                                                                     new TextObject("{=tourn005}Tournament Prize Selection").ToString(), descr.ToString(), prizeElements, true, true, new TextObject("{=tourn006}OK").ToString(), new TextObject("{=tourn007}Cancel").ToString(),
                                                                     new Action <List <InquiryElement> >(OnSelectPrize), new Action <List <InquiryElement> >(OnDeSelectPrize)), true);
                    try
                    {
                        GameMenu.SwitchToMenu("town_arena");
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Log("ERROR: BMTournamentXP: Select Prize: Refresh Menu");
                        ErrorLog.Log(ex.ToStringFull());
                    }
                }
                else
                {
                    InformationManager.ShowInquiry(new InquiryData("Tournament Prize Selection", "You should not be seeing this.  Something went wrong generating the prize list. Your item restrictions may be set too narrow.", true, false, "OK", "", null, null));
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Log("ERROR: BMTournamentXP: Tournament Prize Selection");
                ErrorLog.Log(ex.ToStringFull());
            }
        }
Esempio n. 17
0
        public void SetImage(System.Int32 Zoom, System.Int32 X, System.Int32 Y, System.Drawing.Image Image)
        {
            var ImageIdentifier = new ImageIdentifier(Zoom, X, Y);

            _Cache[ImageIdentifier] = Image;
        }
Esempio n. 18
0
 public IList <ImageIdentifier> ImageQuery(ImageIdentifier queryCriteria)
 {
     throw new NotImplementedException();
 }
Esempio n. 19
0
        public IList <ImageIdentifier> ImageQuery(ImageIdentifier queryCriteria)
        {
            QueryDelegate <ImageIdentifier> query = (criteria, studyRootQuery) => studyRootQuery.ImageQuery(criteria);

            return(new GenericQuery <ImageIdentifier>(query, false).Query(queryCriteria));
        }
Esempio n. 20
0
        /// <summary>Extracts all .hg3 files that meet the pattern into .png's.</summary>
        public static ImageIdentifier ExtractHg3s(string inputDir, string outputDir,
                                                  Hg3Sorting sorting, string pattern,
                                                  Hgx2pngCallback progressCallback, Hgx2pngErrorCallback errorCallback,
                                                  string continueFile = null, string[] remainingFiles = null)
        {
            ImageIdentifier identifier  = new ImageIdentifier();
            DateTime        startTime   = DateTime.UtcNow;
            string          unsortedDir = outputDir;

            if (sorting.HasFlag(Hg3Sorting.Both))
            {
                unsortedDir = Path.Combine(unsortedDir, "Unsorted");
            }
            Directory.CreateDirectory(unsortedDir);

            if (string.IsNullOrWhiteSpace(pattern))
            {
                pattern = "*.hg3";
            }
            else if (!pattern.EndsWith(".hg3", StringComparison.OrdinalIgnoreCase) &&
                     !pattern.EndsWith(".hg3*", StringComparison.OrdinalIgnoreCase))
            {
                pattern += ".hg3";
            }
            string[]    files     = Directory.GetFiles(inputDir, pattern);
            int         fileCount = files.Length;
            Hgx2pngArgs args      = new Hgx2pngArgs()
            {
                FileCount = fileCount,
            };

            // Skip files if we're continuing from a later point
            int start = 0;

            if (continueFile != null)
            {
                for (start = 0; start < fileCount; start++)
                {
                    if (string.Compare(files[start], continueFile, true) >= 0)
                    {
                        break;
                    }
                }
            }

            // Remove non-remaining files.
            // This will be used for retrying files that had errors.
            if (remainingFiles != null)
            {
                List <string> fileList    = new List <string>(files);
                int           remainIndex = 0;
                int           remainCount = remainingFiles.Length;
                for (int i = 0; i < fileList.Count && remainIndex < remainCount &&
                     (continueFile == null || i < start); i++)
                {
                    if (PathHelper.IsPathTheSame(
                            remainingFiles[remainIndex], fileList[i]))
                    {
                        fileList.RemoveAt(i);
                        if (continueFile != null)
                        {
                            start--;
                        }
                        i--;
                        remainIndex++;
                    }
                }
                files = fileList.ToArray();
            }

            DateTime  lastRefresh = DateTime.MinValue;
            Stopwatch writeTime   = new Stopwatch();
            TimeSpan  refreshTime = TimeSpan.FromMilliseconds(20);

            //Stopwatch processTime = new Stopwatch();
            for (int i = start; i < fileCount; i++)
            {
                string file = files[i];
                string name = Path.GetFileNameWithoutExtension(file);

                args.FileIndex = i;
                args.FileName  = name;
                args.FilePath  = file;
                args.Ellapsed  = DateTime.UtcNow - startTime;
                // Round to nearest hundredth
                args.Percent = Math.Round((double)i / fileCount * 10000) / 100;
                // If true, cancel operation
                TimeSpan sinceRefresh = DateTime.UtcNow - lastRefresh;
                if (sinceRefresh >= refreshTime)
                {
                    lastRefresh = DateTime.UtcNow;
                    writeTime.Start();
                    if (progressCallback?.Invoke(args) ?? false)
                    {
                        return(identifier);
                    }
                    writeTime.Stop();
                }

                //processTime.Restart();
                List <Exception> exceptions = new List <Exception>();
                string[]         bmps;
                try {
                    //bmps = Hg3Convert.UnpackHg3(file, null, true);
                    ImageIdentification image = identifier.PreIdentifyImage(file);
                    bmps  = Extracting.Hg3ToBmp(file, image.ExpandImage);
                    image = identifier.IdentifyImage(bmps);
                    string sortedDir = Path.Combine(outputDir, image.OutputDirectory);
                    if (sorting.HasFlag(Hg3Sorting.Sorted))
                    {
                        Directory.CreateDirectory(sortedDir);
                    }
                    for (int j = 0; j < bmps.Length; j++)
                    {
                        try {
                            BmpToPng(bmps[j], sorting, unsortedDir, sortedDir);
                        }
                        catch (ExtractHg3Exception ex) {
                            exceptions.Add(ex);
                        }
                    }
                    //processTime.Stop();
                    //if (processTime.ElapsedMilliseconds >= 500)
                    //	Trace.WriteLine($"Large File: {new FileInfo(file).Length / 1024:###,###,###,###}KB [{processTime.ElapsedMilliseconds}ms]");
                }
                catch (ExtractHg3Exception ex) {
                    exceptions.Add(ex);
                }

                foreach (Exception ex in exceptions)
                {
                    args.TotalErrors++;
                    // If true, cancel operation
                    if (errorCallback?.Invoke(ex, args) ?? false)
                    {
                        return(identifier);
                    }
                }
            }
            args.Ellapsed = DateTime.UtcNow - startTime;
            args.Percent  = 100.0;
            progressCallback?.Invoke(args);
            Trace.WriteLine($"Console Write Time: {writeTime.Elapsed:mm\\:ss\\.fff}");
            return(identifier);
        }
Esempio n. 21
0
 private IEnumerable <SopInstance> GetSopInstances(ImageIdentifier criteria)
 {
     return(GetSopInstances(new ImageEntry {
         Image = criteria
     }));
 }
Esempio n. 22
0
        public static void ResortPngs(string resortDir,
                                      Hgx2pngCallback progressCallback, Hgx2pngErrorCallback errorCallback)
        {
            DateTime startTime = DateTime.UtcNow;

            ImageIdentifier identifier = new ImageIdentifier();
            Hgx2pngArgs     args       = new Hgx2pngArgs();

            string message = "Locating Pngs...";

            Console.WriteLine(message);
            args.FileCount = PathHelper.EnumerateAllFiles(resortDir, "*.png").Count();
            Console.WriteLine($"\r{new string(' ', message.Length)}");

            DateTime  lastRefresh = DateTime.MinValue;
            Stopwatch writeTime   = new Stopwatch();
            TimeSpan  refreshTime = TimeSpan.FromMilliseconds(20);
            int       i           = 0;

            foreach (string file in PathHelper.EnumerateAllFiles(resortDir, "*.png"))
            {
                //string file = files[i];
                ImageIdentification image = identifier.PreIdentifyImage(file);
                string path = Path.Combine(resortDir, image.OutputDirectory, Path.GetFileName(file));
                string name = Path.GetFileName(file);

                args.FileIndex = i++;
                args.FileName  = name;
                args.FilePath  = file;
                args.Ellapsed  = DateTime.UtcNow - startTime;
                // Round to nearest hundredth
                args.Percent = Math.Round((double)i / args.FileCount * 10000) / 100;
                // If true, cancel operation
                TimeSpan sinceRefresh = DateTime.UtcNow - lastRefresh;
                if (sinceRefresh >= refreshTime)
                {
                    lastRefresh = DateTime.UtcNow;
                    writeTime.Start();
                    if (progressCallback?.Invoke(args) ?? false)
                    {
                        return;
                    }
                    writeTime.Stop();
                }

                if (PathHelper.IsPathTheSame(path, file))
                {
                    continue;
                }

                string sortedDir = Path.Combine(resortDir, image.OutputDirectory);
                Directory.CreateDirectory(sortedDir);
                try {
                    BmpToPng(file, Hg3Sorting.Sorted, "", sortedDir);
                }
                catch (ExtractHg3Exception ex) {
                    args.TotalErrors++;
                    // If true, cancel operation
                    if (errorCallback?.Invoke(ex, args) ?? false)
                    {
                        return;
                    }
                }
            }
            args.Ellapsed = DateTime.UtcNow - startTime;
            args.Percent  = 100.0;
            progressCallback?.Invoke(args);
            Trace.WriteLine($"Console Write Time: {writeTime.Elapsed:mm\\:ss\\.fff}");
            PathHelper.DeleteAllEmptyDirectories(resortDir);
        }