public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { double val = (double)value; GridLengthConverter GLConverter = new GridLengthConverter(); GridLength gridLength = (GridLength)(GLConverter.ConvertFromString (val.ToString() + "*")); return gridLength; }
public Main() { InitializeComponent(); var userPrefs = new UserPreferences(); GridLengthConverter myGridLengthConverter = new GridLengthConverter(); GridLength gl1 = (GridLength)myGridLengthConverter.ConvertFromString(userPrefs.WindowLeftColumn.ToString()); this.columnLeft.Width = gl1; gl1 = (GridLength)myGridLengthConverter.ConvertFromString(userPrefs.WindowRightColumn.ToString()); this.columnRight.Width = gl1; this.F1.AddHandler(Favorites.TargetSetClick, new RoutedEventHandler(this.TargetSetClickHandler)); this.F1.AddHandler(Favorites.FavoriteClick, new RoutedEventHandler(this.FavoriteClickEventHandler)); this.T1.AddHandler(TreeExplorer.PopulateEverything, new RoutedEventHandler(this.PopulateEverythingHandler)); this.T1.AddHandler(TreeExplorer.TargetDoubleClick, new RoutedEventHandler(this.TargetDoubleClickHandler)); this.T1.AddHandler(TreeExplorer.TargetClick, new RoutedEventHandler(this.TargetClickHandler)); this.T1.AddHandler(TreeExplorer.StartExplore, new RoutedEventHandler(this.StartExploreHandler)); this.T1.AddHandler(TreeExplorer.FinishedExplore, new RoutedEventHandler(this.FinishedExploreHandler)); this.T1.AddHandler(TreeExplorer.FailedExplore, new RoutedEventHandler(this.FailedExploreHandler)); }
private void r180_Click(object sender, RoutedEventArgs e) { if (beforeRotate != 180) { ArcadeMenu.Display.Rotate(1, Display.Orientations.DEGREES_CW_180); var gridLengthConverter = new System.Windows.GridLengthConverter(); string ww = (this.Width / 4).ToString(); colwidth.Width = (GridLength)gridLengthConverter.ConvertFromString(ww); beforeRotate = 180; } }
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 MainWindow() { InitializeComponent(); this.WindowStyle = WindowStyle.None; this.BringIntoView(); this.Topmost = true; //Get Current Rotation int i = ArcadeMenu.Display.GetCurrentRotate(1); //Sizing tiles to monitor if (i == 3) { var gridLengthConverter1 = new System.Windows.GridLengthConverter(); string ww1 = (this.Width / 20).ToString(); colwidth.Width = (GridLength)gridLengthConverter1.ConvertFromString(ww1); beforeRotate = 270; } if (i == 1) { var gridLengthConverter2 = new System.Windows.GridLengthConverter(); string ww2 = (this.Width / 20).ToString(); colwidth.Width = (GridLength)gridLengthConverter2.ConvertFromString(ww2); beforeRotate = 90; } if (i == 2) { var gridLengthConverter3 = new System.Windows.GridLengthConverter(); string ww3 = (this.Width / 4).ToString(); colwidth.Width = (GridLength)gridLengthConverter3.ConvertFromString(ww3); beforeRotate = 180; } if (i == 0) { var gridLengthConverter = new System.Windows.GridLengthConverter(); string ww = (this.Width / 4).ToString(); colwidth.Width = (GridLength)gridLengthConverter.ConvertFromString(ww); beforeRotate = 0; } //MessageBox.Show(i.ToString()); //Defaults on startup // beforeRotate = ArcadeMenu.Display.GetCurrentRotate(1); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); this.WindowState = WindowState.Maximized; }
/// <summary> /// Create a grid length from a string, consistently in WPF, WP7 and SL. /// </summary> /// <param name="gridLength">The grid length, e.g. 4*, Auto, 23 etc.</param> /// <returns>A gridlength.</returns> public GridLength ConvertFromString(string gridLength) { // If we're NOT in silverlight, we have a gridlength converter // we can use. #if !SILVERLIGHT // Create the standard windows grid length converter. var gridLengthConverter = new System.Windows.GridLengthConverter(); // Return the converted grid length. return((GridLength)gridLengthConverter.ConvertFromString(gridLength)); #else // We are in silverlight and do not have a grid length converter. // We can do the conversion by hand. // Auto is easy. if (gridLength == "Auto") { return(new GridLength(1, GridUnitType.Auto)); } else if (gridLength.Contains("*")) { // It's a starred value, remove the star and get the coefficient as a double. double coefficient = 1; string starVal = gridLength.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("'" + gridLength + "' is not a valid value."); } // We've handled the star value. return(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(gridLength, out pixelVal) == false) { throw new Exception("'" + gridLength + "' is not a valid value."); } // We've handled the star value. return(new GridLength(pixelVal, GridUnitType.Pixel)); } #endif }
/// <summary> /// Create a grid length from a string, consistently in WPF, WP7 and SL. /// </summary> /// <param name="gridLength">The grid length, e.g. 4*, Auto, 23 etc.</param> /// <returns>A grid length.</returns> public GridLength ConvertFromString(string gridLength) { // If we're NOT in silverlight, we have a gridlength converter // we can use. #if !SILVERLIGHT && !NETFX_CORE // Create the standard windows grid length converter. var gridLengthConverter = new System.Windows.GridLengthConverter(); // Return the converted grid length. return (GridLength)gridLengthConverter.ConvertFromString(gridLength); #else // We are in silverlight and do not have a grid length converter. // We can do the conversion by hand. // Auto is easy. if (gridLength == "Auto") { return new GridLength(1, GridUnitType.Auto); } // if if (gridLength.Contains("*")) { // It's a starred value, remove the star and get the coefficient as a double. double coefficient = 1; var starVal = gridLength.Replace("*", string.Empty); // 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("'" + gridLength + "' is not a valid value."); } // if // We've handled the star value. return new GridLength(coefficient, GridUnitType.Star); } // if // It's not auto or star, so unless it's a plain old pixel // value we must throw an exception. double pixelVal; if (double.TryParse(gridLength, out pixelVal) == false) { throw new Exception("'" + gridLength + "' is not a valid value."); } // if // We've handled the star value. return new GridLength(pixelVal, GridUnitType.Pixel); #endif } // ConvertFromString
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); } }
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]; }
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; }
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; }
private void _onScreenLoaded(object sender, RoutedEventArgs e) { if (!_screenLoaded) { Func<string, GridLength[]> parseGridLengths = lengths => { if (lengths.IsEmpty()) return null; var converter = new GridLengthConverter(); return lengths.Split(",").Select(p => (GridLength)converter.ConvertFromString(p)).ToArray(); }; var editorCols = parseGridLengths(USER.Default.Script_EditorCols); if (editorCols != null) { for (var i = 0; i < editorCols.Length; i++) { EditorGrid.ColumnDefinitions[i].Width = editorCols[i]; } } var editorRows = parseGridLengths(USER.Default.Script_EditorRows); if (editorRows != null) { for (var i = 0; i < editorRows.Length; i++) { EditorGrid.RowDefinitions[i].Height = editorRows[i]; } } _codeEditor.SetBinding(CodeEditor.ScriptNodeProperty, this, "SelectedBlock.ScriptNode"); Shell.ModelLoaded += _onShellLoaded; Shell.CurrentClassDragged += _onShellClassDragged; Shell.Closing += _onShellClosing; _screenLoaded = true; } if (Shell.IsModelLoaded) { _onShellLoaded(sender, e); } }
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 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; }
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 void GetDependants(string text) { // get dependancy object! var depended = SQLExecutor.ExecuteStoredProcedure("sp_MSdependencies", new SQLParameter[] { new SQLParameter() { DbType= DbType.String, ParameterName="@objname", Value = "dbo."+text}, new SQLParameter() { DbType= DbType.Int64, ParameterName="@flags", Value = 1315327}, new SQLParameter() { DbType= DbType.String, ParameterName="@objlist", Value = null} }); var tab = new Table(); var gridLenghtConvertor = new GridLengthConverter(); tab.Columns.Add(new TableColumn() { Name = "colD", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.Columns.Add(new TableColumn { Name = "colUD", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.RowGroups.Add(new TableRowGroup()); tab.RowGroups[0].Rows.Add(new TableRow()); var tabRow = tab.RowGroups[0].Rows[0]; Action<bool, List<string>> fnAddRow = (isDepends, values) => { Paragraph para = new Paragraph(); if (isDepends) { para.Inlines.Add(new Run("Object that depend on ") { Foreground = new SolidColorBrush(Colors.Green) }); para.Inlines.Add(new Bold(new Run(text)) { Foreground = new SolidColorBrush(Colors.Green) }); } else { para.Inlines.Add(new Run("Objects on which ") { Foreground = new SolidColorBrush(Colors.Green) }); para.Inlines.Add(new Bold(new Run(text)) { Foreground = new SolidColorBrush(Colors.Green) }); para.Inlines.Add(new Run(" depends") { Foreground = new SolidColorBrush(Colors.Green) }); } para.Inlines.Add(Environment.NewLine); para.Inlines.Add(new Run("—————————————————————————————————————") { Foreground = new SolidColorBrush(Colors.Green) }); para.Inlines.Add(Environment.NewLine); para.Inlines.Add(new Run(string.Join(Environment.NewLine, values))); para.Inlines.Add(new Run(Environment.NewLine)); tabRow.Cells.Add(new TableCell(para)); }; List<string> lsDepended = new List<string>(); List<string> lsDependant = new List<string>(); foreach (DataRow dt in depended.Tables[0].Rows) { lsDepended.Add(dt[1].ToString()); } fnAddRow(true, lsDepended); var depends = SQLExecutor.ExecuteStoredProcedure("sp_MSdependencies", new SQLParameter[] { new SQLParameter() { DbType= DbType.String, ParameterName="@objname", Value = "dbo."+text}, new SQLParameter() { DbType= DbType.Int64, ParameterName="@flags", Value = 1053183}, new SQLParameter() { DbType= DbType.String, ParameterName="@objlist", Value = null} }); foreach (DataRow dt in depends.Tables[0].Rows) { lsDepended.Add(dt[1].ToString()); } fnAddRow(false, lsDepended); txtReferrerInfo.Document.Blocks.Clear(); txtReferrerInfo.Document.Blocks.Add(tab); }
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 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 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 void GetKeyInfo(string text) { ProcessingInfoLbl.Text = "3.Keys"; var dTable = SQLExecutor.ExecuteDataTable("select TC.CONSTRAINT_TYPE, CCU.COLUMN_NAME, CCU.CONSTRAINT_NAME from INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC inner join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE as CCU on TC.CONSTRAINT_CATALOG = CCU.CONSTRAINT_CATALOG and TC.CONSTRAINT_SCHEMA = CCU.CONSTRAINT_SCHEMA and TC.CONSTRAINT_NAME = CCU.CONSTRAINT_NAME where TC.TABLE_NAME = '" + text + "' order by TC.CONSTRAINT_TYPE, CCU.COLUMN_NAME"); List<string> pk = new List<string>(); List<string> fk = new List<string>(); List<string> uk = new List<string>(); if (dTable.Rows.Count > 0) { foreach (DataRow rows in dTable.Rows) { switch (rows[0].ToString()) { case "PRIMARY KEY": pk.Add(rows[1].ToString()); break; case "FOREIGN KEY": fk.Add(rows[1].ToString()); break; case "UNIQUE": uk.Add(rows[1].ToString()); break; default: break; } } } var tab = new Table(); var gridLenghtConvertor = new GridLengthConverter(); tab.Columns.Add(new TableColumn() { Name = "colPK", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.Columns.Add(new TableColumn { Name = "colFK", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.Columns.Add(new TableColumn() { Name = "colUK", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") }); tab.RowGroups.Add(new TableRowGroup()); tab.RowGroups[0].Rows.Add(new TableRow()); var tabRow = tab.RowGroups[0].Rows[0]; Action<string, List<string>> fnAddRow = (txt, values) => { Paragraph para = new Paragraph(); para.Inlines.Add(new Run(txt) { Foreground = new SolidColorBrush(Colors.Green) }); para.Inlines.Add(Environment.NewLine); para.Inlines.Add(new Run("———————————————————————————————") { Foreground = new SolidColorBrush(Colors.Green) }); para.Inlines.Add(Environment.NewLine); para.Inlines.Add(new Run(string.Join(Environment.NewLine, values))); para.Inlines.Add(new Run(Environment.NewLine)); tabRow.Cells.Add(new TableCell(para)); }; if (pk.Count > 0) fnAddRow("PRIMARY KEY", pk); if (fk.Count > 0) fnAddRow("FOREIGN KEY", fk); if (uk.Count > 0) fnAddRow("UNIQUE KEY", uk); txtProcessingInfo.Document.Blocks.Clear(); txtProcessingInfo.Document.Blocks.Add(tab); }
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; }
public void SetBackGroundStatus (String RuntimeMessage) { GridLengthConverter GL = new GridLengthConverter (); if (String.IsNullOrEmpty (RuntimeMessage)) RootGrid.RowDefinitions [3].Height = (GridLength) GL.ConvertFromString ("0"); else { RootGrid.RowDefinitions [3].Height = (GridLength) GL.ConvertFromString ("25"); BackGroundText.Content = RuntimeMessage; } }
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 void CreateRootGeometry (int ScreenHeight, int VideoHeight) { GridLengthConverter GLConverter = new GridLengthConverter (); ColumnDefinition RootGrid_Column = new ColumnDefinition (); RootGrid_Column.Width = (GridLength)GLConverter.ConvertFromString ("*"); this.Grid_Root.ColumnDefinitions.Add (RootGrid_Column); RowDefinition DynamicGrid_Row = new RowDefinition (); DynamicGrid_Row.Height = (GridLength)GLConverter.ConvertFromString (Convert.ToString (ScreenHeight * m_CVM.NavigationWindowGeometrieYFactor) + "*"); this.Grid_Root.RowDefinitions.Add (DynamicGrid_Row); Button_Grid_Root = new Grid (); this.Grid_Root.Children.Insert (0, Button_Grid_Root); Grid.SetColumn (Button_Grid_Root, 0); Grid.SetRow (Button_Grid_Root, 0); RowDefinition StaticGrid_Row = new RowDefinition (); StaticGrid_Row.Height = (GridLength)GLConverter.ConvertFromString (Convert.ToString (ScreenHeight * (1.0 - m_CVM.NavigationWindowGeometrieYFactor)) + "*"); this.Grid_Root.RowDefinitions.Add (StaticGrid_Row); Static_Grid_Root = new Grid (); this.Grid_Root.Children.Add (Static_Grid_Root); Grid.SetColumn (Static_Grid_Root, 0); Grid.SetRow (Static_Grid_Root, 1); WPMediaNavigation.HandleAllButtonPage.Button_Grid_Root = Button_Grid_Root; WPMediaNavigation.HandleAllButtonPage.Static_Grid_Root = Static_Grid_Root; WPMediaNavigation.HandleAllButtonPage.LocalWPMediaRoot = m_CVM.GetLocalWPMediaRoot (); WPMediaNavigation.HandleAllButtonPage.CreatedForHeightFactor = m_CVM.CreatedForHeightFactor; ColumnDefinition StaticRootGrid_Column = new ColumnDefinition(); StaticRootGrid_Column.Width = (GridLength)GLConverter.ConvertFromString("*"); Static_Grid_Root.ColumnDefinitions.Add(StaticRootGrid_Column); //RowDefinition StaticRootGrid_Upper_Row = new RowDefinition (); //StaticRootGrid_Upper_Row.Height = (GridLength)GLConverter.ConvertFromString ("*"); //Static_Grid_Root.RowDefinitions.Add (StaticRootGrid_Upper_Row); //RowDefinition StaticRootGrid_Lower_Row = new RowDefinition (); //StaticRootGrid_Lower_Row.Height = (GridLength)GLConverter.ConvertFromString ("*"); //Static_Grid_Root.RowDefinitions.Add (StaticRootGrid_Lower_Row); }
/// <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; }
private void CreateRequiredGrid (Grid RootGrid, ButtonPageData ActuallXmlButtons) { BrushConverter BRConverter = new BrushConverter (); GridLengthConverter GLConverter = new GridLengthConverter (); RootGrid.Children.Clear (); RootGrid.RowDefinitions.Clear (); RootGrid.ColumnDefinitions.Clear (); int ColumnIndex = 0; while (ColumnIndex < ActuallXmlButtons.m_NumberOfRowsAndColumns.Width) { ColumnDefinition GlobalGrid_Column = new ColumnDefinition (); GlobalGrid_Column.Width = (GridLength)GLConverter.ConvertFromString ("*"); RootGrid.ColumnDefinitions.Add (GlobalGrid_Column); ColumnIndex++; } int RowIndex = 0; while (RowIndex < ActuallXmlButtons.m_NumberOfRowsAndColumns.Height) { RowDefinition GlobalGrid_Row = new RowDefinition (); GlobalGrid_Row.Height = (GridLength)GLConverter.ConvertFromString ("*"); RootGrid.RowDefinitions.Add (GlobalGrid_Row); RowIndex++; } }
//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; }
public MainWindow() { //разрешаем запустить только один экземпляр try { Process process = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(process.ProcessName); foreach (Process _process in processes) { if (_process.Id != process.Id && _process.MainModule.FileName == process.MainModule.FileName) { process.Kill(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.InitializeComponent(); try { //Установка параметров окна из сохраненных настроек if (Settings.WindowResize) { string[] value = (Settings.WindowLocation + "/" + Settings.TasksRows).Split('/'); if (value.Length == 6) { this.Width = Convert.ToDouble(value[0]); this.Height = Convert.ToDouble(value[1]); this.Left = Convert.ToDouble(value[2]); this.Top = Convert.ToDouble(value[3]); GridLengthConverter conv = new GridLengthConverter(); string sep = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; this.TasksRow.Height = (GridLength)conv.ConvertFromString(value[4].Replace(".", sep).Replace(",", sep)); this.TasksRow2.Height = (GridLength)conv.ConvertFromString(value[5].Replace(".", sep).Replace(",", sep)); } } } catch (Exception ex) { ErrorException("Initializing (WindowSize): " + ex.Message, ex.StackTrace); } try { //Определяем наличие Ависинта SysInfo.RetrieveAviSynthInfo(); } catch (Exception ex) { ErrorException("Initializing (AviSynth): " + ex.Message, ex.StackTrace); } try { //Трей System.Windows.Forms.ContextMenuStrip TrayMenu = new System.Windows.Forms.ContextMenuStrip(); TrayIcon = new System.Windows.Forms.NotifyIcon(); //Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/pictures/Top.ico")).Stream; Stream iconStream = Application.GetResourceStream(new Uri("main.ico", UriKind.RelativeOrAbsolute)).Stream; TrayIcon.Icon = new System.Drawing.Icon(iconStream); //Пункт меню "Close to tray" tmnTrayClose = new System.Windows.Forms.ToolStripMenuItem(); tmnTrayClose.Text = "Close to tray"; tmnTrayClose.CheckOnClick = true; tmnTrayClose.Checked = Settings.TrayClose; tmnTrayClose.Click += new EventHandler(tmnTrayClose_Click); TrayMenu.Items.Add(tmnTrayClose); //Пункт меню "Minimize to tray" tmnTrayMinimize = new System.Windows.Forms.ToolStripMenuItem(); tmnTrayMinimize.Text = "Minimize to tray"; tmnTrayMinimize.CheckOnClick = true; tmnTrayMinimize.Checked = Settings.TrayMinimize; tmnTrayMinimize.Click += new EventHandler(tmnTrayMinimize_Click); TrayMenu.Items.Add(tmnTrayMinimize); //Пункт меню "1-Click" tmnTrayClickOnce = new System.Windows.Forms.ToolStripMenuItem(); tmnTrayClickOnce.Text = "Single click to open"; tmnTrayClickOnce.CheckOnClick = true; tmnTrayClickOnce.Checked = Settings.TrayClickOnce; tmnTrayClickOnce.Click += new EventHandler(tmnTrayClickOnce_Click); TrayMenu.Items.Add(tmnTrayClickOnce); //Пункт меню "Disable balloons" tmnTrayNoBalloons = new System.Windows.Forms.ToolStripMenuItem(); tmnTrayNoBalloons.Text = "Disable balloons"; tmnTrayNoBalloons.CheckOnClick = true; tmnTrayNoBalloons.Checked = Settings.TrayNoBalloons; tmnTrayNoBalloons.Click += new EventHandler(tmnTrayNoBalloons_Click); TrayMenu.Items.Add(tmnTrayNoBalloons); TrayMenu.Items.Add(new System.Windows.Forms.ToolStripSeparator()); //Пункт меню "Exit" tmnExit = new System.Windows.Forms.ToolStripMenuItem(); tmnExit.Text = "Exit"; tmnExit.Click += new EventHandler(mnExit_Click); TrayMenu.Items.Add(tmnExit); TrayIcon.ContextMenuStrip = TrayMenu; TrayIcon.Text = "XviD4PSP"; } catch (Exception ex) { ErrorException("Initializing (TrayIcon): " + ex.Message, ex.StackTrace); } try { UpdateRecentFiles(); //Список недавних файлов MenuHider(false); //Делаем пункты меню неактивными SetHotKeys(); //Загружаем HotKeys SetLanguage(); //переводим лейблы textbox_name.Text = textbox_frame.Text = textbox_frame_goto.Text = ""; textbox_time.Text = textbox_duration.Text = "00:00:00"; //Определяем коэффициент dpi SysInfo.RetrieveDPI(this); } catch (Exception ex) { ErrorException("Initializing (Misc): " + ex.Message, ex.StackTrace); } try { //Пользовательские утилиты LoadCustomTools(); } catch (Exception ex) { ErrorException("Initializing (CustomTools): " + ex.Message, ex.StackTrace); } try { //events this.PreviewKeyDown += new KeyEventHandler(MainWindow_KeyDown); this.StateChanged += new EventHandler(MainWindow_StateChanged); this.textbox_name.MouseEnter += new MouseEventHandler(textbox_name_MouseEnter); //Мышь вошла в зону с названием файла this.textbox_name.MouseLeave += new MouseEventHandler(textbox_name_MouseLeave); //Мышь вышла из зоны с названием файла if (Settings.TrayClickOnce) TrayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(TrayIcon_Click); else TrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(TrayIcon_Click); DDHelper ddh = new DDHelper(this); ddh.GotFiles += new DDEventHandler(DD_GotFiles); } catch (Exception ex) { ErrorException("Initializing (Events): " + ex.Message, ex.StackTrace); } }
private static IEnumerable<GridLength> GridLengths(string s) { GridLengthConverter converter = new GridLengthConverter(); return s.Split(',').Select(i => converter.ConvertFromString(i)).OfType<GridLength>(); }
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++; } } }
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; }
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); } } }