private void UpdateBarcodes(TextBlock barcodeText)
        {
            grid.Children.Clear();
            double width = (fixedPage.Width - fixedPage.Margin.Left*2) / totalColumns;
            double height = (fixedPage.Height-fixedPage.Margin.Top*2) / totalRows;
            for (int i = 0; i < totalRows; i++)
            {
                grid.RowDefinitions[i].Height = new GridLength(height);
            }
            for (int j = 0; j < totalColumns; j++)
            {
                grid.ColumnDefinitions[j].Width = new GridLength(width);
            }
            for (int i = 0; i < totalRows; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    var tb = new TextBlock
                                    {
                                        //Margin = barcodeText.Margin,
                                        Text = barcodeText.Text,
                                        FontFamily = barcodeText.FontFamily,
                                        FontSize = barcodeText.FontSize
                                    };
                    tb.HorizontalAlignment = HorizontalAlignment.Center;
                    tb.VerticalAlignment = VerticalAlignment.Center;
                    tb.SetValue(Grid.ColumnProperty, j);
                    tb.SetValue(Grid.RowProperty, i);
                    grid.Children.Add(tb);

                }
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            LayoutGrid = GetTemplateChild(PART_LayoutGrid) as Grid;
            if (LayoutGrid != null)
            {
                if (Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    LayoutGrid.RowDefinitions.Add(new RowDefinition(){ Height = new GridLength(0, GridUnitType.Auto)});
                    LayoutGrid.RowDefinitions.Add(new RowDefinition(){ Height = new GridLength(0, GridUnitType.Auto)});
                }
                else
                {
                    LayoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
                    LayoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Auto) });
                }
            }

            LabelTextElement = GetTemplateChild(PART_LabelTextElement) as TextBlock;
            if (LabelTextElement != null)
            {
                if (Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    LabelTextElement.SetValue(Grid.RowProperty, 1);
                }
                else
                {
                    LabelTextElement.SetValue(Grid.ColumnProperty, 1);
                }
            }
        }
Ejemplo n.º 3
0
		public static void CenterTextBlock (TextBlock blk, FrameworkElement element)
		{
			double x = (element.Width - blk.ActualWidth) / 2;
			double y = (element.Height - blk.ActualHeight) / 2;

			blk.SetValue (Canvas.TopProperty, y);
			blk.SetValue (Canvas.LeftProperty, x);
		}
Ejemplo n.º 4
0
 public static TextBlock setLabel( string text, int row, int col )
 {
     TextBlock label = new TextBlock();
       label.Text = text;
       label.Margin = new Thickness( 5, 1, 1, 1 );
       label.SetValue( Grid.ColumnProperty, col );
       label.SetValue( Grid.RowProperty, row );
       return label;
 }
Ejemplo n.º 5
0
        public static TextBlock PlaceTextboxPrimitive(Grid Container, int Col, int Row)
        {
            TextBlock textBlock = new TextBlock();
            textBlock.SetValue(Grid.ColumnProperty, Col);
            textBlock.SetValue(Grid.RowProperty, Row);
            textBlock.Style = (Style)Application.Current.Resources["CellTextBlock"];

            Container.Children.Add(textBlock);
            return textBlock;
        }
Ejemplo n.º 6
0
 private static TextBlock GenerateTypeText(ref Thickness margin, int row, string value)
 {
     TextBlock elevalue = new TextBlock();
     elevalue.Text = value;
     elevalue.SetValue(Grid.RowProperty, row);
     elevalue.SetValue(Grid.ColumnProperty, 1);
     elevalue.Margin = margin;
     elevalue.MinWidth = 100;
     elevalue.Background = Brushes.AntiqueWhite;
     return elevalue;
 }
Ejemplo n.º 7
0
 private TextBlock CreateLabel(string text, double top, double left)
 {
     TextBlock block = new TextBlock();
     block.Text=text;
     SolidColorBrush brush = new SolidColorBrush();
     brush.Color=Color.FromArgb(0xff, 0xf7, 0xf9, 250);
     block.Foreground=brush;
     block.FontSize=13.0;
     block.SetValue(Canvas.TopProperty, top);
     block.SetValue(Canvas.LeftProperty, left - (block.ActualWidth / 2.0));
     return block;
 }
Ejemplo n.º 8
0
        private void MostrarGrade()
        {
            TxtCurso.Text = Context.Grade.NomeCurso;
            TxtDia.Text = Context.Grade.NomeDia;
            TxtSemestre.Text = Context.Grade.NumeroSemestre.ToString();

            for (int i = 0; i < Context.Grade.Horarios.Count; i++)
            {
                if (i > 0 && Context.Grade.Horarios[i].HorarioInicial != Context.Grade.Horarios[i - 1].HorarioFinal)
                {
                    Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    var intervalo = new TextBlock()
                    {
                        Text = "Intervalo",
                        TextAlignment = System.Windows.TextAlignment.Center,
                        Background = Brushes.LightGray,
                        Width = Tabela.Width,
                        VerticalAlignment = System.Windows.VerticalAlignment.Center,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                    };
                    intervalo.SetValue(Grid.ColumnSpanProperty, 2);
                    intervalo.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);
                    Tabela.Children.Add(intervalo);
                }

                Tabela.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
                var horario = new TextBlock()
                {
                    Text = string.Concat(Context.Grade.Horarios[i].HorarioInicial, " - ", Context.Grade.Horarios[i].HorarioFinal),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                };
                horario.SetValue(Grid.ColumnProperty, 0);
                horario.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);

                var materia = new StackPanel()
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                };
                if (Context.Grade.Horarios[i].Materia != null)
                {
                    materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Materia, FontWeight = FontWeight.FromOpenTypeWeight(600) });
                    materia.Children.Add(new TextBlock() { Text = Context.Grade.Horarios[i].Materia.Professor });
                }
                materia.SetValue(Grid.ColumnProperty, 1);
                materia.SetValue(Grid.RowProperty, Tabela.RowDefinitions.Count - 1);

                Tabela.Children.Add(horario);
                Tabela.Children.Add(materia);
            }
        }
        public void AddNewRow(int Row, string Caption)
        {
            System.Windows.Controls.TextBlock tb = new TextBlock();
            tb.SetValue(Grid.RowProperty,Row);
            tb.SetValue(Grid.ColumnProperty,0);
            tb.Text = Caption;

            System.Windows.Controls.TextBox txtbx = new TextBox();
            txtbx.SetValue(Grid.RowProperty,Row);
            txtbx.SetValue(Grid.ColumnProperty,1);

            ControlGrid.Children.Add(tb);
            ControlGrid.Children.Add(txtbx);
        }
Ejemplo n.º 10
0
 private void DrawNoteNames()
 {
     for (int note = 0; note < pattern.Notes; note++)
     {
         var tb = new TextBlock();
         tb.Text = pattern.NoteNames[note];
         tb.SetValue(Canvas.LeftProperty, 0.0);
         tb.SetValue(Canvas.TopProperty, note * gridSquareWidth);
         tb.Foreground = Brushes.Gray;
         tb.FontFamily = new FontFamily("Segoe UI");
         tb.FontSize = 12;
         drumGridCanvas.Children.Add(tb);
     }
 }
 public override void AddUI(Grid grid)
 {
     if (Config != null && Config.ShownAtRunTime)
     {
         TextBlock tb = new TextBlock()
         {
             Text = Resources.Strings.ZoomToExtentInput,
             Margin = new System.Windows.Thickness(2)
         };
         tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
         tb.SetValue(Grid.ColumnProperty, 1);
         tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
         grid.Children.Add(tb);
     }
 }
Ejemplo n.º 12
0
        private void CreateImage()
        {
            _adornment = new TextBlock();
            _adornment.Text = "Generated";
            _adornment.FontSize = 75;
            _adornment.FontWeight = FontWeights.Bold;
            _adornment.Foreground = Brushes.Gray;
            _adornment.ToolTip = "Click to toggle visibility";
            _adornment.Opacity = _currentOpacity;
            _adornment.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Aliased);
            _adornment.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal);

            _adornment.MouseEnter += (s, e) => { _adornment.Opacity = 1; };
            _adornment.MouseLeave += (s, e) => { _adornment.Opacity = _currentOpacity; };
            _adornment.MouseLeftButtonUp += (s, e) => { LogoAdornment.OnVisibilityChanged(_currentOpacity == 0); };
        }
Ejemplo n.º 13
0
        public Week()
        {
            InitializeComponent();

            for (int h = 0; h < 25; h++) {

                // labels
                TextBlock tb = new TextBlock();
                if (h < 24)
                    tb.Text = h.ToString();
                else
                    tb.Text = "All Day";
                tb.SetValue(Grid.ColumnProperty, h + 1);
                tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                grMain.Children.Add(tb);

                if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
                    for (int d = 0; d < 8; d++) {
                        if (h < 24 || d < 7) { // excluding h = 24 and d = 7
                            Day day = new Day();
                            day.SetValue(Grid.RowProperty, d + 1);
                            day.SetValue(Grid.ColumnProperty, h + 1);
                            day.DataContext = ((ViewModels.MainViewModel)Application.Current.MainWindow.DataContext).DayViewModels[d, h]; // if d == 8 then all days
                            grMain.Children.Add(day);
                        }
                    }
            }
        }
 public void GenerateHours()
 {
     TextBlock tb;
     for (int i = 0; i < 24; i++)
     {
         tb = new TextBlock()
         {
             Height = Constants.GRID_HOURS_CELL_HEIGHT,
             Text = i.ToString("D2"),
             Foreground = new SolidColorBrush(Colors.DarkGray),
             FontSize = Constants.HOUR_FONT_SIZE,
         };
         tb.SetValue(Grid.RowProperty, i + 1);
         tb.SetValue(Grid.ColumnProperty, 0);
         _owningCalendar.hoursDetailsGrid.Children.Add(tb);
     }
 }
Ejemplo n.º 15
0
		public void Canvas_Loaded (object sender, EventArgs e)
		{
			TextBlock n = new TextBlock ();
			n.Text = "I am the textblock";
			n.SetValue (TextBlock.ForegroundProperty, "#FF626262");

			Children.Add (n);
		}
        public MainWindow()
        {
            InitializeComponent();
            
            var button = new Button{Content = "This is a button"};
            var textBlock = new TextBlock{Text="Test"};

            button.SetValue(Grid.ColumnProperty, 0);
            button.SetValue(Grid.RowProperty, 0);
            textBlock.SetValue(Grid.ColumnProperty, 1);
            textBlock.SetValue(Grid.RowProperty, 0);

            TheGrid.Children.Add(button);
            TheGrid.Children.Add(textBlock);

            //TheOrderedStackPanel.Order();
        }
Ejemplo n.º 17
0
 public PickDialog()
 {
     InitializeComponent();
     _converter = new FileNameToIconConverter();
     try
     {
         FileSystemTree.Focus();
         foreach (var drive in Directory.GetLogicalDrives())
         {
             var dirInfo = new DirectoryInfo(drive);
             TreeViewItem item = new TreeViewItem();
             var grid = new Grid();
             grid.ColumnDefinitions.Add(new ColumnDefinition() {Width = GridLength.Auto});
             grid.ColumnDefinitions.Add(new ColumnDefinition() {Width = new GridLength(5, GridUnitType.Star)});
             var textBlock = new TextBlock
             {
                 Text =
                     (string)
                         _converter.Convert(dirInfo.FullName, typeof (string), null, CultureInfo.CurrentCulture)
             };
             textBlock.SetValue(Grid.ColumnProperty, 0);
             textBlock.Foreground = new SolidColorBrush(Colors.SlateGray);
             textBlock.FontSize = 15;
             grid.Children.Add(textBlock);
             var driveTb = new TextBlock {Text = dirInfo.ToString()};
             driveTb.SetValue(Grid.ColumnProperty, 1);
             driveTb.SetValue(Grid.MarginProperty, new Thickness(2, 0, 0, 0));
             driveTb.FontSize = 15;
             grid.Children.Add(driveTb);
             item.Tag = dirInfo;
             item.Header = grid;
             item.Items.Add("*");
             FileSystemTree.Items.Add(item);
         }
         GoToSelectedPath();
     }
     catch (IOException)
     {
         Close();
     }
     catch (UnauthorizedAccessException)
     {            
         Close();
     }
 }
Ejemplo n.º 18
0
 public static Font SetEtoFont(this swc.TextBlock control, Font font, Action <sw.TextDecorationCollection> setDecorations = null)
 {
     if (control == null)
     {
         return(font);
     }
     if (font != null)
     {
         ((FontHandler)font.Handler).Apply(control, setDecorations);
     }
     else
     {
         control.SetValue(swc.Control.FontFamilyProperty, swc.Control.FontFamilyProperty.DefaultMetadata.DefaultValue);
         control.SetValue(swc.Control.FontStyleProperty, swc.Control.FontStyleProperty.DefaultMetadata.DefaultValue);
         control.SetValue(swc.Control.FontWeightProperty, swc.Control.FontWeightProperty.DefaultMetadata.DefaultValue);
         control.SetValue(swc.Control.FontSizeProperty, swc.Control.FontSizeProperty.DefaultMetadata.DefaultValue);
     }
     return(font);
 }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var textBlock = new TextBlock();
            textBlock.SetValue(FrameworkElement.StyleProperty, ElementStyle);

            Dispatcher.BeginInvoke(
                DispatcherPriority.Loaded,
                new Action<TextBlock>(x => x.SetBinding(TextBlock.TextProperty, Binding)),
            textBlock);
            return textBlock;
        }
Ejemplo n.º 20
0
 private void GuideDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (GuideDataGrid.SelectedItem == null)
     {
         //avoid Exception
         return;
     }
     string sp_guide_id = ((DataRowView)GuideDataGrid.SelectedItem).Row["id"].ToString();
     Task<DataTable> task = new Task<DataTable>(() =>
     {
         string sql = @"SELECT * FROM unit_talk_master WHERE id={0}";
         return DAL.GetDataTable(String.Format(sql, sp_guide_id));
     });
     task.ContinueWith(t =>
     {
         if (t.Exception != null)
         {
             Utility.ShowException(t.Exception);
             return;
         }
         if (t.Result == null || t.Result.Rows.Count == 0)
         {
             return;
         }
         DataRow guideData = t.Result.Rows[0];
         GuideTalk.Children.Clear();
         for (int i = 0; i < 128; i++)
         {
             string guide = guideData[i + 6].ToString();  //remove id&5 icon
             if (!string.IsNullOrWhiteSpace(guide))
             {
                 Grid grid = new Grid();
                 grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                 grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                 var tbName = new TextBlock()
                 {
                     Text = Utility.ParseMessageName(i),
                     Background = (SolidColorBrush)Application.Current.Resources["DefaultBrush"]
                 };
                 var tbValue = new TextBox()
                 {
                     Text = guide.Replace("*", "\n"),
                     IsReadOnly = true
                 };
                 grid.Children.Add(tbName);
                 grid.Children.Add(tbValue);
                 tbName.SetValue(Grid.RowProperty, 0);
                 tbValue.SetValue(Grid.RowProperty, 1);
                 GuideTalk.Children.Add(grid);
             }
         }
     }, MainWindow.UiTaskScheduler);
     task.Start();
 }
Ejemplo n.º 21
0
        protected TextBlock SetLeftText(string leftText)
        {
            var textBlock = new TextBlock();
            textBlock.Text = leftText;
            textBlock.SetValue(Grid.RowProperty, 1);
            textBlock.FontSize = 16;
            textBlock.LineHeight = 24;
            textBlock.TextWrapping = System.Windows.TextWrapping.Wrap;
            LeftPanel.Children.Add(textBlock);

            return textBlock;
        }
Ejemplo n.º 22
0
		public void IsRequiredForFormPropertyTest ()
		{
			Assert.IsNotNull (AutomationProperties.IsRequiredForFormProperty, "#0");

			TextBlock block = new TextBlock ();
			block.SetValue (AutomationProperties.IsRequiredForFormProperty, true);
			Assert.AreEqual (AutomationProperties.GetIsRequiredForForm (block),
				block.GetValue (AutomationProperties.IsRequiredForFormProperty), "#1");

			Assert.IsTrue (AutomationProperties.GetIsRequiredForForm (block), "#2");
			Assert.IsTrue ((bool) block.GetValue (AutomationProperties.IsRequiredForFormProperty), "#3");
		}
        private static Control CreateItem(string name, object val, int row, Grid parent) {
            var caption = new TextBlock() { Text = name, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(2, 2, 4, 2) };

            Control value;
            if (val is string || val is double)
                value = new TextBox() { Text = val.ToString(), VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(2, 2, 2, 2) };
            else if (val is int)
                value = new ControlNumericTextBox() { Text = val.ToString(), VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(2, 2, 2, 2) };
            else if (val is bool)
                value = new CheckBox() { IsChecked = (bool)val, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(2, 2, 2, 2) };
            else
                throw new ArgumentException("val type is not supported");

            caption.SetValue(Grid.ColumnProperty, 0);
            value.SetValue(Grid.ColumnProperty, 1);
            caption.SetValue(Grid.RowProperty, row);
            value.SetValue(Grid.RowProperty, row);

            parent.Children.Add(caption);
            parent.Children.Add(value);

            return value;
        }
Ejemplo n.º 24
0
        public void CustomMeasure()
        {
            if (RootCanvas.Children.Count == 0) {
                RootCanvas.Children.Clear();
                _textBlocks.Clear();

                double left = 0;
                double top = 0;
                for (int i = 0; i < 2000; i++) {
                    var textBlock = new TextBlock() { Text = i.ToString() };
                    textBlock.SetValue(Canvas.LeftProperty, left + 1000);
                    textBlock.SetValue(Canvas.TopProperty, top);

                    _textBlocks.Add(new TextBlock() { Text = i.ToString() });
                    RootCanvas.Children.Add(textBlock);

                    left += 10;
                    if (left >= ActualWidth) {
                        left = 0;
                        top += 10.0;
                    }
                }
            }
        }
Ejemplo n.º 25
0
        partial void InitializeBusyIndicator()
        {
            if (_busyIndicator != null)
            {
                return;
            }

            _grid = new Grid();
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });

            var backgroundBorder = new Border();
            backgroundBorder.Background = new SolidColorBrush(Colors.Gray);
            backgroundBorder.Opacity = 0.5;
            backgroundBorder.SetValue(Grid.RowSpanProperty, 4);
            _grid.Children.Add(backgroundBorder);

            _statusTextBlock = new TextBlock();
            _statusTextBlock.Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"];
            _statusTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            _statusTextBlock.SetValue(Grid.RowProperty, 1);
            _grid.Children.Add(_statusTextBlock);

            _busyIndicator = ConstructBusyIndicator();
            _busyIndicator.SetValue(Grid.RowProperty, 2);
            _grid.Children.Add(_busyIndicator);

            _containerPopup = new Popup();
            _containerPopup.VerticalAlignment = VerticalAlignment.Center;
            _containerPopup.HorizontalAlignment = HorizontalAlignment.Center;
            _containerPopup.Child = _grid;

            double rootWidth = Application.Current.Host.Content.ActualWidth;
            double rootHeight = Application.Current.Host.Content.ActualHeight;

            _busyIndicator.Width = rootWidth;

            _grid.Width = rootWidth;
            _grid.Height = rootHeight;

            _containerPopup.UpdateLayout();

            return;
        }
        public static void SetInlineExpression(TextBlock textBlock, string value)
        {
            textBlock.SetValue(InlineExpressionProperty, value);

            textBlock.Inlines.Clear();

            if (string.IsNullOrEmpty(value))
                return;

            var descriptions = GetInlineDescriptions(value);
            if (descriptions.Length == 0)
                return;

            var inlines = GetInlines(textBlock, descriptions);
            if (inlines.Length == 0)
                return;

            textBlock.Inlines.AddRange(inlines);
        }
Ejemplo n.º 27
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     var usernames = (string)value;
     var users = Data.TaskItem.ParseNames(usernames);
     var sb = new StringBuilder();
     int count = 0;
     const string userpic = "pics/NoOwnerTransparent.png";
         //"pics/NoOwner.png";// "pics/unavailable1.png";
         //"uservs.net.png"
         //pics/NoOwner.png
         //pics/unavailable.png
     if (users.Count == 0)
     {
         var imgNoOwner = new Image
                              {
                                  Height = 21,
                                  Width = 21,
                                  Source =
                                      new System.Windows.Media.Imaging.BitmapImage(new Uri(userpic,
                                                                                           UriKind.
                                                                                               RelativeOrAbsolute))
                              };
         imgNoOwner.SetValue(ToolTipService.ToolTipProperty, "No owner");
         imgNoOwner.VerticalAlignment = VerticalAlignment.Center; 
         return imgNoOwner; 
     }
     foreach (Data.UserInfo u in users)
     {
         sb.Append(u.DisplayName);
         if (count != users.Count - 1) sb.Append(";");
         count++;
     }
     string username = sb.ToString();
     var tbUser = new TextBlock {Text = username};
     tbUser.SetValue(ToolTipService.ToolTipProperty, username);
     tbUser.TextWrapping = TextWrapping.Wrap;
     tbUser.VerticalAlignment = VerticalAlignment.Center;
     tbUser.Margin = new Thickness { Left = 10, Bottom = 5, Right = 10, Top = 5 };
     tbUser.Opacity = 0.5;
     return tbUser;
 }
Ejemplo n.º 28
0
        public FileWatcherNode(Core.VplControl hostCanvas)
            : base(hostCanvas)
        {
            AddOutputPortToNode("String", typeof (string));

            var grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(60, GridUnitType.Pixel)});
            grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(100, GridUnitType.Auto)});

            textBlock = new TextBlock {IsHitTestVisible = false, VerticalAlignment = VerticalAlignment.Center};

            textBlock.SetValue(ColumnProperty, 1);

            var button = new Button {Content = "Search"};
            button.Click += button_Click;
            button.Width = 50;

            grid.Children.Add(textBlock);
            grid.Children.Add(button);

            AddControlToNode(grid);
        }
Ejemplo n.º 29
0
        void UpdateSummary()
        {
            View.PhosResultsWindow mw = (View.PhosResultsWindow)Application.Current.Windows.OfType <Window>().Last();
            for (int i = 0; i < MarkerList.Count; i++)
            {
                if (DisplayName.Equals("PhosResultsViewModelBatchMeasurement") && i == 0)
                {
                    continue;
                }
                Tuple <System.Windows.Shapes.Ellipse, TextBlock, Point> t = MarkerList[i];
                string savedEllipse = XamlWriter.Save(t.Item1);
                string savedText    = XamlWriter.Save(t.Item2);
                System.Windows.Shapes.Ellipse     ellipse = (System.Windows.Shapes.Ellipse)XamlReader.Load(XmlReader.Create(new StringReader(savedEllipse)));
                System.Windows.Controls.TextBlock txt     = (TextBlock)XamlReader.Load(XmlReader.Create(new StringReader(savedText)));
                if (DisplayName.Equals("PhosResultsViewModelBatchMeasurement"))
                {
                    ellipse.Width  *= 2;
                    ellipse.Height *= 2;
                    ellipse.Stroke  = ColorLegendList[(int)DiamondResList[i - 1]];
                    txt.FontSize    = 48;
                    txt.Foreground  = ColorLegendList[(int)DiamondResList[i - 1]];
                }
                else
                {
                    ellipse.Stroke = ColorLegendList[(int)DiamondResult];
                }
                ellipse.SetValue(Canvas.LeftProperty, t.Item3.X - ellipse.Width / 2.0);
                ellipse.SetValue(Canvas.TopProperty, t.Item3.Y - ellipse.Height / 2.0);

                txt.SetValue(Canvas.LeftProperty, t.Item3.X - 15);
                txt.SetValue(Canvas.TopProperty, t.Item3.Y - 76);

                mw.CanvasSummary.Children.Add(ellipse);
                if (DisplayName.Equals("PhosResultsViewModelBatchMeasurement"))
                {
                    mw.CanvasSummary.Children.Add(txt);
                }
                if (!DisplayName.Equals("PhosResultsViewModelBatchMeasurement") && i == 0)
                {
                    break;
                }
            }

            if (!mappingMeasure)
            {
                double x = 50;
                double y = 50;
                for (int i = 0; i < ColorLegendList.Count; i++)
                {
                    DrawCanvas.Rect(x, y, 30, 30, ColorLegendList[i - 2], mw.CanvasSummary);
                    DrawCanvas.Text(x + 50, y, ResultString(i - 2), true, ColorLegendList[i - 2], mw.CanvasSummary, false);
                    y += 40;
                }
            }
            else
            {
                // rectangle mask
                double x = Canvas.GetLeft(RectMark);
                double y = Canvas.GetTop(RectMark);
                double w = RectMark.Width;
                double h = RectMark.Height;

                System.Windows.Shapes.Rectangle tmpRect = DrawCanvas.Rect(x, y, (int)w, (int)h, Brushes.Red, mw.CanvasSummary, 0.3);
            }
        }
        public void DrawText(ScreenPoint p, string text, OxyColor fill, string fontFamily, double fontSize,
                             double fontWeight, double rotate, HorizontalAlignment halign, VerticalTextAlign valign)
        {
            var tb = new TextBlock
                         {
                             Text = text,
                             Foreground = new SolidColorBrush(fill.ToColor())
                         };
            if (fontFamily != null)
                tb.FontFamily = new FontFamily(fontFamily);
            if (fontSize > 0)
                tb.FontSize = fontSize;
            if (fontWeight > 0)
                tb.FontWeight = FontWeight.FromOpenTypeWeight((int)fontWeight);

            tb.Measure(new Size(1000, 1000));

            double dx = 0;
            if (halign == HorizontalAlignment.Center)
                dx = -tb.DesiredSize.Width / 2;
            if (halign == HorizontalAlignment.Right)
                dx = -tb.DesiredSize.Width;

            double dy = 0;
            if (valign == VerticalTextAlign.Middle)
                dy = -tb.DesiredSize.Height / 2;
            if (valign == VerticalTextAlign.Bottom)
                dy = -tb.DesiredSize.Height;

            var transform = new TransformGroup();
            transform.Children.Add(new TranslateTransform(dx, dy));
            if (rotate != 0)
                transform.Children.Add(new RotateTransform(rotate));
            transform.Children.Add(new TranslateTransform(p.X, p.Y));
            tb.RenderTransform = transform;

            tb.SetValue(RenderOptions.ClearTypeHintProperty, ClearTypeHint.Enabled);

            Add(tb);
        }
        public override void AddConfigUI(System.Windows.Controls.Grid grid)
        {
            base.AddConfigUI(grid);
            #region Layer name
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            TextBlock layerName = new TextBlock()
            {
                Text = Resources.Strings.LabelLayerName,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            layerName.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(layerName);
            TextBox labelTextBox = new TextBox()
            {
                Text = LayerName == null ? string.Empty : LayerName,
                Margin = new Thickness(2),
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
            };
            labelTextBox.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            labelTextBox.SetValue(Grid.ColumnProperty, 1);
            grid.Children.Add(labelTextBox);
            labelTextBox.TextChanged += (s, e) =>
            {
                LayerName = labelTextBox.Text;
            };
            #endregion
            #region Renderer
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            TextBlock label2 = new TextBlock()
            {
                Text = Resources.Strings.LabelRenderer,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label2);
            Button rendererButton = null;
            if (GeometryType == Core.GeometryType.Unknown)
            {
                TextBlock tb = new TextBlock() { Text = Resources.Strings.NotAvailable, VerticalAlignment = VerticalAlignment.Center };
                ToolTipService.SetToolTip(tb, Resources.Strings.GeometryTypeIsNotKnown);
                tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                tb.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(tb);
            }
            else
            {
                rendererButton = new Button()
                {
                    Content = new Image()
                               {
                                   Source = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/ColorScheme16.png", UriKind.Relative)),
                                   Stretch = Stretch.None,
                                   VerticalAlignment = System.Windows.VerticalAlignment.Center,
                                   HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                               },
                    Width = 22,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Style = Application.Current.Resources["SimpleButtonStyle"] as Style,
                    IsEnabled = (Mode == InputMode.SketchLayer),
                };
                ToolTipService.SetToolTip(rendererButton, Resources.Strings.ConfigureRenderer);
                rendererButton.Click += rendererButton_Click;
                rendererButton.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                rendererButton.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(rendererButton);
            }
            #endregion
            #region Popup Config
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            label2 = new TextBlock()
            {
                Text = Resources.Strings.LabelPopUps,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label2);
            Button popupButton = null;
            if (Layer == null)
            {
                TextBlock tb = new TextBlock() { Text = Resources.Strings.NotAvailable, VerticalAlignment = VerticalAlignment.Center };
                ToolTipService.SetToolTip(tb, Resources.Strings.FieldInformationIsNotKnown);
                tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                tb.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(tb);
            }
            else
            {
                popupButton = new Button()
                {
                    Content = new Image()
                    {
                        Source = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/Show_Popup16.png", UriKind.Relative)),
                        Stretch = Stretch.None,
                        VerticalAlignment = System.Windows.VerticalAlignment.Center,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                    },
                    Width = 22,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Style = Application.Current.Resources["SimpleButtonStyle"] as Style,
                    IsEnabled = (Mode == InputMode.SketchLayer),
                };
                ToolTipService.SetToolTip(popupButton, Resources.Strings.ConfigurePopupFieldAliasesAndVisibility);
                popupButton.Click += popupButton_Click;
                popupButton.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                popupButton.SetValue(Grid.ColumnProperty, 1);
                grid.Children.Add(popupButton);
            }
            #endregion

            #region Transparency
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            label2 = new TextBlock()
            {
                Text = Resources.Strings.LabelTransparency,
                Margin = new Thickness(2),
                VerticalAlignment = System.Windows.VerticalAlignment.Top
            };
            label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label2);

            ContentControl slider = new ContentControl()
            {
                DataContext = this,
                IsEnabled = (Mode == InputMode.SketchLayer),
                Style = ResourceUtility.LoadEmbeddedStyle("Themes/HorizontalTransparencySlider.xaml", "TransparencySliderStyle")
            };
            //Slider slider = new Slider()
            //{
            //    DataContext = this,
            //    IsEnabled = (Mode == InputMode.SketchLayer),
            //    Orientation = Orientation.Horizontal,
            //    Width = 145,
            //    Minimum = 0,
            //    Maximum = 1
            //};
            //slider.SetBinding(Slider.ValueProperty,
            //    new System.Windows.Data.Binding("Opacity") { Mode = System.Windows.Data.BindingMode.TwoWay });
            slider.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
            slider.SetValue(Grid.ColumnProperty, 1);
            grid.Children.Add(slider);
            #endregion

            if (Input)
            {
                #region Input Mode
                grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                TextBlock label = new TextBlock()
                {
                    Text = Resources.Strings.LabelInputFeatures,
                    Margin = new Thickness(2),
                    VerticalAlignment = System.Windows.VerticalAlignment.Center
                };
                label.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                grid.Children.Add(label);

                grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
                StackPanel panel = new StackPanel()
                {
                    Orientation = System.Windows.Controls.Orientation.Vertical,
                    Margin = new Thickness(15, 0, 0, 0),
                };
                panel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
                panel.SetValue(Grid.ColumnSpanProperty, 2);
                RadioButton interactive = new RadioButton()
                {
                    Content = Resources.Strings.Interactively,
                    IsChecked = (Mode == InputMode.SketchLayer),
                    Margin = new Thickness(2),
                    Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush
                };
                panel.Children.Add(interactive);
                RadioButton selection = new RadioButton()
                {
                    Content = Resources.Strings.BySelectingLayerFromMap,
                    IsChecked = (Mode == InputMode.SelectExistingLayer),
                    Margin = new Thickness(2),
                    Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush
                };
                panel.Children.Add(selection);
                RadioButton fromExtent = null;
                if (GeometryType == Core.GeometryType.Polygon)
                {
                    fromExtent = new RadioButton()
                    {
                        Content = Resources.Strings.FromMapExtent,
                        IsChecked = (Mode == InputMode.CurrentExtent),
                        Margin = new Thickness(2),
                        Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush
                    };
                    panel.Children.Add(fromExtent);

                }
                interactive.Checked += (a, b) =>
                {
                    Mode = InputMode.SketchLayer;
                    selection.IsChecked = false;
                    if (fromExtent != null)
                        fromExtent.IsChecked = false;
                    if (popupButton != null)
                        popupButton.IsEnabled = true;
                    if (rendererButton != null)
                        rendererButton.IsEnabled = true;
                    //if (slider != null)
                    //    slider.IsEnabled = true;
                };
                selection.Checked += (a, b) =>
                 {
                     Mode = InputMode.SelectExistingLayer;
                     interactive.IsChecked = false;
                     if (fromExtent != null)
                         fromExtent.IsChecked = false;
                     if (popupButton != null)
                         popupButton.IsEnabled = false;
                     if (rendererButton != null)
                         rendererButton.IsEnabled = false;
                     //if (slider != null)
                     //    slider.IsEnabled = false;
                 };
                if (fromExtent != null)
                {
                    fromExtent.Checked += (a, b) =>
                     {
                         Mode = InputMode.CurrentExtent;
                         interactive.IsChecked = false;
                         selection.IsChecked = false;
                         if (popupButton != null)
                             popupButton.IsEnabled = false;
                         if (rendererButton != null)
                             rendererButton.IsEnabled = false;
                         //if (slider != null)
                         //    slider.IsEnabled = false;
                     };
                }
                grid.Children.Add(panel);
                #endregion
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// 初始化控件
        /// </summary>
        protected virtual void Init_Control()
        {
            // 图片
            ImageSource = new Image();
            ImageSource.Source = IcoImage;
            ImageSource.Width = ImageWidth;
            ImageSource.Height = ImageHeight;

            // 图片的边框
            ImageBorder = new Border();
            ImageBorder.BorderBrush = new SolidColorBrush(Colors.Black);
            ImageBorder.BorderThickness = new Thickness(0);
            ImageBorder.CornerRadius = new CornerRadius(3);
            ImageBorder.Width = ImageSource.Width;
            ImageBorder.Height = ImageSource.Height;
            ImageBorder.Child = ImageSource;

            // 设备名
            TextDeviceName = new TextBlock();
            TextDeviceName.FontSize = 14;
            TextDeviceName.HorizontalAlignment = HorizontalAlignment.Center;
            TextDeviceName.VerticalAlignment = VerticalAlignment.Center;
            TextDeviceName.TextAlignment = TextAlignment.Center;

            // 设备当前状态
            ImageStatues = new Ellipse();
            ImageStatues.Fill = new SolidColorBrush(Colors.Green);
            ImageStatues.Height = 12;
            ImageStatues.Width = 12;

            // 连接时显示的虚线
            LineVirtual = new Line();
            LineVirtual.Stroke = new SolidColorBrush(Colors.Black);
            LineVirtual.StrokeThickness = 2;
            DoubleCollection dc = new DoubleCollection();
            dc.Add(1);
            dc.Add(1);
            LineVirtual.StrokeDashArray = dc;

            // 设置ZIndex
            ImageBorder.SetValue(Canvas.ZIndexProperty, -64);
            TextDeviceName.SetValue(Canvas.ZIndexProperty, 64);

            this.Children.Add(ImageBorder);
            this.Children.Add(TextDeviceName);
            this.Children.Add(ImageStatues);
            this.Children.Add(LineVirtual);
        }
Ejemplo n.º 33
0
        /// <summary>Default constructor, creates the UIElements including a PropertyInspector</summary>
        public WpfPropertyGrid()
        {
            this.ColumnDefinitions.Add(new ColumnDefinition());
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(0)
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(0)
            });

            this.Designer = new WorkflowDesigner();
            TextBlock title = new TextBlock()
            {
                Visibility   = Windows.Visibility.Visible,
                TextWrapping = TextWrapping.NoWrap,
                TextTrimming = TextTrimming.CharacterEllipsis,
                FontWeight   = FontWeights.Bold,
                FontSize     = 30.0
            };
            TextBlock descrip = new TextBlock()
            {
                Visibility   = Windows.Visibility.Visible,
                TextWrapping = TextWrapping.Wrap,
                TextTrimming = TextTrimming.CharacterEllipsis
            };
            DockPanel dock = new DockPanel()
            {
                Visibility    = Windows.Visibility.Visible,
                LastChildFill = true,
                Margin        = new Thickness(3, 0, 3, 0)
            };

            title.SetValue(DockPanel.DockProperty, Dock.Top);
            dock.Children.Add(title);
            dock.Children.Add(descrip);
            this.HelpText = new Border()
            {
                Visibility      = Windows.Visibility.Visible,
                BorderBrush     = SystemColors.ActiveBorderBrush,
                Background      = SystemColors.ControlBrush,
                BorderThickness = new Thickness(1),
                Child           = dock
            };
            this.Splitter = new GridSplitter()
            {
                Visibility          = Windows.Visibility.Visible,
                ResizeDirection     = GridResizeDirection.Rows,
                Height              = 5,
                HorizontalAlignment = Windows.HorizontalAlignment.Stretch
            };

            var inspector = Designer.PropertyInspectorView;

            inspector.Visibility = Visibility.Visible;
            inspector.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Stretch);

            this.Splitter.SetValue(Grid.RowProperty, 1);
            this.Splitter.SetValue(Grid.ColumnProperty, 0);

            this.HelpText.SetValue(Grid.RowProperty, 2);
            this.HelpText.SetValue(Grid.ColumnProperty, 0);

            Binding binding = new Binding("Parent.Background");

            title.SetBinding(BackgroundProperty, binding);
            descrip.SetBinding(BackgroundProperty, binding);

            this.Children.Add(inspector);
            this.Children.Add(this.Splitter);
            this.Children.Add(this.HelpText);

            Type inspectorType = inspector.GetType();
            var  props         = inspectorType.GetProperties(Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                             Reflection.BindingFlags.DeclaredOnly);

            var methods = inspectorType.GetMethods(Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                   Reflection.BindingFlags.DeclaredOnly);

            this.RefreshMethod = inspectorType.GetMethod("RefreshPropertyList",
                                                         Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance | Reflection.BindingFlags.DeclaredOnly);
            this.IsInAlphaViewMethod = inspectorType.GetMethod("set_IsInAlphaView",
                                                               Reflection.BindingFlags.Public | Reflection.BindingFlags.Instance | Reflection.BindingFlags.DeclaredOnly);
            this.OnSelectionChangedMethod = inspectorType.GetMethod("OnSelectionChanged",
                                                                    Reflection.BindingFlags.Public | Reflection.BindingFlags.Instance | Reflection.BindingFlags.DeclaredOnly);
            this.SelectionTypeLabel = inspectorType.GetMethod("get_SelectionTypeLabel",
                                                              Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                              Reflection.BindingFlags.DeclaredOnly).Invoke(inspector, new object[0]) as TextBlock;
            this.PropertyToolBar = inspectorType.GetMethod("get_PropertyToolBar",
                                                           Reflection.BindingFlags.Public | Reflection.BindingFlags.NonPublic | Reflection.BindingFlags.Instance |
                                                           Reflection.BindingFlags.DeclaredOnly).Invoke(inspector, new object[0]) as Control;
            inspectorType.GetEvent("GotFocus").AddEventHandler(this,
                                                               Delegate.CreateDelegate(typeof(RoutedEventHandler), this, "GotFocusHandler", false));

            this.SelectionTypeLabel.Text = string.Empty;
        }