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


C# Label.UpdateLayout方法代码示例

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


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

示例1: DrawValueRulers

        void DrawValueRulers()
        {
            GridRulersCanvas.Children.Clear();

            var valueRulerStep = _settings.ValueRulerStep;
            for (var cur = -Math.Floor(_settings.MinValue / valueRulerStep) * valueRulerStep;
                cur <= _settings.MaxValue; cur += valueRulerStep)
            {
                var height = (GraphBackground.ActualHeight - 1) * _settings.GetAdjustedValue(cur);

                var line = new Line
                {
                    X1 = 0,
                    X2 = GraphBackground.ActualWidth,
                    Y1 = height,
                    Y2 = height,
                    Stroke = Brushes.DarkGray
                };
                GridRulersCanvas.Children.Add(line);

                var labelText = string.Format("{0}%", Math.Round(cur*100, 2));
                var label = new Label {Content = labelText, Foreground = Brushes.Black};
                GridRulersCanvas.Children.Add(label);

                label.UpdateLayout();
                if (height > GraphBackground.ActualHeight - label.ActualHeight)
                    height -= label.ActualHeight;

                Canvas.SetTop(label, height);
                Canvas.SetRight(label, 0);
            }
        }
开发者ID:fandrei,项目名称:CityIndexScreensaver,代码行数:32,代码来源:GraphControl.xaml.cs

示例2: CreateFieldDefinitions

		private double CreateFieldDefinitions (Grid ButtonGrid)
			{
			GridLengthConverter GLConverter = new GridLengthConverter ();
			ThicknessConverter TConverter = new ThicknessConverter ();
			BrushConverter BConverter = new BrushConverter ();
			int RowIndex = 0;
			int NumberOfAllLines = 0;
			double LineHeight = -1;
			foreach (DataColumn Column in m_RowToProcess.Table.Columns)
				{
				if (Column.ColumnName == UserData.m_PrimaryKeyName)
					continue;
				int NumberOfLines = GetNumberOfLines (Column);
				Label ColumnLabel = new Label ();
				ButtonGrid.Children.Add (ColumnLabel);
				Grid.SetColumn (ColumnLabel, 0);
				Grid.SetRow (ColumnLabel, RowIndex);
				ColumnLabel.VerticalAlignment = VerticalAlignment.Top;
				if (String.IsNullOrEmpty (Column.Caption))
					ColumnLabel.Content = Column.ColumnName;
				else
					ColumnLabel.Content = Column.Caption;
				if (m_TableLayoutDefinition.LabelFontSize != -1)
					ColumnLabel.FontSize = m_TableLayoutDefinition.LabelFontSize;
				if (LineHeight == -1)
					{
					ColumnLabel.UpdateLayout ();
					LineHeight = ColumnLabel.DesiredSize.Height;
					}
				Border TextBlockBorder = new Border ();
				ButtonGrid.Children.Add (TextBlockBorder);
				TextBlockBorder.HorizontalAlignment = HorizontalAlignment.Stretch;
				TextBlockBorder.VerticalAlignment = VerticalAlignment.Stretch;
				Grid.SetColumn (TextBlockBorder, 1);
				Grid.SetRow (TextBlockBorder, RowIndex);
				TextBlockBorder.BorderThickness = (Thickness)TConverter.ConvertFromString ("1");
				TextBlockBorder.BorderBrush = (Brush)BConverter.ConvertFromString ("Black");
				if ((Column.DataType.ToString () == "System.String")
					|| (Column.DataType.ToString () == "System.Guid"))
					ProcessStringField (ButtonGrid, TextBlockBorder, Column,
								RowIndex, LineHeight, NumberOfLines);
				NumberOfAllLines += NumberOfLines;
				RowIndex++;
				}
			return (double)((NumberOfAllLines + 2) * LineHeight) + (NumberOfAllLines * 2);
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:46,代码来源:CommonUserInterface.xaml.cs

示例3: CreateFieldDefinitions

		private double CreateFieldDefinitions (Grid ButtonGrid)
			{
			GridLengthConverter GLConverter = new GridLengthConverter ();
			ThicknessConverter TConverter = new ThicknessConverter ();
			BrushConverter BConverter = new BrushConverter ();
			int RowIndex = 0;
			int NumberOfAllLines = 0;
			double LineHeight = -1;
			foreach (DataColumn Column in m_RowToProcess.Table.Columns)
				{
				int NumberOfLines = GetNumberOfLines (Column);
				Label ColumnLabel = new Label ();
				ButtonGrid.Children.Add (ColumnLabel);
				Grid.SetColumn (ColumnLabel, 0);
				Grid.SetRow (ColumnLabel, RowIndex);
				ColumnLabel.VerticalAlignment = VerticalAlignment.Top;
				if (String.IsNullOrEmpty (Column.Caption))
					ColumnLabel.Content = Column.ColumnName;
				else
					ColumnLabel.Content = Column.Caption;
				if (LineHeight == -1)
					{
					ColumnLabel.UpdateLayout ();
					LineHeight = ColumnLabel.DesiredSize.Height;
					}
				Border TextBlockBorder = new Border ();
				ButtonGrid.Children.Add (TextBlockBorder);
				Grid.SetColumn (TextBlockBorder, 1);
				Grid.SetRow (TextBlockBorder, RowIndex);
				TextBlockBorder.BorderThickness = (Thickness)TConverter.ConvertFromString ("1");
				TextBlockBorder.BorderBrush = (Brush)BConverter.ConvertFromString ("Black");
				TextBox ColumnText = new TextBox ();
				TextBlockBorder.Child = ColumnText;
				ColumnText.TextWrapping = TextWrapping.Wrap;
				CVM.CommonValues.SelectionDefinition SpecialFieldProcessing =
						GetSelectionDefinition (m_RowToProcess.Table.TableName, Column.ColumnName);
				if (String.IsNullOrEmpty (SpecialFieldProcessing.m_TableName))
					{
					ColumnText.Text = m_RowToProcess [Column.ColumnName].ToString ();
					Grid.SetColumnSpan (TextBlockBorder, 2);
					}
				else
					{
					if ((m_UpdateAllowed == true)
						&& (SpecialFieldProcessing.m_UpdateAble == true))
						{
						Grid.SetColumnSpan (TextBlockBorder, 1);
						Button OpenSelection = new Button ();
						OpenSelection.Content = "....";
						Grid.SetColumn (OpenSelection, 2);
						Grid.SetRow (OpenSelection, RowIndex);
						OpenSelection.IsEnabled = true;
						OpenSelection.Tag = SpecialFieldProcessing;
						OpenSelection.Click += new RoutedEventHandler (OpenSelection_Click);
						ButtonGrid.Children.Add (OpenSelection);
						}
					if (GetReadableTextForEntryCall == null)
						ColumnText.Text = "Fehler - GetReadableTextForEntryCall not defined";
					else
						ColumnText.Text = GetReadableTextForEntryCall
							(this, SpecialFieldProcessing.m_ForeignTableName, m_RowToProcess [Column.ColumnName].ToString ());
					}
				ColumnText.Height = NumberOfLines * LineHeight;

				if ((m_UpdateAllowed == true)
					&& (m_PrimaryKeyName != Column.ColumnName))
					{
					ColumnText.IsEnabled = true;
					ColumnText.Tag = Column.ColumnName;
					m_UpdateableControls.Add (ColumnText);
					}
				else
					{
					ColumnText.IsEnabled = false;
					}
				NumberOfAllLines += NumberOfLines;
				RowIndex++;
				}
			return (double) ((NumberOfAllLines + 2) * LineHeight) + (NumberOfAllLines * 2);
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:80,代码来源:SimpleDataRowWindow.xaml.cs

示例4: CutString

 /// <summary>
 /// 对字符串进行裁剪
 /// </summary>
 /// <param name="str">字符串</param>
 /// <param name="label">Label控件</param>
 /// <param name="isAlbumName">是否为专辑名称控件</param>
 private void CutString(string str, ref Label label, bool isAlbumName = false)
 {
     if(isAlbumName)
         label.Content = "<" + str + ">";
     else
         label.Content = str;
     if (label.MaxWidth - label.ActualWidth > 1)
         return;
     string tmp = str;
     for (int i = 0; i < str.Length; i++)
     {
         tmp = tmp.Substring(0, tmp.Length - 1);
         label.Content = tmp;
         label.UpdateLayout();
         if (label.MaxWidth - label.ActualWidth > 1)
         {
             if(isAlbumName)
                 label.Content = "<" + tmp.Substring(0, tmp.Length - 2) + "...>";
             else
                 label.Content = tmp.Substring(0, tmp.Length - 1) + "...";
             break;
         }
     }
 }
开发者ID:justplus,项目名称:doubanFMAPI,代码行数:30,代码来源:MainWindow.xaml.cs

示例5: CreateFieldDefinitions

        private double CreateFieldDefinitions (Grid ButtonGrid, Grid ContentGrid)
            {
            GridLengthConverter GLConverter = new GridLengthConverter ();
            ThicknessConverter TConverter = new ThicknessConverter ();
            BrushConverter BConverter = new BrushConverter ();
            RowDefinition ButtonRow = new RowDefinition ();
            ButtonRow.Height = (GridLength)GLConverter.ConvertFromString ("20");
            RowDefinition ContentRow = new RowDefinition ();
            ContentRow.Height = (GridLength)GLConverter.ConvertFromString ("*");
            RootGrid.RowDefinitions.Add (ButtonRow);
            RootGrid.RowDefinitions.Add (ContentRow);

            RootGrid.Children.Add (ButtonGrid);
            Grid.SetRow (ButtonGrid, 0);
            Grid.SetColumn (ButtonGrid, 1);

            ScrollViewer ScrollArea = new ScrollViewer ();
            RootGrid.Children.Add (ScrollArea);
            Grid.SetRow (ScrollArea, 1);
            Grid.SetColumn (ScrollArea, 0);
            Grid.SetColumnSpan (ScrollArea, 3);
            ScrollArea.Content = ContentGrid;

            int RowIndex = 0;
            int NumberOfAllLines = 0;
            double LineHeight = -1;
            WMB.TableContentDefinition SpecialFieldProcessing;
            foreach (DataColumn Column in m_RowToProcess.Table.Columns)
                {
                if (IsSkipingColumns (Column.ColumnName))
                    continue;
                SpecialFieldProcessing = DataBase.GetColumnDefinition 
                    (m_RowToProcess.Table.TableName, Column.ColumnName, true);
                Label ColumnLabel = new Label ();
                ColumnLabel.FontSize *= 1.3;
                if (!String.IsNullOrEmpty (SpecialFieldProcessing.m_ToolTip))
                    ColumnLabel.ToolTip = SpecialFieldProcessing.m_ToolTip;
                ContentGrid.Children.Add (ColumnLabel);
                Grid.SetColumn (ColumnLabel, 0);
                Grid.SetRow (ColumnLabel, RowIndex);
                ColumnLabel.VerticalAlignment = VerticalAlignment.Top;
                if (!String.IsNullOrEmpty (SpecialFieldProcessing.m_ReadableName))
                    Column.Caption = SpecialFieldProcessing.m_ReadableName;
                if (String.IsNullOrEmpty (Column.Caption))
                    ColumnLabel.Content = Column.ColumnName;
                else
                    ColumnLabel.Content = Column.Caption;
                if (LineHeight == -1)
                    {
                    ColumnLabel.UpdateLayout ();
                    LineHeight = ColumnLabel.DesiredSize.Height;
                    }
                if (!String.IsNullOrEmpty (SpecialFieldProcessing.m_Help))
                    {
                    ColumnLabel.Tag = SpecialFieldProcessing.m_Help;
                    ColumnLabel.MouseRightButtonUp += new MouseButtonEventHandler (ColumnLabel_MouseRightButtonUp);
                    }

                int NumberOfLines = GetNumberOfLines (m_RowToProcess, Column);
                Border TextBlockBorder = new Border ();
                ContentGrid.Children.Add (TextBlockBorder);
                Grid.SetColumn (TextBlockBorder, 1);
                Grid.SetRow (TextBlockBorder, RowIndex);
                TextBlockBorder.BorderThickness = (Thickness)TConverter.ConvertFromString ("1");
                TextBlockBorder.BorderBrush = (Brush)BConverter.ConvertFromString ("Black");
                TextBox ColumnText = new TextBox ();
                ColumnText.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                ColumnText.AcceptsReturn = true;
                TextBlockBorder.Child = ColumnText;
                ColumnText.TextWrapping = TextWrapping.Wrap;
                if ((m_UpdateAllowed == true)
                    && (m_PrimaryKeyName != Column.ColumnName))
                    {
                    ColumnText.IsEnabled = true;
                    ColumnText.Tag = Column.ColumnName;
                    m_UpdateableControls.Add (ColumnText);
                    }
                else
                    {
                    ColumnText.IsEnabled = false;
                    }
                if (((String.IsNullOrEmpty (SpecialFieldProcessing.m_TableName))
                     && (SpecialFieldProcessing.m_DefaultContentRules == null))
                    || (SpecialFieldProcessing.m_TypeOfSpecialFieldProcessing
                        == WMB.TableContentDefinition.SQL_COLUMN_PROPERTY_CONNECTED_VALUE))
                    {
                    ColumnText.Text = m_RowToProcess [Column.ColumnName].ToString ();
                    Grid.SetColumnSpan (TextBlockBorder, 2);
                    }
                else
                    {
                    if ((m_UpdateAllowed == true)
                        && (SpecialFieldProcessing.m_UpdateAble == true))
                        {
                        Grid.SetColumnSpan (TextBlockBorder, 1);
                        Button OpenSelection = new Button ();
                        OpenSelection.Content = "....";
                        Grid.SetColumn (OpenSelection, 2);
                        Grid.SetRow (OpenSelection, RowIndex);
                        OpenSelection.IsEnabled = true;
//.........这里部分代码省略.........
开发者ID:heinzsack,项目名称:DEV,代码行数:101,代码来源:CommonUserInterface.cs


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