public SettingsGridLengthCache( Settings settings, string key, string defaultValue ) { this.settings = settings; this.key = key; string text = this.settings[this.key]; if (string.IsNullOrWhiteSpace(text)) { text = defaultValue; } GridLengthConverter converter = new GridLengthConverter(); GridLength original = (GridLength)converter.ConvertFromInvariantString(defaultValue); bool success = false; try { this.cache = (GridLength)converter.ConvertFromInvariantString(text); if (this.cache.GridUnitType != original.GridUnitType) { this.cache = original; } success = true; } catch (NotSupportedException) { } catch (FormatException) { } if (!success) { this.cache = original; } }
Grid BaseSetupRelationGrid() { var converter = new GridLengthConverter(); Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); for (int i = 0; i < CURRENTDISPLAYEDRELATION.Count; i++) { RowDefinition r = new RowDefinition(); r.Height = (GridLength)converter.ConvertFromString("30"); grid.RowDefinitions.Add(r); } grid.RowDefinitions.Add(new RowDefinition()); editBtns = new Button[CURRENTDISPLAYEDRELATION.Count]; dltBtns = new Button[CURRENTDISPLAYEDRELATION.Count]; setBtns = new Button[CURRENTDISPLAYEDRELATION.Count]; modBtns = new Dictionary <int, Button[]>(); for (int i = 0; i < 5; ++i) { modBtns.Add(i + 1, new Button[CURRENTDISPLAYEDRELATION.Count]); } stickLabels = new Label[CURRENTDISPLAYEDRELATION.Count]; return(grid); }
/// <summary> /// Turns a string of lengths, such as "3*,Auto,2000" into a set of gridlength. /// </summary> /// <param name="lengths">The string of lengths, separated by commas.</param> /// <returns>A list of GridLengths.</returns> private static List <GridLength> StringLengthsToGridLengths(string lengths) { // Create the list of GridLengths. List <GridLength> gridLengths = new List <GridLength>(); // If the string is null or empty, this is all we can do. if (string.IsNullOrEmpty(lengths)) { return(gridLengths); } // Split the string by comma. string[] theLengths = lengths.Split(','); // Create a grid length converter. GridLengthConverter gridLengthConverter = new GridLengthConverter(); // Use the grid length converter to set each length. foreach (var length in theLengths) { gridLengths.Add((GridLength)gridLengthConverter.ConvertFromString(length)); } // Return the grid lengths. return(gridLengths); }
private GridLengthCollection ParseString(string s, CultureInfo culture) { GridLengthConverter converter = new GridLengthConverter(); IEnumerable <GridLength> lengths = s.Split(',').Select(p => (GridLength)converter.ConvertFromString(p.Trim())); return(new GridLengthCollection(lengths.ToArray())); }
/// <summary> /// Update all child text entry controls so their widths match the largest width of the group /// </summary> /// <param name="panel">The panel containing the text entry controls</param> private void SetWidths(Panel panel) { // Keep track of the maximum width var maxSize = 0d; // For each child... foreach (var child in panel.Children) { // Ignore any non-text entry controls if (!(child is TextEntryControl control)) { continue; } // Find if this value is larger than the other controls maxSize = Math.Max(maxSize, control.Label.RenderSize.Width + control.Label.Margin.Left + control.Label.Margin.Right); } // Create a grid length converter var grindLength = new GridLengthConverter().ConvertFromString(maxSize.ToString()); // For each child... foreach (var child in panel.Children) { // Ignore any non-text entry controls if (!(child is TextEntryControl control)) { continue; } // Set each controls LabelWidth value to the max size control.LabelWidth = (GridLength)grindLength; } }
public LabelSettings(dynamic row) { InitializeComponent(); Item = controller.GetProductById(row.ItemId); bar_code_height.ItemsSource = Enum.GetValues(typeof(CommonFunction.Common.barcodeHeight)); label_sheet_dd.ItemsSource = Enum.GetValues(typeof(CommonFunction.Common.sheetSizes)); // bar_code_height.SelectedItem= (CommonFunction.Common.barcodeHeight)3; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; GridLengthConverter gridLengthConverter = new GridLengthConverter(); Id = row.Id != null? row.Id : null; lebelSettingCode = row.LabelSettingCode; ItemId = row.ItemId != null? row.ItemId:null; // bar_code_height.Text = row.BarCodeHeight; pageLabel.Content = new Bold(new Run("Label Settings (" + Item.ItemName + ")")); chk_print_barcode.IsChecked = row.PrintBarCode; chk_item_detail.IsChecked = row.PrintItemDetail; print_item_code.IsChecked = row.PrintItemCode; //print_unit_measure.Text = row.PrintUnitMeasure; lb_print_bc.Content = Item.BarCode; lb_print_Id.Content = Item.ItemName; lb_print_price.Content = Item.RetailPrice; print_item_price.IsChecked = row.PrintItemPrice; tb_no_of_prints.Text = row.TotalNoOfPrints; nud_start_column.Value = row.StartColumn == null?0: Convert.ToDouble(row.StartColumn); nud_start_row.Value = row.StartRow == null?0: Convert.ToDouble(row.StartRow); }
/// <summary> /// Функция динамического создания и добавления ячеек сетки /// </summary> /// <param name="amountRows">Размер поля</param> public void gridAddRows(int amountRows) { //Очистка сетки saperGrid.Children.Clear(); saperGrid.RowDefinitions.Clear(); saperGrid.ColumnDefinitions.Clear(); for (int i = 0; i < amountRows; i++) { var converter = new GridLengthConverter(); //Конвертер для преобразования строки в разметку RowDefinition row = new RowDefinition(); //Переменная текущего добавляемого столбца ColumnDefinition col = new ColumnDefinition(); row.Name = "row" + i.ToString(); row.Height = new GridLength(1.0, GridUnitType.Star); //Соотношение столбцов row.Height = (GridLength)converter.ConvertFromString("*"); //Размер столбца col.Name = "col" + i.ToString(); col.Width = new GridLength(1.0, GridUnitType.Star); col.Width = (GridLength)converter.ConvertFromString("*"); saperGrid.RowDefinitions.Add(row); //Добавление строки к сетке saperGrid.ColumnDefinitions.Add(col); //Добавление столбца к сетке } }
private void MainCanvas_SizeChanged(object sender, SizeChangedEventArgs e) { GridLengthConverter c = new GridLengthConverter(); DynamicCfg.Ins.MainCanvasHeight = (c.ConvertToString(new GridLength(mainGridRow.ActualHeight, GridUnitType.Pixel))); //AppCfg.Ins.SubCanvasHeight = c.ConvertToString(new GridLength(subGridRow.ActualHeight, GridUnitType.Star)); }
private static void OnStructureChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is Grid grid) { var converter = new GridLengthConverter(); grid.RowDefinitions.Clear(); grid.ColumnDefinitions.Clear(); if (e.NewValue is string structureString) { var rowsAndColumns = structureString.Split('|'); if (rowsAndColumns.Length == 2) { var rows = rowsAndColumns[0].Split(','); foreach (var row in rows) { grid.RowDefinitions.Add(new RowDefinition { Height = (GridLength)converter.ConvertFromString(row) }); } var columns = rowsAndColumns[1].Split(','); foreach (var column in columns) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = (GridLength)converter.ConvertFromString(column) }); } } } } }
private static GridLengthCollection ParseString(string s) { var converter = new GridLengthConverter(); var lengths = s.Split(',').Select(p => (GridLength)converter.ConvertFromString(p.Trim())); return(new GridLengthCollection(lengths)); }
public void SwitchCubeView(bool switchView) { GridLengthConverter myGridLengthConverter = new GridLengthConverter(); if (!switchView) { GridLength col0Length = (GridLength)myGridLengthConverter.ConvertFromString("1*"); GridLength col1Length = (GridLength)myGridLengthConverter.ConvertFromString("0"); if (col0 != null) { Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate { col0.Width = col0Length; }, null); } if (col1 != null) { Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate { col1.Width = col1Length; }, null); } if (colm != null) { Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate { colm.Width = col1Length; }, null); } } else { GridLength colLength = (GridLength)myGridLengthConverter.ConvertFromString("1*"); //GridLength colmLength = (GridLength)myGridLengthConverter.ConvertFromString("5"); GridLength col0Length = (GridLength)myGridLengthConverter.ConvertFromString("0"); if (col0 != null) { Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate { col0.Width = col0Length; }, null); } if (col1 != null) { Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate { col1.Width = colLength; }, null); } /*if (colm != null) * Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate * { * colm.Width = colmLength; * }, null); */ } }
private void LocalMenu_OnItemClicked(string ActionType) { switch (ActionType) { case "ChartSettings": CWChartSettings cwChartSettingDialog = new CWChartSettings(pivotDgProjectPlanning.ChartSelectionOnly, pivotDgProjectPlanning.ChartProvideColumnGrandTotals, pivotDgProjectPlanning.ChartProvideRowGrandTotals, labelVisibility, seriesIndex, pivotDgProjectPlanning.ChartProvideDataByColumns, chartEnable); cwChartSettingDialog.Closed += delegate { if (cwChartSettingDialog.DialogResult == true) { if (cwChartSettingDialog.IsChartVisible) { chartControl.Diagram = cwChartSettingDialog.ChartDaigram; pivotDgProjectPlanning.ChartProvideEmptyCells = IsPivotTableProvideEmptyCells(); chartControl.Diagram.SeriesTemplate.LabelsVisibility = cwChartSettingDialog.labelVisibility; chartControl.CrosshairEnabled = cwChartSettingDialog.crossHairEnabled; pivotDgProjectPlanning.ChartProvideDataByColumns = cwChartSettingDialog.chartProvideDataByColumns; pivotDgProjectPlanning.ChartSelectionOnly = cwChartSettingDialog.ChartSelectionOnly; pivotDgProjectPlanning.ChartProvideColumnGrandTotals = cwChartSettingDialog.ChartProvideColumnGrandTotals; pivotDgProjectPlanning.ChartProvideRowGrandTotals = cwChartSettingDialog.ChartProvideRowGrandTotals; seriesIndex = cwChartSettingDialog.SeriesIndex; chartControl.Visibility = Visibility.Visible; if (rowgridSplitter.Height.Value == 0 && rowChartControl.Height.Value == 0) { rowgridSplitter.Height = new GridLength(5); var converter = new GridLengthConverter(); rowChartControl.Height = (GridLength)converter.ConvertFrom("Auto"); } } else { chartControl.Visibility = Visibility.Collapsed; rowgridSplitter.Height = new GridLength(0); rowChartControl.Height = new GridLength(0); } chartEnable = cwChartSettingDialog.IsChartVisible; labelVisibility = cwChartSettingDialog.labelVisibility; } }; cwChartSettingDialog.Show(); break; case "ImportPivotTableLayout": controlRibbon_BaseActions(ActionType); if (chartControl.Diagram != null) { chartControl.Visibility = Visibility.Visible; labelVisibility = chartControl.Diagram.SeriesTemplate.LabelsVisibility; seriesIndex = GetSeriesId(); } break; default: controlRibbon_BaseActions(ActionType); break; } }
public void SaveRowDefinitions(RowDefinition topRowDefinition, RowDefinition splitterRowDefinition, RowDefinition bottomRowDefinition) { GridLengthConverter converter = new GridLengthConverter(); this.TopRowDefinitionHeight = converter.ConvertToString(topRowDefinition.Height); this.SplitterRowDefinitionHeight = converter.ConvertToString(splitterRowDefinition.Height); this.BottomRowDefinitionHeight = converter.ConvertToString(bottomRowDefinition.Height); }
public void LoadRowDefinitions(RowDefinition topRowDefinition, RowDefinition splitterRowDefinition, RowDefinition bottomRowDefinition) { GridLengthConverter converter = new GridLengthConverter(); topRowDefinition.Height = (GridLength)converter.ConvertFromString(this.TopRowDefinitionHeight); splitterRowDefinition.Height = (GridLength)converter.ConvertFromString(this.SplitterRowDefinitionHeight); bottomRowDefinition.Height = (GridLength)converter.ConvertFromString(this.BottomRowDefinitionHeight); }
public void ConvertToTest() { var converter = new GridLengthConverter(); Assert.AreEqual("Auto", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.0, GridUnitType.Auto), typeof(string))); Assert.AreEqual("*", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.0, GridUnitType.Star), typeof(string))); Assert.AreEqual("1.5*", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.5, GridUnitType.Star), typeof(string))); Assert.AreEqual("100", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(100, GridUnitType.Pixel), typeof(string))); }
public MatchView() { InitializeComponent(); Events = IoC.Get <IEventAggregator>(); Manager = IoC.Get <IMatchManager>(); gridLengthConverter = new GridLengthConverter(); Events.Subscribe(this); }
public void CanConvertFromTest() { var converter = new GridLengthConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsTrue(converter.CanConvertFrom(typeof(int))); Assert.IsTrue(converter.CanConvertFrom(typeof(double))); Assert.IsFalse(converter.CanConvertFrom(typeof(object))); Assert.IsFalse(converter.CanConvertFrom(typeof(GridLength))); }
/// <summary> /// Добавление разделителей в столбец /// </summary> /// <param name="grid">карта</param> /// <param name="len">длина</param> public static void CreateColDef(Grid grid, string len) { var miniConverter = new GridLengthConverter(); ColumnDefinition miniCol = new ColumnDefinition(); miniCol.Width = new GridLength(1.0, GridUnitType.Star); miniCol.Width = (GridLength)miniConverter.ConvertFromString(len); grid.ColumnDefinitions.Add(miniCol); }
/// <summary> /// /// </summary> /// <param name="leftColumnDefinition"></param> /// <param name="splitterColumnDefinition"></param> /// <param name="rightColumnDefinition"></param> public void SaveColumnDefinitions(ColumnDefinition leftColumnDefinition, ColumnDefinition splitterColumnDefinition, ColumnDefinition rightColumnDefinition) { var converter = new GridLengthConverter(); LeftColumnDefinitionHeight = converter.ConvertToString(leftColumnDefinition.Width); SplitterColumnDefinitionHeight = converter.ConvertToString(splitterColumnDefinition.Width); RightColumnDefinitionHeight = converter.ConvertToString(rightColumnDefinition.Width); }
/// <summary> /// Добавление разделителей в строку /// </summary> /// <param name="grid">карта</param> /// <param name="len">длина</param> public static void CreateRowDef(Grid grid, string len) { var miniConverter = new GridLengthConverter(); RowDefinition miniRow = new RowDefinition(); miniRow.Height = new GridLength(1.0, GridUnitType.Star); miniRow.Height = (GridLength)miniConverter.ConvertFromString(len); grid.RowDefinitions.Add(miniRow); }
private void Default_Click(object sender, RoutedEventArgs e) { Grid.SetColumnSpan(stackList, 1); Grid.SetColumnSpan(stackPlayer, 1); Grid.SetColumn(stackPlayer, 2); Grid.SetRow(stackPlayer, 1); var converter = new GridLengthConverter(); row2.Height = (GridLength)converter.ConvertFromString("*"); row3.Height = (GridLength)converter.ConvertFromString("0"); }
static GridUnitExtension() { _dipMultiplier = DipHelper.GetDipMultiplier(); _thicknessConverter = new ThicknessConverter(); _cornerRadiusConverter = new CornerRadiusConverter(); _sizeConverter = new SizeConverter(); _pointConverter = new PointConverter(); _rectConverter = new RectConverter(); _gridLengthConverter = new GridLengthConverter(); }
private static GridLength ConvertToGridLength(string str) { var result = GridLengthConverter.ConvertFromInvariantString(str); if (result != null) { return((GridLength)result); } throw new DockException("Could not deserialize attribute of type GridLength."); }
/// <summary> /// /// </summary> /// <param name="leftColumnDefinition"></param> /// <param name="splitterColumnDefinition"></param> /// <param name="rightColumnDefinition"></param> public void LoadColumnDefinitions(ColumnDefinition leftColumnDefinition, ColumnDefinition splitterColumnDefinition, ColumnDefinition rightColumnDefinition) { var converter = new GridLengthConverter(); // ReSharper disable PossibleNullReferenceException leftColumnDefinition.Width = (GridLength)converter.ConvertFromString(LeftColumnDefinitionHeight); splitterColumnDefinition.Width = (GridLength)converter.ConvertFromString(SplitterColumnDefinitionHeight); rightColumnDefinition.Width = (GridLength)converter.ConvertFromString(RightColumnDefinitionHeight); // ReSharper restore PossibleNullReferenceException }
private void Horizontal_Click(object sender, RoutedEventArgs e) { Grid.SetColumnSpan(stackList, 3); Grid.SetColumnSpan(stackPlayer, 3); Grid.SetColumn(stackPlayer, 0); Grid.SetRow(stackPlayer, 2); var converter = new GridLengthConverter(); row2.Height = (GridLength)converter.ConvertFromString("auto"); row3.Height = (GridLength)converter.ConvertFromString("*"); }
public TagGraphCanvas() { InitializeComponent(); fileWather = new FileWatcherSafe(FileChanged_BackThread); MainCanvas.SelectedTagChanged += MainCanvasSelectedTagChanged_Callback; SubCanvas.SelectedTagChanged += SubCanvasSelectedTagChanged_Callback; GridLengthConverter c = new GridLengthConverter(); mainGridRow.Height = (GridLength)c.ConvertFromString(DynamicCfg.Ins.MainCanvasHeight); //subGridRow.Height = (GridLength)c.ConvertFromString(AppCfg.Ins.SubCanvasHeight); }
/// <summary> /// Генерация поля для игры в зависимости от выбранного размера /// </summary> /// <param name="size">размер поля</param> private void CreateGrid(int size) { sec = 0; min = 0; hours = 0; timer.Start(); setFlagsCount = 0; buttonMatrix = new Button[size, size]; gameGrid.RowDefinitions.Clear(); gameGrid.ColumnDefinitions.Clear(); gameGrid.Children.Clear(); for (int i = 0; i < size; i++) { var converter = new GridLengthConverter(); RowDefinition row = new RowDefinition(); row.Name = "row" + i.ToString(); row.Height = new GridLength(1.0, GridUnitType.Star); row.Height = (GridLength)converter.ConvertFromString("*"); ColumnDefinition col = new ColumnDefinition(); col.Name = "col" + i.ToString(); col.Width = new GridLength(1.0, GridUnitType.Star); col.Width = (GridLength)converter.ConvertFromString("*"); gameGrid.RowDefinitions.Add(row); gameGrid.ColumnDefinitions.Add(col); } for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button button = new Button(); button.Click += FindBombBtnClick; button.MouseRightButtonDown += AddFlagButton; button.Name = "btn_" + (i + 1).ToString() + "_" + (j + 1).ToString(); button.Background = new SolidColorBrush(Colors.Gray); button.FontSize = 13; button.Foreground = new SolidColorBrush(Colors.Black); button.FontWeight = FontWeights.Bold; gameGrid.Children.Add(button); Grid.SetRow(button, i); Grid.SetColumn(button, j); buttonMatrix[i, j] = button; } } }
private void InitializeChessboard(int[,] chessBoard) { LayoutRoot.Children.Clear(); GridLengthConverter myGridLengthConverter = new GridLengthConverter(); GridLength side = (GridLength)myGridLengthConverter.ConvertFromString("Auto"); for (int i = 0; i < hetmanNumber; i++) { LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition()); LayoutRoot.ColumnDefinitions[i].Width = side; LayoutRoot.RowDefinitions.Add(new RowDefinition()); LayoutRoot.RowDefinitions[i].Height = side; } Rectangle[,] square = new Rectangle[hetmanNumber, hetmanNumber]; for (int row = 0; row < hetmanNumber; row++) { for (int col = 0; col < hetmanNumber; col++) { square[row, col] = new Rectangle(); square[row, col].Height = 800 / hetmanNumber; square[row, col].Width = 800 / hetmanNumber; Grid.SetColumn(square[row, col], col); Grid.SetRow(square[row, col], row); if ((row + col) % 2 == 0) { square[row, col].Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 255, 255)); if (chessBoard[row, col] == 2) { square[row, col].Fill = new ImageBrush { ImageSource = new BitmapImage(new Uri("..\\..\\..\\indeks.png", UriKind.Relative)) }; } } else { square[row, col].Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)); if (chessBoard[row, col] == 2) { square[row, col].Fill = new ImageBrush { ImageSource = new BitmapImage(new Uri("..\\..\\..\\indeks_black.png", UriKind.Relative)) }; } } LayoutRoot.Children.Add(square[row, col]); } } }
public void SetUpGrid() { var converter = new GridLengthConverter(); for (int i = 0; i < 4; i++) { var row = new RowDefinition { Height = (GridLength)converter.ConvertFromString("*") }; SlideChoiceGrid.RowDefinitions.Add(row); } }
// --------------- UI event handlers --------------- private void Window_closing(object sender, EventArgs e) { GridLengthConverter converter = new GridLengthConverter(); // write peristent settings ExplorerSettings settings = new ExplorerSettings(); settings.windowWidth = (int)Width; settings.windowHeight = (int)Height; settings.splitterPosition = Convert.ToInt32(leftColumn.Width.Value); settings.localDirectory = pcdirectory == null ? "Computer" : pcdirectory.FullName; settings.onlyShowPrograms = (bool)OnlyShowPrograms.IsChecked; settings.Save(); }
public void StartTime(TimerData CurrentData) { try { mCurrentData = CurrentData; //Set Colors this.TimerGrid.Background = new SolidColorBrush(Color.FromArgb(CurrentData.BackgroundColor.A, CurrentData.BackgroundColor.R, CurrentData.BackgroundColor.G, CurrentData.BackgroundColor.B)); this.Hours.Foreground = new SolidColorBrush(Color.FromArgb(CurrentData.ForegroundColor.A, CurrentData.ForegroundColor.R, CurrentData.ForegroundColor.G, CurrentData.ForegroundColor.B)); this.Minutes.Foreground = new SolidColorBrush(Color.FromArgb(CurrentData.ForegroundColor.A, CurrentData.ForegroundColor.R, CurrentData.ForegroundColor.G, CurrentData.ForegroundColor.B)); this.Seconds.Foreground = new SolidColorBrush(Color.FromArgb(CurrentData.ForegroundColor.A, CurrentData.ForegroundColor.R, CurrentData.ForegroundColor.G, CurrentData.ForegroundColor.B)); //Set Font this.Hours.FontFamily = new FontFamily(mCurrentData.TimerFont.Name); this.Minutes.FontFamily = new FontFamily(mCurrentData.TimerFont.Name); this.Minutes.Text = mCurrentData.Minutes.ToString("00:"); this.Seconds.FontFamily = new FontFamily(mCurrentData.TimerFont.Name); this.Seconds.Text = mCurrentData.Seconds.ToString("00"); //Reset Column Width GridLengthConverter myGridLengthConverter = new GridLengthConverter(); GridLength gl = (GridLength)myGridLengthConverter.ConvertFromString("*"); this.HourColumn.Width = gl; this.SecondsColumn.Width = gl; if (mCurrentData.FullScreen == true) { this.WindowStyle = System.Windows.WindowStyle.None; this.WindowState = System.Windows.WindowState.Maximized; } else { this.WindowStyle = System.Windows.WindowStyle.ToolWindow; } this.Cursor = Cursors.None; DisplayTime(); } catch (Exception ex) { LogException(ex); } }
public void changeCol(object sender, SelectionChangedEventArgs args) { ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem); GridLengthConverter myGridLengthConverter = new GridLengthConverter(); if (hs1.Value == 0) { GridLength gl1 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString()); col1.Width = gl1; } else if (hs1.Value == 1) { GridLength gl2 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString()); col2.Width = gl2; } else if (hs1.Value == 2) { GridLength gl3 = (GridLength)myGridLengthConverter.ConvertFromString(li.Content.ToString()); col3.Width = gl3; } }
public void changeRow(object sender, SelectionChangedEventArgs args) { ListBoxItem li2 = ((sender as ListBox).SelectedItem as ListBoxItem); GridLengthConverter myGridLengthConverter2 = new GridLengthConverter(); if (hs2.Value == 0) { GridLength gl4 = (GridLength)myGridLengthConverter2.ConvertFromString(li2.Content.ToString()); row1.Height = gl4; } else if (hs2.Value == 1) { GridLength gl5 = (GridLength)myGridLengthConverter2.ConvertFromString(li2.Content.ToString()); row2.Height = gl5; } else if (hs2.Value == 2) { GridLength gl6 = (GridLength)myGridLengthConverter2.ConvertFromString(li2.Content.ToString()); row3.Height = gl6; } }
public UIElement Render(int index) { GridLengthConverter myGridLengthConverter = new GridLengthConverter(); GridLength gl1 = (GridLength)myGridLengthConverter.ConvertFrom("372"); var container = new Grid(); container.Name = "container"; var colDef = new ColumnDefinition(); var colDefSecond = new ColumnDefinition(); container.HorizontalAlignment = HorizontalAlignment.Center; //container.VerticalAlignment = VerticalAlignment.Stretch; //container.Width = 380; container.ColumnDefinitions.Add(colDef); container.ColumnDefinitions[0].Width = gl1; //creating the TextBox for the Text of the Todo var textTextBox = new TextBlock(); textTextBox.Width = 400; textTextBox.Padding = new Thickness(0); textTextBox.Text = this.Text; textTextBox.FontWeight = FontWeights.Bold; textTextBox.Foreground = Brushes.LightGray; //textTextBox.Background = Brushes.White; textTextBox.Background = new SolidColorBrush(Color.FromArgb(255, 28, 102, 126)); textTextBox.FontSize = 12; container.Children.Add(textTextBox); //creating the Delete button var deleteButton = new Button(); deleteButton.Content = "X"; deleteButton.Width = 20; deleteButton.Height = 20; deleteButton.DataContext = index; deleteButton.HorizontalAlignment = HorizontalAlignment.Right; container.Children.Add(deleteButton); return container; }
private void CreateTableDataEnvironment () { GridLengthConverter GLConverter = new GridLengthConverter (); SelectionDataGrid = new DataGrid (); TableDataGrid.Children.Add (SelectionDataGrid); Grid.SetColumn (SelectionDataGrid, 0); SelectionDataGrid.ContextMenu = new System.Windows.Controls.ContextMenu (); if (NameScope.GetNameScope (TableDataGrid) != null) if (NameScope.GetNameScope (TableDataGrid).FindName ("SelectionDataGrid") != null) TableDataGrid.UnregisterName ("SelectionDataGrid"); TableDataGrid.RegisterName ("SelectionDataGrid", SelectionDataGrid); if (NameScope.GetNameScope (TableDataGrid) != null) if (NameScope.GetNameScope (TableDataGrid).FindName ("StandardContext") != null) TableDataGrid.UnregisterName ("StandardContext"); TableDataGrid.RegisterName ("StandardContext", SelectionDataGrid.ContextMenu); SelectionDataGrid.ContextMenu.CustomPopupPlacementCallback = new CustomPopupPlacementCallback (CustomPopupPlacementCallbackHandler); SelectionDataGrid.ContextMenu.Placement = PlacementMode.Custom; SelectionDataGrid.SelectionChanged += new SelectionChangedEventHandler (SelectionDataGrid_SelectionChanged); SelectionDataGrid.ContextMenuOpening += new ContextMenuEventHandler (ContextMenu_ContextMenuOpening); SelectionDataGrid.CanUserAddRows = false; SelectionDataGrid.CanUserDeleteRows = false; SelectionDataGrid.CanUserResizeRows = true; SelectionDataGrid.CanUserResizeColumns = true; //SelectionDataGrid.HorizontalContentAlignment = HorizontalAlignment.Stretch; //SelectionDataGrid.VerticalContentAlignment = VerticalAlignment.Stretch; SelectionDataGrid.ColumnWidth = DataGridLength.SizeToCells; SelectionDataGrid.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected; //SelectionDataGrid.SelectionMode = DataGridSelectionMode.Extended; SelectionDataGrid.MouseDoubleClick += new MouseButtonEventHandler (SelectionDataGrid_MouseDoubleClick); if (AllowDragHandling) { SelectionDataGrid.MouseMove += new MouseEventHandler (SelectionDataGrid_MouseMove); SelectionDataGrid.MouseLeftButtonDown += new MouseButtonEventHandler (SelectionDataGrid_MouseLeftButtonDown); } if (AllowDropHandling) { SelectionDataGrid.Drop += new DragEventHandler (SelectionDataGrid_Drop); SelectionDataGrid.DragEnter += new DragEventHandler (SelectionDataGrid_DragEnter); SelectionDataGrid.DragLeave += new DragEventHandler (SelectionDataGrid_DragLeave); SelectionDataGrid.AllowDrop = true; } ProcessTableData = true; }
private void resizeWindow(int numOfCpus) { var converter = new GridLengthConverter(); RowDefinition rowNum = (RowDefinition) this.FindName("cpuRow" + (numOfCpus + 2).ToString()); rowNum.Height = (GridLength)converter.ConvertFromString("300"); //rowNum.SetValue(HeightProperty, (GridLength)converter.ConvertFromString("300")); //cpuRow6.Height = (GridLength)converter.ConvertFromString("300"); cpuTabControl.SetValue(Grid.RowProperty, numOfCpus + 2); /*if (CPU1Temp.Content.ToString() == "" || CPU2Temp.Content.ToString() == "" || CPU3Temp.Content.ToString() == "" || CPU4Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 240; //MainTabControl.Height = 185; } else if (CPU5Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 285; //MainTabControl.Height = 230; } else if (CPU6Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 330; //MainTabControl.Height = 275; } else if (CPU7Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 375; //MainTabControl.Height = 320; } else if (CPU8Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 420; //MainTabControl.Height = 365; } else if (CPU9Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 465; //MainTabControl.Height = 410; } else if (CPU10Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 510; //MainTabControl.Height = 455; } else if (CPU11Temp.Content.ToString() == "") { Application.Current.MainWindow.Height = 555; //MainTabControl.Height = 500; }*/ }
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); }
void FillTimeControl (Grid TimeControlGrid, Grid BookingControlGrid, DataRow RessourceRow) { String BookingGroup = RessourceRow ["BookingGroup"].ToString (); DataSet BookingGroupDataSet = m_DataBase.GetCommonDataSet ("Select * from BookableUnitsHandlingRules where NameID = '" + BookingGroup + "'"); String TimingTyp = BookingGroupDataSet.Tables ["BookableUnitsHandlingRules"].Rows [0] ["TimingTyp"].ToString (); DataSet TimingEntriesDataSet = m_DataBase.GetCommonDataSet ("Select * from TimeTable where TimingTyp = '" + TimingTyp + "' order by DisplayInColumnOrder"); String MainAdresse = RessourceRow ["MainAdresse"].ToString (); DataSet ActuallBookableUnits = m_DataBase.GetCommonDataSet ("Select * from Ressource where MainAdresse = '" + MainAdresse + "' and BookingGroup = '" + BookingGroup + "' order by Adresse"); List<String> RessourcesToSelect = new List<string> (); foreach (DataRow SelectionRow in ActuallBookableUnits.Tables ["Ressource"].Rows) { RessourcesToSelect.Add (SelectionRow ["ID"].ToString ()); } String WhereClause = "where ((RessourceID = '" + String.Join ("') or (RessourceID = '", RessourcesToSelect.ToArray ()) + "')) "; DataSet GeneratedBookableUnits = m_DataBase.GetCommonDataSet ("Select * from BookableUnits " + WhereClause); DataSet TodaysBookings = m_DataBase.GetCommonDataSet ("Select * from Booking where BookedFor = '" + DayToDisplay.ToString (CVM.CommonValues.ISO_DATE_TIME_FORMAT) + "'"); Grid BookingHeadFrameGrid = new Grid (); GridLengthConverter GLConverter = new GridLengthConverter (); BrushConverter BRConverter = new BrushConverter (); ColumnDefinition BookableRessourceColumn = new ColumnDefinition (); BookableRessourceColumn.Width = (GridLength)GLConverter.ConvertFromString ("15*"); RowDefinition BookableHeadRow = new RowDefinition (); BookableHeadRow.Height = (GridLength)GLConverter.ConvertFromString ("10*"); BookingHeadFrameGrid.RowDefinitions.Add (BookableHeadRow); int RowIndex = 1; BookingHeadFrameGrid.ColumnDefinitions.Add (BookableRessourceColumn); int ColumnIndex = 1; foreach (DataRow TimeTableRow in TimingEntriesDataSet.Tables ["TimeTable"].Rows) { ColumnDefinition TimeTableHeadCol = new ColumnDefinition (); TimeTableHeadCol.Width = (GridLength) GLConverter.ConvertFromString (TimeTableRow ["ColumnWidthXAMLString"].ToString ()); BookingHeadFrameGrid.ColumnDefinitions.Add (TimeTableHeadCol); Button TimeTableButton = new Button (); BookingHeadFrameGrid.Children.Add (TimeTableButton); Grid.SetColumn (TimeTableButton, ColumnIndex++); TimeTableButton.Content = TimeTableRow ["HeadLine"].ToString (); } TimeControlGrid.Children.Add (BookingHeadFrameGrid); ColumnIndex = 1; Grid BookingBodyFrameGrid = new Grid (); foreach (ColumnDefinition HeadCol in BookingHeadFrameGrid.ColumnDefinitions) { ColumnDefinition TimeTableBodyCol = new ColumnDefinition (); TimeTableBodyCol.Width = HeadCol.Width; BookingBodyFrameGrid.ColumnDefinitions.Add (TimeTableBodyCol); } RowIndex = 0; RoutedEventHandler EntryHandler = new RoutedEventHandler (EntryButton_Click); foreach (DataRow BookingUnitRow in ActuallBookableUnits.Tables ["Ressource"].Rows) { String RessourceID = BookingUnitRow ["ID"].ToString (); RowDefinition BookableRessourceRow = new RowDefinition (); BookableRessourceRow.Height = (GridLength)GLConverter.ConvertFromString ("10*"); BookableRessourceRow.MinHeight = 40; BookableRessourceRow.MaxHeight = 40; BookingBodyFrameGrid.RowDefinitions.Add (BookableRessourceRow); Grid SubGrid = m_XAML.CreateGrid (new int[] {5, 2}, new int[] {1}); Grid.SetRow (SubGrid, RowIndex++); Grid.SetColumn (SubGrid, 0); BookingBodyFrameGrid.Children.Add (SubGrid); Button RessourcenButton = new Button (); SubGrid.Children.Add (RessourcenButton); Grid.SetRow (RessourcenButton, 0); Grid.SetColumn (RessourcenButton, 0); RessourcenButton.Content = BookingUnitRow ["NameID"].ToString (); Button RessourcenShortButton = new Button (); SubGrid.Children.Add (RessourcenShortButton); Grid.SetRow (RessourcenShortButton, 0); Grid.SetColumn (RessourcenShortButton, 1); RessourcenShortButton.FontSize = 25; RessourcenShortButton.FontWeight = FontWeights.ExtraBold; RessourcenShortButton.Foreground = (Brush)BRConverter.ConvertFromString ("Black"); RessourcenShortButton.Background = (Brush)BRConverter.ConvertFromString ("#C0C0C0"); RessourcenShortButton.Content = BookingUnitRow ["Adresse"].ToString (); int TimingIndex = 1; foreach (DataRow TimeTableRow in TimingEntriesDataSet.Tables ["TimeTable"].Rows) { String TimeTableID = TimeTableRow ["ID"].ToString (); Button EntryButton = new Button (); EntryButton.Click += EntryHandler; EntryButton.Content = String.Empty; EntryButton.FontSize = 20; EntryButton.FontWeight = FontWeights.ExtraBold; EntryButton.Foreground = (Brush)BRConverter.ConvertFromString ("Red"); EntryButton.Background = (Brush)BRConverter.ConvertFromString ("#C0C0C0"); EntryButton.MouseRightButtonUp += new MouseButtonEventHandler (EntryButton_MouseRightButtonUp); BookingBodyFrameGrid.Children.Add (EntryButton); Grid.SetRow (EntryButton, RowIndex - 1); Grid.SetColumn (EntryButton, TimingIndex++); DataRow [] BookableUnits = GeneratedBookableUnits.Tables ["BookableUnits"].Select (String.Format ("RessourceID = '{0}' and TimeTableID = '{1}'", RessourceID, TimeTableID)); if (BookableUnits.Length != 1) throw new Exception ("Fehlerhafte BookableUnits"); EntryButton.Tag = BookableUnits [0] ["ID"].ToString () + ";" + DayToDisplay.ToString (CVM.CommonValues.ISO_DATE_TIME_FORMAT); EntryButton.Content = GetBooking (TodaysBookings, BookableUnits [0] ["ID"].ToString (), DayToDisplay); } } BookingControlGrid.Children.Add (BookingBodyFrameGrid); }
private static IEnumerable<GridLength> GridLengths(string s) { GridLengthConverter converter = new GridLengthConverter(); return s.Split(',').Select(i => converter.ConvertFromString(i)).OfType<GridLength>(); }
private TextBox [] CreateTwoSubLines (CVM.TableLayoutDefinition ContentInstance, PropertyInfo PropInfo, RowDefinition MainRow, Grid SubGrid, String [] Labels, FieldInfo HelpField) { GridLengthConverter GLConverter = new GridLengthConverter (); MainRow.Height = (GridLength)GLConverter.ConvertFromString ("3*"); MainRow.MinHeight = 60; SubGrid.RowDefinitions.Add (new RowDefinition ()); SubGrid.RowDefinitions [1].Height = (GridLength)GLConverter.ConvertFromString ("2*"); Grid SubSubGrid = new Grid (); SubGrid.Children.Add (SubSubGrid); Grid.SetColumn (SubSubGrid, 0); Grid.SetRow (SubSubGrid, 1); Grid.SetColumnSpan (SubSubGrid, 2); SubSubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubSubGrid.ColumnDefinitions [0].Width = (GridLength)GLConverter.ConvertFromString ("*"); SubSubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubSubGrid.ColumnDefinitions [1].Width = (GridLength)GLConverter.ConvertFromString ("5*"); SubSubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubSubGrid.ColumnDefinitions [2].Width = (GridLength)GLConverter.ConvertFromString ("8*"); SubSubGrid.RowDefinitions.Add (new RowDefinition ()); SubSubGrid.RowDefinitions [0].Height = (GridLength)GLConverter.ConvertFromString ("*"); SubSubGrid.RowDefinitions.Add (new RowDefinition ()); SubSubGrid.RowDefinitions [1].Height = (GridLength)GLConverter.ConvertFromString ("*"); Label WidthLabel = new Label (); WidthLabel.Content = Labels [0]; SubSubGrid.Children.Add (WidthLabel); Grid.SetColumn (WidthLabel, 1); Grid.SetRow (WidthLabel, 0); TextBox Value1 = new TextBox (); SubSubGrid.Children.Add (Value1); Grid.SetColumn (Value1, 2); Grid.SetRow (Value1, 0); Label HeightLabel = new Label (); HeightLabel.Content = Labels [1]; SubSubGrid.Children.Add (HeightLabel); Grid.SetColumn (HeightLabel, 1); Grid.SetRow (HeightLabel, 1); TextBox Value2 = new TextBox (); SubSubGrid.Children.Add (Value2); Grid.SetColumn (Value2, 2); Grid.SetRow (Value2, 1); if (HelpField != null) { Value1.ToolTip = (String)HelpField.GetValue (null); Value2.ToolTip = (String)HelpField.GetValue (null); } Object PropertyContent = PropInfo.GetValue (ContentInstance, BindingFlags.GetProperty, null, null, null); Value1.Tag = PropInfo; Value2.Tag = PropInfo; if (PropInfo.PropertyType == typeof (Size)) { Size ContentSize = (Size) PropertyContent; Value1.Text = Convert.ToString (ContentSize.Width); Value1.Name = "Width"; Value2.Text = Convert.ToString (ContentSize.Height); Value2.Name = "Height"; } if (PropInfo.PropertyType == typeof (Point)) { Point ContentPoint = (Point)PropertyContent; Value1.Text = Convert.ToString (ContentPoint.X); Value1.Name = "X"; Value2.Text = Convert.ToString (ContentPoint.Y); Value2.Name = "Y"; } Value1.LostFocus += new RoutedEventHandler (DoubleField_LostFocus); Value2.LostFocus += new RoutedEventHandler (DoubleField_LostFocus); return new TextBox [] { Value1, Value2 }; }
private RadioButton [] CreateBoolLine (CVM.TableLayoutDefinition ContentInstance, PropertyInfo PropInfo, RowDefinition MainRow, Grid SubGrid, String [] Labels, FieldInfo HelpField) { GridLengthConverter GLConverter = new GridLengthConverter (); MainRow.Height = (GridLength)GLConverter.ConvertFromString ("*"); MainRow.MinHeight = 20; Grid SubSubGrid = new Grid (); SubGrid.Children.Add (SubSubGrid); Grid.SetColumn (SubSubGrid, 1); SubSubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubSubGrid.ColumnDefinitions [0].Width = (GridLength)GLConverter.ConvertFromString ("*"); SubSubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubSubGrid.ColumnDefinitions [1].Width = (GridLength)GLConverter.ConvertFromString ("*"); RadioButton Yes = new RadioButton (); Yes.Name = "Yes"; Yes.VerticalAlignment = VerticalAlignment.Center; Yes.Content = Labels [0]; RadioButton No = new RadioButton (); No.Name = "No"; No.VerticalAlignment = VerticalAlignment.Center; No.Content = Labels [1]; SubSubGrid.Children.Add (Yes); Grid.SetColumn (Yes, 0); SubSubGrid.Children.Add (No); Grid.SetColumn (No, 1); if (HelpField != null) { Yes.ToolTip = (String) HelpField.GetValue (null); No.ToolTip = (String) HelpField.GetValue (null); } Object PropertyContent = PropInfo.GetValue (ContentInstance, BindingFlags.GetProperty, null, null, null); Yes.Tag = PropInfo; No.Tag = PropInfo; String BoolValue = Convert.ToString (PropInfo); if (BoolValue == "Ja") { Yes.IsChecked = true; No.IsChecked = false; } else { Yes.IsChecked = false; No.IsChecked = true; } Yes.Checked += new RoutedEventHandler (YesNo_Checked); No.Checked += new RoutedEventHandler (YesNo_Checked); return new RadioButton [] { Yes, No }; }
private TextBox CreateSimpleLine (CVM.TableLayoutDefinition ContentInstance, PropertyInfo PropInfo, RowDefinition MainRow, Grid SubGrid, FieldInfo HelpField) { GridLengthConverter GLConverter = new GridLengthConverter (); MainRow.Height = (GridLength)GLConverter.ConvertFromString ("*"); MainRow.MinHeight = 20; TextBox SimpleContent = new TextBox (); SubGrid.Children.Add (SimpleContent); Grid.SetColumn (SimpleContent, 1); Grid.SetRow (SimpleContent, 0); if (HelpField != null) { SimpleContent.ToolTip = (String)HelpField.GetValue (null); } Binding SimpleBinding = new Binding(PropInfo.Name); SimpleBinding.Source = ContentInstance; SimpleContent.SetBinding (TextBox.TextProperty, SimpleBinding); SimpleContent.Tag = PropInfo; return SimpleContent; }
private void CreateControlContentForSingleEntry (CVM.TableLayoutDefinition ContentInstance, System.Type ContentClass, Grid Parent) { Parent.Children.Clear (); Parent.RowDefinitions.Clear (); Parent.ColumnDefinitions.Clear (); PropertyInfo [] Properties = ContentClass.GetProperties (); GridLengthConverter GLConverter = new GridLengthConverter (); int RowIndex = 0; foreach (PropertyInfo PropInfo in Properties) { String LabePropertyName = PropInfo.Name; String OptionStringName = LabePropertyName + "_Option"; FieldInfo OptionField = (FieldInfo)ContentClass.GetField (OptionStringName); String Options; if (OptionField != null) { Options = (String)OptionField.GetValue (ContentInstance); if (Options.IndexOf ("NoUpdate") != -1) continue; } String HelpStringName = LabePropertyName + "_Help"; FieldInfo HelpField = (FieldInfo) ContentClass.GetField (HelpStringName); RowDefinition MainRow = new RowDefinition (); Parent.RowDefinitions.Add (MainRow); Grid SubGrid = new Grid (); Parent.Children.Add (SubGrid); Grid.SetRow (SubGrid, RowIndex++); Grid.SetColumn (SubGrid, 0); Label PropertyNameLabel = new Label (); PropertyNameLabel.Content = LabePropertyName; SubGrid.Children.Add (PropertyNameLabel); Grid.SetRow (PropertyNameLabel, 0); SubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubGrid.ColumnDefinitions [0].Width = (GridLength)GLConverter.ConvertFromString ("6" + "*"); SubGrid.ColumnDefinitions.Add (new ColumnDefinition ()); SubGrid.ColumnDefinitions [1].Width = (GridLength)GLConverter.ConvertFromString ("8" + "*"); SubGrid.RowDefinitions.Add (new RowDefinition ()); SubGrid.RowDefinitions [0].Height = (GridLength)GLConverter.ConvertFromString ("*"); if (PropInfo.PropertyType == typeof (int)) { TextBox ContentBox = CreateSimpleLine (ContentInstance, PropInfo, MainRow, SubGrid, HelpField); } if (PropInfo.PropertyType == typeof (double)) { TextBox ContentBox = CreateSimpleLine (ContentInstance, PropInfo, MainRow, SubGrid, HelpField); } if (PropInfo.PropertyType == typeof (Size)) { TextBox [] ContentBoxes = CreateTwoSubLines (ContentInstance, PropInfo, MainRow, SubGrid, new String [] { "Weite", "Höhe" }, HelpField); } if (PropInfo.PropertyType == typeof (Point)) { TextBox [] ContentBoxes = CreateTwoSubLines (ContentInstance, PropInfo, MainRow, SubGrid, new String [] { "Links", "Oben" }, HelpField); } if (PropInfo.PropertyType == typeof (String)) { TextBox ContentBox = CreateSimpleLine (ContentInstance, PropInfo, MainRow, SubGrid, HelpField); } if (PropInfo.PropertyType == typeof (bool)) { RadioButton [] Buttons = CreateBoolLine (ContentInstance, PropInfo, MainRow, SubGrid, new String [] { "Ja", "Nein" }, HelpField); } } }
private static void newTab(out Table tab, out TableRow tabRow) { tab = new Table(); var gridLenghtConvertor = new GridLengthConverter(); tab.Columns.Add(new TableColumn() { Name = "colD", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.Columns.Add(new TableColumn { Name = "colUD2", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.Columns.Add(new TableColumn { Name = "colUD3", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.RowGroups.Add(new TableRowGroup()); tab.RowGroups[0].Rows.Add(new TableRow()); tabRow = tab.RowGroups[0].Rows[0]; }
public Grid CreateGrid(String[] ColumnWidths, String[] RowHeights) { GridLengthConverter GLConverter = new GridLengthConverter (); Grid NewGrid = new Grid (); foreach (String Width in ColumnWidths) { ColumnDefinition NewCol = new ColumnDefinition (); NewCol.Width = (GridLength) GLConverter.ConvertFromString (Width); NewGrid.ColumnDefinitions.Add (NewCol); } foreach (String Height in RowHeights) { RowDefinition NewRow = new RowDefinition (); NewRow.Height = (GridLength) GLConverter.ConvertFromString (Height); NewGrid.RowDefinitions.Add (NewRow); } NewGrid.ShowGridLines = ShowGridLines; return NewGrid; }
//void SelectionDataGrid_MouseRightButtonUp (object Sender, MouseButtonEventArgs e) // { // DataGrid_MouseRightButtonUp (this); // } #endregion #region ManipulatingTableDataEnvironment private void CreateManipulatingTableDataEnvironment () { GridLengthConverter GLConverter = new GridLengthConverter (); int Index = 0; while (Index < 3) { ColumnDefinition ColDef = new ColumnDefinition (); ColDef.Width = (GridLength)GLConverter.ConvertFromString ("*"); ManipulatingTableDataGrid.ColumnDefinitions.Add (ColDef); Index++; } SelectionNewButton = new Button (); SelectionNewButton.Content = "Neu"; SelectionNewButton.Click += new RoutedEventHandler(SelectionNewButton_Click); ; ManipulatingTableDataGrid.Children.Add (SelectionNewButton); Grid.SetColumn (SelectionNewButton, 0); SelectionDeleteButton = new Button (); SelectionDeleteButton.Content = "Löschen"; SelectionDeleteButton.Click += new RoutedEventHandler(SelectionDeleteButton_Click); ManipulatingTableDataGrid.Children.Add (SelectionDeleteButton); Grid.SetColumn (SelectionDeleteButton, 1); SelectionModifyButton = new Button (); SelectionModifyButton.Content = "Ändern"; SelectionModifyButton.Click += new RoutedEventHandler (SelectionModifyButton_Click); ; ManipulatingTableDataGrid.Children.Add (SelectionModifyButton); Grid.SetColumn (SelectionModifyButton, 2); ProcessExternalSelection = true; }
private void CreateExternalSelectionEnvironment () { GridLengthConverter GLConverter = new GridLengthConverter (); int Index = 0; while (Index < 3) { ColumnDefinition ColDef = new ColumnDefinition (); ColDef.Width = (GridLength) GLConverter.ConvertFromString ("*"); ExternalSelectionGrid.ColumnDefinitions.Add (ColDef); Index++; } DoNotChangeSelectedButton = new Button (); DoNotChangeSelectedButton.Content = "Keine Änderung"; DoNotChangeSelectedButton.Click += new RoutedEventHandler (DoNotChangeSelectedButton_Click); ExternalSelectionGrid.Children.Add (DoNotChangeSelectedButton); Grid.SetColumn (DoNotChangeSelectedButton, 0); ClearSelectedButton = new Button (); ClearSelectedButton.Content = "Leer auswählen"; ClearSelectedButton.Click += new RoutedEventHandler (ClearSelectedButton_Click); ExternalSelectionGrid.Children.Add (ClearSelectedButton); Grid.SetColumn (ClearSelectedButton, 1); TakeSelectedButton = new Button (); TakeSelectedButton.Content = "Auswählen"; TakeSelectedButton.Click += new RoutedEventHandler (TakeSelectedButton_Click); ExternalSelectionGrid.Children.Add (TakeSelectedButton); Grid.SetColumn (TakeSelectedButton, 2); ProcessExternalSelection = true; }
private void CreateOneNavigationButton (Grid GridButton, int Index, String ButtonWidth, String ButtonText, String ButtonColor, String ForeGroundColor) { GridLengthConverter GLConverter = new GridLengthConverter (); BrushConverter BRConverter = new BrushConverter (); ColumnDefinition ButtonColumn = new ColumnDefinition (); ButtonColumn.Width = (GridLength)GLConverter.ConvertFromString (ButtonWidth + "*"); GridButton.ColumnDefinitions.Add (ButtonColumn); if (String.IsNullOrEmpty (ButtonText)) { Canvas Filler = new Canvas (); Filler.Background = (Brush)BRConverter.ConvertFromString (ButtonColor); GridButton.Children.Add (Filler); Grid.SetColumn (Filler, Index); Grid.SetRow (Filler, 0); } else { if (ButtonText != "-") { Button PressableButton = m_XAMLHandling.CreatePositionedButton (GridButton, Index, 0, ButtonText); PressableButton.Background = (Brush) BRConverter.ConvertFromString (ButtonColor); PressableButton.Foreground = (Brush) BRConverter.ConvertFromString (ForeGroundColor); PressableButton.FontWeight = (FontWeight) FWConverter.ConvertFromString ("Bold"); PressableButton.FontFamily = new FontFamily ("Interstate Condensed"); PressableButton.UpdateLayout (); PressableButton.FontSize = PressableButton.ActualHeight * 0.6; PressableButton.Click += new RoutedEventHandler (PressableButton_Click); if (ButtonText == INTERNET_NAVIGATION_TEXTE_LEFT) { m_LeftButton = PressableButton; PressableButton.IsEnabled = false; } if (ButtonText == INTERNET_NAVIGATION_TEXTE_RIGHT) { m_RightButton = PressableButton; PressableButton.IsEnabled = false; } if (ButtonText == INTERNET_NAVIGATION_TEXTE_UP) { m_UpButton = PressableButton; PressableButton.IsEnabled = false; } if (ButtonText == INTERNET_NAVIGATION_TEXTE_DOWN) { m_DownButton = PressableButton; PressableButton.IsEnabled = false; } } else { m_TimeToKeepAliveControl = new ProgressBar (); GridButton.Children.Add (m_TimeToKeepAliveControl); Grid.SetColumn (m_TimeToKeepAliveControl, Index); Grid.SetRow (m_TimeToKeepAliveControl, 0); m_TimeToKeepAliveControl.Orientation = Orientation.Horizontal; m_TimeToKeepAliveControl.Background = (Brush)BRConverter.ConvertFromString (CVM.CommonValues.COLOR_AEAG_ORANGE); m_TimeToKeepAliveControl.Foreground = (Brush)BRConverter.ConvertFromString (CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1); } } }
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //Сворачиваемся в трей if (!IsExiting && Settings.TrayIconIsEnabled && Settings.TrayClose) { e.Cancel = true; this.StateChanged -= new EventHandler(MainWindow_StateChanged); this.WindowState = System.Windows.WindowState.Minimized; this.Hide(); this.StateChanged += new EventHandler(MainWindow_StateChanged); if (!Settings.TrayNoBalloons) TrayIcon.ShowBalloonTip(5000, "XviD4PSP", " ", System.Windows.Forms.ToolTipIcon.Info); return; } else IsExiting = true; //Проверяем, есть ли задания в работе (кодируются) foreach (Task task in list_tasks.Items) { if (task.Status == TaskStatus.Encoding) { Message mes = new Message(this); mes.ShowMessage(Languages.Translate("Some jobs are still in progress!") + "\r\n" + Languages.Translate("Are you sure you want to quit?"), Languages.Translate("Warning"), Message.MessageStyle.YesNo); if (mes.result == Message.Result.No) { IsExiting = false; e.Cancel = true; return; } while (this.OwnedWindows.Count > 0) { foreach (Window OwnedWindow in this.OwnedWindows) { OwnedWindow.Close(); } } break; } } //Проверяем, есть ли задания в очереди (ожидают кодирования) foreach (Task task in list_tasks.Items) { if (task.Status == TaskStatus.Waiting) { Message mes = new Message(this); mes.ShowMessage(Languages.Translate("The queue isn`t empty.") + "\r\n" + Languages.Translate("Are you sure you want to quit?"), Languages.Translate("Warning"), Message.MessageStyle.YesNo); if (mes.result == Message.Result.No) { IsExiting = false; e.Cancel = true; return; } break; } } //Убиваем процесс вместо выхода, если нажат Shift bool kill_me = false; if (System.Windows.Input.Keyboard.Modifiers == ModifierKeys.Shift) { kill_me = true; goto finish; } if (m != null) CloseFile(false); //Удаляем резервную копию заданий SafeDelete(Settings.TempPath + "\\backup.tsks"); //Временные файлы if (Settings.DeleteTempFiles) { //удаляем мусор foreach (string dfile in deletefiles) { if (!dfile.Contains("cache")) SafeDelete(dfile); } //Удаление индекс-файлов от FFmpegSource2 if (Settings.DeleteFFCache) { //Которые рядом с исходником foreach (string file in ffcache) SafeDelete(file); //Которые в Темп-папке foreach (string file in Directory.GetFiles(Settings.TempPath, "*.ffindex")) SafeDelete(file); } //Удаление индекс-файлов от LSMASH if (Settings.DeleteLSMASHCache) { //Которые рядом с исходником foreach (string file in lsmashcache) SafeDelete(file); //Которые в Темп-папке (это аудио кэш) foreach (string file in Directory.GetFiles(Settings.TempPath, "*.lwi")) SafeDelete(file); } //Удаление DGIndex-кэша if (Settings.DeleteDGIndexCache) { foreach (string cache_path in dgcache) SafeDirDelete(Path.GetDirectoryName(cache_path), false); } //Удаление DGIndexNV-кэша if (Settings.DeleteDGIndexNVCache) { foreach (string cache_path in dgcacheNV) SafeDirDelete(Path.GetDirectoryName(cache_path), false); } } finish: //Определяем и сохраняем размер и положение окна при выходе if (this.WindowState != System.Windows.WindowState.Maximized && this.WindowState != System.Windows.WindowState.Minimized) //но только если окно не развернуто на весь экран и не свернуто { Settings.WindowLocation = (int)this.Window.ActualWidth + "/" + (int)this.Window.ActualHeight + "/" + (int)this.Window.Left + "/" + (int)this.Window.Top; GridLengthConverter conv = new GridLengthConverter(); Settings.TasksRows = conv.ConvertToString(this.TasksRow.Height) + "/" + conv.ConvertToString(this.TasksRow2.Height); } //Чистим трей TrayIcon.Visible = false; TrayIcon.Dispose(); //Убиваемся, если надо if (kill_me) Process.GetCurrentProcess().Kill(); }
private void CreateCommonFrameGeometry (bool PrintAllowed) { BrushConverter BRConverter = new BrushConverter (); GridLengthConverter GLConverter = new GridLengthConverter (); ColumnDefinition Grid_Root_Column = new ColumnDefinition (); Grid_Root_Column.Width = (GridLength)GLConverter.ConvertFromString ("*"); this.Grid_Root.ColumnDefinitions.Add (Grid_Root_Column); RowDefinition Grid_Root_ContentRow = new RowDefinition (); Grid_Root_ContentRow.Height = (GridLength)GLConverter.ConvertFromString ("18*"); this.Grid_Root.RowDefinitions.Add (Grid_Root_ContentRow); RowDefinition Grid_Root_ButtonRow = new RowDefinition (); Grid_Root_ButtonRow.Height = (GridLength)GLConverter.ConvertFromString ("*"); this.Grid_Root.RowDefinitions.Add (Grid_Root_ButtonRow); Grid GridButton = new Grid (); this.Grid_Root.Children.Add (GridButton); Grid.SetRow (GridButton, 1); Grid.SetColumn (GridButton, 0); RowDefinition GridButton_ButtonRow = new RowDefinition (); GridButton_ButtonRow.Height = (GridLength)GLConverter.ConvertFromString ("*"); GridButton.RowDefinitions.Add (GridButton_ButtonRow); String [] ButtonPositions = new String [] { "10;" + INTERNET_NAVIGATION_TEXTE_LEFT, "1", "20;" + INTERNET_NAVIGATION_TEXTE_BACK, "1", "20;-", "1", "20;" + INTERNET_NAVIGATION_TEXTE_REMAIN, "1", "10;" + INTERNET_NAVIGATION_TEXTE_UP, "1", "10;" + INTERNET_NAVIGATION_TEXTE_DOWN, "1", "10;" + INTERNET_NAVIGATION_TEXTE_RIGHT, "1"}; String [] ButtonPositionsWithPrinter = new String [] {"10;" + INTERNET_NAVIGATION_TEXTE_LEFT, "1", "20;" + INTERNET_NAVIGATION_TEXTE_BACK, "1", "20;-", "1", "20;" + INTERNET_NAVIGATION_TEXTE_REMAIN, "1", "10;" + INTERNET_NAVIGATION_TEXTE_PRINT, "1", "10;" + INTERNET_NAVIGATION_TEXTE_UP, "1", "10;" + INTERNET_NAVIGATION_TEXTE_DOWN, "1", "10;" + INTERNET_NAVIGATION_TEXTE_RIGHT, "1"}; //String [] ButtonScrolls = new String [] { "10;" + INTERNET_NAVIGATION_TEXTE_LEFT, "1", // "30;" + INTERNET_NAVIGATION_TEXTE_BACK, "1", // "30;-", "1", // "30;" + INTERNET_NAVIGATION_TEXTE_REMAIN, "1", // "10;" + INTERNET_NAVIGATION_TEXTE_UP, "1", // "10;" + INTERNET_NAVIGATION_TEXTE_DOWN, "1", // "10;" + INTERNET_NAVIGATION_TEXTE_RIGHT}; String [] ButtonColors = new String [] { CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1}; String [] ButtonColorsWithPrinter = new String [] { CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1, CVM.CommonValues.COLOR_AEAG_LIGHT_BLUE, CVM.CommonValues.COLOR_AEAG_DARK_BLUE_1}; String [] ForegroundColors = new String [] { "White", "", "White", "", "White", "", "White", "", "White", "", "White", "", "White", "", "White"}; String [] ForegroundColorsWithPrinter = new String [] { "White", "", "White", "", "White", "", "White", "", "White", "", "White", "", "White", "", "White", "", "White"}; int Index = 0; if (!PrintAllowed) { foreach (String ButtonDescription in ButtonPositions) { String [] Pos = ButtonDescription.Split (';'); String ButtonText = ""; if (Pos.Length > 1) ButtonText = Pos [1]; CreateOneNavigationButton (GridButton, Index, Pos [0], ButtonText, ButtonColors [Index], ForegroundColors [Index]); Index++; } } else { foreach (String ButtonDescription in ButtonPositionsWithPrinter) { String [] Pos = ButtonDescription.Split (';'); String ButtonText = ""; if (Pos.Length > 1) ButtonText = Pos [1]; CreateOneNavigationButton (GridButton, Index, Pos [0], ButtonText, ButtonColorsWithPrinter [Index], ForegroundColorsWithPrinter [Index]); Index++; } } }
/// <summary> /// updates height of buttons stack /// </summary> private void _UpdateButtonsStackLayout() { double changedSize = _collMaximizedPages.Count * _expander.MinWidth + _horisontalSplitter.Height; GridLengthConverter gridLenghtConverter = new GridLengthConverter(); double contentPresenterHeight = this.ActualHeight - changedSize - _expander.MinWidth * 2; _ResizeMainCollapsedButton(); _buttonsStack.Background = new SolidColorBrush(Colors.Black); _buttonsRow.Height = new GridLength(changedSize); _buttonsStack.Height = changedSize; }
void CreateBasicPageParameter () { BrushConverter BRConverter = new BrushConverter (); GridLengthConverter GLConverter = new GridLengthConverter (); m_GlobalGrid_2 = new Grid (); m_GlobalGrid_2.Visibility = Visibility.Visible; this.Content = m_GlobalGrid_2; m_GlobalGrid_2.IsEnabled = true; ColumnDefinition GlobalGrid_2_Column = new ColumnDefinition (); m_GlobalGrid_2.ColumnDefinitions.Add (GlobalGrid_2_Column); RowDefinition GlobalGrid_2_NameRow = new RowDefinition (); GlobalGrid_2_NameRow.Height = (GridLength)GLConverter.ConvertFromString ("10*"); RowDefinition GlobalGrid_2_Filler_1 = new RowDefinition (); GlobalGrid_2_Filler_1.Height = (GridLength)GLConverter.ConvertFromString ("*"); RowDefinition GlobalGrid_2_PictureRow = new RowDefinition (); GlobalGrid_2_PictureRow.Height = (GridLength)GLConverter.ConvertFromString ("80*"); RowDefinition GlobalGrid_2_Filler_2 = new RowDefinition (); GlobalGrid_2_Filler_2.Height = (GridLength)GLConverter.ConvertFromString ("*"); RowDefinition GlobalGrid_2_InfoRow = new RowDefinition (); GlobalGrid_2_InfoRow.Height = (GridLength)GLConverter.ConvertFromString ("10*"); m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_NameRow); m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_Filler_1); m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_PictureRow); m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_Filler_2); m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_InfoRow); m_Name_2_Canvas = new Canvas (); m_Name_2_Canvas.Visibility = Visibility.Visible; m_GlobalGrid_2.Children.Add (m_Name_2_Canvas); Grid.SetColumn (m_Name_2_Canvas, 0); Grid.SetRow (m_Name_2_Canvas, 0); m_Picture_2_Canvas = new Canvas (); m_Picture_2_Canvas.Visibility = Visibility.Visible; m_GlobalGrid_2.Children.Add (m_Picture_2_Canvas); Grid.SetColumn (m_Picture_2_Canvas, 0); Grid.SetRow (m_Picture_2_Canvas, 2); NameScope.SetNameScope (m_GlobalGrid_2, new NameScope ()); m_Picture_2_Canvas.Background = (Brush)BRConverter.ConvertFromString (WeatherDetailBackGroundColor); m_Info_2_Canvas = new Canvas (); m_Info_2_Canvas.Visibility = Visibility.Visible; m_GlobalGrid_2.Children.Add (m_Info_2_Canvas); Grid.SetColumn (m_Info_2_Canvas, 0); Grid.SetRow (m_Info_2_Canvas, 4); m_Info_2_Canvas.Background = (Brush)BRConverter.ConvertFromString (WeatherHeadlineBackGroundColor); m_GlobalGrid_2.UpdateLayout (); }
private Grid CreateRowDefinitions () { GridLengthConverter GLConverter = new GridLengthConverter (); foreach (DataColumn Column in m_RowToProcess.Table.Columns) { if (Column.ColumnName == UserData.m_PrimaryKeyName) continue; int NumberOfLines = GetNumberOfLines (Column); RowDefinition Row = new RowDefinition (); Row.Height = (GridLength)GLConverter.ConvertFromString (Convert.ToString (NumberOfLines) + "*"); RootGrid.RowDefinitions.Add (Row); } RowDefinition ButtonRow = new RowDefinition (); ButtonRow.Height = (GridLength)GLConverter.ConvertFromString ("*"); RootGrid.RowDefinitions.Add (ButtonRow); Grid ButtonGrid = new Grid (); ButtonGrid.Name = "ButtonGrid"; RootGrid.Children.Add (ButtonGrid); Grid.SetColumn (ButtonGrid, 1); Grid.SetRow (ButtonGrid, RootGrid.RowDefinitions.Count - 1); ColumnDefinition ButtonColumn1 = new ColumnDefinition (); ButtonColumn1.Width = (GridLength)GLConverter.ConvertFromString ("*"); ButtonGrid.ColumnDefinitions.Add (ButtonColumn1); ColumnDefinition ButtonColumn2 = new ColumnDefinition (); ButtonColumn2.Width = (GridLength)GLConverter.ConvertFromString ("*"); ButtonGrid.ColumnDefinitions.Add (ButtonColumn2); if (m_UpdateAllowed == true) { Button CancelButton = new Button (); CancelButton.Content = "Abbrechen"; if (NameScope.GetNameScope (this.RootGrid) != null) if (NameScope.GetNameScope (this.RootGrid).FindName ("AbbrechenButton") != null) RootGrid.UnregisterName ("AbbrechenButton"); RootGrid.RegisterName ("AbbrechenButton", CancelButton); CancelButton.Click += new RoutedEventHandler (CancelButton_Click); Grid.SetColumn (CancelButton, 0); ButtonGrid.Children.Add (CancelButton); Button OKButton = new Button (); OKButton.Content = "Speichern"; if (NameScope.GetNameScope (this.RootGrid) != null) if (NameScope.GetNameScope (this.RootGrid).FindName ("OKButton") != null) RootGrid.UnregisterName ("OKButton"); RootGrid.RegisterName ("OKButton", OKButton); OKButton.Click += new RoutedEventHandler (OKButton_Click); Grid.SetColumn (OKButton, 1); ButtonGrid.Children.Add (OKButton); } else { Button CancelButton = new Button (); CancelButton.Content = "Schließen"; if (NameScope.GetNameScope (this.RootGrid) != null) if (NameScope.GetNameScope (this.RootGrid).FindName ("AbbrechenButton") != null) RootGrid.UnregisterName ("AbbrechenButton"); RootGrid.RegisterName ("AbbrechenButton", CancelButton); CancelButton.Click += new RoutedEventHandler (CancelButton_Click); Grid.SetColumn (CancelButton, 1); ButtonGrid.Children.Add (CancelButton); } return RootGrid; }
/// <summary> /// Turns a string of lengths, such as "3*,Auto,2000" into a set of gridlength. /// </summary> /// <param name="lengths">The string of lengths, separated by commas.</param> /// <returns>A list of GridLengths.</returns> private static List<GridLength> StringLengthsToGridLengths(string lengths) { // Create the list of GridLengths. var gridLengths = new List<GridLength>(); // If the string is null or empty, this is all we can do. if (string.IsNullOrEmpty(lengths)) return gridLengths; // Split the string by comma. var theLengths = lengths.Split(','); // If we're NOT in silverlight, we have a gridlength converter // we can use. #if !SILVERLIGHT // Create a grid length converter. var gridLengthConverter = new GridLengthConverter(); // Use the grid length converter to set each length. foreach (var length in theLengths) gridLengths.Add((GridLength) gridLengthConverter.ConvertFromString(length)); #else // We are in silverlight and do not have a grid length converter. // We can do the conversion by hand. foreach(var length in theLengths) { // Auto is easy. if(length == "Auto") { gridLengths.Add(new GridLength(1, GridUnitType.Auto)); } else if (length.Contains("*")) { // It's a starred value, remove the star and get the coefficient as a double. double coefficient = 1; string starVal = length.Replace("*", ""); // If there is a coefficient, try and convert it. // If we fail, throw an exception. if (starVal.Length > 0 && double.TryParse(starVal, out coefficient) == false) throw new Exception("'" + length + "' is not a valid value."); // We've handled the star value. gridLengths.Add(new GridLength(coefficient, GridUnitType.Star)); } else { // It's not auto or star, so unless it's a plain old pixel // value we must throw an exception. double pixelVal = 0; if(double.TryParse(length, out pixelVal) == false) throw new Exception("'" + length + "' is not a valid value."); // We've handled the star value. gridLengths.Add(new GridLength(pixelVal, GridUnitType.Pixel)); } } #endif // Return the grid lengths. return gridLengths; }
static void OnColumnsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { // wpf resets all attached properties when a template gets destroyed, but this would cause some exceptions if (StackTraceHelper.Get().Contains("ClearTemplateChain")) return; var grid = obj as Grid; if (grid == null) throw new Exception(); var substrings = ParseAndSplit(args); //clear old collection ColumnDefinitionCollection col = grid.ColumnDefinitions; col.Clear(); var converter = new GridLengthConverter(); foreach (var Column in substrings) col.Add(new ColumnDefinition() { Width = (GridLength)converter.ConvertFrom(Column) }); }
/// <summary> /// Initializes the controls for the shortcuts /// </summary> public void InitShortcuts() { String[,] categories = new String[4, 3]; // name, translation id (title), translation id (text categories[0, 0] = "Application"; categories[0, 1] = "ShortcutApplicationTitle"; categories[0, 2] = "ShortcutApplicationText"; categories[1, 0] = "MainWindow"; categories[1, 1] = "ShortcutMainWindowTitle"; categories[1, 2] = "ShortcutMainWindowText"; categories[2, 0] = "MediaCommands"; categories[2, 1] = "ShortcutMediaCommandsTitle"; categories[2, 2] = "ShortcutMediaCommandsText"; categories[3, 0] = "Track"; categories[3, 1] = "ShortcutTrackTitle"; categories[3, 2] = "ShortcutTrackText"; for (int i = 0; i < 4; i++) { DockPanel d = new DockPanel() { Margin = new Thickness(25, 15, 0, 5), LastChildFill = true }; TextBlock t = new TextBlock() { Text = U.T(categories[i, 1]) }; t.Tag = categories[i, 1]; DockPanel.SetDock(t, Dock.Left); ShortcutTitles.Add(t); d.Children.Add(t); Separator s = new Separator(); s.Background = Brushes.LightGray; s.Height = 1; s.Margin = new Thickness(5, 0, 5, 0); DockPanel.SetDock(s, Dock.Left); d.Children.Add(s); DockPanel.SetDock(d, Dock.Top); ShortcutPanel.Children.Add(d); TextBlock tb = new TextBlock(); tb.Margin = new Thickness(50, 5, 0, 5); tb.TextWrapping = TextWrapping.Wrap; tb.Inlines.Add(U.T(categories[i, 2])); tb.Tag = categories[i, 2]; ShortcutDescriptions.Add(tb); DockPanel.SetDock(tb, Dock.Top); ShortcutPanel.Children.Add(tb); GridLengthConverter conv = new GridLengthConverter(); Grid g = new Grid(); g.Margin = new Thickness(50, 5, 0, 5); g.ColumnDefinitions.Add(new ColumnDefinition() { Width = (GridLength)conv.ConvertFrom(170) }); g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); int j; KeyboardShortcutProfile profile = SettingsManager.GetCurrentShortcutProfile(); for (j = 0; j < profile.Shortcuts.Count; j++) g.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); if (categories[i, 0] == "MediaCommands") { GlobalLabel.Content = U.T("ShortcutGlobal"); GlobalLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; Grid.SetColumn(GlobalLabel, 2); Grid.SetRow(GlobalLabel, 0); g.Children.Add(GlobalLabel); } j = 1; foreach (KeyboardShortcut sc in profile.Shortcuts) { // skip now playing if (sc.Name == "Now playing") continue; if (sc.Category != categories[i, 0]) continue; Label l = new Label() { Content = U.T("Shortcut_" + sc.Name.Replace(" ","_")) }; l.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; l.Tag = "Shortcut_" + sc.Name.Replace(" ", "_"); Grid.SetColumn(l, 0); Grid.SetRow(l, j); g.Children.Add(l); ShortcutLabels.Add(l); Button b = new Button() { Content = sc.Keys, MinWidth = 100 }; b.Name = sc.Category + "_" + sc.Name.Replace(" ", "_"); b.LostFocus += PrefShortcutButton_LostFocus; b.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; b.Margin = new Thickness(2); b.Click += PrefShortcutButton_Clicked; shortcutButtons.Add(b.Name, b); Grid.SetColumn(b, 1); Grid.SetRow(b, j); g.Children.Add(b); if (categories[i, 0] == "MediaCommands") { CheckBox cb = new CheckBox() { IsChecked = sc.IsGlobal, Name = b.Name, ToolTip = U.T("ShortcutGlobal", "ToolTip") }; cb.VerticalAlignment = System.Windows.VerticalAlignment.Center; cb.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; cb.Margin = new Thickness(10, 0, 10, 0); cb.Click += PrefShortcutGlobal_Clicked; shortcutCheckBoxes.Add(b.Name, cb); Grid.SetColumn(cb, 2); Grid.SetRow(cb, j); g.Children.Add(cb); } j++; } DockPanel.SetDock(g, Dock.Top); ShortcutPanel.Children.Add(g); } ((Grid)ShortcutPanel.Children[ShortcutPanel.Children.Count - 1]).Margin = new Thickness(50, 5, 0, 25); string selTxt = SettingsManager.CurrentShortcutProfile; int sel = 0; foreach (KeyboardShortcutProfile p in SettingsManager.ShortcutProfiles) { if (selTxt == p.Name) sel = PrefShortcutProfile.Items.Count; PrefShortcutProfile.Items.Add(new ComboBoxItem() { Content = p.Name }); } PrefShortcutProfile.SelectedIndex = sel; }
public void SetBackGroundStatus (String RuntimeMessage) { GridLengthConverter GL = new GridLengthConverter (); BackGroundText.Content = RuntimeMessage; }
private void InsertDataGrid (TabItem TableItem, ref DataGrid TableControl, ref TextBox InformationControl) { GridLengthConverter GLConverter = new GridLengthConverter (); Grid DataContainer = new Grid (); RowDefinition DataGridRow = new RowDefinition (); DataGridRow.Height = (GridLength) GLConverter.ConvertFromString ("20*"); DataContainer.RowDefinitions.Add (DataGridRow); RowDefinition DataGridInformationRow = new RowDefinition (); DataGridInformationRow.Height = (GridLength) GLConverter.ConvertFromString ("*"); DataContainer.RowDefinitions.Add (DataGridInformationRow); TableControl = new DataGrid (); DataContainer.Children.Add (TableControl); Grid.SetRow (TableControl, 0); InformationControl = new TextBox (); DataContainer.Children.Add (InformationControl); Grid.SetRow (InformationControl, 1); TableItem.Content = DataContainer; }