Exemple #1
0
        static void Main(string[] args)
        {
            foreach (String name in Directory.GetFiles(_picturesDirectory, "*.jpg"))
                _knownNames.Add(name);

            Dictionary<DateTime, string> nameDic = new Dictionary<DateTime, string>();
            foreach (String name in _knownNames)
                nameDic.Add(Directory.GetCreationTime(name), name);

            var lastime = nameDic.Count() > 0 ? nameDic.Last().Key : DateTime.Now;

            StreamReader r = new StreamReader(_picturesDirectory +  "\\list.txt");
            String line;
            while ((line = r.ReadLine()) != null)
            {
                nameDic.Add(lastime, line);
                lastime = lastime.AddSeconds(1);
            }

            foreach (var item in nameDic.OrderByDescending(x=>x.Key))
                FindFollowers(
                    String.Format("https://api.twitter.com/1/followers/ids.json?screen_name=@{0}", Path.GetFileNameWithoutExtension(item.Value)));
        }
        private void DistributeSelectedEffectsEqually()
        {
            if (!TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements))
            {
                MessageBox.Show(TimelineControl.grid.alignmentHelperWarning);
                return;
            }

            //Before we do anything lets make sure there is time to work with
            //I don't remember why I put this here, for now its commented out until its verified that its not needed, then it will be removed
            //if (TimelineControl.SelectedElements.First().EndTime == TimelineControl.SelectedElements.Last().EndTime)
            //{
            //	MessageBox.Show("The first and last effect cannot have the same end time.", "Warning", MessageBoxButtons.OK);
            //	return;
            //}
            bool startAtLastElement = false;
            var totalElements = TimelineControl.SelectedElements.Count();
            var startTime = TimelineControl.SelectedElements.First().StartTime;
            var endTime = TimelineControl.SelectedElements.Last().EndTime;
            if (TimelineControl.SelectedElements.First().StartTime > TimelineControl.SelectedElements.Last().StartTime)
            {
                startAtLastElement = true;
                startTime = TimelineControl.SelectedElements.Last().StartTime;
                endTime = TimelineControl.SelectedElements.First().EndTime;
            }
            var totalDuration = endTime - startTime;
            var effectDuration = totalDuration.TotalSeconds/totalElements;
            TimeSpan effectTS = TimeSpan.FromSeconds(effectDuration);
            //var msgString = string.Format("Total Elements: {0}\n Start Time: {1}\n End Time: {2}\n Total Duration: {3}\n Effect Duration: {4}\n TimeSpan Duration: {5}\n Start at last element: {6}", totalElements,startTime,endTime,totalDuration,effectDuration, effectTS.TotalSeconds, startAtLastElement);
            //MessageBox.Show(msgString);
            //Sanity Check - Keep effects from becoming less than minimum.
            if (effectDuration < .001)
            {
                MessageBox.Show(
                    string.Format(
                        "Unable to complete request. The resulting duration would fall below 1 millisecond.\nCalculated duration: {0}",
                        effectDuration), "Warning", MessageBoxButtons.OK);
                return;
            }

            var elementsToDistribute = new Dictionary<Element, Tuple<TimeSpan, TimeSpan>>();
            if (!startAtLastElement)
            {
                //Lets move the first one
                elementsToDistribute.Add(TimelineControl.SelectedElements.ElementAt(0),
                            new Tuple<TimeSpan, TimeSpan>(startTime, startTime + effectTS));
                for (int i = 1; i <= totalElements - 1; i++)
                {
                    var thisStartTime = elementsToDistribute.Last().Value.Item2;
                    elementsToDistribute.Add(TimelineControl.SelectedElements.ElementAt(i), new Tuple<TimeSpan, TimeSpan>(thisStartTime, thisStartTime + effectTS));
                }
            }
            else
            {
                //Lets move the first(last) one
                elementsToDistribute.Add(TimelineControl.SelectedElements.Last(), new Tuple<TimeSpan, TimeSpan>(startTime, startTime + effectTS));
                for (int i = totalElements - 2; i >= 0; i--)
                {
                    var thisStartTime = elementsToDistribute.Last().Value.Item2;
                    elementsToDistribute.Add(TimelineControl.SelectedElements.ElementAt(i), new Tuple<TimeSpan, TimeSpan>(thisStartTime, thisStartTime + effectTS));
                }
            }

            if (elementsToDistribute.Any())
            {
                TimelineControl.grid.MoveResizeElements(elementsToDistribute, ElementMoveType.Distribute);
            }
        }
        private void DistributeSelectedEffects()
        {
            if (!TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements))
            {
                MessageBox.Show(TimelineControl.grid.alignmentHelperWarning);
                return;
            }

            var startTime = TimelineControl.SelectedElements.First().StartTime;
            var endTime = TimelineControl.SelectedElements.Last().EndTime;
            if (startTime > endTime)
            {
                startTime = TimelineControl.SelectedElements.Last().StartTime;
                endTime = TimelineControl.SelectedElements.First().EndTime;
            }
            var dDialog = new EffectDistributionDialog();
            var elementCount = TimelineControl.SelectedElements.Count();

            dDialog.ElementCount = elementCount.ToString();
            dDialog.StartTime = startTime;
            dDialog.EndTime = endTime;
            dDialog.RadioEqualDuration = true;
            dDialog.RadioStairStep = true;
            dDialog.StartWithFirst = true;
            dDialog.ShowDialog();
            if (dDialog.DialogResult == DialogResult.OK)
            {
                startTime = dDialog.StartTime;
                endTime = dDialog.EndTime;
                TimeSpan duration = endTime - startTime;
                double offset = duration.TotalSeconds/elementCount;

                var elementsToDistribute = new Dictionary<Element, Tuple<TimeSpan, TimeSpan>>();
                if (dDialog.StartWithFirst)
                {
                    //We start with the first effect
                    for (int i = 0; i <= elementCount - 1; i++)
                    {
                        double thisStartTime = startTime.TotalSeconds;
                        double thisEndTime = thisStartTime + offset;
                        //Generic placement of starttime eq to prev end time
                        if (i > 0)
                            thisStartTime = elementsToDistribute.Last().Value.Item2.TotalSeconds;
                        //Determine Start time
                        if (i > 0 && dDialog.RadioEffectPlacementOverlap)
                            thisStartTime = thisStartTime - Convert.ToDouble(dDialog.EffectPlacementOverlap.TotalSeconds);
                        if (i > 0 && dDialog.RadioPlacementSpacedDuration)
                            thisStartTime = thisStartTime + Convert.ToDouble(dDialog.SpacedPlacementDuration.TotalSeconds);
                        if (dDialog.RadioDoNotChangeDuration && !dDialog.RadioEffectPlacementOverlap &&
                            !dDialog.RadioPlacementSpacedDuration)
                            thisStartTime = startTime.TotalSeconds + (offset*i);
                        //Determine End time
                        if (dDialog.RadioEqualDuration)
                            thisEndTime = thisStartTime + offset;
                        if (dDialog.RadioDoNotChangeDuration)
                            thisEndTime = thisStartTime + TimelineControl.SelectedElements.ElementAt(i).Duration.TotalSeconds;
                        if (dDialog.RadioSpecifiedDuration)
                            thisEndTime = thisStartTime + Convert.ToDouble(dDialog.SpecifiedEffectDuration.TotalSeconds);
                        elementsToDistribute.Add(TimelineControl.SelectedElements.ElementAt(i),
                            new Tuple<TimeSpan, TimeSpan>(TimeSpan.FromSeconds(thisStartTime), TimeSpan.FromSeconds(thisEndTime)));
                    }
                }
                if (dDialog.StartWithLast)
                {
                    //We start with the last effect
                    int placeCount = 0;
                    for (int i = elementCount - 1; i >= 0; i--)
                    {
                        var thisStartTime = startTime.TotalSeconds;
                        var thisEndTime = thisStartTime + offset;
                        //Generic placement of starttime eq to prev end time
                        if (i < elementCount - 1)
                            thisStartTime = elementsToDistribute.Last().Value.Item2.TotalSeconds;
                        //Determine Start time
                        if (i < elementCount - 1 && dDialog.RadioEffectPlacementOverlap)
                            thisStartTime = thisStartTime - Convert.ToDouble(dDialog.EffectPlacementOverlap.TotalSeconds);
                        if (i < elementCount - 1 && dDialog.RadioPlacementSpacedDuration)
                            thisStartTime = thisStartTime + Convert.ToDouble(dDialog.SpacedPlacementDuration.TotalSeconds);
                        if (dDialog.RadioDoNotChangeDuration && !dDialog.RadioEffectPlacementOverlap &&
                            !dDialog.RadioPlacementSpacedDuration)
                            thisStartTime = startTime.TotalSeconds + (offset*placeCount);
                        //Determine End time
                        if (dDialog.RadioEqualDuration)
                            thisEndTime = thisStartTime + offset;
                        if (dDialog.RadioDoNotChangeDuration)
                            thisEndTime = thisStartTime + TimelineControl.SelectedElements.ElementAt(i).Duration.TotalSeconds;
                        if (dDialog.RadioSpecifiedDuration)
                            thisEndTime = thisStartTime + Convert.ToDouble(dDialog.SpecifiedEffectDuration.TotalSeconds);
                        elementsToDistribute.Add(TimelineControl.SelectedElements.ElementAt(i),
                            new Tuple<TimeSpan, TimeSpan>(TimeSpan.FromSeconds(thisStartTime), TimeSpan.FromSeconds(thisEndTime)));
                        placeCount++;
                    }
                }
                if (elementsToDistribute.Any())
                {
                    TimelineControl.grid.MoveResizeElements(elementsToDistribute, ElementMoveType.Distribute);
                }
            }
        }
Exemple #4
0
        private void getUrls(Dictionary<string, object> dictionary)
        {
            var posts = dictionary.Last().Value;

            foreach (var o in posts as List<object>)
            {
                var temp = o as Dictionary<string, object>;

                if (String.IsNullOrEmpty(temp["photo-url-1280"].ToString()) ||
                    String.IsNullOrWhiteSpace(temp["photo-url-1280"].ToString()))
                {
                    allImages.Add(new Uri(temp["photo-url-500"].ToString()));
                }
                else
                {
                    allImages.Add(new Uri(temp["photo-url-1280"].ToString()));
                }
            }
        }
        //public  int IntParseFast(string value)
        //{
        //    int result = 0;
        //    for (int i = 0; i < value.Length; i++)
        //    {
        //        char letter = value[i];
        //        result = 10 * result + (letter - 48);
        //    }
        //    return result;
        //}

        /// <summary>
        /// Parse RidBags ex. %[content:binary]; where [content:binary] is the actual binary base64 content.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="recordString"></param>
        /// <param name="document"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        private int ParseRidBags(int i, string recordString, ODocument document, string fieldName)
        {
            //move to first base64 char
            i++;

            StringBuilder builder = new StringBuilder();

            while (recordString[i] != ';')
            {
                builder.Append(recordString[i]);
                i++;
            }

            // use a list as it preserves order at this stage which may be important when using ordered edges
            var rids = new List<ORID>();

            var value = Convert.FromBase64String(builder.ToString());
            using (var stream = new MemoryStream(value))
            using (var reader = new BinaryReader(stream))
            {
                var first = reader.ReadByte();
                int offset = 1;
                if ((first & 2) == 2)
                {
                    // uuid parsing is not implemented
                    offset += 16;
                }

                if ((first & 1) == 1) // 1 - embedded,0 - tree-based 
                {
                    var entriesSize = reader.ReadInt32EndianAware();
                    for (int j = 0; j < entriesSize; j++)
                    {
                        var clusterid = reader.ReadInt16EndianAware();
                        var clusterposition = reader.ReadInt64EndianAware();
                        rids.Add(new ORID(clusterid, clusterposition));
                    }
                }
                else
                {
                    // Maybe not parse this type of Field and only then Requested retrieve ?
                    // Lazy loading

                    if (_connection == null || !_connection.IsActive)
                        throw new OException(OExceptionType.Connection, "Connection is not opened or is null");

                    // Tree based RidBag - (collectionPointer)(size:int)(changes)

                    // Collection Pointer - (fileId:long)(pageIndex:long)(pageOffset:int)
                    var fileId = reader.ReadInt64EndianAware();
                    var pageIndex = reader.ReadInt64EndianAware();
                    var pageOffset = reader.ReadInt32EndianAware();

                    // size
                    var size = reader.ReadInt32EndianAware();

                    //only process ridbag if size > 0, otherwise the call to SBTreeBonsaiFirstKey operation makes the connection crash (the server probably isn't expecting this use case)
                    if (size > 0)
                    {
                        // Changes - (changesSize:int)[(link:rid)(changeType:byte)(value:int)]*
                        var changesSize = reader.ReadInt32EndianAware();
                        if (changesSize > 0)
                        //for (int j = 0; j < changesSize; j++)
                        {
                            throw new NotImplementedException("RidBag Changes not yet implemented");
                        }

                        var operation = new SBTreeBonsaiFirstKey(null);
                        operation.FileId = fileId;
                        operation.PageIndex = pageIndex;
                        operation.PageOffset = pageOffset;


                        // Not realy quiete about this
                        var connection = OClient.ReleaseConnection(_connection.Alias);

                        var entries = new Dictionary<ORID, int>();
                        try
                        {
                            var orid = connection.ExecuteOperation(operation);
                            var ft = true;
                            var key = orid.GetField<ORID>("rid");
                            do
                            {
                                var op = new SBTreeBonsaiGetEntriesMajor(null);
                                op.FileId = fileId;
                                op.PageIndex = pageIndex;
                                op.PageOffset = pageOffset;
                                op.FirstKey = key;
                                op.Inclusive = ft;

                                var res = connection.ExecuteOperation(op);
                                entries = res.GetField<Dictionary<ORID, int>>("entries");

                                rids.AddRange(entries.Keys);

                                if (entries.Count == 0)
                                    break;

                                key = entries.Last().Key;
                                ft = false;

                            } while (true);
                        }
                        finally
                        {
                            OClient.ReturnConnection(connection);
                        }
                    }
                }
            }

            document[fieldName] = rids;
            //move past ';'
            i++;

            return i;
        }
Exemple #6
0
        public short[] AssemblytoBinary(List<string> assemblyLines)
        {
            //short[] binaryInstructions = new short[assemblyLines.Count];//cant use this cause loading can be 3 instructions
            List<short> binaryInstructions = new List<short>(assemblyLines.Count);
            int count = -1;
            string[] separators = {" ","   "};
            Memory.setAssemblyInstructions(assemblyLines);
            Dictionary<List<string>, int> newCommands = new Dictionary<List<string>, int>();
            foreach (var line in assemblyLines)
            {
                count++;
                //Elements is an array containing each segment of the instruction delimited by whitespace
                //example: line is lda #$5 ---> element[0] = "lda", element[1] = "#$5"
                Debug.Write("Line is " + line + "\n");
                //string[] elements = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                string[] elements = line.Split(new char[0],StringSplitOptions.RemoveEmptyEntries);
               
                short opcode = 0, flag = 0, value = 0;
                short currLineBinary = 0;
                
                if (instructionCodes.ContainsKey(elements[0]))
                {
                    opcode = instructionCodes[elements[0]];
                    Debug.Write("Opcode is " + elements[0] + " and its value is " + opcode);
                }
                else
                {
                    //throw an error here cause we used an illegal opcode
                    Debug.Write("Error: Opcode " + elements[0] + " is invalid.");
                }
                if (elements.Length > 1 )
                {
                    
                    Debug.Write("Value in elements[1] is " + elements[1]);
                    Debug.Write(" Substring in element[1] is " + elements[1].Substring(0, 1));
                    string substring = elements[1].Substring(0, 1);
                    if (substring.Equals("#", StringComparison.OrdinalIgnoreCase)) //instructionsCodes.ContainsKey(substring);
                    {
                        flag = instructionCodes[substring];
                        Debug.Write(" elements 1 length is " + (elements[1].Length));
                        Debug.Write(" Flag is " + elements[1] + " and its value is " + flag);
                        var argumentString = elements[1].Substring(2, elements[1].Length-2);
                        Debug.Write(" Argument string is " + argumentString);
                        value = Convert.ToInt16(argumentString);
                        Debug.Write(" Argument string is " + argumentString);
                    }
                    else if (substring.Equals("$", StringComparison.OrdinalIgnoreCase))
                    {
                        var argumentString = elements[1].Substring(1, elements[1].Length-1);
                        value = Convert.ToInt16(argumentString);
                        Debug.Write("Argument string is " + argumentString);
                    }
                    else//branch case
                    {
                        value = (short)(labels[elements[1]]);
                        Debug.Write(" Label is " + elements[1] + " and its value is " + value);
                    }
                    
                }
                //Segmentation fault
                if ((value > 255) && (opcode == 9216))
                {
                    Debug.Write("Index out of bounds for stack.");
                    throw new Exception("Segmentation fault: index of " + value + " is out of bounds."); ;
                }
                //Special case - shift bits to load stuff
                else if ((value > 255) && (opcode == 8704) && (flag == 256))
                {
                    Debug.Write("Special shift case for load");
                    short instrPart1, shift, instrPart2;
                    string valueWhole, valuePart1, valuePart2;

                    valueWhole = Convert.ToString(value, 2).PadLeft(16, '0');
                    Debug.Write("Larger than normal load value: " + valueWhole);
                    valuePart1 = valueWhole.Substring(0, 8);
                    valuePart2 = valueWhole.Substring(8, 8);

                    instrPart1 = (short)(8960 | Convert.ToInt16(valuePart1,2));
                    shift = 19208;// (18944 | 256 | 8)
                    instrPart2 = (short)(25856 | Convert.ToInt16(valuePart2,2));
                    Debug.Write("Part 1 is " + valuePart1 + " and part 2 is " + valuePart2);

                    binaryInstructions.Add(instrPart1);
                    binaryInstructions.Add(shift);
                    binaryInstructions.Add(instrPart2);

                    Debug.WriteLine("Just added " + instrPart1 + ", " + shift + ", and " + instrPart2);
                    //1 instruction is becoming 3, so we need to adjust our labels
                    Dictionary<string, int> temp = new Dictionary<string, int>(labels.Count+10);
                    //var labelArray = labels.ToArray();
                    foreach(var label in labels)
                    {
                        if (label.Value > count)
                        {
                            temp.Add(label.Key, (label.Value + 2));
                        }
                        else
                        {
                            temp.Add(label.Key, label.Value);
                        }
                        Debug.WriteLine("Copied over " + temp.Last().Key + ", " + temp.Last().Value);
                    }
                    labels = temp;

                    //also have to update the assemblyInstructions
                    List<string> tempLines = new List<string>(3);
                    tempLines.Add("or #$" + Convert.ToInt16(valuePart2, 2));
                    tempLines.Add("shl #$" + 8);
                    tempLines.Add("lda #$" + Convert.ToInt16(valuePart1, 2));
                    newCommands.Add(tempLines, count);
                   
                   // instrPart1 = 8704 | 256 | Convert.ToInt16(valuePart1);
                    
                    continue;
                    

                }
                //Special case for adding numbers larger than 255
                else if ( (value > 255) && (opcode == 16896) && (flag == 256) )
                {
                    short staSpecial = 13312; //special store to temp register command
                    short addSpecial = 20992;//special add between temp and ACC
                    Debug.Write("Special shift case for add");
                    short instrPart1, shift, instrPart2;
                    string valueWhole, valuePart1, valuePart2;

                    valueWhole = Convert.ToString(value, 2).PadLeft(16, '0');
                    Debug.Write("Larger than normal load value: " + valueWhole);
                    valuePart1 = valueWhole.Substring(0, 8);
                    valuePart2 = valueWhole.Substring(8, 8);

                    instrPart1 = (short)(8960 | Convert.ToInt16(valuePart1, 2));
                    shift = 19208;// (18944 | 256 | 8)
                    instrPart2 = (short)(25856 | Convert.ToInt16(valuePart2, 2));
                    Debug.Write("Part 1 is " + valuePart1 + " and part 2 is " + valuePart2);

                    binaryInstructions.Add(staSpecial);
                    binaryInstructions.Add(instrPart1);
                    binaryInstructions.Add(shift);
                    binaryInstructions.Add(instrPart2);
                    binaryInstructions.Add(addSpecial);

                    Debug.WriteLine("Just added " + instrPart1 + ", " + shift + ", and " + instrPart2);
                    //1 instruction is becoming 3, so we need to adjust our labels
                    Dictionary<string, int> temp = new Dictionary<string, int>(labels.Count + 10);
                    //var labelArray = labels.ToArray();
                    foreach (var label in labels)
                    {
                        if (label.Value > count)
                        {
                            temp.Add(label.Key, (label.Value + 5));
                        }
                        else
                        {
                            temp.Add(label.Key, label.Value);
                        }
                        Debug.WriteLine("Copied over " + temp.Last().Key + ", " + temp.Last().Value);
                    }
                    labels = temp;

                    //also have to update the assemblyInstructions
                    List<string> tempLines = new List<string>(5);
                    tempLines.Add("add $TEMP");
                    tempLines.Add("or #$" + Convert.ToInt16(valuePart2, 2));
                    tempLines.Add("shl #$" + 8);
                    tempLines.Add("lda #$" + Convert.ToInt16(valuePart1, 2));
                    tempLines.Add("sta $TEMP");
                    newCommands.Add(tempLines, count);

                    // instrPart1 = 8704 | 256 | Convert.ToInt16(valuePart1);
                    
                    continue;

                }
                Debug.Write("Opcode is " + Convert.ToString(opcode, 2));
                Debug.Write(" Flag is " + flag);
                Debug.Write(" and value is " + value);
                currLineBinary = (short)((ushort)opcode | (ushort)flag | (ushort)value);
                Debug.Write("Instruction is " + line + " and binary is " + (Convert.ToString(currLineBinary, 2).PadLeft(16, '0')));
                Debug.Write("Command: ");
                foreach (var temp in elements)
                {
                    Debug.Write(temp + " " );
                    if (instructionCodes.ContainsKey(temp))
                    {
                        //STOPPED HERE - have to piece together the parts of the instruction first
                    }

                }
                Debug.Write("\n");

                var tempString = Convert.ToString(currLineBinary, 2).PadLeft(16, '0');
                Debug.Write("Temp string is " + tempString + " and currLineBinary is " + currLineBinary);// + " and temp short is " + tempShort);

                binaryInstructions.Add(currLineBinary);
                //binaryInstructions[count] = currLineBinary;
                Debug.Write("Added the short " + currLineBinary + " to the array of binary instructions.\n");
              
            }

            int addedCount = 0;
            foreach (var temp in newCommands)
            {
                int adjustedIndex = temp.Value + addedCount;
                Debug.Write("Removed: " + assemblyLines.ElementAt(adjustedIndex));
                assemblyLines.RemoveAt(temp.Value + addedCount);
                foreach (var item in temp.Key)
                {
                    assemblyLines.Insert(adjustedIndex, item);
                    addedCount++;
                }
                addedCount--;
                Debug.WriteLine(", added count is " + addedCount);
            }

            Debug.WriteLine("New assembly lines:");
            foreach (var temp in assemblyLines)
            {
                Debug.WriteLine(temp);
            }

            for (int i = 0; i < binaryInstructions.Count(); i++)
            {
                Debug.Write("\nLine " + i + ": " + binaryInstructions[i]);
            }
                return binaryInstructions.ToArray();
        }
Exemple #7
0
        /// <summary>
        /// Creates the aggregate items.
        /// </summary>
        /// <param name="currentReport">The current report.</param>
        /// <param name="forGroups">if set to <c>true</c> [for groups].</param>
        /// <returns>List{TextBox}.</returns>
        private List<TextBox> CreateAggregateItems(Report currentReport, bool forGroups)
        {
            var height = new Unit(16);
            var aggregateItems = new Dictionary<string, List<TextBox>>();
            var additionalInfoForLastAggregateItem = new Dictionary<Unit, float>();

            //calculate server-side aggregates
            var aggregateDefinitions = _aggregateDict.ToList()
                .SelectMany(i => i.Value)
                .Where(d => !AggregateHelper.IsPageAggregateType(d.SummaryType))
                .ToList();

            var queryCriteria = new AggregateDataSourceQueryCriteria
            {
                ProcessName = _processName,
                FilterDefinition = GetFilterDefinition(currentReport)
            };
            var serverAggregateResults = AggregateProcessor.CalculateAggregates(aggregateDefinitions, queryCriteria);

            foreach (var aggregateInfo in _aggregateDict)
            {
                var col = _colDict.FirstOrDefault(x => x.Value[0] == aggregateInfo.Key);

                if (!col.Equals(default(KeyValuePair<int, string[]>)))
                {
                    var fieldValueMap = ((TextBox)currentReport.Items["detail"].Items["rowPanel"].Items[col.Key - 1]).Value.TrimStart('=');

                    var locationX = ((TextBox)currentReport.Items["detail"].Items["rowPanel"].Items[col.Key - 1]).Location.X;

                    var width = GetWidth(currentReport, aggregateInfo);

                    var locationY = new Unit(0, locationX.Type);

                    var list = new List<TextBox>();

                    foreach (var criteria in aggregateInfo.Value)
                    {
                        var textbox = new TextBox();
                        textbox.Style.Padding.Left = new Unit(1);
                        textbox.Style.Padding.Right = new Unit(1);
                        textbox.Style.Font.Size = new Unit(9);
                        textbox.Style.Font.Name = "Arial Unicode MS";
                        textbox.Style.VerticalAlign = VerticalAlign.Middle;
                        textbox.Size = new SizeU(Unit.Inch(width), height);
                        textbox.CanGrow = true;
                        textbox.TextWrap = true;
                        textbox.Location = new PointU(locationX, locationY);

                        if (_aggregateDict.Last().Equals(aggregateInfo))
                        {
                            EventHandler textboxItemDataBoundHandler = (s, e) =>
                                {
                                    var ft = new FormattedText((string)((Telerik.Reporting.Processing.TextBox)s).Value, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(new System.Windows.Media.FontFamily(((Telerik.Reporting.Processing.VisualElement)s).Style.Font.Name), new System.Windows.FontStyle(), new FontWeight(), new FontStretch()), ((Telerik.Reporting.Processing.VisualElement)s).Style.Font.Size.Value, System.Windows.Media.Brushes.Black);

                                    if (ft.Width > ((Telerik.Reporting.Processing.TextBox)s).Size.Width.Value)
                                    {
                                        foreach (var f in additionalInfoForLastAggregateItem)
                                        {
                                            ((Telerik.Reporting.Processing.ReportItem)s).Location = new PointU(f.Key, ((Telerik.Reporting.Processing.ReportItem)s).Location.Y);
                                            ((Telerik.Reporting.Processing.ReportItem)s).Size = new SizeU(Unit.Inch(f.Value + ((Telerik.Reporting.Processing.ReportItem)s).Size.Width.Value), height);
                                            if (((Telerik.Reporting.Processing.ReportItem)s).Size.Width.Value >= ft.Width)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                };
                            textbox.ItemDataBound += textboxItemDataBoundHandler;

                            EventHandler textboxDisposedHandler = null;
                            textboxDisposedHandler = (sender, args) =>
                            {
                                textbox.ItemDataBound -= textboxItemDataBoundHandler;
                                textbox.Disposed -= textboxDisposedHandler;
                            };
                            textbox.Disposed += textboxDisposedHandler;
                        }

                        if (AggregateHelper.IsPageAggregateType(criteria.SummaryType))
                        {
                            var aggregateFunction = forGroups ? "Exec" : "PageExec";
                            var aggregateFunctionParameter = forGroups ? ":scope:" : aggregateInfo.Key + "TextBox";

                            textbox.Value = string.Format(
                                    @"='{0}: ' + AfterCalculateAggregates({7}('{8}', {2}(BeforeCalculateAggregates(Fields.[{1}], ""{2}"", ""{3}"", ""{4}"", ""{5}"", ""{6}""))), ""{2}"", ""{3}"", ""{4}"", ""{5}"", ""{6}"")",
                                    AggregateHelper.GetAttribute(criteria.SummaryType).ShortName,
                                    aggregateInfo.Key,
                                    criteria.SummaryType,
                                    criteria.CustomConverter,
                                    criteria.TargetType,
                                    criteria.TypeName,
                                    criteria.ConverterParameter,
                                    aggregateFunction,
                                    aggregateFunctionParameter);
                        }
                        else
                        {
                            var result = serverAggregateResults.FirstOrDefault(r => r.ColumnName == criteria.ColumnName && r.SummaryType == criteria.SummaryType);
                            textbox.Value = string.Format("{0}: {1}", AggregateHelper.GetAttribute(criteria.SummaryType).ShortName, result);
                        }

                        list.Add(textbox);

                        locationY += height;
                    }
                    aggregateItems.Add(aggregateInfo.Key, list);
                }
            }

            if (aggregateItems.Count > 1)
            {
                var lastItem = aggregateItems.Last();
                aggregateItems.Remove(lastItem.Key);

                var penultimateItem = aggregateItems.Last();

                var indexOfPenultimateItem = _colDict.First(x => x.Value[0] == penultimateItem.Key).Key;
                var indexOfLastItem = _colDict.First(x => x.Value[0] == lastItem.Key).Key;
                if (indexOfLastItem - indexOfPenultimateItem > 1) // if exists at least one column between last and penultimate aggregate columns
                {
                    // fill additional info for last aggrigate item
                    var i = Convert.ToInt32((indexOfLastItem - indexOfPenultimateItem - 1) / 2);
                    foreach (var column in _colDict)
                    {
                        if (column.Key >= i + indexOfPenultimateItem + 1 && column.Value[0] != lastItem.Key)
                        {
                            var item = ((ReportItem)currentReport.Items["detail"].Items["rowPanel"].Items.FirstOrDefault(x => x.Name == string.Format("{0}TextBox", column.Value[0])));
                            if (item != null)
                            {
                                additionalInfoForLastAggregateItem.Add(item.Location.X, item.Size.Width.Value);
                            }
                        }
                    }

                    var descending = additionalInfoForLastAggregateItem.Reverse();
                    additionalInfoForLastAggregateItem = descending.ToDictionary(x => x.Key, x => x.Value);

                    // new size of penultimate item
                    foreach (var textbox in penultimateItem.Value)
                    {
                        textbox.Size = new SizeU(Unit.Inch(textbox.Size.Width.Value / 2), height);
                    }
                }
                aggregateItems.Add(lastItem.Key, lastItem.Value);
            }

            var returnList = new List<TextBox>();
            foreach (var aggregateItem in aggregateItems)
            {
                returnList.AddRange(aggregateItem.Value);
            }

            return returnList;
        }