本文整理汇总了C#中System.Collections.Dictionary.Last方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Last方法的具体用法?C# Dictionary.Last怎么用?C# Dictionary.Last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.Last方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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/[email protected]{0}", Path.GetFileNameWithoutExtension(item.Value)));
}
示例2: DistributeSelectedEffectsEqually
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);
}
}
示例3: DistributeSelectedEffects
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);
}
}
}
示例4: getUrls
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()));
}
}
}
示例5: ParseRidBags
//.........这里部分代码省略.........
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;
}
示例6: AssemblytoBinary
//.........这里部分代码省略.........
{
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)
示例7: CreateAggregateItems
/// <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);
//.........这里部分代码省略.........