public Grid getGrid() { Grid grid = new Grid(); RowDefinition rowDefinition = new RowDefinition { Height = (GridLength)GL.ConvertFrom("40") }; grid.RowDefinitions.Add(rowDefinition); rowDefinition = new RowDefinition { Height = (GridLength)GL.ConvertFrom("45") }; grid.RowDefinitions.Add(rowDefinition); rowDefinition = new RowDefinition { Height = (GridLength)GL.ConvertFrom("36") }; grid.RowDefinitions.Add(rowDefinition); rowDefinition = new RowDefinition { Height = (GridLength)GL.ConvertFrom("42") }; grid.RowDefinitions.Add(rowDefinition); rowDefinition = new RowDefinition { Height = (GridLength)GL.ConvertFrom("2") }; grid.RowDefinitions.Add(rowDefinition); rowDefinition = new RowDefinition { Height = (GridLength)GL.ConvertFrom("60") }; grid.RowDefinitions.Add(rowDefinition); ColumnDefinition colDefinition = new ColumnDefinition { Width = (GridLength)GL.ConvertFrom("150") }; grid.ColumnDefinitions.Add(colDefinition); colDefinition = new ColumnDefinition { Width = (GridLength)GL.ConvertFrom("10") }; grid.ColumnDefinitions.Add(colDefinition); colDefinition = new ColumnDefinition { Width = (GridLength)GL.ConvertFrom("*") }; grid.ColumnDefinitions.Add(colDefinition); return(grid); }
/// <summary> /// Hides/Shows "Filter" group box. /// </summary> /// <param name="filterGroupBoxIsVisible"></param> public void Setup_FilterGroupBoxIsVisible(bool filterGroupBoxIsVisible) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); if (filterGroupBoxIsVisible) { groupVisibility.Visibility = Visibility.Visible; mainGrid.RowDefinitions[0].Height = (GridLength)gridLengthConverter.ConvertFrom("90"); } else { mainGrid.RowDefinitions[0].Height = (GridLength)gridLengthConverter.ConvertFrom("0"); groupVisibility.Visibility = Visibility.Hidden; } }
public void ConvertFromTest() { var converter = new GridLengthConverter(); Assert.AreEqual(new GridLength(1.0, GridUnitType.Auto), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "Auto")); Assert.AreEqual(new GridLength(1.0, GridUnitType.Star), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "*")); Assert.AreEqual(new GridLength(1.5, GridUnitType.Star), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "1.5*")); Assert.AreEqual(new GridLength(100, GridUnitType.Pixel), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "100")); Assert.AreEqual(new GridLength(100, GridUnitType.Pixel), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "100 px")); Assert.AreEqual(new GridLength(96, GridUnitType.Pixel), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "1 in")); Assert.AreEqual(new GridLength(37.795275590551178, GridUnitType.Pixel), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "1 cm")); Assert.AreEqual(new GridLength(1.3333333333333333, GridUnitType.Pixel), converter.ConvertFrom(null, CultureInfo.InvariantCulture, "1 pt")); Assert.AreEqual(new GridLength(1.0, GridUnitType.Auto), converter.ConvertFrom(null, CultureInfo.InvariantCulture, double.NaN)); Assert.AreEqual(new GridLength(100, GridUnitType.Pixel), converter.ConvertFrom(null, CultureInfo.InvariantCulture, 100.0)); }
private bool CreateGridStations() { bool result = false; try { GridStations = new Grid(); svToRoots.Content = GridStations; var toCount = Stations.stationList.Count; var valueOfRow = (double)toCount / 5; var rowCount = Math.Ceiling(valueOfRow); GridLengthConverter gridLengthConverter = new GridLengthConverter(); ColumnDefinition gridCol = null; RowDefinition gridRow = null; for (var i = 0; i < 4; i++) { gridCol = new ColumnDefinition(); gridCol.Width = (GridLength)gridLengthConverter.ConvertFrom("5*"); GridStations.ColumnDefinitions.Add(gridCol); if (i != 3) { gridCol = new ColumnDefinition(); gridCol.Width = (GridLength)gridLengthConverter.ConvertFrom("*"); GridStations.ColumnDefinitions.Add(gridCol); } } for (var i = 0; i <= rowCount; i++) { gridRow = new RowDefinition(); gridRow.Height = (GridLength)gridLengthConverter.ConvertFrom("5*"); GridStations.RowDefinitions.Add(gridRow); if (i != rowCount) { gridRow = new RowDefinition(); gridRow.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); GridStations.RowDefinitions.Add(gridRow); } } result = true; } catch (Exception ex) { result = false; log.Error("Error StationPage -> CreateGridStations() : " + ex.ToString()); } return(result); }
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 ChangeToLoginScreen() { tbar_main.IsEnabled = false; mn_main.IsEnabled = false; MainTabControl.IsEnabled = false; DataTabControl.IsEnabled = false; gs_main.IsEnabled = false; tb_username.Clear(); tb_password.Clear(); GridLengthConverter gridLengthConverter = new GridLengthConverter(); LoginRow.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); MainAppRow.Height = (GridLength)gridLengthConverter.ConvertFrom("0"); Constant.userName = ""; Constant.userAuthor = -2; tb_username.Focus(); }
public void ChangeToMainScreen(int userAuthor) { tbar_main.IsEnabled = true; mn_main.IsEnabled = true; MainTabControl.IsEnabled = true; DataTabControl.IsEnabled = true; gs_main.IsEnabled = true; GridLengthConverter gridLengthConverter = new GridLengthConverter(); LoginRow.Height = (GridLength)gridLengthConverter.ConvertFrom("0"); MainAppRow.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); if (userAuthor == 0) { return; } if (userAuthor == 1) { return; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType == typeof(GridLength)) { return(value == null ? new GridLength(0) : converter.ConvertFrom(parameter)); } else { return(value == null ? 0 : parameter); } }
private bool CreatePassengerCountGrid() { bool result = false; try { PassengerCountGrid = new Grid(); var minGroupCount = Convert.ToInt32(Parameters.TVMDynamic.GetParameter("sys_MinGroupCount")); var maxGroupCount = Convert.ToInt32(Parameters.TVMDynamic.GetParameter("sys_MaxGroupCount")); var btnCount = maxGroupCount - minGroupCount + 1; var valueOfRow = (double)btnCount / 5; var rowCount = Math.Ceiling(valueOfRow); GridLengthConverter gridLengthConverter = new GridLengthConverter(); ColumnDefinition gridCol = null; RowDefinition gridRow = null; for (var i = 0; i < 5; i++) { gridCol = new ColumnDefinition(); gridCol.Width = (GridLength)gridLengthConverter.ConvertFrom("5*"); PassengerCountGrid.ColumnDefinitions.Add(gridCol); gridCol = new ColumnDefinition(); gridCol.Width = (GridLength)gridLengthConverter.ConvertFrom("*"); PassengerCountGrid.ColumnDefinitions.Add(gridCol); } for (var i = 0; i < rowCount; i++) { gridRow = new RowDefinition(); gridRow.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); PassengerCountGrid.RowDefinitions.Add(gridRow); } result = true; scrollCountGrid.Content = PassengerCountGrid; } catch (Exception ex) { result = false; } return(result); }
private bool CreateTicketCountGrid() { bool result = false; try { TicketCountGrid = new Grid(); var toCount = Convert.ToInt32(Parameters.TVMDynamic.GetParameter("sys_MaxTicket")); var valueOfRow = (double)toCount / 2; var rowCount = Math.Ceiling(valueOfRow); GridLengthConverter gridLengthConverter = new GridLengthConverter(); ColumnDefinition gridCol = null; RowDefinition gridRow = null; for (var i = 0; i < 2; i++) { gridCol = new ColumnDefinition(); gridCol.Width = (GridLength)gridLengthConverter.ConvertFrom("10*"); TicketCountGrid.ColumnDefinitions.Add(gridCol); gridCol = new ColumnDefinition(); gridCol.Width = (GridLength)gridLengthConverter.ConvertFrom("*"); TicketCountGrid.ColumnDefinitions.Add(gridCol); } for (var i = 0; i < rowCount; i++) { gridRow = new RowDefinition(); gridRow.Height = (GridLength)gridLengthConverter.ConvertFrom("3*"); TicketCountGrid.RowDefinitions.Add(gridRow); } result = true; scrollCountGrid.Content = TicketCountGrid; } catch (Exception ex) { result = false; } return(result); }
void InitializeEntityTree(string preSelectEntity, string preSelectPDef) { IfcSchemaEntityTree.GetAllEntityDict(); InitializeComponent(); textBox_Search.Focus(); if (m_SingleNodeSelection) { label_Show.Visibility = System.Windows.Visibility.Hidden; comboBox_ShowItems.Visibility = System.Windows.Visibility.Hidden; } else { HelpRun.Text = Properties.Resources.HelpSelectEntityForExport; comboBox_ShowItems.ItemsSource = new List <string>() { Properties.Resources.ShowAll, Properties.Resources.ShowChecked, Properties.Resources.ShowUnchecked }; comboBox_ShowItems.SelectedIndex = 0; // Default selection to show All } // If the IFC schema version is selected for export, the combobox will be disabled for selection ComboBox_IFCSchema.IsEnabled = false; // Assign default if (string.IsNullOrEmpty(m_IfcVersion)) { m_IfcVersion = IFCVersion.IFC4.ToString(); ComboBox_IFCSchema.IsEnabled = true; } ComboBox_IFCSchema.ItemsSource = IfcSchemaEntityTree.GetAllCachedSchemaNames(); ComboBox_IFCSchema.SelectedItem = m_IfcVersion; if (m_SingleNodeSelection) { Grid_Main.ColumnDefinitions[2].MinWidth = 200; } else { // In multi-selection mode, hide the TreView panel for the PredefinedType Grid_Main.ColumnDefinitions[2].MinWidth = 0; GridLengthConverter grLenConv = new GridLengthConverter(); GridLength grLen = (GridLength)grLenConv.ConvertFrom(0); Grid_Main.ColumnDefinitions[2].Width = grLen; } LoadTreeviewFilterElement(); PreSelectItem(preSelectEntity, preSelectPDef); IfcSchemaEntityTree.GenerateEntityTrie(ref m_EntityTrie); }
private void StopSimulation() { grdDebugSet.Visibility = Visibility.Hidden; GridLengthConverter gridLengthConverter = new GridLengthConverter(); RDefSim.Height = (GridLength)gridLengthConverter.ConvertFrom("0"); MakeEnableDgOpeList(); OpeScript.GetInstance().Initialize(); OpeInfoTable.GetInstance().UnregisterAllOpeToHotKey(GetHWnd()); btnSimulation.IsChecked = false; }
private static void SetWidthOrHeight(XmlElement xmlElement, FrameworkElement parentFrameworkElement, bool isParentHorizontal, int row, int column) { GridLengthConverter converter = new GridLengthConverter(); Grid grid = parentFrameworkElement as Grid; if (grid != null) { if (isParentHorizontal) { if (row < grid.RowDefinitions.Count) { if (xmlElement.HasAttribute("Height")) { grid.RowDefinitions[row].Height = (GridLength)converter.ConvertFrom(GetStringAttribute(xmlElement, "Height")); } else { grid.RowDefinitions[row].Height = new GridLength(1, GridUnitType.Star); } } } else { if (column < grid.ColumnDefinitions.Count) { if (xmlElement.HasAttribute("Width")) { grid.ColumnDefinitions[column].Width = (GridLength)converter.ConvertFrom(GetStringAttribute(xmlElement, "Width")); } else { grid.ColumnDefinitions[column].Width = new GridLength(1, GridUnitType.Star); } } } } }
private void StartSimulation() { MakeDisenableDgOpeList(); RowDefinition row_def = new RowDefinition(); GridLengthConverter gridLengthConverter = new GridLengthConverter(); RDefSim.Height = (GridLength)gridLengthConverter.ConvertFrom("1*"); grdDebugSet.Visibility = Visibility.Visible; OpeScript.GetInstance().Initialize(TbxOutput); OpeInfoTable.GetInstance().RegisterAllOpeToHotKey(GetHWnd()); btnSimulation.IsChecked = true; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!((bool?)value).HasValue) { return(Binding.DoNothing); } if (targetType == typeof(GridLength)) { return((bool)value ? new GridLength(0) : converter.ConvertFrom(parameter)); } else { return((bool)value ? 0 : parameter); } }
public GridLength GetGridLength <T>(T input) { var result = new GridLength(1, GridUnitType.Star); if (!_gridLengthConverter.CanConvertFrom(input.GetType())) { return(result); } var convertedValue = _gridLengthConverter.ConvertFrom(input); if (convertedValue != null) { result = (GridLength)convertedValue; } return(result); }
internal static IEnumerable <GridLength> Parse(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, string text) { try { var lengths = text.Split(SeparatorChars, StringSplitOptions.RemoveEmptyEntries) .Select(x => (GridLength)GridLengthConverter.ConvertFrom(typeDescriptorContext, cultureInfo, x)); return(lengths); } catch (Exception e) { var message = $"Could not parse grid lengts from {text}.\r\n" + $"Expected a string like '* 20 Auto'\r\n" + $"Valid separators are {{{string.Join(", ", SeparatorChars.Select(x => $"'x'"))}}}"; throw new FormatException(message, e); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var gridLengthConverter = new GridLengthConverter(); var gridLengthRaw = gridLengthConverter.ConvertFrom(parameter); if (gridLengthRaw == null) { throw new ArgumentException("Parameter must be convertable to GridLength"); } var defaultGridLength = (GridLength)gridLengthRaw; var boolValue = (bool)value; return(boolValue ? defaultGridLength : new GridLength(0)); }
/// <summary> /// DataGrid绑定数据源描述 /// </summary> /// <param name="headerName">列名</param> /// <param name="showAs">显示为</param> /// <param name="width">宽度</param> /// <param name="displayIndex">显示顺序</param> /// <param name="resourceKey">自定义列Key</param> public BindDescriptionAttribute(string headerName, ShowScheme showAs = ShowScheme.普通文本, string width = "Auto", int displayIndex = 0, string resourceKey = "") { HeaderName = headerName; DisplayIndex = displayIndex; ResourceKey = resourceKey; ShowAs = showAs; var convert = new DataGridLengthConverter(); Width = (DataGridLength)convert.ConvertFrom(width); var gridCOnvert = new GridLengthConverter(); CloumnWidth = (GridLength)gridCOnvert.ConvertFrom(width); if (showAs == ShowScheme.自定义 && string.IsNullOrWhiteSpace(resourceKey)) { throw new ArgumentException($"自定义列时需要指定{nameof(resourceKey)}参数!"); } }
/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param> /// <param name="value">The <see cref="T:System.Object" /> to convert.</param> /// <returns> /// An <see cref="T:System.Object" /> that represents the converted value. /// </returns> /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed.</exception> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var s = value as string; if (s != null) { var glc = new GridLengthConverter(); var c = new List <GridLength>(); foreach (var item in s.Split(SplitterChars)) { c.Add((GridLength)glc.ConvertFrom(item)); } return(c); } return(base.ConvertFrom(context, culture, value)); }
private static void RowDefinitionsPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (sender is Grid grid && e.NewValue is string newValue) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); grid.RowDefinitions.Clear(); string[] gridLengthLiterals = newValue.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string gridLengthLiteral in gridLengthLiterals) { if (gridLengthConverter.ConvertFrom(gridLengthLiteral) is GridLength gridLength) { RowDefinition rowDefinition = new RowDefinition { Height = gridLength }; grid.RowDefinitions.Add(rowDefinition); } } } }
public void CreateGrid(Grid grid) { for (int j = 0; j < SizeY; j++) { ColumnDefinition column = new ColumnDefinition(); GridLengthConverter gridLengthConverter = new GridLengthConverter(); column.Width = (GridLength)gridLengthConverter.ConvertFrom("30"); grid.ColumnDefinitions.Add(column); } for (int i = 0; i < SizeX; i++) { RowDefinition row = new RowDefinition(); grid.RowDefinitions.Add(row); GridLengthConverter gridLengthConverter = new GridLengthConverter(); row.Height = (GridLength)gridLengthConverter.ConvertFrom("30"); } }
public void Saisie_Grid(object sender, RoutedEventArgs e, Grid g) { gr.Children.Clear(); gr.RowDefinitions.Clear(); // Create Rows RowDefinition r1 = new RowDefinition(); r1.Height = new GridLength(145); RowDefinition r2 = new RowDefinition(); GridLengthConverter gridLengthConverter1 = new GridLengthConverter(); r2.Height = (GridLength)gridLengthConverter1.ConvertFrom("*"); RowDefinition r3 = new RowDefinition(); GridLengthConverter gridLengthConverter2 = new GridLengthConverter(); r3.Height = (GridLength)gridLengthConverter2.ConvertFrom("Auto"); g.RowDefinitions.Add(r1); g.RowDefinitions.Add(r2); g.RowDefinitions.Add(r3); }
public static void DefinedGridColumnChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { if (depObj is null) { return; } string[] ColumnSetting = ((string)e.NewValue).Split(','); if (depObj is Grid || ColumnSetting.Length != 0) { Grid grid = (Grid)depObj; grid.ColumnDefinitions.Clear(); foreach (string setting in ColumnSetting) { GridLengthConverter converter = new GridLengthConverter(); ColumnDefinition rowDef = new ColumnDefinition() { Width = (GridLength)converter.ConvertFrom(setting.Trim()) }; grid.ColumnDefinitions.Add(rowDef); } } }
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; }
/// <summary> /// Prepare the control. /// </summary> public void PrepareControl() { this.RowDefinitions.Clear(); var gridLengthConverter = new GridLengthConverter(); this.RowDefinitions.Add(new RowDefinition() { Height = (GridLength)gridLengthConverter.ConvertFrom(35) }); var button = new Button { Content = "+", HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Width = 25, Height = 25, Margin = new Thickness(5), }; button.SetValue(Grid.RowProperty, 0); button.Click += (object sender, RoutedEventArgs e) => { var newElement = this.CreateNewElement(); if (newElement == null) { return; } this.AddElement(newElement); }; this.Children.Add(button); }
public static void DefinedGridRowsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) // logic related to the property goes here { if (depObj is null) { return; } string[] RowSetting = ((string)e.NewValue).Split(','); if (depObj is Grid || RowSetting.Length != 0) { Grid grid = (Grid)depObj; grid.RowDefinitions.Clear(); foreach (string setting in RowSetting) { GridLengthConverter converter = new GridLengthConverter(); RowDefinition rowDef = new RowDefinition() { Height = (GridLength)converter.ConvertFrom(setting.Trim()) }; grid.RowDefinitions.Add(rowDef); } } }
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) }); }
private void LocalMenu_OnItemClicked(string ActionType) { switch (ActionType) { case "RefreshGrid": BindGrid(true); pivotDgInvTrans.RefreshData(); break; case "LocalFilter": if (filterDialog == null) { if (filterCleared) { filterDialog = new CWServerFilter(api, typeof(InvTransClient), null, null, UserFields); } else { filterDialog = new CWServerFilter(api, typeof(InvTransClient), null, null, UserFields); } filterDialog.Closing += filterDialog_Closing; filterDialog.Show(); } else { filterDialog.Show(true); } break; case "ClearLocalFilter": filterDialog = null; filterValues = null; filterCleared = true; BindGrid(); pivotDgInvTrans.RefreshData(); break; case "ChartSettings": CWChartSettings cwChartSettingDialog = new CWChartSettings(pivotDgInvTrans.ChartSelectionOnly, pivotDgInvTrans.ChartProvideColumnGrandTotals, pivotDgInvTrans.ChartProvideRowGrandTotals, labelVisibility, seriesIndex, pivotDgInvTrans.ChartProvideDataByColumns, chartEnable); cwChartSettingDialog.Closed += delegate { if (cwChartSettingDialog.DialogResult == true) { if (cwChartSettingDialog.IsChartVisible) { chartControl.Diagram = cwChartSettingDialog.ChartDaigram; pivotDgInvTrans.ChartProvideEmptyCells = IsPivotTableProvideEmptyCells(); chartControl.Diagram.SeriesTemplate.LabelsVisibility = cwChartSettingDialog.labelVisibility; chartControl.CrosshairEnabled = cwChartSettingDialog.crossHairEnabled; pivotDgInvTrans.ChartProvideDataByColumns = cwChartSettingDialog.chartProvideDataByColumns; pivotDgInvTrans.ChartSelectionOnly = cwChartSettingDialog.ChartSelectionOnly; pivotDgInvTrans.ChartProvideColumnGrandTotals = cwChartSettingDialog.ChartProvideColumnGrandTotals; pivotDgInvTrans.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; } }
private void LocalMenu_OnItemClicked(string ActionType) { switch (ActionType) { case "Search": BtnSearch(); break; case "RefreshGrid": BtnSearch(); break; 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; 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 "Lines": if (selectedCellRow != null && selectedCellColumnFields != null) { OpenBudgetTransactions(selectedCellColumnFields, selectedCellRow); } break; case "Check": AddDockItem(TabControls.TMPlanningCheckPage, null); break; case "ImportPivotTableLayout": case "LoadSavedLayout": controlRibbon_BaseActions(ActionType); pivotDgProjectPlanning.Visibility = Visibility.Visible; break; default: controlRibbon_BaseActions(ActionType); break; } }
/// <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 ConvertFromShouldThrowWhenValueIsNull() { var converter = new GridLengthConverter(); AssertHelper.Throws<ArgumentNullException>(() => converter.ConvertFrom(null, CultureInfo.InvariantCulture, null)); ; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return((bool)value ? new GridLength(0) : converter.ConvertFrom(parameter)); }
private void expander4_Expanded(object sender, RoutedEventArgs e) { Expander expander = sender as Expander; if (expander == expander4) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); g4.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); g5.Height = GridLength.Auto; g6.Height = GridLength.Auto; expander4.IsExpanded = true; expander5.IsExpanded = false; expander6.IsExpanded = false; } if (expander == expander5) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); g4.Height = GridLength.Auto; g5.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); g6.Height = GridLength.Auto; expander4.IsExpanded = false; expander5.IsExpanded = true; expander6.IsExpanded = false; } if (expander == expander6) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); g4.Height = GridLength.Auto; g5.Height = GridLength.Auto; g6.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); expander4.IsExpanded = false; expander5.IsExpanded = false; expander6.IsExpanded = true; } }
private void GridSplitter_MouseDoubleClick(object sender, MouseButtonEventArgs e) { GridLengthConverter glc = new GridLengthConverter(); gMainDisplay.RowDefinitions[0].Height = GridLength.Auto; gMainDisplay.RowDefinitions[0].Height = (GridLength)glc.ConvertFrom(gMainDisplay.RowDefinitions[0].MinHeight + 4); Debug.WriteLine(String.Format("Margin: {0}", ((GridSplitter)sender).Margin)); Debug.WriteLine(String.Format("ActualHeight: {0}", stackPanelSupplyPiles.ActualHeight)); }
private void Expander_Expanded(object sender, RoutedEventArgs e) { Expander expander = sender as Expander; if (expander == expander1) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); g1.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); g2.Height = GridLength.Auto; g3.Height = GridLength.Auto; expander1.IsExpanded = true; expander2.IsExpanded = false; expander3.IsExpanded = false; } if (expander == expander2) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); g1.Height = GridLength.Auto; g2.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); g3.Height = GridLength.Auto; expander1.IsExpanded = false; expander2.IsExpanded = true; expander3.IsExpanded = false; } if (expander == expander3) { GridLengthConverter gridLengthConverter = new GridLengthConverter(); g1.Height = GridLength.Auto; g2.Height = GridLength.Auto; g3.Height = (GridLength)gridLengthConverter.ConvertFrom("*"); expander1.IsExpanded = false; expander2.IsExpanded = false; expander3.IsExpanded = true; } }