当前位置: 首页>>代码示例>>C#>>正文


C# List.Max方法代码示例

本文整理汇总了C#中System.Windows.Documents.List.Max方法的典型用法代码示例。如果您正苦于以下问题:C# List.Max方法的具体用法?C# List.Max怎么用?C# List.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.List的用法示例。


在下文中一共展示了List.Max方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPlotSeries

 private void AddPlotSeries(List<Tuple<List<Tuple<double, double>>, double>> ansv, double stepX, double stepY)
 {
     _stepX = stepX;
     _stepY = stepY;
     if (!_firstLoaded)
     {
         DrawGrid(ansv.Min(item => item.Item1.Min(it => it.Item1)), ansv.Max(item => item.Item1.Max(it => it.Item1)), stepX,
             ansv.Min(item => item.Item1.Min(it => it.Item2)), ansv.Max(item => item.Item1.Max(it => it.Item2)), stepY);
         PopulateSlider(ansv.Min(it => it.Item2), ansv.Max(it => it.Item2),
             (from a in ansv from b in ansv let d = Math.Abs(a.Item2 - b.Item2) where a.Item1 != b.Item1 select d).Min());
     }
     _XandYandParam.Add(ansv);
     Redraw();
 }
开发者ID:xnastia,项目名称:ConsoleAMPVicsek,代码行数:14,代码来源:ManipulativeMultiPlot.xaml.cs

示例2: btnAddBranch_Click

 private void btnAddBranch_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(txtStreet.Text)
         || String.IsNullOrEmpty(txtCity.Text)
         || String.IsNullOrEmpty(txtState.Text)
         || String.IsNullOrEmpty(txtZip.Text)
         || String.IsNullOrEmpty(cbManagerIds.Text))
     {
         MessageBox.Show("Must provide full address and select a manager Id", "Input Error",
             MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         using(var connection = DatabaseService.GetAccessConnection())
         {
             string commandString = String.Format(DatabaseService.Queries["InsertNewBranch"]
                 ,"'" + txtStreet.Text + "'"
                 , "'" + txtCity.Text + "'"
                 , "'" + txtState.Text + "'"
                 , "'" + txtZip.Text + "'"
                 , "'" + cbManagerIds.Text + "'");
             connection.Open();
             OleDbCommand cmd = new OleDbCommand(commandString, 
                 connection);
             cmd.ExecuteNonQuery();
             connection.Close();
     }
         List<int> currentBranchIds = new List<int>();
         DataTable branchNumberDT = DatabaseService.GetDataTable("GetBranchNumbers");
         foreach (DataRow row in branchNumberDT.Rows)
         {
             currentBranchIds.Add(int.Parse(row["BranchNumber"].ToString()));
         }
         int newestBranch = currentBranchIds.Max();
         if (!String.IsNullOrEmpty(txtPhone1.Text))
         {
             addPhoneNumber(txtPhone1.Text, newestBranch);
             txtPhone1.Text = "";
         }
         if (!String.IsNullOrEmpty(txtPhone2.Text))
         {
             addPhoneNumber(txtPhone2.Text, newestBranch);
             txtPhone2.Text = "";
         }
         if (!String.IsNullOrEmpty(txtPhone3.Text))
         {
             addPhoneNumber(txtPhone3.Text, newestBranch);
             txtPhone3.Text = "";
         }
         MessageBox.Show("Branch successfully added.", "Branch Added");
         txtStreet.Text = "";
         txtCity.Text = "";
         txtState.Text = "";
         txtZip.Text = "";
         cbManagerIds.SelectedIndex = -1;
     }
 }
开发者ID:RupertTheSlim,项目名称:Programming,代码行数:57,代码来源:BranchEntry.xaml.cs

示例3: CellsToArray

 private int[,] CellsToArray(List<List<Cell>> cells)
 {
     var result = new int[cells.Count(), cells.Max(cellsRow => cellsRow.Count())];
     for (int x = 0; x < cells.Count(); ++x)
     {
         for (int y = 0; y < cells[x].Count(); ++y)
         {
             result[x, y] = cells[x][y].Value;
         }
     }
     return result;
 }
开发者ID:DormantDreams,项目名称:video-game-level-scanner,代码行数:12,代码来源:PreviewImagesWindow.xaml.cs

示例4: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            int highestPrice = 65;
            List<int> vals = new List<int>() { 10, 20, 30, 40, 50 };
            int min = vals.Min();
            int max = vals.Max();
            max = highestPrice > max ? highestPrice : max;
            double range = max - min;

            // Draw max in red
            Color c = new Color() { ScA = 1, ScR = 1, ScG = 0, ScB = 0 };
            // y = 0 is at the top of the canvas
            var line = new Line() { X1 = 0, Y1 = 0, X2 = canvas.Width, Y2 = 0, Stroke = new SolidColorBrush(c), StrokeThickness = 2.0 };
            canvas.Children.Add(line);
            // Add txt so we can visualize better
            var txt = new TextBlock() { Text = max.ToString() };
            Canvas.SetLeft(txt, canvas.Width / 2);
            Canvas.SetTop(txt, 0 - 9);
            canvas.Children.Add(txt);

            foreach (int val in vals)
            {
                double percent = 1.0 - ((val - min) / range); // 0 is at the top, so invert it by doing 1.0 - xxx
                double y = percent * canvas.Height;
                // Draw line in a shade of blue/green
                c = new Color() { ScA = 1, ScR = 0, ScG = 0.5f, ScB = (float)percent };
                line = new Line() { X1 = 0, Y1 = y, X2 = canvas.Width, Y2 = y, Stroke = new SolidColorBrush(c), StrokeThickness = 2.0 };
                canvas.Children.Add(line);

                // Add txt so we can visualize better
                txt = new TextBlock() { Text = val.ToString() };
                Canvas.SetLeft(txt, canvas.Width / 2);
                Canvas.SetTop(txt, y - 9);
                canvas.Children.Add(txt);
            }
        }
开发者ID:AdamMartell,项目名称:Projects,代码行数:38,代码来源:MainWindow.xaml.cs

示例5: btn_simulate_Click

        private void btn_simulate_Click(object sender, RoutedEventArgs e)
        {
            int nbrSim = Convert.ToInt32(txt_nbrsim.Text);
            double initWealth = Properties.Settings.Default.InitWealth;

            List<double> finalEarnings = new List<double>();
            List<int> counts = new List<int>();

            for (int i = 0; i < nbrSim; i++)
            {
                MartStrategy MStrat = new MartStrategy(5, 250, initWealth);
                double bid = MStrat.Bet();
                Number res;
                double payoff;
                int count = 0;
                while (bid <= MStrat.Wealth)
                {
                    MStrat.PlaceBet(bid);
                    res = _RGame.Play();
                    payoff = _RGame.GetPayoffColor(NumberColor.Red, bid, res);
                    MStrat.Setup(payoff);
                    bid = MStrat.Bet();
                    count++;
                }
                finalEarnings.Add(MStrat.Earnings-initWealth);
                counts.Add(count);
            }

            txt_earnings.Text = finalEarnings.Average().ToString();
            txt_plays.Text = counts.Average().ToString();
            txt_maxEarnings.Text = finalEarnings.Max().ToString();
            txt_maxLosses.Text = finalEarnings.Min().ToString();
            txt_totEarnings.Text = finalEarnings.Where(x => x > 0).Sum().ToString();
            txt_totLosses.Text = finalEarnings.Where(x => x < 0).Sum().ToString();
            txt_balance.Text = finalEarnings.Sum().ToString();
        }
开发者ID:SRKX,项目名称:casino-martingale,代码行数:36,代码来源:AutoSim.xaml.cs

示例6: Timer_Tick

        //初始化指数和、指数积、奖金的方法
        void Timer_Tick(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            string[] ZhuArr = null;
            string ButtonContext = string.Empty;
            int i = 0;

            double SumMinOdds = 0.00;//指数和 最小
            double SumMaxOdds = 0.00;//指数和 最大

            double ProductMinOdds = 1.00;//指数积 最小
            double ProductMaxOdds = 1.00;//指数积 最大

            List<double> DoubleList = new List<double>();

            var selfcols = this.DataGrid1.Columns[0];

            foreach (var item in DataGrid1.ItemsSource)
            {
                //--对象所在的单元格
                var cells = selfcols.GetCellContent(item);
                if (cells != null)
                {
                    //--单元格所包含的元素
                    Grid grid = cells as Grid;

                    StackPanel Sp = grid.Children[0] as StackPanel;

                    StackPanel Sp1 = Sp.Children[1] as StackPanel;

                    ZhuArr = GameNumber[i].Substring(GameNumber[i].IndexOf('(') + 1, GameNumber[i].LastIndexOf(')') - GameNumber[i].IndexOf('(') - 1).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string s in ZhuArr)
                    {
                        Button b = ReturnShowNum(Sp1.Children[0] as StackPanel, s);

                        if (b == null)
                        {
                            b = ReturnShowNum(Sp1.Children[1] as StackPanel, s);
                            if (b == null)
                            {
                                b = ReturnShowNum(Sp1.Children[2] as StackPanel, s);
                            }
                        }

                        if (b != null)
                        {
                            b.Background = new SolidColorBrush(Colors.Red);//改变按钮颜色

                            DoubleList.Add(Netball.RetuntDouble(ToolTipService.GetToolTip(b).ToString()));
                        }
                    }

                    SumMinOdds += DoubleList.Min();
                    SumMaxOdds += DoubleList.Max();

                    ProductMinOdds *= DoubleList.Min();
                    ProductMaxOdds *= DoubleList.Max();
                }

                i++;
                DoubleList.Clear();

            }

            this.tbSum.Text = string.Format("{0:f2}", SumMinOdds) + "~" + string.Format("{0:f2}", SumMaxOdds);
            this.tbProduct.Text = string.Format("{0:f2}", ProductMinOdds) + "~" + string.Format("{0:f2}", ProductMaxOdds);
            this.tbPremium.Text = string.Format("{0:f2}", ProductMinOdds * 2) + "~" + string.Format("{0:f2}", ProductMaxOdds * 2);


            Timer.Stop();
        }
开发者ID:ichari,项目名称:ichari,代码行数:73,代码来源:BF.xaml.cs

示例7: PruneAutosavesSprtGetDeletes

        private static int[] PruneAutosavesSprtGetDeletes(List<int>[] deletableSets, int numToDelete)
        {
            if (deletableSets.Sum(o => o.Count) == numToDelete)
            {
                // Everything in deletable sets needs to be deleted, so just return them all instead of taking the expense of load balancing
                return deletableSets.SelectMany(o => o).ToArray();
            }

            List<int> retVal = new List<int>();

            for (int cntr = 0; cntr < numToDelete; cntr++)
            {
                // Get the largest sets
                int maxSize = deletableSets.Max(o => o.Count);
                List<int>[] largest = deletableSets.Where(o => o.Count == maxSize).ToArray();

                // Pick a random set, and a random index within that set
                int setIndex = StaticRandom.Next(largest.Length);
                int innerIndex = StaticRandom.Next(largest[setIndex].Count);

                // Store the value pointed to
                retVal.Add(largest[setIndex][innerIndex]);

                // Now remove this from the set
                largest[setIndex].RemoveAt(innerIndex);
            }

            return retVal.ToArray();
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:29,代码来源:PanelFile.xaml.cs

示例8: GetMaxCompanyDocNum

        private string GetMaxCompanyDocNum(List<V_CompanyDocNum> listnums)
        {
            string StrResult = "";
            string StrYear = "";
            List<int> list = new List<int>();
            listnums.ForEach(item =>
            {
                list.Add(GetCompanyNums(item.NUM));
            });
            StrResult = list.Max().ToString();
            StrYear = StrResult.Substring(0, 4);//获取年份
            StrResult = StrResult.Substring(4, StrResult.Length - 4);//取后面的数字
            var ents = from ent in listnums
                       where ent.NUM !=null && ent.NUM.Contains(StrResult)
                       select ent;
            if (ents.Count() > 0)
            {
                string StrMax = ents.FirstOrDefault().NUM;
                StrResult = StrMax.Replace(StrResult, (System.Convert.ToInt32(StrResult) + 1).ToString());


            }
            return StrResult;

        }
开发者ID:JuRogn,项目名称:OA,代码行数:25,代码来源:AddDistrbuteForm.xaml.cs

示例9: cardView_OnDragging

        void cardView_OnDragging(object sender, EventArgs e)
        {
            lock (cardArrangeLock)
            {
                // First, find the two stacks that the card is hovering above.
                var relevantStacks = new List<CardStack>();
                var yOverlap = new List<double>();
                CardStack resultDeckStack = null;
                double maxOverlap = 0;
                double resultOverlap = 0;

                foreach (var stack in _allCardStacks)
                {
                    Rect rect = stack.BoundingBox;
                    rect.Intersect(new Rect(InteractingCard.Position, new Size(InteractingCard.Width, InteractingCard.Height)));
                    if (rect.Size.Height > 0)
                    {
                        if (stack.Parent != _resultPanel)
                        {
                            relevantStacks.Add(stack);
                            yOverlap.Add(rect.Size.Height);
                        }
                        else if (rect.Size.Width > maxOverlap)
                        {
                            resultDeckStack = stack;
                            maxOverlap = rect.Size.Width;
                            resultOverlap = rect.Size.Height;
                        }
                    }
                }

                if (resultDeckStack != null)
                {
                    relevantStacks.Add(resultDeckStack);
                    yOverlap.Add(resultOverlap);
                }
                Trace.Assert(relevantStacks.Count <= 2 && yOverlap.Count == relevantStacks.Count);

                // Second, set the interacting card of all card stacks accordingly
                foreach (var stack in _allCardStacks)
                {
                    CardInteraction status;
                    if (relevantStacks.Contains(stack) || stack == _sourceDeck)
                    {
                        stack.InteractingCard = InteractingCard;
                        status = CardInteraction.Drag;
                    }
                    else
                    {
                        stack.InteractingCard = null;
                        status = CardInteraction.None;
                    }
                    if (status != stack.CardStatus || status == CardInteraction.Drag)
                    {
                        stack.CardStatus = status;
                        stack.RearrangeCards();
                    }
                }

                // Finally, in the stack with greatest overlapping y-distance, highlight the slot.
                _ResetHighlightSlot();

                if (relevantStacks.Count == 0)
                {
                    _highlightedStack = null;
                }
                else
                {
                    _highlightedStack = relevantStacks[yOverlap.IndexOf(yOverlap.Max())];
                    var highlightedSlot = _stackToSlot[_highlightedStack];
                    if (highlightedSlot.Cards.Count > 0)
                    {
                        int index = Math.Min(_highlightedStack.InteractingCardIndex, highlightedSlot.Cards.Count - 1);
                        _highlightedCardSlot = highlightedSlot.Cards[index];
                        _highlightedCardSlot.CardModel.IsFaded = true;
                    }
                }
            }
        }
开发者ID:pxoylngx,项目名称:sgs,代码行数:79,代码来源:CardArrangeBox.xaml.cs

示例10: ArrangeItems

		public static void ArrangeItems(IEnumerable<DesignItem> items, ArrangeDirection arrangeDirection)
		{
			var collection = items;

			var _context = collection.First().Context as XamlDesignContext;

			var container = collection.First().Parent;

			if (collection.Any(x => x.Parent != container))
				return;

			var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
			if (placement == null)
				return;

			var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);
			
			//var changeGroup = container.OpenGroup("Arrange Elements");

			List<ItemPos> itemList = new List<ItemPos>();
			foreach (var item in collection)
			{
				itemList.Add(GetItemPos(operation, item));
			}

			var xmin = itemList.Min(x => x.Xmin);
			var xmax = itemList.Max(x => x.Xmax);
			var mpos = (xmax - xmin) / 2 + xmin;
			var ymin = itemList.Min(x => x.Ymin);
			var ymax = itemList.Max(x => x.Ymax);
			var ympos = (ymax - ymin) / 2 + ymin;

			foreach (var item in collection)
			{
				switch (arrangeDirection)
				{
					case ArrangeDirection.Left:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
								{
									item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(xmin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double) ((FrameworkElement) item.Component).ActualWidth);
									item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
								}
							}
							else if (container.Component is Grid)
							{
								if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
								{
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Left = xmin;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double)((FrameworkElement)item.Component).ActualWidth);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Right = pos;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
							}
						}
						break;
					case ArrangeDirection.HorizontalMiddle:
						{
							if (container.Component is Canvas)
							{
								if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
								{
									if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
									{
										item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(mpos - (((FrameworkElement)item.Component).ActualWidth) / 2);
									}
									else
									{
										var pp = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
										var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
										item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
									}
								}
							}
							else if (container.Component is Grid)
							{
								if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
								{
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Left = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
									item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
								}
								else
								{
									var pp = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
									var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
									var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
									margin.Right = pos;
//.........这里部分代码省略.........
开发者ID:lvv83,项目名称:SharpDevelop,代码行数:101,代码来源:ModelTools.cs

示例11: btnUploadOK_Click

        void btnUploadOK_Click(object sender, RoutedEventArgs e)
        {
            listImages.Visibility = System.Windows.Visibility.Visible;
            btnSave.IsEnabled = true;

            List<ImageItem> list = new List<ImageItem>();
            foreach (object item in listImages.Items)
            {
                list.Add((ImageItem)item);
            }

            common.Image newImage = new common.Image();
            newImage.IsChanged = true;
            newImage.FileName = txtFileName.Text;
            newImage.ImageContent = _byteArray;
            newImage.ImageSmallContent = _byteArraySmall;
            newImage.CreatedBy = newImage.UpdatedBy = Globals.UserLogin.UserName;
            newImage.DisplayIndex = list != null && list.Count > 0 ? (list.Max(i => i.ImageDataItem.DisplayIndex) + 1) : 1;
            newImage.ImageTypeId = (int) this.ImageType;
            newImage.ItemId = this.ItemId;

            ImageItem imageItem = new ImageItem(newImage);
            imageItem.btnDelete.Click += new RoutedEventHandler(btnDelete_Click);
            imageItem.btnDelete.Visibility = this.IsReadOnly ? Visibility.Collapsed : Visibility.Visible;
            listImages.Items.Add(imageItem);

            uiPopupUpload.Close();
        }
开发者ID:netthanhhung,项目名称:Medical,代码行数:28,代码来源:ImageUpload.xaml.cs

示例12: WrapItemsNewContainer

		public static void WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType)
		{
			var collection = items;
			
			var _context = collection.First().Context as XamlDesignContext;
			
			var oldContainer = collection.First().Parent;
			
			if (collection.Any(x => x.Parent != oldContainer))
				return;
			
			var newInstance = Activator.CreateInstance(containerType);
			DesignItem newPanel = _context.Services.Component.RegisterComponentForDesigner(newInstance);
			var changeGroup = newPanel.OpenGroup("Wrap in Container");
			
			List<ItemPos> itemList = new List<ItemPos>();
			
			foreach (var item in collection) {
				
				var itemPos = new ItemPos(){ DesignItem = item };
				itemList.Add(itemPos);
				
				if (oldContainer.Component is Canvas) {
					var canvas = oldContainer.View as Canvas;
					
					if (item.Properties.GetAttachedProperty(Canvas.RightProperty) != null && item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet) {
						itemPos.HorizontalAlignment = HorizontalAlignment.Right;
						itemPos.Xmax = canvas.ActualWidth - (double)item.Properties.GetAttachedProperty(Canvas.RightProperty).ValueOnInstance;
						itemPos.Xmin = itemPos.Xmax - ((FrameworkElement)item.View).ActualWidth;
					}
					else if (item.Properties.GetAttachedProperty(Canvas.LeftProperty) != null && item.Properties.GetAttachedProperty(Canvas.LeftProperty).IsSet) {
						itemPos.HorizontalAlignment = HorizontalAlignment.Left;
						itemPos.Xmin = (double)item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance;
						itemPos.Xmax = itemPos.Xmin + ((FrameworkElement)item.View).ActualWidth;
					} else {
						itemPos.HorizontalAlignment = HorizontalAlignment.Left;
						itemPos.Xmax = itemPos.Xmin + ((FrameworkElement)item.View).ActualWidth;
					}
					
					if (item.Properties.GetAttachedProperty(Canvas.BottomProperty) != null && item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet) {
						itemPos.VerticalAlignment = VerticalAlignment.Bottom;
						itemPos.Ymax = canvas.ActualHeight - (double)item.Properties.GetAttachedProperty(Canvas.BottomProperty).ValueOnInstance;
						itemPos.Ymin = itemPos.Ymax - ((FrameworkElement)item.View).ActualHeight;
					}
					else if (item.Properties.GetAttachedProperty(Canvas.TopProperty) != null && item.Properties.GetAttachedProperty(Canvas.TopProperty).IsSet) {
						itemPos.VerticalAlignment = VerticalAlignment.Top;
						itemPos.Ymin = (double)item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance;
						itemPos.Ymax = itemPos.Ymin + ((FrameworkElement)item.View).ActualHeight;
					} else {
						itemPos.VerticalAlignment = VerticalAlignment.Top;
						itemPos.Ymax = itemPos.Ymin + ((FrameworkElement)item.View).ActualHeight;
					}
					
					item.Properties.GetAttachedProperty(Canvas.RightProperty).Reset();
					item.Properties.GetAttachedProperty(Canvas.LeftProperty).Reset();
					item.Properties.GetAttachedProperty(Canvas.TopProperty).Reset();
					item.Properties.GetAttachedProperty(Canvas.BottomProperty).Reset();
				} else if (oldContainer.Component is Grid) {
					var grid = oldContainer.View as Grid;
					
					if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance == HorizontalAlignment.Right) {
						itemPos.HorizontalAlignment = HorizontalAlignment.Right;
						itemPos.Xmax = grid.ActualWidth - ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Right;
						itemPos.Xmin = itemPos.Xmax - ((FrameworkElement)item.View).ActualWidth;
					} else {
						itemPos.HorizontalAlignment = HorizontalAlignment.Left;
						itemPos.Xmin = ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Left;
						itemPos.Xmax = itemPos.Xmin + ((FrameworkElement)item.View).ActualWidth;
					}
					
					if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance == VerticalAlignment.Bottom) {
						itemPos.VerticalAlignment = VerticalAlignment.Bottom;
						itemPos.Ymax = grid.ActualHeight - ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Bottom;
						itemPos.Ymin = itemPos.Ymax - ((FrameworkElement)item.View).ActualHeight;
					} else {
						itemPos.VerticalAlignment = VerticalAlignment.Top;
						itemPos.Ymin = ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Top;
						itemPos.Ymax = itemPos.Ymin + ((FrameworkElement)item.View).ActualHeight;
					}
					
					item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).Reset();
					item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).Reset();
					item.Properties.GetProperty(FrameworkElement.MarginProperty).Reset();
				}
				
				var parCol = item.ParentProperty.CollectionElements;
				parCol.Remove(item);
			}
			
			var xmin = itemList.Min(x => x.Xmin);
			var xmax = itemList.Max(x => x.Xmax);
			var ymin = itemList.Min(x => x.Ymin);
			var ymax = itemList.Max(x => x.Ymax);
			
			if (oldContainer.Component is Canvas) {
				newPanel.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(xmax - xmin);
				newPanel.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(ymax - ymin);
				newPanel.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(xmin);
				newPanel.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
			} else if (oldContainer.Component is Grid) {
//.........这里部分代码省略.........
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:101,代码来源:ModelTools.cs

示例13: buttonScalingScore_Click

        private void buttonScalingScore_Click(object sender, RoutedEventArgs e)
        {
            int cols, rows;
            double horizLength, vertLength;
            if (!parseChessboardParameters(out cols, out rows, out horizLength, out vertLength))
            {
                return;
            }

            // 以下改造
            MotionDataHandler handler;
            string path;
            if (openMotionData(out handler, out path))
            {
                CvMat displayMat1 = null;
                CvMat displayMat3 = null;
                CvMat displayMat4 = null;
                CvMat gray = null;

                int length = handler.FrameCount;
                if (length == 0) { return; }

                CvSize boardSize = new CvSize(cols, rows);
                CvSize imageSize = new CvSize();
                List<Tuple<double, double>> pairs = new List<Tuple<double, double>>();
                CvPoint2D32f[] lastCorners = null;

                IEnumerable<CvMat> colorImages, depthImages;
                Utility.LoadImages(handler.GetColorImagePaths(), out colorImages);
                Utility.LoadImages(handler.GetDepthImagePaths(), out depthImages);
                var images = colorImages.Zip(depthImages, (first, second) => Tuple.Create(first, second));

                foreach (Tuple<CvMat, CvMat> imagePair in images)
                {
                    CvMat imageMat = imagePair.Item1;
                    CvMat depthMat = imagePair.Item2;
                    
                    if (displayMat4 == null)
                    {
                        displayMat4 = CvEx.InitCvMat(imageMat);
                    }

                    imageSize = new CvSize(imageMat.Cols, imageMat.Rows);
                    CvPoint2D32f[] corners;
                    int count;
                    CvEx.InitCvMat(ref gray, imageMat, MatrixType.U8C1);
                    imageMat.CvtColor(gray, ColorConversion.RgbToGray);
                    if (gray.FindChessboardCorners(boardSize, out corners, out count, ChessboardFlag.AdaptiveThresh))
                    {
                        CvEx.CloneCvMat(ref displayMat1, imageMat);
                        CvTermCriteria criteria = new CvTermCriteria(50, 0.01);
                        gray.FindCornerSubPix(corners, count, new CvSize(3, 3), new CvSize(-1, -1), criteria);
                        CvPoint3D32f?[] cornerPoints = new CvPoint3D32f?[corners.Length];
                        for (int j = 0; j < corners.Length; j++)
                        {
                            CvPoint2D32f corner = corners[j];
                            double? value = CalcEx.BilateralFilterDepthMatSinglePixel(corner, depthMat, 100, 4, 9);
                            if (value.HasValue)
                            {
                                cornerPoints[j] = new CvPoint3D32f(corner.X, corner.Y, value.Value);
                            }
                        }
                        for (int x = 0; x < cols; x++)
                        {
                            for (int y = 0; y < rows; y++)
                            {
                                if (!cornerPoints[x + y * cols].HasValue)
                                    continue;
                                CvPoint3D32f point1 = cornerPoints[x + y * cols].Value;
                                CvPoint3D64f undistortPoint1 = this.UndistortionData.GetRealFromScreenPos(point1, imageSize);
                                foreach (var offset in new[] { new { X = 1, Y = 0, D = horizLength }, new { X = 0, Y = 1, D = vertLength } })
                                {
                                    int dx = x + offset.X;
                                    int dy = y + offset.Y;
                                    if (dx >= cols || dy >= rows)
                                        continue;
                                    if (!cornerPoints[dx + dy * cols].HasValue)
                                        continue;

                                    CvPoint3D32f point2 = cornerPoints[dx + dy * cols].Value;
                                    CvPoint3D64f undistortPoint2 = this.UndistortionData.GetRealFromScreenPos(point2, imageSize);
                                    double distance = Math.Sqrt(CvEx.GetDistanceSq(undistortPoint1, undistortPoint2));
                                    double scale = distance / offset.D;
                                    CvColor color = CalcEx.HSVtoRGB(Math.Max(0, Math.Min(300, scale * 600 - 450)), scale, 2 - scale);
                                    displayMat4.DrawLine((int)point1.X, (int)point1.Y, (int)point2.X, (int)point2.Y, new CvScalar(color.R, color.G, color.B), 1, LineType.AntiAlias);
                                    pairs.Add(new Tuple<double, double>(distance, offset.D));
                                }
                            }
                        }
                        CvEx.DrawChessboardCornerFrame(displayMat1, boardSize, corners, new CvScalar(64, 128, 64));
                        displayMat1.DrawChessboardCorners(boardSize, corners, true);
                        lastCorners = corners;
                        putImage(displayMat1, PixelFormats.Rgb24);
                    }
                    else
                    {
                        CvEx.CloneCvMat(ref displayMat3, imageMat);
                        putImage(displayMat3, PixelFormats.Rgb24);
                    }
                }
//.........这里部分代码省略.........
开发者ID:guozanhua,项目名称:KinectMotionCapture,代码行数:101,代码来源:CameraUndistortWindow.xaml.cs

示例14: GenerateSeriesPath

        private Path GenerateSeriesPath(List<Tuple<double, double>> ansv)
        {
            var myPath = new Path
            {
                Height = MyCanvas.Height,
                Width = MyCanvas.Width,
                Stroke = Brushes.Black,
                StrokeThickness = 3
            };

            myPath.MouseLeftButtonUp += (sender, args) =>
            {
                if (Equals((sender as Path).Stroke, Brushes.Black))
                {
                    (sender as Path).Stroke = Brushes.Red;
                    MyActiveLabel.Content = _seriesComments[MyCanvas.Children.IndexOf(sender as Path) - 5];
                }
                else
                {
                    (sender as Path).Stroke = Brushes.Black;
                    MyActiveLabel.Content = "Select plot for further info";
                }
            };

            if (ansv == null) return myPath;
            var segment = new PolyLineSegment();
            double scaleY = MyCanvas.Height / ansv.Max(item => item.Item2);
            double scaleX = MyCanvas.Width / ansv.Max(item => item.Item1);
            for (int i = ansv.Count - 1; i >= 0; i--)
            {
                segment.Points.Add(new Point(ansv[i].Item1 * scaleX, MyCanvas.Height - ansv[i].Item2 * scaleY));
            }
            var fig = new PathFigure();
            fig.Segments.Add(segment);
            fig.StartPoint = segment.Points.First();
            var geom = new PathGeometry();
            geom.Figures.Add(fig);
            myPath.Data = geom;
            return myPath;
        }
开发者ID:xnastia,项目名称:ConsoleAMPVicsek,代码行数:40,代码来源:ManipulativeMultiPlot.xaml.cs

示例15: SetSlider

        private void SetSlider(RegionValueCollection regionValCol)
        {
            SliderGrd.Visibility = System.Windows.Visibility.Visible;
            ClearSlider();
            if (regionValCol == null || regionValCol.Count == 0)
                return;
            if (_isShare)
                PageSlider.IsEnabled = true;
            else
                PageSlider.IsEnabled = false;

            SetUnitLabel(regionValCol.Product, _isValue);
            SetCategoryNameLabel((regionValCol.Polygons == Polygons.Provinces) ? SanofiRegionTypes.Province : SanofiRegionTypes.Tehran);

            List<double> qtys = new List<double>();
            foreach (RegionData rv in regionValCol)
                qtys.Add(rv.Get(_isValue));
            double maximum = qtys.Max();

            double secondMaximum = 0;
            _totalRegionsValue = 0;
            foreach (double i in qtys)
            {
                _totalRegionsValue += i;
                if (i < maximum && i > secondMaximum)
                    secondMaximum = i;
            }
            PageSlider.Maximum = secondMaximum;
            PageSlider.Value = secondMaximum;
            _currentMaxRegionValue = secondMaximum;

            List<double> translateTransforms = new List<double>();
            foreach (RegionData rv in regionValCol)
            {
                if (rv.Get(_isValue) == maximum)
                {
                    SetMaximumText(rv);
                    continue;
                }
                translateTransforms = AddLabelToSlider(rv, translateTransforms);
            }
        }
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:42,代码来源:MainPage.xaml.cs


注:本文中的System.Windows.Documents.List.Max方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。