private async Task UpdateInfoAsync()
        {
            try
            {
                await _updateSemaphore.WaitAsync();

                InfoCollection.Clear();
                string nl   = Environment.NewLine;
                var    cred = DevicePortalUtil.GetCredential();
                if (cred != null)
                {
                    var ring = await DevicePortalUtil.GetFlightRingAsync(cred.UserName, cred.Password);

                    if (ring != null)
                    {
                        CurrentFlightRing = ring;
                    }
                    var telemetryLevelOutput = await DevicePortalUtil.GetTelemetryLevelAsync(cred.UserName, cred.Password);

                    if (telemetryLevelOutput != DevicePortalUtil.InvalidTelemetryValue)
                    {
                        InfoCollection.Add(new InfoDisplayData(Common.GetLocalizedText("TelemetryLevelText") + ": ",
                                                               DevicePortalUtil.TelemetryLevelToFriendlyName(telemetryLevelOutput)));
                    }
                }
                else
                {
                    App.LogService.Write("Credential is null", Windows.Foundation.Diagnostics.LoggingLevel.Warning);
                }
            }
            finally
            {
                _updateSemaphore.Release();
            }
        }
예제 #2
0
        public HashInfoProvider(IEnumerable <HashCalculator> hashCalculators)
        {
            infos = new InfoCollection();

            int i = 0;

            if (hashCalculators.FirstOrDefault() == null)
            {
                return;
            }
            if (hashCalculators.FirstOrDefault().HashObj.Hash == null)
            {
                return;
            }


            foreach (var hashCalculator in hashCalculators)
            {
                BaseOption baseOption = ((hashCalculator.HashObj is TTH) ? BaseOption.Base32 : BaseOption.Heximal);
                Add(StreamType.Hash, i++, EntryKey.None, BaseConverter.ToString(hashCalculator.HashObj.Hash, baseOption).ToLower(), hashCalculator.Name.ToLower());

                if (hashCalculator.HashObj is Ed2k)
                {
                    Ed2k ed2k = (Ed2k)hashCalculator.HashObj;
                    if (!ed2k.BlueIsRed)
                    {
                        baseOption = BaseOption.Heximal;
                        Add(StreamType.Hash, i++, EntryKey.None, BaseConverter.ToString(ed2k.BlueHash, baseOption).ToLower(), hashCalculator.Name.ToLower() + "_alt");
                    }
                }
            }
        }
예제 #3
0
 public void DownCommand(TestVM curr)
 {
     if (InfoCollection.IndexOf(curr) < InfoCollection.Count)
     {
         InfoCollection.Move(InfoCollection.IndexOf(curr), InfoCollection.IndexOf(curr) + 1);
     }
 }
예제 #4
0
        protected override void RegisterAvailableViewsCore(InfoCollection collection)
        {
            base.RegisterAvailableViewsCore(collection);

            //Sürükle bırak yaptığımızda oluşucak gridin varsayılan yerine bizim oluşturduğumuz grid den meydana gelmesi için yazıldı.
            collection.Add(new MyGridInfoRegistrator());
        }
예제 #5
0
        public MatroskaProvider(MatroskaFile mfi)
        {
            infos = new InfoCollection();
            MFI   = mfi;

            Add(EntryKey.Size, MFI.SectionSize.ToString(), "byte");
            Add(EntryKey.Date, MFI.Segment.SegmentInfo.ProductionDate.HasValue ? MFI.Segment.SegmentInfo.ProductionDate.Value.ToString("yyyy.MM.dd HH.mm.ss.ffff") : null, null);
            Add(EntryKey.Duration, MFI.Segment.SegmentInfo.Duration.HasValue ? (MFI.Segment.SegmentInfo.Duration.Value * (MFI.Segment.SegmentInfo.TimecodeScale / 1000000000d)).ToString("0.000", CultureInfo.InvariantCulture) : null, "s");
            Add(EntryKey.WritingApp, MFI.Segment.SegmentInfo.WritingApp, null);
            Add(EntryKey.MuxingApp, MFI.Segment.SegmentInfo.MuxingApp, null);


            int[] indeces = new int[3];
            bool  hasVideo, hasAudio, hasSubtitle, is3d;

            hasVideo = hasAudio = hasSubtitle = is3d = false;
            foreach (var track in MFI.Segment.Tracks.Items)
            {
                if (!track.TrackType.HasValue)
                {
                    throw new Exception("TrackType missing");
                }
                switch (track.TrackType.Value)
                {
                case TrackEntrySection.Types.Video:
                    AddStreamInfo(track, StreamType.Video, indeces[0]++);
                    hasVideo = true;
                    is3d     = track.Video.StereoMode != VideoSection.DisplayMode.Mono;
                    is3d    |= track.TrackOperation != null ? track.TrackOperation.Is3d : false;
                    break;

                case TrackEntrySection.Types.Audio: AddStreamInfo(track, StreamType.Audio, indeces[1]++); hasAudio = true; break;

                case TrackEntrySection.Types.Subtitle: AddStreamInfo(track, StreamType.Text, indeces[2]++); hasSubtitle = true; break;

                default: break;
                }
            }

            if (MFI.EbmlHeader.DocType.Equals("webm"))
            {
                Add(EntryKey.Extension, "webm", null);
            }
            else if (is3d)
            {
                Add(EntryKey.Extension, "mk3d", null);
            }
            else if (hasVideo)
            {
                Add(EntryKey.Extension, "mkv", null);
            }
            else if (hasAudio)
            {
                Add(EntryKey.Extension, "mka", null);
            }
            else if (hasSubtitle)
            {
                Add(EntryKey.Extension, "mks", null);
            }
        }
예제 #6
0
        //public static TestVM building1 { set; get; }


        public void UpCommand(TestVM curr)
        {
            if (InfoCollection.IndexOf(curr) >= 1)
            {
                InfoCollection.Move(InfoCollection.IndexOf(curr), InfoCollection.IndexOf(curr) - 1);
            }
        }
        public AggressionProvider(InfoCollection information, Dictionary <InfoProviderType, InfoProviderBase> allInformationProviders, AIRandomControl aiRandomControl)
            : base(information, InfoProviderType.AIAggression, allInformationProviders, aiRandomControl)
        {
            requiredInfoTypes = new List <InfoType>()
            {
            };
            providedInfoTypes = new List <InfoPiece> {
                //Old scaled values
                new InfoPiece(InfoType.AP_AvgScaledOppRaiseFreq_Double, 0),
                new InfoPiece(InfoType.AP_AvgScaledOppCallFreq_Double, 0),
                new InfoPiece(InfoType.AP_AvgScaledOppPreFlopPlayFreq_Double, 0),

                //New live values including accuracy
                new InfoPiece(InfoType.AP_AvgLiveOppPreFlopPlayFreq_Double, 0),
                new InfoPiece(InfoType.AP_AvgLiveOppPostFlopPlayFreq_Double, 0),
                new InfoPiece(InfoType.AP_AvgLiveOppCurrentRoundAggr_Double, 0),
                new InfoPiece(InfoType.AP_AvgLiveOppCurrentRoundAggrAcc_Double, 0),
            };

            AddProviderInformationTypes();

            lock (locker)
            {
                if (CurrentJob == null)
                {
                    playerAggressionCache = new List <PlayerAggression>();
                }
                else
                {
                    //For now we will just start a blank list but we should be using the serialised data in the job.
                    playerAggressionCache = new List <PlayerAggression>();
                }
            }
        }
예제 #8
0
 public void GetAllKeyInfoCollection()
 {
     foreach (var item in KeyList)
     {
         InfoCollection.Add(GetKeyInfo(item));
     }
 }
예제 #9
0
        /// <summary>
        /// Retrieve the latest commit matching the specified criteria
        /// </summary>
        /// <param name="streamId">Unique stream identifier</param>
        /// <param name="atBucketRevision">Get the last commit less or equal the specified bucket revision</param>
        /// <returns>Last commit info</returns>
        public async Task <CommitInfo> GetLastCommitAsync(Guid?streamId = null, long?atBucketRevision = null)
        {
            if (atBucketRevision <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(atBucketRevision), "Parameter must be greater than 0.");
            }

            var filter = Builders <CommitInfo> .Filter.Empty;

            if (streamId != null)
            {
                filter = filter & Builders <CommitInfo> .Filter.Eq(p => p.StreamId, streamId.Value);
            }
            if (atBucketRevision != null)
            {
                filter = filter & Builders <CommitInfo> .Filter.Lte(p => p.BucketRevision, atBucketRevision.Value);
            }

            var result = await InfoCollection
                         .Find(filter)
                         .Sort(Builders <CommitInfo> .Sort.Descending(p => p.BucketRevision))
                         .FirstOrDefaultAsync()
                         .ConfigureAwait(false);

            return(result);
        }
예제 #10
0
 /// <summary>
 ///  向容器中注册所有的控件
 /// </summary>
 /// <param name="collection"></param>
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(new CustomGridInfoRegistrator());//表格 自定义
     //collection.Add(new CustomBandedGridInfoRegistrator());//带表头
     //collection.Add(new CardInfoRegistrator());//卡片
     //collection.Add(new AdvBandedGridInfoRegistrator());//高级表头
 }
예제 #11
0
        void ShowNavigationItemActionOnExecuting(object sender, CancelEventArgs cancelEventArgs)
        {
            InfoCollection availableViews = ((XpandGridListEditor)View.Editor).Grid.AvailableViews;

            foreach (var availableView in availableViews.OfType <XpandXafGridView>())
            {
                CloseNestedWindow(availableView);
            }
        }
예제 #12
0
        //-------------------------------------------------------------------------

        public AddManualEntryPopup(MainForm form, InfoCollection infoCollection) : base(form, infoCollection)
        {
            _infoCollection = infoCollection;

            InitializeComponent();

            popupGroupBox.Location = new Point(12, 92);
            popupGroupBox.Visible  = false;
            form.Controls.Add(popupGroupBox);
        }
예제 #13
0
        //-------------------------------------------------------------------------

        public static IEnumerable <BasePopup> CreatePopups(MainForm form, InfoCollection infoCollection)
        {
            object[] constructorArgs = { form, infoCollection };

            foreach (var type in Assembly.GetAssembly(typeof(BasePopup)).GetTypes().
                     Where(myType => myType.IsSubclassOf(typeof(BasePopup))))
            {
                yield return(( BasePopup )Activator.CreateInstance(type, constructorArgs));
            }
        }
예제 #14
0
        //-------------------------------------------------------------------------

        public UpdateExistingCategoryBudgetPopup(MainForm form, InfoCollection infoCollection) : base(form, infoCollection)
        {
            _infoCollection = infoCollection;

            InitializeComponent();

            popupGroupBox.Location = new Point(12, 92);
            popupGroupBox.Visible  = false;
            form.Controls.Add(popupGroupBox);

            RefreshCategoriesComboBox();
        }
예제 #15
0
            public AIInstance(InstanceSelector instanceSelector, int instanceNumber, Queue decisionRequestQueue, AIRandomControl aiRandomControl)
            {
                taskTrees = new Dictionary <RequestedInfoKey, InfoProviderTaskTree>();

                this.instanceSelector     = instanceSelector;
                this.instanceNumber       = instanceNumber;
                this.decisionRequestQueue = decisionRequestQueue;
                this.decisionInProgress   = new object();

                //Setup the AI's and providers here
                infoStore = new InfoCollection();

                infoProviderDictList = new Dictionary <InfoProviderType, InfoProviderBase>();
                aiDictList           = new Dictionary <AIGeneration, AIBase>();

                //Setup the 1st infostore instance
                var GP   = new GameProvider(infoStore, infoProviderDictList, aiRandomControl);
                var WRP  = new ProviderWinRatio.WinRatioProvider(infoStore, infoProviderDictList, aiRandomControl);
                var BP   = new BetsProvider(infoStore, infoProviderDictList, aiRandomControl);
                var CP   = new CardsProvider(infoStore, infoProviderDictList, aiRandomControl);
                var AP   = new AggressionProvider(infoStore, infoProviderDictList, aiRandomControl);
                var PAPP = new PlayerActionPredictionProvider(infoStore, infoProviderDictList, aiRandomControl);

                //Hard lock the infostore collection preventing any further changes.
                infoStore.HardLockInfoList();

                //Setup the AI list
                //We are going to lock the AI's into random mode.
                aiDictList.Add(AIGeneration.SimpleV1, new SimpleAIV1(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV2, new SimpleAIV2(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV1, new NeuralAIv1(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV3, new SimpleAIV3(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV2, new NeuralAIv2(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV4AggressionTrack, new SimpleAIV4AggTrack(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV3, new NeuralAIv3(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV4, new NeuralAIv4(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV5, new SimpleAIv5(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV6, new SimpleAIv6(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV5, new NeuralAIv5(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV6, new NeuralAIv6(aiRandomControl));
                aiDictList.Add(AIGeneration.SimpleV7, new SimpleAIv7(aiRandomControl));
                aiDictList.Add(AIGeneration.CheatV1, new CheatV1(aiRandomControl));
                aiDictList.Add(AIGeneration.NeuralV7, new NeuralAIv7(aiRandomControl));

                if (ConcurrencyMode.Concurrency == ConcurrencyMode.ConcurencyModel.MultiCore)
                {
                    providerTasks = new Dictionary <InfoProviderType, Task>();
                }
                else
                {
                    providerActions = new Dictionary <InfoProviderType, Action>();
                }
            }
예제 #16
0
        public OgmOggProvider(OgmOggFile provider)
        {
            infos         = new InfoCollection();
            this.provider = provider;

            Add(EntryKey.Size, provider.FileSize.ToString(), "byte");
            Add(EntryKey.Overhead, provider.Overhead.ToString(), "byte");

            Add(EntryKey.Duration, provider.Tracks.Max(t => !(t is UnkownTrack) && t.Duration.HasValue ? t.Duration.Value.TotalSeconds : 0).ToString("0.000", CultureInfo.InvariantCulture), "s");

            bool isOgv = true;

            int[] indeces = new int[4];
            foreach (var track in provider.Tracks)
            {
                if (track is VideoTrack)
                {
                    AddStreamInfo(track, StreamType.Video, indeces[0]++);
                    isOgv &= track.CodecName != null && track.CodecName.Equals("Theora");
                }
                else if (track is AudioTrack)
                {
                    AddStreamInfo(track, StreamType.Audio, indeces[1]++);
                    isOgv &= track.CodecName != null && (track.CodecName.Equals("Flac") || track.CodecName.Equals("Vorbis"));
                }
                else if (track is SubtitleTrack)
                {
                    AddStreamInfo(track, StreamType.Text, indeces[2]++);
                    isOgv = false;
                }
                else if (track is UnkownTrack)
                {
                    Add(StreamType.Unkown, indeces[3], EntryKey.Id, () => track.Id.ToString(), null);
                    Add(StreamType.Unkown, indeces[3], EntryKey.Size, () => track.Length.ToString(), "byte");
                    indeces[3]++;
                    isOgv = false;
                }
            }

            if (provider.Tracks.Count == 1 && ((Collection <Track>)provider.Tracks)[0].CodecName.Equals("Vorbis"))
            {
                Add(EntryKey.Extension, "ogg", null);
            }
            else if (isOgv)
            {
                Add(EntryKey.Extension, "ogv", null);
            }
            else
            {
                Add(EntryKey.Extension, "ogm", null);
            }
        }
예제 #17
0
        //-------------------------------------------------------------------------

        public MainForm(InfoCollection infoCollection)
        {
            _infoCollection = infoCollection;

            _popups = PopupFactory.CreatePopups(this, infoCollection).ToList();

            InitialiseForms();
            SetupEvents();

            InitializeComponent();

            InitialiseMainForm();
        }
예제 #18
0
파일: AppData.cs 프로젝트: derekadombek/Xam
        public string Serialize()
        {
            if (CurrentInfo != null)
            {
                CurrentInfoIndex = InfoCollection.IndexOf(CurrentInfo);
            }
            XmlSerializer serializer = new XmlSerializer(typeof(AppData));

            using (StringWriter stringWrite = new StringWriter())
            {
                serializer.Serialize(stringWrite, this);
                return(stringWrite.GetStringBuilder().ToString());
            }
        }
예제 #19
0
        static void Main()
        {
            _infoCollection = new InfoCollection(new ManualEntriesManager(),
                                                 new CategoriesManager(),
                                                 new RecurringEntryManager());

            _appManager = new AppManager(_infoCollection);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(_infoCollection));

            _appManager.Shutdown();
        }
예제 #20
0
        public bool HasLocation()
        {
            var hasLocation = false;

            foreach (var areasCollection in InfoCollection.Select(x => x.AreasCollection))
            {
                foreach (var area in areasCollection)
                {
                    if (area.Latitude.HasValue && area.Longitude.HasValue)
                    {
                        hasLocation = true;
                        break;
                    }
                }
            }
            return(hasLocation);
        }
예제 #21
0
        public void PrintSummaryInfo(bool detail = true)
        {
            int totalCount = InfoCollection.Sum(x => x.KeyLength + x.ValueLength);

            Logger.WriteInfo($"Total keys count:{InfoCollection.Count.ToString()}, Bytes total length:{totalCount.ToString()}");
            Logger.WriteInfo("All keys type info:");
            foreach (var key in HashList.Keys)
            {
                //Keys Percent info
                int    itemCount = HashList[key].Sum(x => x.KeyLength + x.ValueLength);
                double percent   = (double)(itemCount * 100) / (double)totalCount;
                Logger.WriteInfo($"Key item: {key}, Count: {HashList[key].Count.ToString()}, Percent:{percent:0.00}%");
            }

            Logger.WriteInfo("All hash keys type info:");
            ConvertHashType();
            foreach (var key in ProtoHashList.Keys)
            {
                Logger.WriteInfo($"Key item: {key}, Count: {ProtoHashList[key].Count.ToString()}");
            }

            if (!detail)
            {
                return;
            }

            //打印Basic信息
            var sortList = InfoCollection.OrderBy(o => o.BasicString).ThenBy(o => o.HashString).ToList();

            foreach (var item in sortList)
            {
                Logger.WriteInfo($"BasicCategory={item.BasicString}, HashCategory={item.HashString}, Length=[{item.KeyLength},{item.ValueLength}], RedisKey={item.RedisKey}");
            }
            //打印Object信息
            foreach (var item in HashList.Keys)
            {
                Logger.WriteInfo("------------------------------------------------------------------------------------");
                Logger.WriteInfo($"Data Type: {item}");
                foreach (var keyinfo in HashList[item])
                {
                    Logger.WriteInfo(keyinfo.ValueInfo.ToString());
                }
                Logger.WriteInfo("------------------------------------------------------------------------------------");
            }
        }
예제 #22
0
        /// <summary>
        /// Trigger an update of all info providers in 1st instance
        /// </summary>
        /// <returns></returns>
        private void UpdateInfoStore(long playerId, databaseCache currentCache, InfoCollection localInfoStore, List <InfoProviderBase> localInfoProviders)
        {
            //Update the shared cache tracker for the current cache
            cacheTracker.Update(playerId, currentCache);

            //Reset all update flags to false
            localInfoStore.ResetAllUpdateFlags();

            foreach (var provider in localInfoProviders)
            {
                provider.TriggerUpdateInfo(playerId, currentCache, cacheTracker);
            }

            foreach (var provider in localInfoProviders)
            {
                provider.UpdateFinished(providersTimeOutMilliSeconds);
            }
        }
예제 #23
0
        protected override void RegisterAvailableViewsCore(InfoCollection collection)
        {
            base.RegisterAvailableViewsCore(collection);
            collection.Add(new MyGridViewInfoRegistrator());

            this.KeyDown += (s, e) =>
            {
                try
                {
                    var gc = this;

                    if (gc != null)
                    {
                        ControlNavigator cn = (ControlNavigator)gc.EmbeddedNavigator;
                        switch (e.KeyCode)
                        {
                        case Keys.F6:
                            if (e.Shift)
                            {
                                if (cn.Buttons.Remove.Enabled && cn.Buttons.Remove.Visible)
                                {
                                    cn.Buttons.DoClick(cn.Buttons.Remove);
                                }
                            }
                            else
                            {
                                if (cn.Buttons.Append.Enabled && cn.Buttons.Append.Visible)
                                {
                                    cn.Buttons.DoClick(cn.Buttons.Append);
                                }
                            }

                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.GetFullExceptionErrMessage());
                }
            };
        }
예제 #24
0
        public Play GetDecision(DecisionRequest currentDecision, InfoCollection infoStore)
        {
            //this.playerId = playerId;
            //this.aiConfigStr = aiConfigStr;
            //this.cache = genericGameCache;
            this.currentDecision = currentDecision;
            this.infoStore       = infoStore;

            //Set the random seed value here
            if (aiRandomControl.DecisionRandomPerHandSeedEnabled)
            {
                //decimal distanceToDealer = (infoStore.GetInfoValue(InfoType.GP_DealerDistance_Byte) - 1) / (infoStore.GetInfoValue(InfoType.GP_NumActivePlayers_Byte) - 1);
                //decimal currentWinPercentage = infoStore.GetInfoValue(InfoType.WR_CardsOnlyWinPercentage);
                //decimal currentPotValue = infoStore.GetInfoValue(InfoType.BP_TotalPotAmount_Decimal);

                var hashFunc = new Func <long, long>((long key) =>
                {
                    key = (~key) + (key << 21);            // key = (key << 21) - key - 1;
                    key = key ^ (key >> 24);
                    key = (key + (key << 3)) + (key << 8); // key * 265
                    key = key ^ (key >> 14);
                    key = (key + (key << 2)) + (key << 4); // key * 21
                    key = key ^ (key >> 28);
                    key = key + (key << 31);
                    return(key);
                });

                //long randomSeed = hashFunc((long)(7919 * (distanceToDealer + 1))) ^
                //    hashFunc((long)(currentWinPercentage * 100)) ^
                //    hashFunc((long)(currentPotValue * 991)) ^
                //    hashFunc(1 + currentDecision.Cache.getNumHandsPlayed());

                //(randomGen as CMWCRandom).ReSeed(randomSeed);

                //We can now seed based on the table and hand random number
                (randomGen as CMWCRandom).ReSeed((long)(currentDecision.Cache.TableRandomNumber ^ hashFunc(currentDecision.Cache.CurrentHandRandomNumber()) ^ hashFunc(1 + currentDecision.Cache.getCurrentHandSeqIndex())));
            }

            //Validate the decision and then set the decision time if currently 0.
            return(GetDecision());
        }
예제 #25
0
        public MatroskaProvider(MatroskaFile mfi)
        {
            infos = new InfoCollection();
            MFI = mfi;

            Add(EntryKey.Size, MFI.SectionSize.ToString(), "byte");
            Add(EntryKey.Date, MFI.Segment.SegmentInfo.ProductionDate.HasValue ? MFI.Segment.SegmentInfo.ProductionDate.Value.ToString("yyyy.MM.dd HH.mm.ss.ffff") : null, null);
            Add(EntryKey.Duration, MFI.Segment.SegmentInfo.Duration.HasValue ? (MFI.Segment.SegmentInfo.Duration.Value * (MFI.Segment.SegmentInfo.TimecodeScale / 1000000000d)).ToString("0.000", CultureInfo.InvariantCulture) : null, "s");
            Add(EntryKey.WritingApp, MFI.Segment.SegmentInfo.WritingApp, null);
            Add(EntryKey.MuxingApp, MFI.Segment.SegmentInfo.MuxingApp, null);

            int[] indeces = new int[3];
            bool hasVideo, hasAudio, hasSubtitle, is3d;
            hasVideo = hasAudio = hasSubtitle = is3d = false;
            foreach(var track in MFI.Segment.Tracks.Items) {
                if(!track.TrackType.HasValue) throw new Exception("TrackType missing");
                switch(track.TrackType.Value) {
                    case TrackEntrySection.Types.Video:
                        AddStreamInfo(track, StreamType.Video, indeces[0]++);
                        hasVideo = true;
                        is3d = track.Video.StereoMode != VideoSection.DisplayMode.Mono;
                        is3d |= track.TrackOperation != null ? track.TrackOperation.Is3d : false;
                        break;
                    case TrackEntrySection.Types.Audio: AddStreamInfo(track, StreamType.Audio, indeces[1]++); hasAudio = true; break;
                    case TrackEntrySection.Types.Subtitle: AddStreamInfo(track, StreamType.Text, indeces[2]++); hasSubtitle = true; break;
                    default: break;
                }
            }

            if(MFI.EbmlHeader.DocType.Equals("webm")) {
                Add(EntryKey.Extension, "webm", null);
            } else if(is3d) {
                Add(EntryKey.Extension, "mk3d", null);
            } else if(hasVideo) {
                Add(EntryKey.Extension, "mkv", null);
            } else if(hasAudio) {
                Add(EntryKey.Extension, "mka", null);
            } else if(hasSubtitle) {
                Add(EntryKey.Extension, "mks", null);
            }
        }
예제 #26
0
        public HashInfoProvider(IEnumerable<HashCalculator> hashCalculators)
        {
            infos = new InfoCollection();

            int i = 0;
            if(hashCalculators.FirstOrDefault() == null) return;
            if(hashCalculators.FirstOrDefault().HashObj.Hash == null) return;

            foreach(var hashCalculator in hashCalculators) {
                BaseOption baseOption = ((hashCalculator.HashObj is TTH) ? BaseOption.Base32 : BaseOption.Heximal);
                Add(StreamType.Hash, i++, EntryKey.None, BaseConverter.ToString(hashCalculator.HashObj.Hash, baseOption).ToLower(), hashCalculator.Name.ToLower());

                if(hashCalculator.HashObj is Ed2k) {
                    Ed2k ed2k = (Ed2k)hashCalculator.HashObj;
                    if(!ed2k.BlueIsRed) {
                        baseOption = BaseOption.Heximal;
                        Add(StreamType.Hash, i++, EntryKey.None, BaseConverter.ToString(ed2k.BlueHash, baseOption).ToLower(), hashCalculator.Name.ToLower() + "_alt");
                    }
                }
            }
        }
예제 #27
0
        public OgmOggProvider(OgmOggFile provider)
        {
            infos = new InfoCollection();
            this.provider = provider;

            Add(EntryKey.Size, provider.FileSize.ToString(), "byte");
            Add(EntryKey.Overhead, provider.Overhead.ToString(), "byte");

            Add(EntryKey.Duration, provider.Tracks.Max(t => !(t is UnkownTrack) && t.Duration.HasValue ? t.Duration.Value.TotalSeconds : 0).ToString("0.000", CultureInfo.InvariantCulture), "s");

            bool isOgv = true;
            int[] indeces = new int[4];
            foreach(var track in provider.Tracks) {
                if(track is VideoTrack) {
                    AddStreamInfo(track, StreamType.Video, indeces[0]++);
                    isOgv &= track.CodecName != null && track.CodecName.Equals("Theora");
                } else if(track is AudioTrack) {
                    AddStreamInfo(track, StreamType.Audio, indeces[1]++);
                    isOgv &= track.CodecName != null && (track.CodecName.Equals("Flac") || track.CodecName.Equals("Vorbis"));
                } else if(track is SubtitleTrack) {
                    AddStreamInfo(track, StreamType.Text, indeces[2]++);
                    isOgv = false;
                } else if(track is UnkownTrack) {
                    Add(StreamType.Unkown, indeces[3], EntryKey.Id, () => track.Id.ToString(), null);
                    Add(StreamType.Unkown, indeces[3], EntryKey.Size, () => track.Length.ToString(), "byte");
                    indeces[3]++;
                    isOgv = false;
                }
            }

            if(provider.Tracks.Count == 1 && ((Collection<Track>)provider.Tracks)[0].CodecName.Equals("Vorbis")) {
                Add(EntryKey.Extension, "ogg", null);
            } else if(isOgv) {
                Add(EntryKey.Extension, "ogv", null);
            } else {
                Add(EntryKey.Extension, "ogm", null);
            }
        }
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(new BasicGridViewInfoRegistratorReadOnly());
 }
예제 #29
0
 ///<summary>Registers the views usable by the grid.</summary>
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(SmartGridView.CreateRegistrator());
 }
예제 #30
0
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(new MyGridViewInfoRegistrator());
     collection.Add(new MyBandedGridViewInfoRegistrator());
 }
예제 #31
0
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(new CustomGridInfoRegistrator());
 }
예제 #32
0
 ///<summary>Registers the views usable by the grid.</summary>
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(SmartGridView.CreateRegistrator());
 }
예제 #33
0
        public FileExtensionProvider(string path)
        {
            infos = new InfoCollection();

            var fileTypes = new IFileType[] {
                //new MpegAudioFileType(),
                //new MpegVideoFileType(),
                //new WavFileType(),
                new SrtFileType(),
                new AssSsaFileType(),
                new IdxFileType(),
                new SamiFileType(),
                new C7zFileType(),
                new ZipFileType(),
                new RarFileType(),
                new RaFileType(),
                new FlacFileType(),
                new LrcFileType(),
                new AviFileType(),
                new SubFileType(),
                new TmpFileType(),
                new PJSFileType(),
                new JSFileType(),
                new RTFileType(),
                new SMILFileType(),
                new TTSFileType(),
                new XSSFileType(),
                new ZeroGFileType(),
                new SUPFileType(),
                new FanSubberFileType(),
                new Sasami2kFileType()
            };

            using(Stream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                int b;
                bool needMoreBytes = true;
                while(needMoreBytes) {
                    b = stream.ReadByte();
                    if(b == -1 || stream.Position > 1 << 30) return;

                    needMoreBytes = false;
                    foreach(var fileType in fileTypes.Where(f => f.IsCandidate)) {
                        fileType.CheckMagicByte((byte)b);
                        needMoreBytes |= fileType.NeedsMoreMagicBytes;
                    }
                }

                foreach(var fileType in fileTypes.Where(f => f.IsCandidate)) {
                    stream.Position = 0;
                    fileType.ElaborateCheck(stream);
                }
            }

            var exts = fileTypes.Where(f => f.IsCandidate);

            if(exts.Count() != 1) {
                if(exts.Any(ft => ft.PossibleExtensions[0].Equals("zip"))) exts = new List<IFileType>(new IFileType[] { new ZipFileType() });
                if(exts.Any(ft => ft.PossibleExtensions[0].Equals("7z"))) exts = new List<IFileType>(new IFileType[] { new C7zFileType() });
                if(exts.Any(ft => ft.PossibleExtensions[0].Equals("rar"))) exts = new List<IFileType>(new IFileType[] { new RarFileType() });
            }

            string extsStr;
            if(fileTypes.Any(f => f.IsCandidate)) {
                extsStr = exts.Aggregate<IFileType, IEnumerable<string>>(new string[0], (acc, f) => acc.Concat(f.PossibleExtensions)).Aggregate((acc, str) => acc + " " + str);
            } else {
                extsStr = null;
            }

            Add(EntryKey.Extension, extsStr, null);

            if(exts.Count() == 1) exts.Single().AddInfo(Add);
        }
예제 #34
0
 protected override void RegisterAvailableViewsCore(InfoCollection collection)
 {
     base.RegisterAvailableViewsCore(collection);
     collection.Add(new CustomGridInfoRegistrator());
 }
예제 #35
0
        //-------------------------------------------------------------------------

        public BarGraph(InfoCollection infoCollection)
        {
            _infoCollection = infoCollection;

            _bars = new Bars(_infoCollection.CategoriesInfo);
        }
예제 #36
0
        public PlayerActionPredictionProvider(InfoCollection information, Dictionary <InfoProviderType, InfoProviderBase> allInformationProviders, AIRandomControl aiRandomControl)
            : base(information, InfoProviderType.PlayerActionPrediction, allInformationProviders, aiRandomControl)
        {
            requiredInfoTypes = new List <InfoType>()
            {
                InfoType.CP_AKQToBoardRatio_Real,                                       //Same for all
                InfoType.CP_AOnBoard_Bool,                                              //Same for all
                InfoType.CP_FlushPossible_Bool,                                         //Same for all
                InfoType.CP_KOnBoard_Bool,                                              //Same for all
                InfoType.CP_StraightPossible_Bool,                                      //Same for all
                InfoType.GP_GameStage_Byte,                                             //Same for all
                InfoType.GP_NumActivePlayers_Byte,                                      //Provided
                InfoType.GP_NumPlayersDealtIn_Byte,                                     //Same for all
                InfoType.GP_NumTableSeats_Byte,                                         //Same for all
                InfoType.GP_NumUnactedPlayers_Byte,                                     //Provided
                InfoType.BP_BetsToCall_Byte,                                            //Provided
                InfoType.BP_LastRoundBetsToCall_Byte,                                   // ********* From CACHE
                InfoType.BP_MinimumPlayAmount_Decimal,                                  //Provided
                InfoType.BP_PlayerLastAction_Short,                                     // ********* From CACHE
                InfoType.BP_PlayerMoneyInPot_Decimal,                                   // ********* From CACHE
                InfoType.BP_TotalNumCalls_Byte,                                         //Provided
                InfoType.BP_TotalNumRaises_Byte,                                        //Provided
                InfoType.BP_TotalPotAmount_Decimal,                                     //Provided
                InfoType.BP_LastAdditionalRaiseAmount,
                InfoType.GP_DealerDistance_Byte,                                        // ********* From CACHE
                InfoType.AP_AvgScaledOppPreFlopPlayFreq_Double                          //We don't actually need this we just want to make sure the agression provider has been added
            };

            providedInfoTypes = new List <InfoPiece>()
            {
                new InfoPiece(InfoType.PAP_RaiseToStealAmount_Amount, 0),
                new InfoPiece(InfoType.PAP_RaiseToStealSuccess_Prob, 0),
                new InfoPiece(InfoType.PAP_RaiseToCallAmount_Amount, 0),
                new InfoPiece(InfoType.PAP_RaiseToBotCall_Prob, 1),
                new InfoPiece(InfoType.PAP_FoldToBotCall_Prob, 0),
                new InfoPiece(InfoType.PAP_RaiseToBotCheck_Prob, 1),
            };
            AddProviderInformationTypes();

            //Create the player action prediction network manager if it's has not already been created.
            if (networkManager == null)
            {
                networkManager = new playerActionPredictionNetworkManager();
            }

#if logging
            //If we are logging configure the logger
            ILoggerRepository            repository             = LogManager.GetRepository(Assembly.GetCallingAssembly());
            IBasicRepositoryConfigurator configurableRepository = repository as IBasicRepositoryConfigurator;

            PatternLayout layout = new PatternLayout();
            layout.ConversionPattern = "%level% [%thread%] - %message%newline";
            layout.ActivateOptions();

            FileAppender appender = new FileAppender();
            appender.Layout       = layout;
            appender.File         = "aiDecisions_PAP.csv";
            appender.AppendToFile = true;
            appender.ActivateOptions();
            configurableRepository.Configure(appender);
#endif
        }
예제 #37
0
        public MediaInfoProvider(string filePath)
        {
            infos = new InfoCollection();

            Func<string, string, string> nonEmpty = (a, b) => string.IsNullOrEmpty(a) ? b : a;

            MIL = IntPtr.Size == 8 ? (IMediaInfo)new MediaInfo_x64() : (IMediaInfo)new MediaInfo_x86();
            MIL.Option("Internet", "No");
            //if(!MIL.Option("Info_Version").Equals("MediaInfoLib - v0.7.42")) throw new Exception("Mediainfo library version mismatch. Needed: v0.7.42, Used: " + MIL.Option("Info_Version"));

            MIL.Open(filePath);

            Add(EntryKey.Size, Get("FileSize"), "byte");
            Add(EntryKey.Duration, Get("Duration", str => (double.Parse(str, CultureInfo.InvariantCulture) / 1000d).ToString("0.000", CultureInfo.InvariantCulture)), "s");
            Add(EntryKey.FileExtension, Get("FileExtension") != null ? Get("FileExtension").ToLower() : null, null);
            Add(EntryKey.WritingApp, Get("Encoded_Application"), null);
            Add(EntryKey.MuxingApp, Get("Encoded_Library"), null);

            double dummy;
            StreamType st;
            int streamCount;
            int[] indeces = new int[3];
            Converter<eStreamType, StreamType> streamConverter = a => a == eStreamType.Video ? StreamType.Video : (a == eStreamType.Audio ? StreamType.Audio : (a == eStreamType.Text ? StreamType.Text : (StreamType)(-1)));
            foreach(eStreamType streamKind in Enum.GetValues(typeof(eStreamType))) {
                streamCount = MIL.Count_Get(streamKind);
                st = streamConverter(streamKind);
                if((int)st == -1) continue;
                for(int i = 0;i < streamCount;i++) {
                    Add(st, i, EntryKey.Size, Get(streamKind, i, "StreamSize"), "byte");
                    Add(st, i, EntryKey.Title, Get(streamKind, i, "Title"), null);
                    Add(st, i, EntryKey.Id, Get(streamKind, i, "UniqueID"), null);
                    Add(st, i, EntryKey.Language, Get(streamKind, i, "Language"), null);
                    Add(st, i, EntryKey.Duration, Get(streamKind, i, "Duration", str => (double.Parse(str.Split('/')[0], CultureInfo.InvariantCulture) / 1000).ToString("0.000", CultureInfo.InvariantCulture)), "s");
                    Add(st, i, EntryKey.Bitrate, () => Get(streamKind, i, "BitRate").Split('/').First(e => double.TryParse(e, out dummy)), null);
                    Add(st, i, EntryKey.CodecId, ((Get(streamKind, i, "Format") + " -- " + nonEmpty(Get(streamKind, i, "Format_Version"), Get(streamKind, i, "CodecID"))).Trim() + " -- " + Get(streamKind, i, "Format_Profile").Split('/')[0]).Trim(), null);
                    Add(st, i, EntryKey.CodecIdAlt, Get(streamKind, i, "CodecID"), null);
                    Add(st, i, EntryKey.EncodeSettings, Get(streamKind, i, "Encoded_Library_Settings"), null);
                    Add(st, i, EntryKey.EncodeLibrary, Get(streamKind, i, "Encoded_Library"), null);
                    Add(st, i, EntryKey.BitrateMode, Get(streamKind, i, "BitRate_Mode"), null);

                    switch(streamKind) {
                        case eStreamType.Video:
                            Add(st, i, EntryKey.FrameRate, Get(streamKind, i, "FrameRate").Split('/')[0].Trim(), null);
                            Add(st, i, EntryKey.MaxFrameRate, Get(streamKind, i, "FrameRate_Maximum"), null);
                            Add(st, i, EntryKey.MinFrameRate, Get(streamKind, i, "FrameRate_Minimum"), null);
                            Add(st, i, EntryKey.VFR, Get(streamKind, i, "FrameRate_Mode").Contains("VFR") ? Get(streamKind, i, "FrameRate") : null, null);
                            Add(st, i, EntryKey.FrameCount, Get(streamKind, i, "FrameCount"), null);
                            Add(st, i, EntryKey.Width, () => Get(streamKind, i, "Width").Split('/')[0], null);
                            Add(st, i, EntryKey.ColorBitDepth, Get(streamKind, i, "BitDepth"), null);
                            Add(st, i, EntryKey.Height, () => Get(streamKind, i, "Height").Split('/')[0], null);
                            Add(st, i, EntryKey.DAR, Get(streamKind, i, "DisplayAspectRatio"), null);
                            Add(st, i, EntryKey.PAR, () => double.Parse(Get(streamKind, i, "PixelAspectRatio")) != 1 ? Get(streamKind, i, "PixelAspectRatio") : null, null);
                            indeces[0]++;
                            break;
                        case eStreamType.Audio:
                            Add(st, i, EntryKey.SamplingRate, Get(streamKind, i, "SamplingRate").Split('/')[0], null);
                            Add(st, i, EntryKey.SampleCount, Get(streamKind, i, "SamplingCount").Split('/')[0], null);
                            Add(st, i, EntryKey.ChannelCount, Get(streamKind, i, "Channel(s)").Split('/')[0], null);
                            indeces[1]++;
                            break;
                        case eStreamType.Text:
                            indeces[2]++;
                            break;
                    }
                }
            }

            string milInfo = Get("Format/Extensions") != null ? Get("Format/Extensions").ToLower() : "";
            //string fileExt = System.IO.Path.GetExtension(filePath).ToLower();
            if(milInfo.Contains("asf") && milInfo.Contains("wmv") && milInfo.Contains("wma")) {
                if(indeces[0] == 0 && indeces[1] != 0 && indeces[2] == 0) {
                    Add(EntryKey.Extension, "wma", null);
                } else {
                    Add(EntryKey.Extension, "wmv", null);
                }
            } else if(milInfo.Contains("ts") && milInfo.Contains("m2t")) {
                if(System.IO.Path.GetExtension(filePath).Equals(".ts")) Add(EntryKey.Extension, "ts", null); //Blame worf

            } else if(milInfo.Contains("mpeg") && milInfo.Contains("mpg")) {
                if(indeces[0] == 0 || indeces[1] == 0 && indeces[1] != 0) {
                    Add(EntryKey.Extension, "sub", null);
                } else {
                    Add(EntryKey.Extension, "mpg", null);
                }
            } else if((milInfo.Contains("mp1") && milInfo.Contains("mp2") && milInfo.Contains("mp3")) || milInfo.Contains("wav")) {
                switch(Get(eStreamType.Audio, 0, "Format_Profile")) {
                    case "Layer 1": Add(EntryKey.Extension, "mp1", null); break;
                    case "Layer 2": Add(EntryKey.Extension, "mp2", null); break;
                    case "Layer 3": Add(EntryKey.Extension, "mp3", null); break;
                }

            } else if(milInfo.Contains("mp4") && milInfo.Contains("m4a") && milInfo.Contains("m4v")) {
                /*if(indeces[2] != 0 || (indeces[0] != 0 && indeces[1] != 0)) {
                    Add(EntryKey.Extension, "mp4", null);
                } else if(indeces[0] != 0 && indeces[1] == 0) {
                    Add(EntryKey.Extension, "m4v", null);
                } else if(indeces[0] == 0 && indeces[1] != 0) {
                    Add(EntryKey.Extension, "m4a", null);
                }*/
                if(indeces[0] == 0 && indeces[2] == 0 && indeces[1] != 0) {
                    Add(EntryKey.Extension, "m4a", null);
                } else if(indeces[0] != 0  && indeces[1] == 0 && indeces[2] == 0) {
                    Add(EntryKey.Extension, "m4v", null);
                } else {
                    Add(EntryKey.Extension, "mp4", null);
                }
            } else if(milInfo.Contains("dts")) {
                milInfo = Get(eStreamType.General, 0, "Audio_Codec_List").ToLower();
                if(milInfo.Contains("dts-hd")) {
                    Add(EntryKey.Extension, "dtshd", null);
                } else if(milInfo.Contains("truehd")) {
                    Add(EntryKey.Extension, "thd", null);
                } else {
                    Add(EntryKey.Extension, "dts", null);
                }
            }

            if(this[StreamType.General, 0, EntryKey.Extension] == null) {
                if(milInfo.Contains("rm") || milInfo.Contains("rmvb")) {
                    Add(EntryKey.Extension, "rm", null);
                }
                if(milInfo.Contains("asf") || milInfo.Contains("wmv") /*|| milInfo.Contains("wma")*/) {
                    Add(EntryKey.Extension, "wmv", null);
                }
                if(milInfo.Contains("mov") || milInfo.Contains("qt")) {
                    Add(EntryKey.Extension, "mov", null);
                }
            }

            if(this[StreamType.General, 0, EntryKey.Extension] == null) {
                Add(EntryKey.Extension, milInfo.Split(' ')[0], null);
            }
        }