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);
            }
        }
예제 #2
0
		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);
			}
예제 #3
0
		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);
			}
예제 #4
0
 /// <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;
         }
     }
 }
예제 #5
0
        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;
                        OpenSelection.Tag = SpecialFieldProcessing;
                        OpenSelection.Click += new RoutedEventHandler (OpenSelection_Click);
                        ContentGrid.Children.Add (OpenSelection);
                        }
                    if (GetReadableTextForEntryCall == null)
                        ColumnText.Text = "Fehler - GetReadableTextForEntryCall not defined";
                    else
                        {
                        if (SpecialFieldProcessing.m_TypeOfSpecialFieldProcessing
                            == WMB.TableContentDefinition.SQL_COLUMN_PROPERTY_CONNECTOR_ID)
                            {
                            ColumnText.Text = GetReadableTextForEntryCall
                                (this, SpecialFieldProcessing.m_ForeignTableName,
                                    m_RowToProcess [Column.ColumnName].ToString ());
                            }
                        else
                            {
                            ColumnText.Text = m_RowToProcess [Column.ColumnName].ToString ();
                            }
                        ColumnText.IsReadOnly = true;
                        ColumnText.IsEnabled = false;
                        }
                    }
                //ColumnText.Height = NumberOfLines * LineHeight;

                NumberOfAllLines += NumberOfLines;
                RowIndex++;
                }
            return (double)((NumberOfAllLines + 2) * LineHeight) + (NumberOfAllLines * 2);
            }