public TableState(string display, DataTable table, GroupingType groupingType)
 {
     this.Table        = table;
     this.Display      = display;
     this.GroupingType = groupingType;
     this.StateGUID    = Guid.NewGuid();
 }
Esempio n. 2
0
 private void GroupByComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (GroupByComboBox.SelectedItem != null)
     {
         string         groupBy = GroupByComboBox.SelectedItem.ToString();
         CollectionView view    = (CollectionView)CollectionViewSource.GetDefaultView(ContractsListView.ItemsSource);
         view.GroupDescriptions.Clear();
         if (groupBy.Contains("Specialization"))
         {
             IEnumerable <ContractGroupContainer> contractGroupContainers = BL_Object.getAllCountractsGroupedBySpecialization(true);
             ContractsListView.ItemsSource = contractGroupContainers;
             view = (CollectionView)CollectionViewSource.GetDefaultView(ContractsListView.ItemsSource);
             view.GroupDescriptions.Add(new PropertyGroupDescription("Key"));
             grouping = GroupingType.Specialization;
         }
         if (groupBy.Contains("Address"))
         {
             IEnumerable <ContractGroupContainer> contractGroupContainers = BL_Object.getAllCountractsGroupedByAddress(true);
             ContractsListView.ItemsSource = contractGroupContainers;
             view = (CollectionView)CollectionViewSource.GetDefaultView(ContractsListView.ItemsSource);
             view.GroupDescriptions.Add(new PropertyGroupDescription("Key"));
             grouping = GroupingType.Address;
         }
         if (groupBy.Contains("Establishment Date"))
         {
             IEnumerable <ContractGroupContainer> contractGroupContainers = BL_Object.getAllCountractsGroupedByTime(true);
             ContractsListView.ItemsSource = contractGroupContainers;
             view = (CollectionView)CollectionViewSource.GetDefaultView(ContractsListView.ItemsSource);
             view.GroupDescriptions.Add(new PropertyGroupDescription("Key"));
             grouping = GroupingType.EstablishmentDate;
         }
     }
 }
        internal void ChangeGrouping(GroupingType groupingType)
        {
            if (Collection == null)
            {
                return;
            }

            if (groupingType == GroupingType.IsSelected)
            {
                Collection.LiveGroupingProperties.Clear();
                Collection.LiveGroupingProperties.Add("IsSelected");
                Collection.IsLiveGroupingRequested = true;
            }
            else
            {
                Collection.IsLiveGroupingRequested = false;
            }

            // Prevent the collection from updating until outside of the using block.
            using (Collection.DeferRefresh())
            {
                Collection.GroupDescriptions.Clear();
                if (groupingType != GroupingType.None)
                {
                    Collection.GroupDescriptions.Add(new PropertyGroupDescription(groupingType.ToString()));
                }
            }
        }
Esempio n. 4
0
        public AssemblyData ReadAssembly(string assemblyPath, GroupingType groupType, string workingDirectory)
        {
            var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath);

            var data = new AssemblyData(assemblyPath, assembly.GetName().Name, groupType);

            try
            {
                foreach (var fixtureType in assembly.GetTypes())
                {
                    if (!ReadFixture(fixtureType, data, workingDirectory))
                    {
                        //Console.WriteLine(string.Format("Journals could not be created for {0}", fixtureType.Name));
                    }
                }

                data.Fixtures = data.Fixtures.Sorted(x => x.Name);
                return(data);
            }
            catch (ReflectionTypeLoadException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.LoaderExceptions);
                throw new Exception("A referenced type could not be loaded.");
            }

            return(null);
        }
 public TableState(string display, DataTable table, GroupingType groupingType)
 {
     this.Table = table;
     this.Display = display;
     this.GroupingType = groupingType;
     this.StateGUID = Guid.NewGuid();
 }
Esempio n. 6
0
        private long GetSizeOfAsset(AssetReference a, GroupingType t)
        {
            long size = 0;

            // You can not read scene and do estimate
            if (a.isSceneAsset)
            {
                t = GroupingType.ByFileSize;
            }

            if (t == GroupingType.ByRuntimeMemorySize)
            {
                var objects = a.allData;
                foreach (var o in objects)
                {
                    #if UNITY_5_6_OR_NEWER
                    size += Profiler.GetRuntimeMemorySizeLong(o);
                    #else
                    size += Profiler.GetRuntimeMemorySize(o);
                    #endif
                }

                a.ReleaseData();
            }
            else if (t == GroupingType.ByFileSize)
            {
                System.IO.FileInfo fileInfo = new System.IO.FileInfo(a.absolutePath);
                if (fileInfo.Exists)
                {
                    size = fileInfo.Length;
                }
            }

            return(size);
        }
Esempio n. 7
0
        void AddGroup(GroupingType groupType)
        {
            Button button = NewButton(groupType);

            groups.Add(button);
            Controls.Add(button);

            Setup();
        }
Esempio n. 8
0
        public AssemblyData(string path, string name, GroupingType groupType)
        {
            Categories = new ObservableCollection<ITestGroup>();
            Fixtures = new ObservableCollection<ITestGroup>();
            IsNodeExpanded = true;
            GroupingType = groupType;

            Path = path;
            Name = name;
        }
Esempio n. 9
0
        // Generate a list of valid groups for a button: disallowing already-used groups
        // and also ancestors of earlier buttons and descendants of later buttons.
        // "context" is the button to generate the list for.
        // Pass null for the Add Group button.
        private List <GroupingType> GetRemainingGroupTypes(Button context)
        {
            List <GroupingType> remainingGroupTypes = new List <GroupingType>(potentialGroups);

            foreach (GroupingType customField in customFields)
            {
                remainingGroupTypes.Add(customField);
            }

            // Remove group types which are not relevant to any of the things being searched for.
            foreach (GroupingType gt in remainingGroupTypes.ToArray())
            {
                if (!WantGroupingType(gt))
                {
                    remainingGroupTypes.Remove(gt);
                }
            }

            int posRelativeToContext = -1;  // -1 for before; 0 for context itself; +1 for after

            foreach (Button button in groups)
            {
                if (button == context)
                {
                    posRelativeToContext = 0;
                }
                else if (posRelativeToContext == 0)
                {
                    posRelativeToContext = 1;
                }

                GroupingType groupType = button.Tag as GroupingType;
                if (groupType == null)
                {
                    continue;
                }

                // Remove the button type itself.
                remainingGroupTypes.Remove(groupType);
                // Also if we are still to the left of context, also remove ancestor types of this button;
                // conversely, if we are to the right of context, remove descendant types of this button.
                // Also having Folder on another button precludes all other choices.
                foreach (GroupingType gt in remainingGroupTypes.ToArray())
                {
                    if (posRelativeToContext == -1 && groupType.IsDescendantOf(gt) ||
                        posRelativeToContext == 1 && gt.IsDescendantOf(groupType) ||
                        posRelativeToContext != 0 && groupType is FolderGroupingType)
                    {
                        remainingGroupTypes.Remove(gt);
                    }
                }
            }

            return(remainingGroupTypes);
        }
        public AssemblyData(string path, string name, GroupingType groupType)
        {
            Categories     = new ObservableCollection <ITestGroup>();
            Fixtures       = new ObservableCollection <ITestGroup>();
            IsNodeExpanded = true;
            GroupingType   = groupType;

            Path = path;
            Name = name;

            Fixtures.CollectionChanged   += Fixtures_CollectionChanged;
            Categories.CollectionChanged += Categories_CollectionChanged;
        }
Esempio n. 11
0
        public YearResult GetResultFor(GroupingType groupingType, CalculationType calculationType)
        {
            switch (groupingType)
            {
            case GroupingType.ByDay:
                return(GetDataByDay(CalculationFactory.GetCalculationFunction(calculationType)));

            case GroupingType.ByMonth:
                return(GetDataByMonth(CalculationFactory.GetCalculationFunction(calculationType)));

            default:
                throw new ApplicationException("Invalid grouping type when getting results");
            }
        }
Esempio n. 12
0
        // Do we want this grouping type, based on the search-for?
        private bool WantGroupingType(GroupingType gt)
        {
            QueryScope scope = (searcher == null ? null : searcher.QueryScope);

            if (scope == null)
            {
                return(true);
            }
            if (scope.WantType(ObjectTypes.Folder))
            {
                return(false);  // searching for folder forbids all grouping types (we add group by folder back in separately)
            }
            return(scope.WantAnyOf(gt.AppliesTo));
        }
Esempio n. 13
0
        public static Func <Measurement, int> GetGroupingSelector(GroupingType groupingType)
        {
            switch (groupingType)
            {
            case GroupingType.ByDay:
                return(x => x.DateTime.Day);

            case GroupingType.ByMonth:
                return(x => x.DateTime.Month);

            default:
                throw new ApplicationException("Cannot get grouping selector");
            }
        }
Esempio n. 14
0
 public static IGroupSessions GetSessionGrouperInstance(GroupingType groupingType)
 {
     switch (groupingType)
     {
         case GroupingType.Alphabetical:
             return new AlphanumericSessionGrouper();
         case GroupingType.Track:
             return new TrackSessionGrouper();
         case GroupingType.Block:
             return new BlockSessionGrouper();
         case GroupingType.Room:
             return new RoomSessionGrouper();
         default:
             throw new InvalidOperationException("Invalid Grouping Type");
     }
 }
Esempio n. 15
0
        public GroupedTableLoader <T> Create <T>(TgOptions <T> gridOptions, ExcelWorksheet worksheet)
        {
            GroupingType groupingType = gridOptions.GroupOptions.GroupingType;

            switch (groupingType)
            {
            case GroupingType.GroupHeaderOnColumn:
                return(new GroupedTableByColumnLoader <T>(gridOptions, worksheet));

            case GroupingType.GroupHeaderOnRow:
                return(new GroupedTableByRowLoader <T>(gridOptions, worksheet));

            default:
                throw new ArgumentException(nameof(groupingType));
            }
        }
        public AssemblyData ReadAssembly(string assemblyPath, GroupingType groupType, string workingDirectory)
        {
            var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath);

            var data = new AssemblyData(assemblyPath, assembly.GetName().Name, groupType);

            foreach (var fixtureType in assembly.GetTypes())
            {
                if (!ReadFixture(fixtureType, data, workingDirectory))
                {
                    //Console.WriteLine(string.Format("Journals could not be created for {0}", fixtureType.Name));
                }
            }

            data.Fixtures = data.Fixtures.Sorted(x => x.Name);
            return(data);
        }
Esempio n. 17
0
        private long GetSizeOfAsset(AssetReference a, GroupingType t)
        {
            long size = 0;

            // You can not read scene and do estimate
            if (a.isSceneAsset)
            {
                t = GroupingType.ByFileSize;
            }

            if (t == GroupingType.ByFileSize)
            {
                size = a.GetFileSize();
            }

            return(size);
        }
Esempio n. 18
0
        /// <summary>
        /// Change the grouping property
        /// </summary>
        /// <param name="groupingType"></param>
        internal void ChangeGrouping(GroupingType groupingType)
        {
            if (Collection == null)
            {
                return;
            }

            // Prevent the collection from updating until outside of the using block.
            using (Collection.DeferRefresh())
            {
                Collection.GroupDescriptions.Clear();
                if (groupingType != GroupingType.None)
                {
                    Collection.GroupDescriptions.Add(new PropertyGroupDescription(groupingType.ToString()));
                }
            }
        }
Esempio n. 19
0
        void addGroupItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            if (menuItem == null)
            {
                return;
            }

            GroupingType groupType = menuItem.Tag as GroupingType;

            if (groupType == null)
            {
                return;
            }

            AddGroup(groupType);
        }
Esempio n. 20
0
        // Whether to show Folder on a button's drop-down menu
        // As before, pass context==null for the Add Group Button
        private bool ShowFolderOption(Button context)
        {
            // If this is the Add Group Button, we allow the option if there are no existing buttons
            if (context == null)
            {
                return(groups.Count == 0);
            }

            // For normal buttons, if this button already shows Folder, we don't allow it on the menu again
            GroupingType groupType = context.Tag as GroupingType;

            if (groupType is FolderGroupingType)
            {
                return(false);
            }

            // Otheriwse we allow it only on the first button
            return(groups.Count != 0 && groups[0] == context);
        }
Esempio n. 21
0
        public static IGroupSessions GetSessionGrouperInstance(GroupingType groupingType)
        {
            switch (groupingType)
            {
            case GroupingType.Alphabetical:
                return(new AlphanumericSessionGrouper());

            case GroupingType.Track:
                return(new TrackSessionGrouper());

            case GroupingType.Block:
                return(new BlockSessionGrouper());

            case GroupingType.Room:
                return(new RoomSessionGrouper());

            default:
                throw new InvalidOperationException("Invalid Grouping Type");
            }
        }
            public void New(GroupingType groupingType, ulong groupingID, string opDirPath, string opArchiveName, string password)
            {
                if (password != null && password.Equals (string.Empty)) {
                    throw new MfsIllegalArgumentException (
                        MfsErrorMessages.GetMessage (MessageType.NULL_OR_EMPTY, "Password")
                    );
                }

                List<ulong> filesInGrouping = null;

                switch (groupingType) {
                    case GroupingType.ASPECT:
                        _parent.AspectObj.DoAspectChecks (groupingID);
                        filesInGrouping = _dbOperations.GetDocumentsAppliedWithAspect (groupingID);
                        break;
                    case GroupingType.BRIEFCASE:
                        _parent.BriefcaseObj.DoBriefcaseChecks (groupingID);
                        filesInGrouping = _dbOperations.GetDocumentsInBriefcase (groupingID);
                        break;
                    case GroupingType.COLLECTION:
                        _parent.CollectionObj.DoCollectionChecks (groupingID);
                        filesInGrouping = _dbOperations.GetDocumentsInCollection (groupingID);
                        break;
                    case GroupingType.NONE:
                        throw new MfsIllegalArgumentException (
                            MfsErrorMessages.GetMessage (MessageType.BAD_ARG, "Grouping type")
                        );
                }

                List<byte[]> filesData = new List<byte[]> (filesInGrouping.Count);
                List<string> fileNames = new List<string> (filesInGrouping.Count);
                foreach (ulong fileID in filesInGrouping) {
                    byte[] fileData = _parent.FileObj.RetrieveOriginal (fileID);
                    filesData.Add (fileData);
                    string fileName = _parent.FileObj.GetName (fileID);
                    fileNames.Add (fileName);
                }

                MfsStorageDevice.ArchiveFiles (filesData, fileNames, opDirPath, opArchiveName, password);
            }
Esempio n. 23
0
        private Button NewButton(GroupingType groupType)
        {
            Button button = new Button();

            button.AutoSize                = true;
            button.AutoSizeMode            = AutoSizeMode.GrowAndShrink;
            button.Text                    = groupType.ToString();
            button.UseVisualStyleBackColor = true;

            button.TextAlign         = ContentAlignment.MiddleLeft;
            button.TextImageRelation = TextImageRelation.TextBeforeImage;
            button.Padding           = new Padding(0, 0, 2, 0);
            button.Image             = Properties.Resources.expanded_triangle;
            button.ImageAlign        = ContentAlignment.MiddleRight;

            button.Tag        = groupType;
            button.Click     += new EventHandler(button_Click);
            button.MouseDown += new MouseEventHandler(button_MouseDown);
            button.MouseUp   += new MouseEventHandler(button_MouseUp);
            button.MouseMove += new MouseEventHandler(button_MouseMove);

            return(button);
        }
        private Rdl.GroupingType CreateGrouping()
        {
            Rdl.GroupingType groupingType = new GroupingType();
            try
            {
                groupingType.Name  = "pagegrp";
                groupingType.Items = new object[]
                {
                    //   true,
                    //   true,
                    CreateGroupExpressions(),
                };
                groupingType.ItemsElementName = new ItemsChoiceType17[]
                {
                    //    ItemsChoiceType17.PageBreakAtStart,
                    //   ItemsChoiceType17.PageBreakAtEnd,

                    ItemsChoiceType17.GroupExpressions
                };
            }
            catch (Exception ex) { }
            return(groupingType);
        }
        public AssemblyData ReadAssembly(string assemblyPath, GroupingType groupType, string workingDirectory)
        {
            // NOTE: We use reflection only load here so that we don't have to resolve all binaries
            // This is an assumption by Dynamo tests which reference assemblies that can be resolved
            // at runtime inside Revit.
            var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath);

            var data = new AssemblyData(assemblyPath, assembly.GetName().Name, groupType);

            try
            {
                var revitReference = assembly.GetReferencedAssemblies().FirstOrDefault(x => x.Name.Contains("RevitAPI"));

                if (revitReference != null)
                {
                    data.ReferencedRevitVersion = $"{(revitReference.Version.Major + 2000)}";
                }

                foreach (var fixtureType in assembly.GetTypes())
                {
                    if (!ReadFixture(fixtureType, data, workingDirectory))
                    {
                        //Console.WriteLine(string.Format("Journals could not be created for {0}", fixtureType.Name));
                    }
                }

                data.Fixtures = data.Fixtures.Sorted(x => x.Name);
                return(data);
            }
            catch (ReflectionTypeLoadException ex)
            {
                Console.WriteLine($"ERROR: Failed to resolve assembly:");
                Console.WriteLine($"ERROR: {ex.Message}");
                Console.WriteLine($"ERROR: {ex.LoaderExceptions}");
                throw new Exception("A referenced type could not be loaded.");
            }
        }
Esempio n. 26
0
        public IEnumerable <string> GroupingNames(VimScene vim, GroupingType gt)
        {
            switch (gt)
            {
            // TODO: this should only show names where we can find a node with geometry that uses it.
            case GroupingType.Category:
                return(vim.Model.CategoryList.Select(x => x.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Family:
                return(vim.Model.FamilyList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Room:
                return(vim.Model.RoomList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Level:
                return(vim.Model.LevelList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Model:
                return(vim.Model.ModelList.Select(x => x.Title ?? "<unnamed>").ToEnumerable());

            case GroupingType.Workset:
                return(vim.Model.WorksetList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.DesignOption:
                return(vim.Model.DesignOptionList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Assembly:
                return(vim.Model.AssemblyInstanceList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Element:
                return(vim.Model.ElementList.Select(x => x?.Name ?? "<unnamed>").ToEnumerable());

            case GroupingType.Node:
            default:
                return(vim.Model.NodeList.Select(x => x.Element?.Name ?? "<unnamed>").ToEnumerable());
            }
        }
Esempio n. 27
0
        public IArray <int> NodesToId(VimScene vim, GroupingType gt)
        {
            switch (gt)
            {
            case GroupingType.Category:
                return(vim.VimNodes.Select(n => n.Category?.Index ?? -1));

            case GroupingType.Family:
                return(vim.VimNodes.Select(n => n.Family?.Index ?? -1));

            case GroupingType.Room:
                return(vim.VimNodes.Select(GetRoom));

            case GroupingType.Level:
                return(vim.VimNodes.Select(n => n.Element?._Level.Index ?? -1));

            case GroupingType.Model:
                return(vim.VimNodes.Select(n => n.Element?._Model.Index ?? -1));

            case GroupingType.Workset:
                return(vim.VimNodes.Select(n => n.Element?._Workset.Index ?? -1));

            case GroupingType.DesignOption:
                return(vim.VimNodes.Select(n => n.Element?._DesignOption.Index ?? -1));

            case GroupingType.Assembly:
                return(vim.VimNodes.Select(n => n.Element?._AssemblyInstance.Index ?? -1));

            case GroupingType.Element:
                return(vim.VimNodes.Select(n => n.Element?.Index ?? -1));

            case GroupingType.Node:
            default:
                return(vim.VimNodes.Select(n => n.Id));
            }
        }
        public PartialViewResult Partial_AddUserTo(GroupingType groupingType, Guid groupingID)
        {
            List<Models.User> users = new List<Models.User>();
            switch(groupingType){
                case GroupingType.Company:
                    users = DAL.loadCompanyUsers(groupingID);
                    break;
                case GroupingType.Project:
                    users = new List<Models.User>();  // Add this when project users is working.DAL.loadProjectUsers(groupingID);
                    break;
                default:
                    break;
            }

            AddUserTo returnMe = new AddUserTo()
            {
                CurrentUsers = users,
                DestinationID = groupingID,
                DestinationType = groupingType,
                ToAdd = new AddingUser() { Administrator = false, EmailAddress = "" }
            };

            return PartialView("Partial_AddUserTo", returnMe);
        }
        /// <summary>
        /// Pulls a list of videos from Giant Bomb
        /// </summary>
        /// <param name="apiKey">API key unique to the user</param>
        /// <param name="videoCategoryId">Numerical ID of which category to query</param>
        /// <returns></returns>
        public static async Task <VideosResponse> GetVideosAsync(string apiKey, string videoGroupingId, GroupingType grouping)
        {
            var response = await GetVideosAsync(apiKey, 0, videoGroupingId, grouping);

            return(response);
        }
Esempio n. 30
0
 public void UseForwardGrouping()
 {
     _groupingType = GroupingType.Forward;
 }
Esempio n. 31
0
 public void UseCenteredGrouping()
 {
     _groupingType = GroupingType.Centered;
 }
Esempio n. 32
0
 private void SwitchToTab(Tabs tab, GroupingType groupingType, DataTable table, string display, string imageID, bool purgeStateStack)
 {
     SwitchToTab(tab, groupingType, table, display, imageID, purgeStateStack, null);
 }
Esempio n. 33
0
        public static bool Export(DateTime[] timestamps, Series[] series, TimeSpanOption aggregationPeriod, string filename, BackgroundWorker worker = null, GroupingType groupingType = GroupingType.Centered)
        {
            var progress         = 0;
            var firstTimeStamp   = timestamps.Min().RoundDown(aggregationPeriod.TimeSpan);
            var finalTimeStamp   = timestamps.Max().RoundUp(aggregationPeriod.TimeSpan);
            var totalTimeSpan    = finalTimeStamp - firstTimeStamp;
            var sortedTimestamps = timestamps.OrderBy(x => x).ToArray();

            var halfOfTimeSpan = aggregationPeriod.TimeSpan.Subtract(new TimeSpan(aggregationPeriod.TimeSpan.Ticks / 2));

            var aggregatedTimestamps  = new List <DateTime>();
            var currentTimestampIndex = 0;

            for (var timestamp = firstTimeStamp; timestamp <= finalTimeStamp; timestamp = timestamp.Add(aggregationPeriod.TimeSpan))
            {
                aggregatedTimestamps.Add(timestamp);
                var inclusiveStart = DateTime.MinValue;
                var exclusiveEnd   = DateTime.MaxValue;

                switch (groupingType)
                {
                case GroupingType.Centered:
                    inclusiveStart = timestamp - halfOfTimeSpan;
                    exclusiveEnd   = timestamp + halfOfTimeSpan;
                    break;

                case GroupingType.Forward:
                    inclusiveStart = timestamp;
                    exclusiveEnd   = timestamp.Add(aggregationPeriod.TimeSpan);
                    break;
                }

                var timestampsList = new List <DateTime>();

                while (currentTimestampIndex < sortedTimestamps.Length && sortedTimestamps[currentTimestampIndex] < inclusiveStart)
                {
                    currentTimestampIndex++;
                }


                while (currentTimestampIndex < sortedTimestamps.Length && sortedTimestamps[currentTimestampIndex] < exclusiveEnd)
                {
                    timestampsList.Add(sortedTimestamps[currentTimestampIndex]);
                    currentTimestampIndex++;
                }

                var includedTimestamps = timestampsList.ToArray();

                foreach (var x in series)
                {
                    x.AggregatedValues[timestamp] =
                        x.AggregationModel.AggregationMethod.Aggregate((from includedTimestamp in includedTimestamps where x.Values.ContainsKey(includedTimestamp) select new KeyValuePair <DateTime, float>(includedTimestamp, x.Values[includedTimestamp])).OrderBy(y => y.Key).ToArray(), inclusiveStart, exclusiveEnd, timestamp);
                }

                if (worker == null || !worker.WorkerReportsProgress)
                {
                    continue;
                }

                var currentTimeSpan = timestamp - firstTimeStamp;
                var currentProgress = (int)(currentTimeSpan.TotalSeconds / totalTimeSpan.TotalSeconds * 100);

                if (currentProgress <= progress)
                {
                    continue;
                }

                worker.ReportProgress(currentProgress);
                progress = currentProgress;
            }
            try
            {
                using (var writer = File.CreateText(filename))
                {
                    writer.Write("YYYY/MM/DD hh:mm");
                    foreach (var x in series)
                    {
                        writer.Write("," + x.Name);
                    }

                    foreach (var aggregatedTimestamp in aggregatedTimestamps)
                    {
                        writer.Write(writer.NewLine);
                        writer.Write(aggregatedTimestamp.ToString("yyyy/MM/dd HH:mm"));
                        foreach (var x in series)
                        {
                            writer.Write(",");
                            if (x.AggregatedValues.ContainsKey(aggregatedTimestamp) && !float.IsNaN(x.AggregatedValues[aggregatedTimestamp]))
                            {
                                writer.Write(x.AggregatedValues[aggregatedTimestamp]);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        public AssemblyData ReadAssembly(string assemblyPath, GroupingType groupType, string workingDirectory)
        {
            var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath);

            var data = new AssemblyData(assemblyPath, assembly.GetName().Name, groupType);

            foreach (var fixtureType in assembly.GetTypes())
            {
                if (!ReadFixture(fixtureType, data, workingDirectory))
                {
                    //Console.WriteLine(string.Format("Journals could not be created for {0}", fixtureType.Name));
                }
            }

            data.Fixtures = data.Fixtures.Sorted(x => x.Name);
            return data;
        }
Esempio n. 35
0
        private void SwitchToTab(Tabs tab, GroupingType groupingType, DataTable table, string display, string imageId, bool purgeStateStack, int? scrollState)
        {
            CF_setButtonOff(BUTTON_NOW_PLAYING);
            CF_setButtonOff(BUTTON_PLAYLISTS);
            CF_setButtonOff(BUTTON_INBOX);
            CF_setButtonOff(BUTTON_POPULAR);
            CF_setButtonOff(BUTTON_SEARCH);

            if(currentPlaylistworker != null)
            {
                currentPlaylistworker.CancelAsync();
                currentPlaylistworker = null;
            }

            SetupDynamicButtons(tab);

            var list = advancedlistArray[CF_getAdvancedListID("mainList")];
            string templateID = GetTemplateIDForGroupingType(groupingType);
            list.TemplateID = templateID;

            if(purgeStateStack)
            {
                //purge the table states stack
                while (TableStates.Count > 0)
                {
                    var state = TableStates.Pop();
                    if (state.Table != NowPlayingTable)
                    {
                        state.Dispose();
                    }
                }
            }

            TableStates.Push(new TableState(display, table, groupingType));
            CF_updateText("LocationLabel", GetCurrentStateStackText());

            MainTableBindingSource.DataSource = table;

            CurrentTab = tab;
            CurrentGroupingType = groupingType;
            switch (CurrentTab)
            {
                case Tabs.NowPlaying:
                    CF_setButtonOn(BUTTON_NOW_PLAYING);
                    break;
                case Tabs.Playlists:
                    CF_setButtonOn(BUTTON_PLAYLISTS);
                    break;
                case Tabs.Inbox:
                    CF_setButtonOn(BUTTON_INBOX);
                    break;
                case Tabs.Popular:
                    CF_setButtonOn(BUTTON_POPULAR);
                    break;
                case Tabs.Search:
                    CF_setButtonOn(BUTTON_SEARCH);
                    break;
            }

            list.Refresh();

            if (scrollState.HasValue)
            {
                if(CurrentTab != Tabs.NowPlaying) //it will be taken care of by SyncMainTableWithView if it is a NowPlaying Tab
                    this.MainTableBindingSource.Position = scrollState.Value;

                list.SelectedIndex = scrollState.Value;
            }

            if (CurrentTab == Tabs.NowPlaying)
                SyncMainTableWithView();
            else
                LoadImage(imageId);

            if (CurrentGroupingType == GroupingType.Playlists)
            {
                CheckAndStartPlaylistTimer();
            }
        }
Esempio n. 36
0
        public void AddLevel(int partsPerMatch, ArrayList participants, GroupingType groupType, TournyType tournyType)
        {
            ArrayList copy = new ArrayList(participants);

            if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow)
                copy.Sort();

            PyramidLevel level = new PyramidLevel();

            switch ( tournyType )
            {
                case TournyType.RedVsBlue:
                    {
                        TournyParticipant[] parts = new TournyParticipant[2];

                        for (int i = 0; i < parts.Length; ++i)
                            parts[i] = new TournyParticipant(new ArrayList());

                        for (int i = 0; i < copy.Count; ++i)
                        {
                            ArrayList players = ((TournyParticipant)copy[i]).Players;

                            for (int j = 0; j < players.Count; ++j)
                            {
                                Mobile mob = (Mobile)players[j];

                                if (mob.Kills >= 5)
                                    parts[0].Players.Add(mob);
                                else
                                    parts[1].Players.Add(mob);
                            }
                        }

                        level.Matches.Add(new TournyMatch(new ArrayList(parts)));
                        break;
                    }
                case TournyType.RandomTeam:
                    {
                        TournyParticipant[] parts = new TournyParticipant[partsPerMatch];

                        for (int i = 0; i < partsPerMatch; ++i)
                            parts[i] = new TournyParticipant(new ArrayList());

                        for (int i = 0; i < copy.Count; ++i)
                            parts[i % parts.Length].Players.AddRange(((TournyParticipant)copy[i]).Players);

                        level.Matches.Add(new TournyMatch(new ArrayList(parts)));
                        break;
                    }
                case TournyType.FreeForAll:
                    {
                        level.Matches.Add(new TournyMatch(copy));
                        break;
                    }
                case TournyType.Standard:
                    {
                        if (partsPerMatch == 2 && (participants.Count % 2) == 1)
                        {
                            int lowAdvances = int.MaxValue;

                            for (int i = 0; i < participants.Count; ++i)
                            {
                                TournyParticipant p = (TournyParticipant)participants[i];

                                if (p.FreeAdvances < lowAdvances)
                                    lowAdvances = p.FreeAdvances;
                            }

                            ArrayList toAdvance = new ArrayList();

                            for (int i = 0; i < participants.Count; ++i)
                            {
                                TournyParticipant p = (TournyParticipant)participants[i];

                                if (p.FreeAdvances == lowAdvances)
                                    toAdvance.Add(p);
                            }

                            if (toAdvance.Count == 0)
                                toAdvance = copy; // sanity

                            int idx = Utility.Random(toAdvance.Count);

                            ((TournyParticipant)toAdvance[idx]).AddLog("Advanced automatically due to an odd number of challengers.");
                            level.FreeAdvance = (TournyParticipant)toAdvance[idx];
                            ++level.FreeAdvance.FreeAdvances;
                            copy.Remove(toAdvance[idx]);
                        }

                        while (copy.Count >= partsPerMatch)
                        {
                            ArrayList thisMatch = new ArrayList();

                            for (int i = 0; i < partsPerMatch; ++i)
                            {
                                int idx = 0;

                                switch ( groupType )
                                {
                                    case GroupingType.HighVsLow:
                                        idx = (i * (copy.Count - 1)) / (partsPerMatch - 1);
                                        break;
                                    case GroupingType.Nearest:
                                        idx = 0;
                                        break;
                                    case GroupingType.Random:
                                        idx = Utility.Random(copy.Count);
                                        break;
                                }

                                thisMatch.Add(copy[idx]);
                                copy.RemoveAt(idx);
                            }

                            level.Matches.Add(new TournyMatch(thisMatch));
                        }

                        if (copy.Count > 1)
                            level.Matches.Add(new TournyMatch(copy));

                        break;
                    }
            }

            this.m_Levels.Add(level);
        }
Esempio n. 37
0
        public static bool Export(DateTime[] timestamps, Series[] series, TimeSpanOption aggregationPeriod, string filename, BackgroundWorker worker = null, GroupingType groupingType = GroupingType.Centered)
        {
            var progress = 0;
            var firstTimeStamp = timestamps.Min().RoundDown(aggregationPeriod.TimeSpan);
            var finalTimeStamp = timestamps.Max().RoundUp(aggregationPeriod.TimeSpan);
            var totalTimeSpan = finalTimeStamp - firstTimeStamp;
            var sortedTimestamps = timestamps.OrderBy(x => x).ToArray();

            var halfOfTimeSpan = aggregationPeriod.TimeSpan.Subtract(new TimeSpan(aggregationPeriod.TimeSpan.Ticks / 2));

            var aggregatedTimestamps = new List<DateTime>();
            var currentTimestampIndex = 0;
            for (var timestamp = firstTimeStamp; timestamp <= finalTimeStamp; timestamp = timestamp.Add(aggregationPeriod.TimeSpan))
            {
                aggregatedTimestamps.Add(timestamp);
                var inclusiveStart = DateTime.MinValue;
                var exclusiveEnd = DateTime.MaxValue;

                switch (groupingType)
                {
                    case GroupingType.Centered:
                        inclusiveStart = timestamp - halfOfTimeSpan;
                        exclusiveEnd = timestamp + halfOfTimeSpan;
                        break;
                    case GroupingType.Forward:
                        inclusiveStart = timestamp;
                        exclusiveEnd = timestamp.Add(aggregationPeriod.TimeSpan);
                        break;
                }

                var timestampsList = new List<DateTime>();

                while (currentTimestampIndex < sortedTimestamps.Length && sortedTimestamps[currentTimestampIndex] < inclusiveStart)
                    currentTimestampIndex++;

                while (currentTimestampIndex < sortedTimestamps.Length && sortedTimestamps[currentTimestampIndex] < exclusiveEnd)
                {
                    timestampsList.Add(sortedTimestamps[currentTimestampIndex]);
                    currentTimestampIndex++;
                }

                var includedTimestamps = timestampsList.ToArray();

                foreach (var x in series)
                {
                    x.AggregatedValues[timestamp] =
                        x.AggregationModel.AggregationMethod.Aggregate((from includedTimestamp in includedTimestamps where x.Values.ContainsKey(includedTimestamp) select new KeyValuePair<DateTime, float>(includedTimestamp, x.Values[includedTimestamp])).OrderBy(y => y.Key).ToArray(), inclusiveStart, exclusiveEnd, timestamp);
                }

                if (worker == null || !worker.WorkerReportsProgress) continue;

                var currentTimeSpan = timestamp - firstTimeStamp;
                var currentProgress = (int)(currentTimeSpan.TotalSeconds / totalTimeSpan.TotalSeconds * 100);

                if (currentProgress <= progress) continue;

                worker.ReportProgress(currentProgress);
                progress = currentProgress;
            }
            try
            {
                using (var writer = File.CreateText(filename))
                {
                    writer.Write("YYYY/MM/DD hh:mm");
                    foreach (var x in series)
                    {
                        writer.Write("," + x.Name);
                    }

                    foreach (var aggregatedTimestamp in aggregatedTimestamps)
                    {
                        writer.Write(writer.NewLine);
                        writer.Write(aggregatedTimestamp.ToString("yyyy/MM/dd HH:mm"));
                        foreach (var x in series)
                        {
                            writer.Write(",");
                            if (x.AggregatedValues.ContainsKey(aggregatedTimestamp) && !float.IsNaN(x.AggregatedValues[aggregatedTimestamp]))
                            {
                                writer.Write(x.AggregatedValues[aggregatedTimestamp]);
                            }
                        }
                    }
                }

            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Esempio n. 38
0
 public GroupingParameter(GroupingType groupingType)
 {
     GroupingType = groupingType;
 }
Esempio n. 39
0
        public void AddLevel(int partsPerMatch, List<TournyParticipant> participants, GroupingType groupType,
            TournyType tournyType)
        {
            var copy = new List<TournyParticipant>(participants);

            if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow)
            {
                copy.Sort();
            }

            var level = new PyramidLevel();

            switch (tournyType)
            {
                case TournyType.RedVsBlue:
                {
                    var parts = new TournyParticipant[2];

                    for (int i = 0; i < parts.Length; ++i)
                    {
                        parts[i] = new TournyParticipant(new List<Mobile>());
                    }

                    for (int i = 0; i < copy.Count; ++i)
                    {
                        List<Mobile> players = copy[i].Players;

                        for (int j = 0; j < players.Count; ++j)
                        {
                            Mobile mob = players[j];

                            if (mob.Kills >= 5)
                            {
                                parts[0].Players.Add(mob);
                            }
                            else
                            {
                                parts[1].Players.Add(mob);
                            }
                        }
                    }

                    level.Matches.Add(new TournyMatch(new List<TournyParticipant>(parts)));
                    break;
                }
                case TournyType.RandomTeam:
                {
                    var parts = new TournyParticipant[partsPerMatch];

                    for (int i = 0; i < partsPerMatch; ++i)
                    {
                        parts[i] = new TournyParticipant(new List<Mobile>());
                    }

                    for (int i = 0; i < copy.Count; ++i)
                    {
                        parts[i % parts.Length].Players.AddRange(copy[i].Players);
                    }

                    level.Matches.Add(new TournyMatch(new List<TournyParticipant>(parts)));
                    break;
                }
                case TournyType.FreeForAll:
                {
                    level.Matches.Add(new TournyMatch(copy));
                    break;
                }
                case TournyType.Standard:
                {
                    if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1)
                    {
                        int lowAdvances = int.MaxValue;

                        for (int i = 0; i < participants.Count; ++i)
                        {
                            TournyParticipant p = participants[i];

                            if (p.FreeAdvances < lowAdvances)
                            {
                                lowAdvances = p.FreeAdvances;
                            }
                        }

                        var toAdvance = new List<TournyParticipant>();

                        for (int i = 0; i < participants.Count; ++i)
                        {
                            TournyParticipant p = participants[i];

                            if (p.FreeAdvances == lowAdvances)
                            {
                                toAdvance.Add(p);
                            }
                        }

                        if (toAdvance.Count == 0)
                        {
                            toAdvance = copy; // sanity
                        }

                        int idx = Utility.Random(toAdvance.Count);

                        toAdvance[idx].AddLog("Advanced automatically due to an odd number of challengers.");
                        level.FreeAdvance = toAdvance[idx];
                        ++level.FreeAdvance.FreeAdvances;
                        copy.Remove(toAdvance[idx]);
                    }

                    while (copy.Count >= partsPerMatch)
                    {
                        var thisMatch = new List<TournyParticipant>();

                        for (int i = 0; i < partsPerMatch; ++i)
                        {
                            int idx = 0;

                            switch (groupType)
                            {
                                case GroupingType.HighVsLow:
                                    idx = (i * (copy.Count - 1)) / (partsPerMatch - 1);
                                    break;
                                case GroupingType.Nearest:
                                    idx = 0;
                                    break;
                                case GroupingType.Random:
                                    idx = Utility.Random(copy.Count);
                                    break;
                            }

                            thisMatch.Add(copy[idx]);
                            copy.RemoveAt(idx);
                        }

                        level.Matches.Add(new TournyMatch(thisMatch));
                    }

                    if (copy.Count > 1)
                    {
                        level.Matches.Add(new TournyMatch(copy));
                    }

                    break;
                }
            }

            m_Levels.Add(level);
        }
        /// <summary>
        /// Pulls a list of videos from Giant Bomb
        /// </summary>
        /// <param name="apiKey">API key unique to the user</param>
        /// <param name="videoGroupingId">Numerical ID of which grouping to query</param>
        /// <param name="grouping">Whether the group is a category or a show</param>
        /// <param name="offset">If viewing multiple pages of videos, how many videos to skip in the query</param>
        /// <returns></returns>
        public static async Task <VideosResponse> GetVideosAsync(string apiKey, int offset, string videoGroupingId, GroupingType grouping)
        {
            VideosResponse response = null;

            try
            {
                string categoryParameter = string.Empty;
                if (!String.IsNullOrWhiteSpace(videoGroupingId))
                {
                    switch (grouping)
                    {
                    case GroupingType.Category:
                        categoryParameter = "&filter=video_categories:" + videoGroupingId;
                        break;

                    case GroupingType.Show:
                        categoryParameter = "&filter=video_show:" + videoGroupingId;
                        break;

                    case GroupingType.None:
                        break;
                    }
                }

                string offsetParameter = string.Empty;
                if (offset > 0)
                {
                    offsetParameter = "&offset=" + offset;
                }

                var uri = new Uri("https://www.giantbomb.com/api/videos/?format=json&api_key=" + apiKey + categoryParameter + offsetParameter);
                response = await Utilities.HttpRequestAgent.GetDeserializedResponseAsync <VideosResponse>(uri);

                response = RemoveInvalidVideos(response);
            }
            catch (Exception e)
            {
                Serilog.Log.Error(e, "Error pulling videos with category ID " + videoGroupingId + " and offset " + offset);
            }

            return(response);
        }
Esempio n. 41
0
 public override bool IsDescendantOf(GroupingType gt)
 {
     return(gt == parent || (parent != null && parent.IsDescendantOf(gt)));
 }
Esempio n. 42
0
        public virtual IList<IAssemblyData> ReadAssembly(string assemblyPath, string workingDirectory, GroupingType groupType, bool isTesting)
        {
            IList<IAssemblyData> data = new List<IAssemblyData>();

            try
            {
                AssemblyLoader loader;
                AssemblyData assData;

                if (!isTesting)
                {
                    // Create a temporary application domain to load the assembly.
                    var tempDomain = AppDomain.CreateDomain("RTF_Domain");
                    loader = (AssemblyLoader)tempDomain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, "RTF.Framework.AssemblyLoader", false, 0, null, new object[] { assemblyPath }, CultureInfo.InvariantCulture, null);
                    assData = loader.ReadAssembly(assemblyPath, groupType, workingDirectory);
                    data.Add(assData);
                    AppDomain.Unload(tempDomain);
                }
                else
                {
                    loader = new AssemblyLoader(assemblyPath);
                    assData = loader.ReadAssembly(assemblyPath, groupType, workingDirectory);
                    data.Add(assData);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The specified assembly could not be loaded for testing.");
                return null;
            }

            return data;
        }
 // methods
 private void UpdateListing(GroupingType groupingType)
 {
     Parameter = new GroupingParameter(groupingType);
     NotifyOfPropertyChange("PageTitle");
     NotifyOfPropertyChange("ListSource");
 }
Esempio n. 44
0
 internal SqlGroupByClause(GroupingType groupingType, IEnumerable <ISqlExpression> items) : base(null)
 {
     GroupingType = groupingType;
     Items.AddRange(items);
 }
Esempio n. 45
0
        public override IList<IAssemblyData> ReadAssembly(string assemblyPath, string workingDirectory,
            GroupingType groupType, bool isTesting)
        {
            var dummyTestPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "RunnerTests.dll");
            var assData = new AssemblyData(dummyTestPath, "RunnerTests", groupType);

            var cat1 = new CategoryData(assData, "Smoke");
            var cat2 = new CategoryData(assData, "Integration");
            var cat3 = new CategoryData(assData, "Failure");
            assData.Categories = new ObservableCollection<ITestGroup>() { cat1, cat2, cat3 };

            var fix1 = new FixtureData(assData, "FixtureA");
            var fix2 = new FixtureData(assData, "FixtureB");
            assData.Fixtures = new ObservableCollection<ITestGroup>() { fix1, fix2 };

            var testModelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "empty.rfa");

            var test1 = new TestData(fix1, "TestA", testModelPath, false);
            var test2 = new TestData(fix1, "TestB", testModelPath, false);
            var test3 = new TestData(fix1, "TestC", testModelPath, false);
            var test4 = new TestData(fix2, "TestD", testModelPath, false);
            var test5 = new TestData(fix2, "TestE", @"C:\foo.rfa", false);

            cat1.Tests = new ObservableCollection<ITestData>() { test1, test2 };
            cat2.Tests = new ObservableCollection<ITestData>() { test3 };
            cat3.Tests = new ObservableCollection<ITestData>() { test4, test5 };

            fix1.Tests = new ObservableCollection<ITestData>() { test1, test2, test3 };
            fix2.Tests = new ObservableCollection<ITestData>() { test4, test5 };

            fix1.Assembly = assData;
            fix2.Assembly = assData;
            cat1.Assembly = assData;
            cat2.Assembly = assData;
            cat3.Assembly = assData;

            return new List<IAssemblyData>{assData};
        }
Esempio n. 46
0
        public Tournament(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                case 4:
                    {
                        this.m_EventController = reader.ReadItem() as EventController;

                        goto case 3;
                    }
                case 3:
                    {
                        this.m_SuddenDeathRounds = reader.ReadEncodedInt();

                        goto case 2;
                    }
                case 2:
                    {
                        this.m_TournyType = (TournyType)reader.ReadEncodedInt();

                        goto case 1;
                    }
                case 1:
                    {
                        this.m_GroupType = (GroupingType)reader.ReadEncodedInt();
                        this.m_TieType = (TieType)reader.ReadEncodedInt();
                        this.m_SignupPeriod = reader.ReadTimeSpan();

                        goto case 0;
                    }
                case 0:
                    {
                        if (version < 3)
                            this.m_SuddenDeathRounds = 3;

                        this.m_ParticipantsPerMatch = reader.ReadEncodedInt();
                        this.m_PlayersPerParticipant = reader.ReadEncodedInt();
                        this.m_SignupPeriod = reader.ReadTimeSpan();
                        this.m_Stage = TournamentStage.Inactive;
                        this.m_Pyramid = new TournyPyramid();
                        this.m_Ruleset = new Ruleset(RulesetLayout.Root);
                        this.m_Ruleset.ApplyDefault(this.m_Ruleset.Layout.Defaults[0]);
                        this.m_Participants = new ArrayList();
                        this.m_Undefeated = new ArrayList();
                        this.m_Arenas = new ArrayList();

                        break;
                    }
            }

            Timer.DelayCall(SliceInterval, SliceInterval, new TimerCallback(Slice));
        }
Esempio n. 47
0
 public virtual bool IsDescendantOf(GroupingType gt)
 {
     return(false);
 }
Esempio n. 48
0
            protected readonly GroupingType parent;  // the GroupingType next up in the tree: null for the top of the tree

            public XenModelObjectPropertyGroupingType(ObjectTypes appliesTo, PropertyNames property, GroupingType parent)
                : base(appliesTo, property)
            {
                this.parent = parent;
            }
Esempio n. 49
0
 private string GetTemplateIDForGroupingType(GroupingType groupingType)
 {
     switch (groupingType)
     {
         case GroupingType.Songs:
             return TEMPLATE_SONGS;
         case GroupingType.Albums:
             return TEMPLATE_ALBUMS;
         case GroupingType.Artists:
             return TEMPLATE_ARTISTS;
         case GroupingType.Playlists:
             return TEMPLATE_PLAYLISTS;
         default:
             throw new Exception("Unrecognized grouping type");
     }
 }