本文整理汇总了C#中System.Windows.Documents.List.Last方法的典型用法代码示例。如果您正苦于以下问题:C# List.Last方法的具体用法?C# List.Last怎么用?C# List.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResultsWindow
public ResultsWindow(Stats stat, List<Node> results, EightSquares eightPuzzle, int expanded, int total)
{
InitializeComponent();
this.eightPuzzle = eightPuzzle;
this.stat = stat;
expandedCount.Text += expanded;
genCount.Text += total;
movesMade.Text += results.Last().gValue;
avgBranchingFactor.Text += Math.Round((Double)total / expanded, 3);
Double temp = (double)1 / (double)results.Last().gValue;
effBranchingFactor.Text += Math.Round(Math.Pow(expanded, temp), 3);
List<Data> source = new List<Data>();
foreach (Node n in results)
{
source.Add(new Data()
{
hValue = n.hValue,
gValue = n.gValue,
fValue = n.fValue,
action = n.action,
state = stringifyState(n),
thisNode = n
});
actionsToGoal.Text += (n.action != String.Empty && n.gValue != results.Count - 1) ? String.Format("{0}, ", n.action) : n.action;
}
grid.ItemsSource = source;
//grid.DataContext = results[0];
}
示例2: CalcAgeChampions
// takes list of participants sorted by place in age division, returns top 3..ish
List<AgeChampion> CalcAgeChampions(List<AgeChampion> champions, List<Participant> participants, int place = 1)
{
Participant p = participants.First();
participants.Remove(p);
// no points scored, cannot be a champion
if (ParticipantPoints(p) == 0)
return champions;
champions.Add(new AgeChampion(p, place, ParticipantPoints(p)));
// no more possible champions
if (participants.Count == 0)
return champions;
// if the same number of points, equal age champion w/ same place
if (champions.Last().Points == ParticipantPoints(participants.First()))
CalcAgeChampions(champions, participants, place);
// room for more champions
else if (champions.Count < 3)
CalcAgeChampions(champions, participants, place + 1);
return champions;
}
示例3: FragmentData
public static List<Fragment> FragmentData(Fragment data, int mtu, int header = 20)
{
var localData = new Fragment(data);
var result = new List<Fragment>();
while (localData.Length + header > mtu)
{
var temp = new Fragment(EightMultiple(mtu - header),
true,
localData.Offset);
localData.Length -= temp.Length;
localData.Offset = (temp.Length / 8) + ((result.Count > 0) ? result.Last().Offset : 0);
result.Add(temp);
}
if (localData.Length != 0)
{
localData.Offset += (result.Count > 0) ? result.Last().Offset : 0;
result.Add(localData);
}
return result;
}
示例4: SetDataSource
public void SetDataSource(List<Dictionary<string, object>> dataSource)
{
if (dataSource == null || dataSource.Count == 0)
{
return;
}
this.SearchChartView.ClearPoints();
var entry0 = dataSource[0];
var entryf = dataSource.Last();
DateTime beginTime = DateTime.Parse((string)entry0["time"]);
DateTime finalTime = DateTime.Parse((string)entryf["time"]);
this.SearchChartView.UpdateTimeAxis(beginTime, finalTime, dataSource, dataSource.Count());
this.SearchChartView.SetDataPoints(dataSource);
/*
foreach (var e in dataSource)
{
this.SearchChartView.AddCurvesDataPoint(e);
}
*/
}
示例5: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawLine(new Pen(Brushes.White, _firstThresholdThickness), new Point(-_firstThresholdThickness/2, 0), new Point(-_firstThresholdThickness/2, ActualHeight));
var con = 17.817;
List<double> points = new List<double>();
double lasX = 0;
for (int index = 0; index < NumberFrets; index++)
{
double x = lasX + (ActualWidth - lasX) / con;
lasX = x;
points.Add(x);
}
double scale = ActualWidth / points.Last();
for (int index = 0; index < NumberFrets; index++)
{
Point strPoint = new Point(points[index]* scale, 0);
Point endPoint = new Point(points[index]* scale, ActualHeight);
drawingContext.DrawLine(new Pen(Brushes.Black, 2), strPoint, endPoint);
}
}
示例6: StartModelWindow
public StartModelWindow()
{
InitializeComponent();
environments = new List<EnvironmentPreset>(); //добавляем параметры для различных сред
environments.Add(new EnvironmentPreset("H2O", 1, new Element[]{new Element(1, 20.4), new Element(16, 3.76)}, new int[]{2, 1}));
environments.Add(new EnvironmentPreset("D2O", 1.11f, new Element[] { new Element(2, 3.39), new Element(16, 3.76) }, new int[] {2, 1}));
environments.Add(new EnvironmentPreset("Be", 1.848f, new Element[]{new Element(9, 6.14)}, new int[]{1}));
environments.Add(new EnvironmentPreset("BeO", 3.02f, new Element[] { new Element(9, 6.14), new Element(16, 3.76) }, new int[] {1, 1}));
environments.Add(new EnvironmentPreset("C", 2.25f, new Element[] { new Element(12, 4.75) }, new int[] {1}));
lstEnvironment.ItemsSource = environments;
lstEnvironment.SelectedItem = environments.Last();
this.position = new Vector3D(0, 0, 0); //координаты источника
this.energy = 3; //начальная энергия (МэВ)
this.count = 10; //число судеб для рассмотрения
//по умолчанию среда - углерод
this.env = ((EnvironmentPreset)lstEnvironment.SelectedItem);
this.DataContext = this;
}
示例7: SetParameter
public void SetParameter ()
{
if (m_Arguments.Count == 0)
return;
if (!File.Exists (m_Arguments ["P0"]))
return;
#region Data for Root PreviewBeitrag
m_TypeOfBeitrag = WMB.Basics.GetCommandLineContent (m_Arguments, CVM.CommonValues.WPMEDIA_TYPE_OF_BEITRAG);
m_OrderNumber = WMB.Basics.GetCommandLineContent (m_Arguments, CVM.CommonValues.WPMEDIA_ORDER_NUMBER);
m_BeitragsIDOfPreviewBeitrag = WMB.Basics.GetCommandLineContent (m_Arguments, WPMediaManagement.ManagedProgrammData.Param_VideoBeitragsID);
m_ConnectedBeitragsID = WMB.Basics.GetCommandLineContent (m_Arguments, WPMediaManagement.ManagedProgrammData.Param_LogicallyConnectedBeitragsID);
//m_FullBeitragToDisplay = new ArrayList ();
//m_StartingTimesToDisplay = new ArrayList ();
m_ProgrammManagement = new WPMediaManagement.ManagedProgrammManagement ();
if (!m_ProgrammManagement.ProgrammData.FullBeitragList.ContainsKey (m_BeitragsIDOfPreviewBeitrag))
{
WMB.Basics.ReportErrorToEventViewer ("ProgrammPreview.SetParameter",
"Für die ID \"" + m_BeitragsIDOfPreviewBeitrag + "\" gibt es keinen Eintrag");
}
m_BeitragsFullDataSetOfPreviewBeitrag = m_ProgrammManagement.ProgrammData.FullBeitragList [m_BeitragsIDOfPreviewBeitrag];
DataRow [] BeitragsSchedulingRows = m_ProgrammManagement.ProgrammData.SchedulingDataSet.Tables ["Scheduling"].Select
("OrderNumber = '" + m_OrderNumber + "'");
if (BeitragsSchedulingRows.Length < 1)
{
WMB.Basics.ReportErrorToEventViewer ("ProgrammPreview.SetParameter",
"Für die OrderNumber = \"" + m_OrderNumber + "\" gibt es keinen Eintrag");
m_TypeOfBeitrag = String.Empty;
return;
}
m_BeitragsSchedulingRow = BeitragsSchedulingRows [0];
List<Slide> SlideList = new List<Slide> ();
#endregion
if (m_TypeOfBeitrag == WPMediaManagement.ManagedProgrammData.BLOCK_PREVIEW)
{
Dictionary<String, List<String>> StartTimes = m_ProgrammManagement.ProgrammData.GetStartTimesForEachBeitragIDInThisBlock
(m_BeitragsSchedulingRow ["ParentBlockOrderNumber"].ToString ());
m_CompleteRunningTime = (m_HostCVM.TimeToStop - m_HostCVM.GetDateTimeNow).TotalSeconds;
TimeSpan PictureIntervall = TimeSpan.FromSeconds(((m_CompleteRunningTime
- CVM.CommonValues.DEFAULT_TIME_FOR_COMMON_OPEN_CHANNEL_INFO
- CVM.CommonValues.DEFAULT_TIME_FOR_COMMON_BIETE_SUCHE_INFO
- CVM.CommonValues.DEFAULT_TIME_FOR_COMMON_PREVIEW_INFO)
/ StartTimes.Keys.Count));
foreach (String BeitragID in StartTimes.Keys)
{
if (!m_ProgrammManagement.ProgrammData.FullBeitragList.ContainsKey(BeitragID))
{
WMB.Basics.ReportErrorToEventViewer("ProgrammPreview.CreateListOfDisplayableBeitraege",
"Der Beitrag \"" + BeitragID + "\" ist nicht zugreifbar");
continue;
}
SlideList.Add (new Slide ());
SlideList.Last ().Content = new ProgrammEntryPreview (this, BeitragID, m_TypeOfBeitrag)
{
BeitragToPreviewFullDataSet = m_ProgrammManagement.ProgrammData.FullBeitragList [BeitragID],
StartTimesForThisBeitragIDInThisBlock = (StartTimes [BeitragID])
};
SlideList.Last ().Options.DisplayDuration = PictureIntervall;
}
m_CompleteRunningTime = (m_HostCVM.TimeToStop - m_HostCVM.GetDateTimeNow).TotalSeconds;
}
else
{
TimeSpan PictureIntervall = m_ProgrammManagement.ProgrammData.GetDefinedDuration(m_BeitragsSchedulingRow);
m_CompleteRunningTime = PictureIntervall.TotalSeconds;
if (!m_ProgrammManagement.ProgrammData.FullBeitragList.ContainsKey (m_ConnectedBeitragsID))
{
WMB.Basics.ReportErrorToEventViewer ("ProgrammPreview.CreateListOfDisplayableBeitraege",
"Der Beitrag \"" + m_ConnectedBeitragsID + "\" ist nicht zugreifbar");
}
else
{
SlideList.Add (new Slide ());
SlideList.Last ().Content = new ProgrammEntryPreview (this, m_ConnectedBeitragsID, m_TypeOfBeitrag)
{
BeitragToPreviewFullDataSet = m_ProgrammManagement.ProgrammData.FullBeitragList [m_ConnectedBeitragsID]
};
SlideList.Last ().Options.DisplayDuration = PictureIntervall;
}
}
SlideShow.Slides = SlideList.ToArray();
SlideShow.TargetControl = TargetContent;
}
示例8: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
this.ManipulationStarted += new EventHandler<ManipulationStartedEventArgs>(_uppart_ManipulationStarted);
this.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(_uppart_ManipulationDelta);
this.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(_uppart_ManipulationCompleted);
_pageElements.Add(_border0);
_pageElements.Add(_border2);
_pageElements.Add(_border1);
_pixellist = new PixelData[6];
_bmps = new WriteableBitmap[6];
for (int i = 0; i < _bmps.Length; ++i)
{
var bmp = new WriteableBitmap(480, 400);
_bmps[i] = bmp;
_pixellist[i].Pixels = bmp.Pixels;
}
_samplebitmaps = new List<WriteableBitmap>();
string[] fn = new string[]
{
"img.jpg",
"img01.jpg",
"img02.jpg",
"img03.jpg",
"img04.jpg",
"img05.jpg",
"img06.jpg",
"img07.jpg"
};
foreach (var f in fn)
{
var wbmp = BitmapFromResource(f);
var wbmpout0 = new WriteableBitmap(480, 400);
var wbmpout1 = new WriteableBitmap(480, 400);
SplitBitmap(wbmp, wbmpout0, wbmpout1);
_samplebitmaps.Add(wbmpout0);
_samplebitmaps.Add(wbmpout1);
}
var firstpage = new FlipPage
{
Front = _samplebitmaps[0],
Back = _samplebitmaps[0]
};
_pages.Add(firstpage);
for (int i = 1; i < _samplebitmaps.Count - 1; i += 2)
{
var page = new FlipPage
{
Front = _samplebitmaps[i],
Back = _samplebitmaps[i + 1]
};
_pages.Add(page);
}
var lastpage = new FlipPage
{
Front = _samplebitmaps.Last(),
Back = _samplebitmaps.Last()
};
_pages.Add(lastpage);
MovePageTo(0);
const string XAML_MOVE_ANI = @"
<Storyboard x:Name=""_sbCurrentPage""
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
>
<DoubleAnimation Duration=""0:0:0.4"" To=""0"" Storyboard.TargetProperty=""CurrentPageNum"">
<DoubleAnimation.EasingFunction>
<PowerEase EasingMode=""EaseOut""/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>";
_sbPageMove = XamlReader.Load(XAML_MOVE_ANI) as Storyboard;
Storyboard.SetTarget(_sbPageMove, this);
}
示例9: CalculateDrawingDetails
void CalculateDrawingDetails(List<List<DrawingValues>> DrawingsGrid,
DrawingStandards Standards, String PictureName)
{
Standards.UsedFrame = GetDrawingFrame(PictureName);
Standards.TargetWidth = ((double)Standards.FullWidth * ((double)Standards.UsedFrame.PositionRight
- (double)Standards.UsedFrame.PositionLeft)) / 100;
double FullTargetHeight = ((double)Standards.FullHeight * ((double)Standards.UsedFrame.PositionBottom
- (double)Standards.UsedFrame.PositionTop)) / 100;
int NumberOfLines = DrawingsGrid.Count();
if (PictureName.Contains("Sport"))
{
Standards.HeightUnit = FullTargetHeight / ((double)6 + 0.2);
Standards.TargetHeight = Standards.HeightUnit*(NumberOfLines + 0.2);
}
else
{
Standards.HeightUnit = FullTargetHeight / ((double)11 + 0.2);
Standards.TargetHeight = Standards.HeightUnit * (NumberOfLines + 0.2);
}
Standards.HeightUnit = Standards.TargetHeight/((double) NumberOfLines + 0.2);
int NumberOfColumns = DrawingsGrid.Last().Count();
Standards.WidthUnit = Standards.TargetWidth / ((double)NumberOfColumns + 4);
Standards.RowStartings = new List<double>();
Standards.ColumnStartings = new List<double>();
double MarginXValue = 4;
double MarginYValue = 4;
int RunningIndex = 0;
foreach (List<DrawingValues> drawingValueses in DrawingsGrid)
{
if (RunningIndex == 0)
{
Standards.RowStartings.Add(0);
}
else
if (RunningIndex == 2)
{
Standards.RowStartings.Add(Standards.RowStartings.Last() + (Standards.HeightUnit * 1.2));
}
else
Standards.RowStartings.Add(Standards.RowStartings.Last( ) + Standards.HeightUnit);
if (RunningIndex > 0)
{
SetTop(drawingValueses, Standards.RowStartings.Last(), MarginYValue);
if (RunningIndex == 1)
SetBottom(drawingValueses, Standards.RowStartings.Last()
+ (Standards.HeightUnit*1.2), MarginYValue);
else
SetBottom(drawingValueses, Standards.RowStartings.Last()
+ Standards.HeightUnit, MarginYValue);
}
RunningIndex++;
}
RunningIndex = 0;
foreach (DrawingValues drawingValues in DrawingsGrid.Last())
{
if (RunningIndex == 0)
{
Standards.ColumnStartings.Add(0);
SetLeft(GetColumnDrawingValues(DrawingsGrid, RunningIndex), 0, MarginXValue);
SetRight(GetColumnDrawingValues(DrawingsGrid, RunningIndex), (Standards.WidthUnit * 5), MarginXValue);
RunningIndex++;
continue;
}
if (RunningIndex == 1)
{
Standards.ColumnStartings.Add(Standards.ColumnStartings[0] + (Standards.WidthUnit * 5));
SetLeft(GetColumnDrawingValues(DrawingsGrid, RunningIndex),
Standards.ColumnStartings.Last(), MarginXValue);
SetRight(GetColumnDrawingValues(DrawingsGrid, RunningIndex),
Standards.ColumnStartings.Last() + (Standards.WidthUnit), MarginXValue);
RunningIndex++;
continue;
}
Standards.ColumnStartings.Add(Standards.ColumnStartings[RunningIndex - 1] + Standards.WidthUnit);
SetLeft(GetColumnDrawingValues(DrawingsGrid, RunningIndex),
Standards.ColumnStartings.Last(), MarginXValue);
SetRight(GetColumnDrawingValues(DrawingsGrid, RunningIndex),
Standards.ColumnStartings.Last() + (Standards.WidthUnit), MarginXValue);
RunningIndex++;
}
DrawingsGrid[0][0].OuterTop = 0;
DrawingsGrid[0][0].OuterLeft = 0;
DrawingsGrid[0][0].OuterBottom = Standards.HeightUnit;
DrawingsGrid[0][0].OuterRight = Standards.TargetWidth;
DrawingsGrid[0][0].MarginTop = DrawingsGrid[0][0].OuterTop + MarginYValue;
DrawingsGrid[0][0].MarginLeft = DrawingsGrid[0][0].OuterLeft + MarginXValue;
DrawingsGrid[0][0].MarginBottom = DrawingsGrid[0][0].OuterBottom - MarginYValue;
DrawingsGrid[0][0].MarginRight = DrawingsGrid[0][0].OuterRight - MarginXValue;
}
示例10: ListarUnidadeMedidas
private void ListarUnidadeMedidas()
{
List<Contrato.UnidadeMedida> lstUnidadeMedidas = new List<Contrato.UnidadeMedida>();
Contrato.EntradaUnidadeMedida entUnidadeMedida = new Contrato.EntradaUnidadeMedida();
entUnidadeMedida.UsuarioLogado = Comum.Util.UsuarioLogado.Login;
entUnidadeMedida.EmpresaLogada = Comum.Parametros.EmpresaProduto;
entUnidadeMedida.Chave = Comum.Util.Chave;
entUnidadeMedida.UnidadeMedida = new Contrato.UnidadeMedida() { Ativo = true };
Servico.BrasilDidaticosClient servBrasilDidaticos = new Servico.BrasilDidaticosClient(Comum.Util.RecuperarNomeEndPoint());
Contrato.RetornoUnidadeMedida retUnidadeMedida = servBrasilDidaticos.UnidadeMedidaListar(entUnidadeMedida);
servBrasilDidaticos.Close();
// Se encontrou unidades de medidas
if (retUnidadeMedida.UnidadeMedidas != null)
// Adiciona as unidades de medidas
lstUnidadeMedidas.AddRange(retUnidadeMedida.UnidadeMedidas);
if (lstUnidadeMedidas != null)
{
List<Objeto.UnidadeMedida> objUnidadeMedidas = null;
if (_produto != null && _produto.UnidadeMedidas != null)
{
objUnidadeMedidas = new List<Objeto.UnidadeMedida>();
foreach (Contrato.UnidadeMedida unidadeMedida in lstUnidadeMedidas)
{
if (unidadeMedida != null)
{
objUnidadeMedidas.Add(new Objeto.UnidadeMedida { Selecionado = false, Id = unidadeMedida.Id, Nome = unidadeMedida.Nome, Ativo = unidadeMedida.Ativo });
Contrato.UnidadeMedida objUnidadeMedida = (from ft in _produto.UnidadeMedidas where ft.Nome == unidadeMedida.Nome select ft).FirstOrDefault();
if (objUnidadeMedida != null)
{
objUnidadeMedidas.Last().Selecionado = true;
objUnidadeMedidas.Last().Quantidade = objUnidadeMedida.Quantidade;
objUnidadeMedidas.Last().QuantidadeItens = objUnidadeMedida.QuantidadeItens;
}
}
}
}
else
objUnidadeMedidas = (from t in lstUnidadeMedidas
select new Objeto.UnidadeMedida { Selecionado = false, Id = t.Id, Nome = t.Nome, Quantidade = t.Quantidade, QuantidadeItens = t.QuantidadeItens, Ativo = t.Ativo }).ToList();
dgUnidadeMedidas.ItemsSource = objUnidadeMedidas;
}
}
示例11: GetCrossSectionProfile
public void GetCrossSectionProfile(List<Point> list, string fileName, int TotalPoints, double fPointWidth)
{
BitmapImage myBitmapImage = GetImage(fileName);
if (myBitmapImage == null)
{
return;
}
FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
newFormatedBitmapSource.BeginInit();
newFormatedBitmapSource.Source = myBitmapImage;
newFormatedBitmapSource.DestinationFormat = PixelFormats.Rgb24;
newFormatedBitmapSource.EndInit();
int width = newFormatedBitmapSource.PixelWidth;
int stride = width * 3;
int size = newFormatedBitmapSource.PixelHeight * stride;
byte[] pixels = new byte[size];
Array.Clear(pixels, 0, size);
newFormatedBitmapSource.CopyPixels(pixels, stride, 0);
int x = 0;
int y = 0;
Point ptCenter = new Point();
ptCenter.X = newFormatedBitmapSource.PixelWidth / 2;
ptCenter.Y = newFormatedBitmapSource.PixelHeight / 2;
int r_begin_min = (int)Math.Min(ptCenter.X, ptCenter.Y);
ScaleTransform scaleTransform = new ScaleTransform(fPointWidth, fPointWidth);
double delta = TotalPoints / 360;
for (double angle = 0; angle < 360; angle += delta)
{
double rad_angle = Math.PI * angle / 180.0;
int r_begin = (int)Math.Sqrt(2 * r_begin_min * r_begin_min);
for (double r = r_begin; r > 0; r-=1)
{
x = (int)(r * Math.Cos(rad_angle)) + (int)ptCenter.X;
y = (int)(r * Math.Sin(rad_angle)) + (int)ptCenter.Y;
if (x >= newFormatedBitmapSource.PixelWidth ||
y >= newFormatedBitmapSource.PixelHeight ||
x < 0 || y < 0)
{
continue;
}
int index = y * stride + 3 * x;
byte red = pixels[index];
byte green = pixels[index + 1];
byte blue = pixels[index + 2];
Color cur_col = Color.FromRgb(red, green, blue);
if (cur_col != Color.FromRgb(255, 255, 255))
{
int x_add = x - (int)ptCenter.X;
int y_add = y - (int)ptCenter.Y;
Point ptToAdd = new Point(x_add, y_add);
if (list.Count == 0 || list.Last() != ptToAdd)
{
list.Add(ptToAdd);
if (list.Count == 215)
{
int h = 0 + 4;
}
}
break;
}
}
}
if (scaleTransform != null)
{
for (int i = 0; i < list.Count; i++)
{
list[i] = scaleTransform.Transform(list[i]);
}
}
}
示例12: ArrangeOverride
/// <summary>
/// Arranges children giving them a proportional space according to their <see cref="SplitSize"/> attached property value
/// </summary>
/// <param name="finalSize"></param>
/// <returns></returns>
protected override Size ArrangeOverride(Size finalSize)
{
//Compute the list of visible children
List<FrameworkElement> visibleChildren = new List<FrameworkElement>();
for (int i = 0; i < VisualChildrenCount; i++)
{
FrameworkElement child = GetVisualChild(i) as FrameworkElement;
IDockableControl dockableControl = child as IDockableControl;
if (dockableControl != null &&
!dockableControl.IsDocked)
{
child.Arrange(new Rect());
if (i == VisualChildrenCount - 1 &&
i > 0)
{
child = GetVisualChild(i - 1) as FrameworkElement;
Debug.Assert(child is ResizingPanelSplitter);
child.Arrange(new Rect());
if (visibleChildren.Count > 0)
{
Debug.Assert(visibleChildren[visibleChildren.Count - 1] is ResizingPanelSplitter);
visibleChildren[visibleChildren.Count - 1].Arrange(new Rect());
visibleChildren.RemoveAt(visibleChildren.Count - 1);
}
}
else if (i < VisualChildrenCount - 1)
{
i++;
child = GetVisualChild(i) as FrameworkElement;
child.Arrange(new Rect());
Debug.Assert(child is ResizingPanelSplitter);
}
continue;
}
visibleChildren.Add(child);
}
//with no children fill the space
if (visibleChildren.Count == 0)
{
_childrenFinalSizes = new Size[] { };
return new Size();
}
Debug.Assert(!(visibleChildren.Last<FrameworkElement>() is ResizingPanelSplitter));
_childrenFinalSizes = new Size[visibleChildren.Count];
var splitters = from FrameworkElement child in visibleChildren
where child is ResizingPanelSplitter
select child;
var childStars = from FrameworkElement child in visibleChildren
where (!(child is ResizingPanelSplitter)) && child.IsStar()
select child;
var childAbsolutes = from FrameworkElement child in visibleChildren
where (!(child is ResizingPanelSplitter)) && child.IsAbsolute()
select child;
var childAutoSizes = from FrameworkElement child in visibleChildren
where (!(child is ResizingPanelSplitter)) && child.IsAuto()
select child;
//calculate the size of the splitters
Size splitterSize = new Size();
foreach (ResizingPanelSplitter splitter in splitters)
{
splitterSize.Width += splitter.MinWidth;
splitterSize.Height += splitter.MinHeight;
}
Size minimumSize = new Size(splitterSize.Width, splitterSize.Height);
foreach (FrameworkElement child in childStars)
{
minimumSize.Width += child.MinWidth;
minimumSize.Height += child.MinHeight;
}
foreach (FrameworkElement child in childAbsolutes)
{
minimumSize.Width += child.MinWidth;
minimumSize.Height += child.MinHeight;
}
foreach (FrameworkElement child in childAutoSizes)
{
minimumSize.Width += child.MinWidth;
minimumSize.Height += child.MinHeight;
}
//.........这里部分代码省略.........
示例13: HtmlDocSourceChanged
static void HtmlDocSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var current = sender as RichTextBoxFromHtml;
if (current == null)
return; // throw exception
HtmlDocument doc = e.NewValue as HtmlDocument;
if (doc == null)
return;
Brush linkForeGround = Application.Current.Resources["DefaultGreenBrush"] as Brush;
Brush linkMouseOverForeGround = Application.Current.Resources["DefaultBlueBrush"] as Brush;
var p = new List<Inline>();
foreach (var item in doc.DocumentNode.ChildNodes)
{
var r = new Run();
switch (item.NodeType)
{
case HtmlNodeType.Comment:
throw new NotImplementedException();
case HtmlNodeType.Document:
throw new NotImplementedException();
case HtmlNodeType.Element:
if (item.Name == "br")
{
if (p.Count == 0 || p.Last().GetType() != typeof(LineBreak))
p.Add(new LineBreak());
continue;
}
else if (item.Name == "blockquote")
{
// TODO: iterate into the element for one more level
r.Foreground = current.SubtleForeground;
r.Text = item.InnerText;
}
else if (item.Name == "img")
{
if (Microsoft.Phone.Info.DeviceStatus.DeviceTotalMemory / 1048576 < 256)
{
r.Foreground = current.Foreground;
r.Text = item.GetAttributeValue("src", "<有图片>");
}
else
{
Image MyImage = new Image();
var _imgsrc = new BitmapImage();
_imgsrc.CreateOptions = BitmapCreateOptions.BackgroundCreation | BitmapCreateOptions.DelayCreation;
_imgsrc.UriSource = new Uri(item.Attributes["src"].Value, UriKind.Absolute);
_imgsrc.ImageFailed += (ss, ee) =>
{
WebClient wc = new WebClient();
wc.Headers["Referer"] = "http://www.guokr.com";
wc.OpenReadCompleted += (s, eee) =>
{
try
{
_imgsrc.SetSource(eee.Result);
}
catch
{
}
};
wc.OpenReadAsync(_imgsrc.UriSource);
};
MyImage.Source = _imgsrc;
InlineUIContainer MyUI = new InlineUIContainer();
MyImage.HorizontalAlignment = HorizontalAlignment.Left;
MyImage.MaxWidth = 300;
MyUI.Child = MyImage;
p.Add(MyUI);
continue;
}
}
else if (item.Name == "a")
{
var h = new Hyperlink();
h.Foreground = linkForeGround;
h.TextDecorations = null;
h.MouseOverForeground = linkMouseOverForeGround;
h.MouseOverTextDecorations = null;
h.Inlines.Add(HtmlEntity.DeEntitize(item.InnerText));
if (item.Attributes.Contains("href"))
{
string url = item.Attributes["href"].Value;
h.Click += (ss, ee) =>
{
var t = new WebBrowserTask();
t.Uri = new Uri(url, UriKind.Absolute);
t.Show();
};
}
p.Add(h);
continue;
}
else if (item.Name == "b")
{
r.FontWeight = FontWeights.Bold;
r.Foreground = current.Foreground;
r.Text = HtmlEntity.DeEntitize(item.InnerText);
//.........这里部分代码省略.........
示例14: UpdatePage
private void UpdatePage(DateTime date)
{
try
{
var ValuesList = new List<DateValues>();
VentsTools.currentActionString = "Подключаюсь к Базе данных";
_fndHwnd = GetCurrentThreadId();
//запустим таймер с задержкой в 1с для отображения прогрессбара (бесячий кругалек, когда все зависло)
ProgressBarPerform = new KeyValuePair<bool, int>(true, 1000);
string ventName = (string)Dispatcher.Invoke(new Func<string>(() => (VentsListBox.SelectedItem as Vents).name)); // возвращает название выбранного вентилятора
bool RDVres = _vt.ReadDayValuesFromDB(VentsConst.connectionString, VentsConst._DATAtb, ventName, date, ref ValuesList);
if (!RDVres)
throw new Exception(String.Format("Не удалось получить ежедневные данные для {0} за {1}", (string)Dispatcher.Invoke(new Func<string>(delegate { return (VentsListBox.SelectedItem as Vents).descr; })), (string)Dispatcher.Invoke(new Func<string>(delegate { return (string)dateP.DisplayDate.ToString(); }))));
//разобьем список на несколько по VentsConst._VALUE_ROWS_HOURTABLE итемов в каждом
var parts = ValuesList.DivideByLenght(VentsConst._VALUE_ROWS_DAYTABLE);
double cellWidth = (double)Dispatcher.Invoke(new Func<double>(() => workGrid.Width / VentsConst._MAXIMUM_COLUMNS_DAYTABLE));
double cellHeight = (double)Dispatcher.Invoke(new Func<double>(() => workGrid.Height / VentsConst._MAXIMUM_ROWS_DAYTABLE));
Dispatcher.Invoke(new Action(delegate { BuildDayTable(parts, cellWidth, cellHeight); })); //построим таблицу
#region autogenerated datagrid
//Dispatcher.Invoke(new Action(delegate
//{
// workGrid.Children.Clear();
// for (int i = 0; i < 3;i++ )
// {
// List<DateValues> listDV = parts[i];
// DataGrid dataGrid = new DataGrid();
// dataGrid.AutoGenerateColumns = true;
// dataGrid.MaxHeight = 380;
// //dataGrid.MaxWidth = 140;
// dataGrid.Width = 156;
// dataGrid.MaxWidth = 156;
// dataGrid.Margin = new Thickness(200 + dataGrid.Width * i, 59, 0, 0);
// dataGrid.RowHeight = 30;
// dataGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
// dataGrid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
// dataGrid.CanUserAddRows = false;
// dataGrid.CanUserDeleteRows = false;
// dataGrid.CanUserReorderColumns = false;
// dataGrid.CanUserResizeColumns = false;
// dataGrid.CanUserResizeRows = false;
// dataGrid.CanUserSortColumns = false;
// dataGrid.IsReadOnly = true;
// dataGrid.IsHitTestVisible = false;
// dataGrid.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
// dataGrid.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
// // dataGrid.HorizontalGridLinesBrush = new SolidColorBrush(Color.FromRgb(255,255,255));
// dataGrid.ItemsSource = listDV;
// dataGrid.AutoGeneratingColumn += new EventHandler<DataGridAutoGeneratingColumnEventArgs>(OnAutoGeneratingColumn);
// // var trtr = dataGrid.ColumnWidth;
// workGrid.Children.Add(dataGrid);
// }
//}));
#endregion
//calculate monthly electric power expense
int monthlyExpense = 0;
if (date != _firstMonth)
{
bool daylyRes = _vt.ReadMonthlyExpenseFromDB(VentsConst.connectionString, VentsConst._DATAtb, ventName, date, ref monthlyExpense);
if (!daylyRes)
{
throw new Exception(String.Format("Не удалось получить данные для месячного расхода {0} за {1}", (string)Dispatcher.Invoke(new Func<string>(delegate { return (VentsListBox.SelectedItem as Vents).descr; })), (string)Dispatcher.Invoke(new Func<string>(delegate { return (string)dateP.DisplayDate.ToString(); }))));
}
}
else
{
monthlyExpense = ValuesList.Last<DateValues>().value - ValuesList.First<DateValues>().value;
}
monthlyExpense = monthlyExpense * 100;
Dispatcher.Invoke(new Action(delegate { totaltb.Text = String.Format("Расход {0} за {1} равен {2} кВтч", (VentsListBox.SelectedItem as Vents).descr, date.GetDateTimeFormats('O')[0].Substring(0, 8), monthlyExpense.ToString()); }));
//generate current action string and update content of main window textbox
string descr = (string)Dispatcher.Invoke(new Func<string>(delegate { return (VentsListBox.SelectedItem as Vents).descr; }));
VentsTools.currentActionString = String.Format("Показания за {0} {1}", date.Date.GetDateTimeFormats('D', CultureInfo.CreateSpecificCulture("ru-ru"))[0], descr);
ProgressBarPerform = new KeyValuePair<bool, int>(false, 1000);
_fndHwnd = IntPtr.Zero;
}
catch (Exception ex)
{
VentsTools.currentActionString = "Не удалось подключиться к базе данных";
_log.Error(ex.Message);
ProgressBarPerform = new KeyValuePair<bool, int>(false, 1000);
_fndHwnd = IntPtr.Zero;
}
}
示例15: SSLStrip_OnSSLStripped
// SSL stripped
private void SSLStrip_OnSSLStripped(string sourceIP, string destIP, List<string> changed)
{
Window.Dispatcher.BeginInvoke(new UI(delegate
{
// construct "changes"
var changedText = string.Empty;
foreach(var change in changed)
{
if(change != changed.Last())
{
changedText += change + ", ";
} else {
changedText += change;
}
}
var text = string.Empty;
// build whole output string
if (sourceIP != string.Empty)
{
text = "Stripped: »" + changedText + "« (" + sourceIP + " -> " + destIP + ")";
} else
{
text = "Information: »" + changedText + "«";
}
var resultText = new Run(text);
resultText.Foreground = new SolidColorBrush(Window.ColorSSLStrip);
var thickness = new Thickness(0, 0, 0, 5);
var paragraph = new Paragraph(resultText);
paragraph.Margin = thickness;
// don't repeat the same entries
if (lastSSLText != text)
{
lastSSLText = text;
if(Window.TSSLText.Document.Blocks.Count > 0) {
Window.TSSLText.Document.Blocks.InsertBefore(Window.TSSLText.Document.Blocks.First(), paragraph);
} else {
Window.TSSLText.Document.Blocks.Add(paragraph);
}
}
}));
}