public void InitializeItems(Altaxo.Collections.ListNodeList list) { int rowsNeeded = (list.Count + 1) >> 1; int diff = rowsNeeded - _guiGrid.RowDefinitions.Count; for (int i = diff - 1; i >= 0; --i) _guiGrid.RowDefinitions.Add(new RowDefinition()); _guiGrid.Children.Clear(); int itemIdx = -1; foreach (var t in list) { itemIdx++; int column = itemIdx % 2; int row = itemIdx >> 1; var label = new Label() { Content = t.Text }; label.SetValue(Grid.ColumnProperty, 2 * column); label.SetValue(Grid.RowProperty, row); _guiGrid.Children.Add(label); var uiElement = (FrameworkElement)t.Tag; uiElement.SetValue(Grid.ColumnProperty, 2 * column + 1); uiElement.SetValue(Grid.RowProperty, row); uiElement.Margin = new Thickness(4); _guiGrid.Children.Add(uiElement); } }
public void createGrid(int x, int y) { Border border = new Border(); border.Background = new SolidColorBrush(Colors.Black); levelGrid = new Grid(); level.Children.Add(levelGrid); levelGrid.Background = new SolidColorBrush(Colors.Green); levelGrid.Width = x * levelGridCellSize; levelGrid.Height = y * levelGridCellSize; levelGrid.ShowGridLines = true; levelGrid.MouseDown += new MouseButtonEventHandler(levelGrid_MouseDown); for (int i = 0; i < x; i++) { ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(levelGridCellSize); levelGrid.ColumnDefinitions.Add(col); } for (int i = 0; i < y; i++) { RowDefinition row = new RowDefinition(); row.Height = new GridLength(levelGridCellSize); levelGrid.RowDefinitions.Add(row); for (int j = 0; j < y; j++) { Label label = new Label(); label.Content = i + " " + j; label.SetValue(Grid.ColumnProperty, j); label.SetValue(Grid.RowProperty, i); levelGrid.Children.Add(label); } } }
public static void GenereateFields() { // Get the Grid from the MainWindow Grid AuthenticationGrid = ((MainWindow)System.Windows.Application.Current.MainWindow).AuthenticationGrid; // Build a list of Digest Auth Fields List<string> fields = new List<string>(); fields.Add("Username"); fields.Add("Password"); for (int i = 0; i < fields.Count; i++) { // Add a row to the AuthGrid RowDefinition rowDefinition = new RowDefinition(); rowDefinition.Height = GridLength.Auto; AuthenticationGrid.RowDefinitions.Add(rowDefinition); // Add a Label Label label = new Label(); label.SetValue(Grid.RowProperty, i + 1); label.SetValue(Grid.ColumnProperty, 0); label.Name = "AuthenticationKey" + i; label.Content = fields[i] + ":"; AuthenticationGrid.Children.Add(label); // Add a textbox TextBox textBox = new TextBox(); textBox.SetValue(Grid.RowProperty, i + 1); textBox.SetValue(Grid.ColumnProperty, 1); textBox.Name = "AuthenticationValue" + i; AuthenticationGrid.Children.Add(textBox); } }
private void cnvCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { Point p = e.GetPosition(cnvCanvas); Label l = new Label(); l.Content = "X"; l.SetValue(Canvas.LeftProperty, p.X); l.SetValue(Canvas.TopProperty, p.Y); cnvCanvas.Children.Add(l); }
public virtual void initEntityForm( object obj,bool AddState) { if (AddState == true) { btnAdd.Visibility = Visibility.Visible; btnUpdate.Visibility = Visibility.Collapsed; } else { btnAdd.Visibility = Visibility.Collapsed; btnUpdate.Visibility = Visibility.Visible; } Type type = obj.GetType(); //设置Title txtEntityTitle.Text = "详情"; this.Title = type.Name; EntityGrid.SetValue(Grid.ShowGridLinesProperty, true); //显示网格 //设置实体属性 PropertyInfo[] infos = type.GetProperties(); for (int i = 0; i < infos.Count(); i++) { RowDefinition row=new RowDefinition(); EntityGrid.RowDefinitions.Add(row); PropertyInfo pinfo = infos[i]; if (pinfo.Name == "EntityKey") continue; Label lable = new Label(); lable.Content=pinfo.Name+":"; lable.Margin = new Thickness(0, 10, 0, 0); EntityGrid.Children.Add(lable); lable.SetValue(Grid.ColumnProperty, 0); lable.SetValue(Grid.RowProperty, i); //EntityGrid. //LeftLabelArea.Children.Add(lable); //pinfo.Name; //pinfo.GetValue(obj, null); TextBox txtBox = new TextBox(); txtBox.Name = pinfo.Name.Trim(); txtBox.Margin = new Thickness(0, 10, 0, 0); string strPinfoValue = string.Empty; if (pinfo.GetValue(obj, null) != null) { strPinfoValue = pinfo.GetValue(obj, null).ToString(); } txtBox.Text = strPinfoValue; //RightDataArea.Children.Add(txtBox); EntityGrid.Children.Add(txtBox); txtBox.SetValue(Grid.ColumnProperty, 1); txtBox.SetValue(Grid.RowProperty, i); } }
public MainWindow() { Snowflakes = new ObservableCollection<object>(); InitializeComponent(); // Add month names to bottom. string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; foreach ( string month in months ) { var label = new Label { Content = month, Foreground = Brushes.White, FontSize = 14 }; label.SetValue( TimePanel.XProperty, DateTime.Parse( month + " 2015" ) ); label.SetValue( TimePanel.YProperty, Timeline.VisibleIntervalY.End ); Timeline.Children.Add( label ); } }
public void SetParametersSource(List<System.Data.OleDb.OleDbParameter> parms) { int nRow = -1; foreach (var p in parms) { _grid.RowDefinitions.Add(new RowDefinition()); ++nRow; // create label var lbl = new Label(); lbl.Content = CleanupName(p.ParameterName); lbl.SetValue(Grid.RowProperty, nRow); _grid.Children.Add(lbl); // create input control Control ctl = GetControl(p); ctl.Tag = p; ctl.SetValue(Grid.RowProperty, nRow); ctl.SetValue(Grid.ColumnProperty, 1); _grid.Children.Add(ctl); if (_focus == null) { _focus = ctl; } } }
private void showScore(String map) { //Remove all rows except for the first one. (The header row) highScoreGrid.RowDefinitions.Clear(); highScoreGrid.Children.Clear(); highScoreGrid.RowDefinitions.Add(new RowDefinition()); highScoreGrid.Children.Add(headerPlayer); highScoreGrid.Children.Add(headerMoves); highScoreGrid.Children.Add(headerTimer); //Get the highscores for the chosen map. ModelScore[] scores = highScore.getHighScore(map).ToArray(); //Show the scores. int rowNumber = 1; foreach (ModelScore score in scores) { //Create the row RowDefinition row = new RowDefinition(); row.Height = new GridLength(rowHeight, GridUnitType.Pixel); highScoreGrid.RowDefinitions.Add(row); //Add the information to the row columns.. Label player = new Label(); player.Content = score.PlayerName; player.SetValue(Grid.ColumnProperty, 0); player.SetValue(Grid.RowProperty, rowNumber); highScoreGrid.Children.Add(player); Label moves = new Label(); moves.Content = score.Moves; moves.SetValue(Grid.ColumnProperty, 1); moves.SetValue(Grid.RowProperty, rowNumber); highScoreGrid.Children.Add(moves); Label time = new Label(); time.Content = (score.Time / 60) + ":" + (score.Time % 60); time.SetValue(Grid.ColumnProperty, 2); time.SetValue(Grid.RowProperty, rowNumber); highScoreGrid.Children.Add(time); rowNumber++; } }
public static Label MakeSimpleLabel(string text, Rect bounds, System.Windows.Media.Brush brush) { Label label = new Label { Content = text }; if (bounds.Width != 0) { label.SetValue(Canvas.LeftProperty, bounds.Left); label.SetValue(Canvas.TopProperty, bounds.Top); label.Width = bounds.Width; label.Height = bounds.Height; } label.Foreground = brush; label.FontFamily = new System.Windows.Media.FontFamily("Arial"); label.FontWeight = FontWeight.FromOpenTypeWeight(600); label.FontStyle = FontStyles.Normal; label.HorizontalAlignment = HorizontalAlignment.Center; label.VerticalAlignment = VerticalAlignment.Center; return label; }
public void DrawLabel(int x, int y, int width, int height, string text, Color color) { Label label = new Label(); label.Content = text; label.SetValue(Canvas.LeftProperty, (double)x); label.SetValue(Canvas.TopProperty, (double)y); label.Background = new SolidColorBrush(Colors.Transparent); label.Foreground = new SolidColorBrush(color); if (label.Width > width) { label.Width = width; } //label.Width = 20; label.Height = height; ToolTipService.SetToolTip(label, text); Canvas.Children.Add(label); }
public RowEditorWindow(ImportStagingService service, int rowId, List<ImportFieldMapping> mappings, DataRowView row) { InitializeComponent(); this.Service = service; this.RowID = rowId; this.Row = row; this.Mappings = mappings; int rowIndex = 0; foreach (ImportFieldMapping mapping in mappings) { gridFields.RowDefinitions.Add(CreateRowDefinition()); var lbl = new Label(); lbl.SetValue(Grid.RowProperty, rowIndex); lbl.Content = mapping.SourceColumn; gridFields.Children.Add(lbl); var txt = new Extensibility.TextBox(); txt.SetValue(Grid.ColumnProperty, 1); txt.SetValue(Grid.RowProperty, rowIndex); txt.Height = 23; var objValue = row[mapping.SourceColumn]; var strValue = (objValue == null ? "" : objValue.ToString()); var value = new FieldValue(mapping.TargetColumn, strValue); var binding = new Binding("Value"); binding.Source = value; binding.ValidatesOnDataErrors = true; txt.SetBinding(TextBox.TextProperty, binding); // txt.Text = strValue; var fieldMapping = mapping; // need to keep a copy of this mapping so its captured in the closure txt.TextChanged += new TextChangedEventHandler((source, e) => { var textbox = source as TextBox; if (textbox.Text != strValue) { _changeMap[fieldMapping.SourceColumn] = textbox.Text; } else { if (_changeMap.ContainsKey(fieldMapping.SourceColumn)) { _changeMap.Remove(fieldMapping.SourceColumn); } } }); gridFields.Children.Add(txt); rowIndex++; } }
public SudokuSquare(int id, int x, int y) { Rectangle rectangle = new Rectangle(); rectangle.Width = 40; rectangle.Height = 37; rectangle.SetValue(Canvas.TopProperty, Convert.ToDouble(y)); rectangle.SetValue(Canvas.LeftProperty, Convert.ToDouble(x)); GradientStopCollection gradients = new GradientStopCollection(); Label label = new Label(); label.Height = 37; label.Width = 40; label.FontSize = 25; label.SetValue(Canvas.TopProperty, Convert.ToDouble(y - 5)); label.SetValue(Canvas.LeftProperty, Convert.ToDouble(x + 7)); label.Name = "B" + (id).ToString(); }
/// <summary> /// 构造函数,参数为主体网格,以及行数列数 /// </summary> /// <param name="grid"></param> /// <param name="row"></param> /// <param name="column"></param> public GameFrame(Grid grid, int row, int column) { boxDropInterval = 500; this.grid = grid; this.row = row; this.column = column; State = GameState.Stoped; boxNum = 0; Hard = 1; for (int i = 0; i < column; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < row; i++) { grid.RowDefinitions.Add(new RowDefinition()); } container = new Container(row, column); boxFactory = new BoxFactory(); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { Label lbl = new Label(); container.map[i, j] = new GridData(); container.map[i, j].Lbl = lbl; container.map[i, j].Value = BoxShape.NULL; lbl.SetValue(Grid.RowProperty, i); lbl.SetValue(Grid.ColumnProperty, j); grid.Children.Add(lbl); } } ClearMap(); }
public void Initialize(string[] names) { for (int i = 0; i < names.Length; ++i) { RowDefinition rowDef = new RowDefinition(); rowDef.Height = new GridLength(30.0); this.CellGrid.RowDefinitions.Add(rowDef); Label label = new Label(); label.Content = names[i]; this.CellGrid.Children.Add(label); label.SetValue(Grid.RowProperty, i); label.SetValue(Grid.ColumnProperty, 0); Label valueLabel = new Label(); this.labels.Add(valueLabel); this.CellGrid.Children.Add(valueLabel); valueLabel.SetValue(Grid.RowProperty, i); valueLabel.SetValue(Grid.ColumnProperty, 1); } }
private void SetDay(Grid Day,string sub,string start,string end) { int startidx = TimeRow.IndexOf(start); int endidx = TimeRow.IndexOf(end) - startidx; CreateRowDefinition(Day); Label l = new Label(); l.Style = (Style)this.Resources["CommonLabel"]; TextBlock tb = new TextBlock(); tb.TextWrapping = TextWrapping.WrapWithOverflow; tb.Text = sub; l.Content = tb; l.SetValue(Grid.RowProperty, startidx); l.SetValue(Grid.RowSpanProperty, endidx + 1); l.ContextMenu = (ContextMenu)this.Resources["context"]; Day.Children.Add(l); }
private System.Windows.Controls.Label DrawNode(string text) { System.Windows.Controls.Label lbl = new System.Windows.Controls.Label(); lbl.Name = "lbl"; lbl.Content = text; lbl.ToolTip = text; lbl.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; Thickness thickness = new Thickness(2, 2, 2, 2); lbl.Margin = thickness; lbl.SetValue(Grid.RowProperty, 0); lbl.Background = Brushes.Tomato; return(lbl); }
//private MainWindow mainWidow; public BiasesWindow() { InitializeComponent(); BiasesInterface.BiasName bname = 0; //foreach (BiasesInterface.BiasName bname in BiasesInterface.BiasName) for (byte i = 0; i < 26; i++) { var newPanel = new DockPanel(); newPanel.Margin = new Thickness(5); var newSlider = new Slider() { Maximum = BiasesInterface.BiasMaxVoltage[bname], Value = BiasesInterface.BiasVoltage[bname], SmallChange = 1, LargeChange = 10, Width = 100, Name = BiasesInterface.stringNames[bname] }; var newLabel = new Label(); var valueLabel = new Label(); newLabel.Width = 100; newLabel.SetValue(DockPanel.DockProperty, Dock.Right); newLabel.Content = BiasesInterface.stringNames[bname]; valueLabel.SetValue(DockPanel.DockProperty, Dock.Left); valueLabel.Width = 40; valueLabel.Tag = "value"; valueLabel.Content = BiasesInterface.BiasVoltage[bname].ToString(); newSlider.ValueChanged += newSlider_ValueChanged; newSlider.Tag = i; newPanel.Children.Add(newSlider); newPanel.Children.Add(newLabel); newPanel.Children.Add(valueLabel); sliderPanel.Children.Add(newPanel); bname++; } }
public void Values_Initialize(IEnumerable<Tuple<string, Type, object>> values) { _elements.Clear(); _guiGrid.Children.Clear(); _guiGrid.RowDefinitions.Clear(); int idx = 0; foreach (var tuple in values) { _guiGrid.RowDefinitions.Add(new RowDefinition()); _guiGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(4) }); var label = new Label { Content = tuple.Item1 + ":" }; label.SetValue(Grid.RowProperty, idx * 2); _guiGrid.Children.Add(label); FrameworkElement fe; if (tuple.Item2 == typeof(double)) { var item = new Altaxo.Gui.Common.NumericDoubleTextBox(); fe = item; if (tuple.Item3 is double) item.SelectedValue = (double)tuple.Item3; } else { throw new NotImplementedException(); } fe.SetValue(Grid.ColumnProperty, 2); fe.SetValue(Grid.RowProperty, idx * 2); _guiGrid.Children.Add(fe); _elements.Add(new Tuple<Type, FrameworkElement>(tuple.Item2, fe)); ++idx; } // append another RowDefinition to ensure that the textboxes are not expanded vertically _guiGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(4, GridUnitType.Star) }); }
public LevelEditDialog(string text, object maxLevel, bool showPreview, bool showPreview2, bool autoFill) : base("Level edit", "cde.ico", SizeToContent.Height, ResizeMode.CanResize) { _autoFill = autoFill; InitializeComponent(); Extensions.SetMinimalSize(this); int max; if (maxLevel is int) { max = (int)maxLevel; } else if (maxLevel is string) { if (!Int32.TryParse((string)maxLevel, out max)) { max = 20; } } else { max = 20; } if (max <= 0) { _tkInfo.Visibility = Visibility.Visible; _partialFill = true; max = 30; } string[] values = text.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < max; i++) { Label label = new Label(); label.Content = "Level " + (i + 1); label.Padding = new Thickness(0); label.Margin = new Thickness(3); label.VerticalAlignment = VerticalAlignment.Center; label.SetValue(Grid.RowProperty, i % 10); label.SetValue(Grid.ColumnProperty, (i / 10) * 3); _upperGrid.Children.Add(label); } int numOfColumns = ((max - 1) / 10) + 1; numOfColumns = numOfColumns > 3 ? 3 : numOfColumns; Width = 300 * numOfColumns; for (int i = 0; i < numOfColumns; i++) { _upperGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); _upperGrid.ColumnDefinitions.Add(new ColumnDefinition()); _upperGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(-1, GridUnitType.Auto) }); } for (int i = 0; i < max; i++) { Label preview = new Label(); preview.Padding = new Thickness(0); preview.Margin = new Thickness(3); preview.VerticalAlignment = VerticalAlignment.Center; preview.HorizontalAlignment = HorizontalAlignment.Right; TextBlock preview2 = new TextBlock(); preview2.Padding = new Thickness(0); preview2.Margin = new Thickness(7, 6, 0, 6); preview2.TextAlignment = TextAlignment.Left; preview2.IsHitTestVisible = false; preview2.VerticalAlignment = VerticalAlignment.Center; preview2.Foreground = Brushes.DarkGray; TextBox box = new TextBox(); box.Margin = new Thickness(3, 6, 3, 6); box.VerticalAlignment = VerticalAlignment.Center; box.SetValue(Grid.RowProperty, i % 10); preview2.SetValue(Grid.RowProperty, i % 10); preview.SetValue(Grid.RowProperty, i % 10); box.SetValue(Grid.ColumnProperty, (i / 10) * 3 + 1); preview2.SetValue(Grid.ColumnProperty, (i / 10) * 3 + 1); preview.SetValue(Grid.ColumnProperty, (i / 10) * 3 + 2); _upperGrid.Children.Add(box); _upperGrid.Children.Add(preview2); if (showPreview) { _upperGrid.Children.Add(preview); } if (showPreview2) { box.GotFocus += delegate { preview2.Visibility = Visibility.Collapsed; }; box.LostFocus += delegate { if (box.Text == "") { preview2.Visibility = Visibility.Visible; } }; } if (showPreview) { box.TextChanged += delegate { int val; if (Int32.TryParse(box.Text, out val)) { if (val % 1000 == 0) { if (val > 60000) { preview.Content = String.Format("{0:0}m:{1:00}s", val / 60000, (val % 60000) / 1000); } else { preview.Content = String.Format("{0:0}s", val / 1000); } } else { if (val > 60000) { preview.Content = String.Format("{0:0}m:{1:00}.{2:000}s", val / 60000, (val % 60000) / 1000, val % 1000); } else { preview.Content = String.Format("{0:0}.{1:000}s", val / 1000, val % 1000); } } } else { preview.Content = ""; } }; } box.KeyDown += delegate { if (Keyboard.IsKeyDown(Key.Enter)) { DialogResult = true; Close(); } }; if (i < values.Length) box.Text = values[i]; if (showPreview2) { box.TextChanged += delegate { if (box.Text != "") { preview2.Visibility = Visibility.Collapsed; } _updatePreviews(); }; } _boxes.Add(box); if (showPreview2) _previews.Add(preview2); } _updatePreviews(); WindowStartupLocation = WindowStartupLocation.CenterOwner; }
private Label GetLabel() { if (brush == null) brush = new SolidColorBrush(color); if (label == null) { label = Game.MakeSimpleLabel(text, boundsRect, brush); if (doScroll) { label.FontSize = Math.Max(20, boundsRect.Height / 30); label.Width = 10000; } else label.FontSize = Math.Min(Math.Max(10, boundsRect.Width * 2 / text.Length), Math.Max(10, boundsRect.Height / 20)); label.VerticalContentAlignment = VerticalAlignment.Bottom; label.HorizontalContentAlignment = (doScroll) ? HorizontalAlignment.Left : HorizontalAlignment.Center; label.SetValue(Canvas.LeftProperty, offset * boundsRect.Width); } renderedRect = new Rect(label.RenderSize); if (doScroll) { offset -= 0.0015; if (offset * boundsRect.Width < boundsRect.Left - 10000) return null; label.SetValue(Canvas.LeftProperty, offset * boundsRect.Width + boundsRect.Left); } return label; }
/// <summary> /// Setup after the window loads. /// </summary> /// <param name="sender">The sending object.</param> /// <param name="e">The event.</param> private void Window_Loaded(object sender, RoutedEventArgs e) { double univWidth = Settings.Default.PaneWidth; double univHeight = Settings.Default.PaneHeight; CheckAutoKill.IsChecked = true; _multiverse = new UniverseDisplayCell[Settings.Default.UniversePaneRows][]; for (int row = 0; row < Settings.Default.UniversePaneRows; row++) { _multiverse[row] = new UniverseDisplayCell[Settings.Default.UniversePaneColumns]; for (int col = 0; col < Settings.Default.UniversePaneColumns; col++) { double x = col*univWidth; double y = row*univHeight; // Label var lab = new Label { Foreground = Brushes.Black, Background = Brushes.LightGray, FontSize = 10, Content = "..." }; lab.SetValue(Canvas.LeftProperty, x); lab.SetValue(Canvas.TopProperty, y); // Universe image. int paneWidth = Settings.Default.PaneWidth; int paneHeight = Settings.Default.PaneHeight; _multiverse[row][col] = new UniverseDisplayCell(paneWidth, paneHeight, lab); _multiverse[row][col].UniverseRunner.Randomize(new MersenneTwisterGenerateRandom()); _multiverse[row][col].Visualize(); _multiverse[row][col].UniverseRunner.AutoKill = true; _cells.Add(_multiverse[row][col]); var img = new Image {Source = _multiverse[row][col].Image}; img.SetValue(Canvas.LeftProperty, x); img.SetValue(Canvas.TopProperty, y); CanvasOutput.Children.Add(img); // Universe grid. var rect = new Rectangle { //Fill = _currentGrid[row][col] ? Brushes.Black : Brushes.White, Width = univWidth, Height = univHeight, Stroke = Brushes.Black }; rect.SetValue(Canvas.LeftProperty, x); rect.SetValue(Canvas.TopProperty, y); CanvasOutput.Children.Add(rect); // Add label CanvasOutput.Children.Add(lab); } } CanvasOutput.SetValue(WidthProperty, Settings.Default.UniversePaneColumns*univWidth); CanvasOutput.SetValue(HeightProperty, Settings.Default.UniversePaneRows*univHeight); BtnDeselect.IsEnabled = false; }
private void btnStart_Click(object sender, RoutedEventArgs e) { btnStart.Visibility = Visibility.Collapsed; string input = ""; input = Inputbox.ShowInputDialog(ref input, "Podaj liczbę graczy", 500, 70); int tries = 0; while (!input.All(char.IsDigit)) { tries++; input = Inputbox.ShowInputDialog(ref input, "Coś poszło nie tak. Podaj jeszcze raz liczbę graczy", 500, 70); } int numCols = int.Parse(input); //create column for each player for (int i = 0; i < numCols; ++i) { resultTable.ColumnDefinitions.Add(new ColumnDefinition()); } //create row for each possible category for (int i = 0; i < 18; ++i) { resultTable.RowDefinitions.Add(new RowDefinition()); } //set height of each created row foreach (var g in resultTable.RowDefinitions) { g.Height = new GridLength(1, GridUnitType.Auto); } // set width of each created column foreach (var g in resultTable.ColumnDefinitions) { g.Width = new GridLength(1, GridUnitType.Star); g.MinWidth = 120; } //create label for each cell in table for (int j = 0; j < numCols; j++) { for (int i = 0; i < 18; ++i) { int idx = resultTable.Children.Add(new System.Windows.Controls.Label()); System.Windows.Controls.Label x = resultTable.Children[idx] as System.Windows.Controls.Label; x.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; //check wheteher it is first row (names) if (i == 0) { string imie = Inputbox.ShowInputDialog(ref input, "Podaj imię gracza nr" + (j + 1), 500, 70); x.Content = imie; x.FontWeight = FontWeights.UltraBold; x.Name = "Player" + (j + 1); RegisterName(x.Name, x); } else { x.Content = string.Empty; x.FontWeight = FontWeights.Bold; x.Name = "P" + (j + 1) + "B" + i; RegisterName(x.Name, x); } x.Height = 20; x.FontSize = 18; x.Margin = new System.Windows.Thickness(5); x.Padding = new System.Windows.Thickness(1); x.SetValue(Grid.RowProperty, i); x.SetValue(Grid.ColumnProperty, j); x.SetValue(Grid.ColumnSpanProperty, 1); x.SetValue(Grid.RowSpanProperty, 1); } } ActivePlayer.PersonId = 1; ActivePlayer.NumberOfPlayers = numCols; }
void cnvPaint_Drop(object sender, DragEventArgs e) { try { if (e.Data.GetData(typeof(Button)) != null) { if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); Button btn = new Button(); btn.Height = 25; btn.Width = 100; btn.Content = "Button"; btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown); btn.SetValue(Canvas.LeftProperty, 10.0); btn.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(btn); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD)) { if (currentControl.rect.Visibility == Visibility.Visible) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } } else if (e.Data.GetData(typeof(TabControl)) != null) { if (((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); TabControl lbl = new TabControl(); //lbl.Content = "TabControl"; lbl.HorizontalContentAlignment = HorizontalAlignment.Center; lbl.Height = 25; lbl.Width = 100; lbl.PreviewMouseDown += new MouseButtonEventHandler(tabDrag999_PreviewMouseDown); lbl.SetValue(Canvas.LeftProperty, 10.0); lbl.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.cnvPOD.Children.Add(lbl); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown); objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(Label)) != null) { if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); Label lbl = new Label(); lbl.Content = "Label"; lbl.HorizontalContentAlignment = HorizontalAlignment.Center; lbl.Height = 25; lbl.Width = 100; lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown); lbl.SetValue(Canvas.LeftProperty, 10.0); lbl.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.cnvPOD.Children.Add(lbl); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown); objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(TextBox)) != null) { if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); TextBox txt = new TextBox(); txt.IsReadOnly = true; txt.Cursor = Cursors.Arrow; txt.Height = 25; txt.Width = 100; txt.Text = "TextBox"; txt.MouseDown += new MouseButtonEventHandler(txt_MouseDown); txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown); txt.SetValue(Canvas.LeftProperty, 10.0); txt.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(txt); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(ComboBox)) != null) { if (((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); ComboBox cmb = new ComboBox(); cmb.Cursor = Cursors.Arrow; cmb.Height = 25; cmb.Width = 100; cmb.Text = "ComboBox"; cmb.PreviewMouseDown += new MouseButtonEventHandler(cmb_PreviewMouseDown); cmb.SetValue(Canvas.LeftProperty, 10.0); cmb.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(cmb); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(ListBox)) != null) { if (((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); ListBox lst = new ListBox(); lst.Cursor = Cursors.Arrow; lst.Height = 25; lst.Width = 100; lst.PreviewMouseDown += new MouseButtonEventHandler(lst_PreviewMouseDown); lst.SetValue(Canvas.LeftProperty, 10.0); lst.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(lst); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(CheckBox)) != null) { if (((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); CheckBox chk = new CheckBox(); chk.Cursor = Cursors.Arrow; chk.Height = 25; chk.Width = 100; chk.Content = "Check Box"; chk.PreviewMouseDown += new MouseButtonEventHandler(chk_PreviewMouseDown); chk.SetValue(Canvas.LeftProperty, 10.0); chk.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(chk); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(RadioButton)) != null) { if (((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); RadioButton rad = new RadioButton(); rad.Cursor = Cursors.Arrow; rad.Height = 25; rad.Width = 100; rad.Content = "Radio Button"; rad.PreviewMouseDown += new MouseButtonEventHandler(rad_PreviewMouseDown); rad.SetValue(Canvas.LeftProperty, 10.0); rad.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(rad); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } newDrag = 1; r1.Visibility = Visibility.Collapsed; MyPropGrid.ControlToBind = currentControl; } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "cnvPaint_Drop()", "ctlCRMDesigner.xaml.cs"); } }
/// <summary> /// /// </summary> /// <param name="filePath"></param> private async void ParseFileReportAsync(string filePath) { fileReport = await App.GetFileReportAsync(filePath); FileReportMD5_Lbl.Content = fileReport.MD5; FileReportSHA256_Lbl.Content = fileReport.SHA256; FileReportSHA1_Lbl.Content = fileReport.SHA1; FileDetails_Stack.Visibility = Visibility.Visible; FileScorePanel.Visibility = Visibility.Visible; FileBigPicture.Visibility = Visibility.Collapsed; FileReportDate_Lbl.Content = fileReport.ScanDate; FileReportPositives_Lbl.Content = fileReport.Positives; FileReportTotalEngines_Lbl.Content = fileReport.Total; if (fileReport.Positives < 3) { FileScorePanel.Background = System.Windows.Media.Brushes.LightGreen; FileScore_Lbl.Content = "(Safe)"; FileScore_Icon.Source = safeIcon; } else if (fileReport.Positives < 5) { FileScorePanel.Background = System.Windows.Media.Brushes.Orange; FileScore_Lbl.Content = "(Be carefull)"; FileScore_Icon.Source = warningIcon; } else { FileScorePanel.Background = System.Windows.Media.Brushes.Red; FileScore_Lbl.Content = "(Dangerous)"; FileScore_Icon.Source = dangerIcon; } int row = 2; foreach (var item in fileReport.Scans) { if (item.Value.Detected) { System.Windows.Controls.Label name = new System.Windows.Controls.Label(); System.Windows.Controls.Label virus = new System.Windows.Controls.Label(); System.Windows.Controls.Label update = new System.Windows.Controls.Label(); System.Windows.Controls.Label version = new System.Windows.Controls.Label(); name.Content = item.Key; virus.Content = item.Value.Result; update.Content = item.Value.Update; version.Content = item.Value.Version; name.SetValue(Grid.RowProperty, row); name.SetValue(Grid.ColumnProperty, 0); virus.SetValue(Grid.RowProperty, row); virus.SetValue(Grid.ColumnProperty, 1); update.SetValue(Grid.RowProperty, row); update.SetValue(Grid.ColumnProperty, 2); version.SetValue(Grid.RowProperty, row); version.SetValue(Grid.ColumnProperty, 3); FileReport_Grid.Children.Add(name); FileReport_Grid.Children.Add(virus); FileReport_Grid.Children.Add(update); FileReport_Grid.Children.Add(version); ++row; } } }
/* Draws a section's meeting times on the specified grid. * * @param grid : The grid to draw on * @param startTime : The starting time of the section (Form: "11:30 am") * @param endTime : The ending time of the section (Form: "12:30 pm") * @param days : The days the section meets */ private void drawSchedule(Grid grid, string startTime, string endTime, string days, string labelText = "") { //If the time is TBA, it needs to be drawn at the bottom. bool tba = false; if (startTime.ToLower().Equals("tba")) { tba = true; } string startMeridian, endMeridian; int hourStart, hourEnd; string[] splitStartTime, splitEndTime; if (!tba) { //Change "11:30 am" to "11:30" startTime = startTime.Replace(" ", ""); endTime = endTime.Replace(" ", ""); //Begin parsing the time string for what we need. "11", "30", "am" startMeridian = startTime.Substring(startTime.Length - 2, 2); endMeridian = endTime.Substring(endTime.Length - 2, 2); startTime = startTime.Substring(0, startTime.Length - 2); endTime = endTime.Substring(0, endTime.Length - 2); //Get the first part to determine where to start splitStartTime = startTime.Split(':'); splitEndTime = endTime.Split(':'); hourStart = Convert.ToInt32(splitStartTime[0]); hourEnd = Convert.ToInt32(splitEndTime[0]); days = days.ToLower(); } else { startMeridian = "pm"; endMeridian = "pm"; hourStart = 9 + (tbaCount % 2); hourEnd = 10 + (tbaCount % 2); splitStartTime = "0:0".Split(':'); splitEndTime = "0:0".Split(':'); //We can't have too many TBA courses on one day or it would draw off screen. switch (tbaCount) { case 0: case 1: days = "m"; break; case 2: case 3: days = "t"; break; case 4: case 5: days = "w"; break; case 6: case 7: days = "r"; break; case 8: case 9: days = "f"; break; default: //This should be impossible. 8 distance learning classes? As if. days = "f"; break; } tbaCount++; } //Do position calculation for the start time. // Our system starts at 7:00 am, but the grid starts at 7:30. So we start the position at 3. // Then, every 10 minutes is another position, so each hour is 6 positions. int positionStart = 3; //Make our clock a 24 hour system if (startMeridian == "pm" && hourStart != 12) hourStart += 12; //The hour of the first class is at 7 -- so hourStart -= 7; positionStart += 6 * (hourStart - 1); positionStart += (int)((Math.Floor((Convert.ToDouble(splitStartTime[1])))) / 10.0); //Position calculation for the end time. Same as above. int positionEnd = 3; //Make our clock a 24 hour system if (endMeridian == "pm" && hourEnd != 12) hourEnd += 12; //The hour of the first class is at 7 hourEnd -= 7; positionEnd += 6 * (hourEnd - 1); positionEnd += (int)((Math.Floor((Convert.ToDouble(splitEndTime[1])))) / 10.0); Canvas canvas = new Canvas(); foreach (char character in days) { Rectangle block = new Rectangle(); canvas.Children.Add(block); block.Fill = new SolidColorBrush(Colors.Cyan); block.Stroke = new SolidColorBrush(Colors.Black); block.StrokeThickness = 1.2d; block.RadiusX = block.RadiusY = 5.0d; //Rounds the block corner. block.Width = ((tabBase.ActualWidth / 6) + .80f); block.Height = (positionEnd - positionStart) * 6.7; //Each position is 6.7 points tall. Label info = new Label(); if (labelText.ToLower().IndexOf("observation") > 0) { labelText = labelText.Replace("Practice Study Observation", "PSO"); } info.Content = labelText; canvas.Children.Add(info); switch (character) { case 'm': block.SetValue(Canvas.TopProperty, 60d + (Double)(6.7 * positionStart)); block.SetValue(Canvas.LeftProperty, 40d); info.SetValue(Canvas.TopProperty, 61d + (Double)(6.7 * positionStart)); info.SetValue(Canvas.LeftProperty, 45d); break; case 't': block.SetValue(Canvas.TopProperty, 60d + (Double)(6.7 * positionStart)); block.SetValue(Canvas.LeftProperty, 40d + ((tabBase.ActualWidth / 6) + .80f) * 1); info.SetValue(Canvas.TopProperty, 61d + (Double)(6.7 * positionStart)); info.SetValue(Canvas.LeftProperty, 45d + ((tabBase.ActualWidth / 6) + .80f) * 1); break; case 'w': block.SetValue(Canvas.TopProperty, 60d + (Double)(6.7 * positionStart)); block.SetValue(Canvas.LeftProperty, 40d + ((tabBase.ActualWidth / 6) + .80f) * 2); info.SetValue(Canvas.TopProperty, 61d + (Double)(6.7 * positionStart)); info.SetValue(Canvas.LeftProperty, 45d + ((tabBase.ActualWidth / 6) + .80f) * 2); break; case 'r': block.SetValue(Canvas.TopProperty, 60d + (Double)(6.7 * positionStart)); block.SetValue(Canvas.LeftProperty, 40d + ((tabBase.ActualWidth / 6) + .80f) * 3); info.SetValue(Canvas.TopProperty, 61d + (Double)(6.7 * positionStart)); info.SetValue(Canvas.LeftProperty, 45d + ((tabBase.ActualWidth / 6) + .80f) * 3); break; case 'f': block.SetValue(Canvas.TopProperty, 60d + (Double)(6.7 * positionStart)); block.SetValue(Canvas.LeftProperty, 40d + ((tabBase.ActualWidth / 6) + .80f) * 4); info.SetValue(Canvas.TopProperty, 61d + (Double)(6.7 * positionStart)); info.SetValue(Canvas.LeftProperty, 45d + ((tabBase.ActualWidth / 6) + .80f) * 4); break; } } grid.Children.Add(canvas); }
void CreateTimeHeader(MouseButtonEventHandler mLeft, MouseButtonEventHandler MouseDoubleClick) { string[] times = new string[] { "8.30-10.05", "10.25-12.00", "12.20-13.55", "14.15-15.50", "16.00-17.35", "17.45-19.20" }; int timeStringIndex = 0; timeLabels = new Label[72]; for (int timeIndex = 0; timeIndex < 72; timeIndex++) { Label groupLabel = new Label(); groupLabel.Content = times[timeStringIndex]; groupLabel.Height = CELL_HEIGHT; groupLabel.Width = 100; groupLabel.BorderBrush = new SolidColorBrush(Colors.Green); groupLabel.BorderThickness = new Thickness(1); groupLabel.SetValue(Grid.RowProperty, timeIndex + ROW_HEADER); groupLabel.SetValue(Grid.ColumnProperty, 1); groupLabel.FontSize = 10; groupLabel.HorizontalContentAlignment = HorizontalAlignment.Center; gdData.Children.Add(groupLabel); timeLabels[timeIndex] = groupLabel; timeStringIndex++; groupLabel.MouseLeftButtonDown += mLeft; groupLabel.MouseDoubleClick += MouseDoubleClick; if (timeStringIndex == 6) { timeStringIndex = 0; } } }
void CreateDayHeader() { int rowIndex = ROW_HEADER; string[] days = new string[] { "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота" }; foreach (string day in days) { Label groupLabel = new Label(); groupLabel.LayoutTransform = new RotateTransform(270); groupLabel.Content = day; groupLabel.Height = 30; groupLabel.Width = CELL_HEIGHT * 6; groupLabel.BorderBrush = new SolidColorBrush(Colors.Green); groupLabel.BorderThickness = new Thickness(1); groupLabel.SetValue(Grid.RowProperty, rowIndex); groupLabel.SetValue(Grid.ColumnProperty, 0); groupLabel.SetValue(Grid.RowSpanProperty, 6); groupLabel.FontSize = 14; groupLabel.HorizontalContentAlignment = HorizontalAlignment.Center; gdData.Children.Add(groupLabel); rowIndex += 6; } }
private void EndTrigger(Point endPoint) { // 實線結束點 (100%) Ellipse endEllipse = new Ellipse(); endEllipse.Width = 10; endEllipse.Height = 10; endEllipse.Fill = ONE_LINE_COLOR; endEllipse.SetValue(Canvas.LeftProperty, (double)endPoint.X - 5); endEllipse.SetValue(Canvas.TopProperty, (double)endPoint.Y - 5); DesigningCanvas.Children.Add(endEllipse); //計算虛線終點 Point calcEndPoint = new Point(); calcEndPoint.X = endPoint.X - g_startPoint.X + endPoint.X; calcEndPoint.Y = endPoint.Y - g_startPoint.Y + endPoint.Y; ////劃一條虛斜線 LineGeometry lineGeometry = new LineGeometry(); lineGeometry.StartPoint = endPoint; lineGeometry.EndPoint = calcEndPoint; System.Windows.Shapes.Path myPath = new System.Windows.Shapes.Path(); myPath.Stroke = SLOPE_LINE_COLOR; myPath.StrokeThickness = SLOPE_LINE_THICKNESS; myPath.Data = lineGeometry; myPath.StrokeDashArray = new DoubleCollection() { 2, 3 }; DesigningCanvas.Children.Add(myPath); //// 虛線結束點 (200%) Ellipse endDottedEllipse = new Ellipse(); endDottedEllipse.Width = 10; endDottedEllipse.Height = 10; endDottedEllipse.Fill = DOUBLE_LINE_COLOR; endDottedEllipse.SetValue(Canvas.LeftProperty, (double)calcEndPoint.X - 5); endDottedEllipse.SetValue(Canvas.TopProperty, (double)calcEndPoint.Y - 5); DesigningCanvas.Children.Add(endDottedEllipse); dSpotX = (double)calcEndPoint.X - 10 - ((double)endPoint.X - 10); dSpotY = (double)calcEndPoint.Y - 10 - ((double)endPoint.Y - 10); // 橫軸線 // 0% Line LineGeometry startlineGeometry = new LineGeometry(); startlineGeometry.StartPoint = new Point(g_startPoint.X, g_startPoint.Y); startlineGeometry.EndPoint = new Point(calcEndPoint.X, g_startPoint.Y); System.Windows.Shapes.Path startLinePath = new System.Windows.Shapes.Path(); startLinePath.Stroke = NONE_LINE_COLOR; startLinePath.StrokeThickness = HORIZONTAL_LINE_THICKNESS; startLinePath.Data = startlineGeometry; DesigningCanvas.Children.Add(startLinePath); StartPath = startLinePath; // 50% Line LineGeometry midLineGeometry = new LineGeometry(); midLineGeometry.StartPoint = new Point(g_startPoint.X, (g_startPoint.Y + endPoint.Y) / 2); midLineGeometry.EndPoint = new Point(calcEndPoint.X, (g_startPoint.Y + endPoint.Y) / 2); System.Windows.Shapes.Path midLinePath = new System.Windows.Shapes.Path(); midLinePath.Stroke = HALF_LINE_COLOR; midLinePath.StrokeThickness = HORIZONTAL_LINE_THICKNESS; midLinePath.Data = midLineGeometry; DesigningCanvas.Children.Add(midLinePath); //dLineY = (g_startPoint.Y + endPoint.Y) / 2 - g_startPoint.Y; // 100% Line LineGeometry solidLineEndGeometry = new LineGeometry(); solidLineEndGeometry.StartPoint = new Point(g_startPoint.X, endPoint.Y); solidLineEndGeometry.EndPoint = new Point(calcEndPoint.X, endPoint.Y); System.Windows.Shapes.Path solidEndPath = new System.Windows.Shapes.Path(); solidEndPath.Stroke = ONE_LINE_COLOR; solidEndPath.StrokeThickness = HORIZONTAL_LINE_THICKNESS; solidEndPath.Data = solidLineEndGeometry; DesigningCanvas.Children.Add(solidEndPath); // 200% Line LineGeometry dottedLineGeometry = new LineGeometry(); dottedLineGeometry.StartPoint = new Point(g_startPoint.X, calcEndPoint.Y);; dottedLineGeometry.EndPoint = new Point(calcEndPoint.X, calcEndPoint.Y);; System.Windows.Shapes.Path dottedLinePath = new System.Windows.Shapes.Path(); dottedLinePath.Stroke = DOUBLE_LINE_COLOR; dottedLinePath.StrokeThickness = HORIZONTAL_LINE_THICKNESS; dottedLinePath.Data = dottedLineGeometry; DesigningCanvas.Children.Add(dottedLinePath); // 標數字 double labelXpoint = 0; if (g_startPoint.X > calcEndPoint.X) { labelXpoint = calcEndPoint.X; } else { labelXpoint = g_startPoint.X; } System.Windows.Controls.Label startLabel = new System.Windows.Controls.Label(); startLabel.Content = @"0%"; startLabel.Foreground = NONE_LINE_COLOR; startLabel.SetValue(Canvas.LeftProperty, labelXpoint - 50); startLabel.SetValue(Canvas.TopProperty, g_startPoint.Y - 10); startLabel.FontSize = 10; DesigningCanvas.Children.Add(startLabel); System.Windows.Controls.Label midLabel = new System.Windows.Controls.Label(); midLabel.Content = @"50%"; midLabel.Foreground = HALF_LINE_COLOR; midLabel.SetValue(Canvas.LeftProperty, labelXpoint - 50); midLabel.SetValue(Canvas.TopProperty, (g_startPoint.Y + endPoint.Y) / 2 - 10); midLabel.FontSize = 10; DesigningCanvas.Children.Add(midLabel); dLabelY = ((g_startPoint.Y + endPoint.Y) / 2 - 10) - (g_startPoint.Y - 10); System.Windows.Controls.Label endSolidLineLabel = new System.Windows.Controls.Label(); endSolidLineLabel.Content = @"100%"; endSolidLineLabel.Foreground = ONE_LINE_COLOR; endSolidLineLabel.SetValue(Canvas.LeftProperty, labelXpoint - 50); endSolidLineLabel.SetValue(Canvas.TopProperty, endPoint.Y - 10); endSolidLineLabel.FontSize = 10; DesigningCanvas.Children.Add(endSolidLineLabel); System.Windows.Controls.Label endDottedLineLabel = new System.Windows.Controls.Label(); endDottedLineLabel.Content = @"200%"; endDottedLineLabel.Foreground = DOUBLE_LINE_COLOR; endDottedLineLabel.SetValue(Canvas.LeftProperty, labelXpoint - 50); endDottedLineLabel.SetValue(Canvas.TopProperty, calcEndPoint.Y - 10); endDottedLineLabel.FontSize = 10; DesigningCanvas.Children.Add(endDottedLineLabel); try { foreach (object control in DesigningCanvas.Children) { if (control.GetType() != typeof(System.Windows.Controls.Label)) { ((Shape)control).PreviewMouseLeftButtonDown += this.MouseLeftButtonDown; ((Shape)control).PreviewMouseLeftButtonUp += this.PreviewMouseLeftButtonUp; ((Shape)control).Cursor = System.Windows.Input.Cursors.Hand; } if (control.GetType() == typeof(System.Windows.Controls.Label)) { ((System.Windows.Controls.Control)control).PreviewMouseLeftButtonDown += this.MouseLeftButtonDown; ((System.Windows.Controls.Control)control).PreviewMouseLeftButtonUp += this.PreviewMouseLeftButtonUp; ((System.Windows.Controls.Control)control).Cursor = System.Windows.Input.Cursors.Hand; if (null == LastControl) { LastControl = (System.Windows.Controls.Control)control; } } } } catch (Exception ex) { //string a = ex.Message; } g_lineGeometry = null; }
void MergeCells(Label prevLabel, int colIndex) { int colIndexPrevLabel = (int)prevLabel.GetValue(Grid.ColumnProperty); int mergeCount = colIndex - colIndexPrevLabel + 1; prevLabel.SetValue(Grid.ColumnSpanProperty, mergeCount); prevLabel.Width = CELL_WIDTH * mergeCount; }
private void Mon_MouseDown(object sender, MouseButtonEventArgs e) { var element = (UIElement)e.Source; if (e.ClickCount == 2 && element is Grid) { Grid Day = sender as Grid; Setting set = new Setting(); set.SetData(Day.Name, TimeRow); if (set.ShowDialog() == true) { string start = set.StartTime; string end = set.EndTime; int startidx = TimeRow.IndexOf(start); int endidx = TimeRow.IndexOf(end) - startidx; CreateRowDefinition(Day); Label l = new Label(); l.Style = (Style)this.Resources["CommonLabel"]; TextBlock tb = new TextBlock(); tb.TextWrapping = TextWrapping.WrapWithOverflow; tb.Text = set.Sub; tb.Margin = new Thickness(0, 0, 0, 0); l.Content = tb; l.SetValue(Grid.RowProperty, startidx); l.SetValue(Grid.RowSpanProperty, endidx+1); l.ContextMenu = (ContextMenu)this.Resources["context"]; if (!CheckReCreate(Day, startidx, endidx)) return; Day.Children.Add(l); TimeXml.Save(Day.Name,set.Sub,start,end,set.Book); } } }
public void Show_OtherConnections() { Label input_label = new Label(); input_label.Content = "输入端:"; input_label.SetValue(Canvas.LeftProperty,(double)input_list[0].GetValue(Canvas.LeftProperty)); input_label.SetValue(Canvas.TopProperty, 10.0); MainWindow.mainwindow.canvas.Children.Add(input_label); Label output_label = new Label(); output_label.Content = "输出端:"; output_label.SetValue(Canvas.TopProperty, 10.0); output_label.SetValue(Canvas.LeftProperty, (double)output_list[0].GetValue(Canvas.LeftProperty)); MainWindow.mainwindow.canvas.Children.Add(output_label); //显示输入口和输出口的端口号 for (int i = 0; i < n; i++) { Label label_in = new Label(); label_in.Content = i.ToString(); label_in.SetValue(Canvas.TopProperty, (double)input_list[i].GetValue(Canvas.TopProperty)); label_in.SetValue(Canvas.LeftProperty, 10.0); MainWindow.mainwindow.canvas.Children.Add(label_in); Label label_out = new Label(); label_out.Content = i.ToString(); label_out.SetValue(Canvas.TopProperty, (double)output_list[i].GetValue(Canvas.TopProperty)); label_out.SetValue(Canvas.LeftProperty, (double)output_list[i].GetValue(Canvas.LeftProperty)+tboxwidth + 10); MainWindow.mainwindow.canvas.Children.Add(label_out); } //输入口,输出口与Rectangle之间的连接 for (int i = 0; i < n; i++) { Line line = new Line(); line.Stroke = new SolidColorBrush(Colors.Black); line.X1 =(double)input_list[i].GetValue(Canvas.LeftProperty)+tboxwidth; line.Y1 = (double)input_list[i].GetValue(Canvas.TopProperty) + tboxheight / 2; line.X2 = line.X1 + betweenspace; line.Y2 = line.Y1; MainWindow.mainwindow.canvas.Children.Add(line); } for (int i = 0; i < n; i++) { Line line = new Line(); line.Stroke = new SolidColorBrush(Colors.Black); line.X2 = (double) output_list[i].GetValue(Canvas.LeftProperty); line.Y2 = (double)output_list[i].GetValue(Canvas.TopProperty) + tboxheight / 2; line.X1 = line.X2 -betweenspace; line.Y1 = line.Y2; MainWindow.mainwindow.canvas.Children.Add(line); } }
void tbi_Drop(object sender, DragEventArgs e) { try { if (e.Data.GetData(typeof(Label)) != null) { if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); Label lbl = new Label(); lbl.Content = "Label"; lbl.HorizontalContentAlignment = HorizontalAlignment.Center; lbl.Height = 25; lbl.Width = 100; lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown); lbl.SetValue(Canvas.LeftProperty, 10.0); lbl.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.cnvPOD.Children.Add(lbl); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown); objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } else if (e.Data.GetData(typeof(TextBox)) != null) { if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls") { Point p = e.GetPosition((IInputElement)cnvPaint); TextBox txt = new TextBox(); txt.IsReadOnly = true; txt.Cursor = Cursors.Arrow; txt.Height = 25; txt.Width = 100; txt.Text = "TextBox"; txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown); txt.SetValue(Canvas.LeftProperty, 10.0); txt.SetValue(Canvas.TopProperty, 10.0); ctlPOD objPOD = new ctlPOD(); objPOD.AllowDrop = true; objPOD.Height = 25; objPOD.Width = 100; objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown); objPOD.SetValue(Canvas.LeftProperty, p.X); objPOD.SetValue(Canvas.TopProperty, p.Y); MyPropGrid.ControlToBind = objPOD; objPOD.cnvPOD.Children.Add(txt); currentControl = objPOD; cnvPaint.Children.Add(objPOD); } else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD)) { Point p = e.GetPosition((IInputElement)cnvPaint); ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X); ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y); } } newDrag = 1; r1.Visibility = Visibility.Collapsed; MyPropGrid.ControlToBind = currentControl; } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "tbi_Drop()", "ctlCRMDesigner.xaml.cs"); } }
public void InitializeUI() { // load data Type t = typeof(Person); var properties = t.GetProperties(); int row = 0; foreach (PropertyInfo property in properties) { grid.RowDefinitions.Add(new RowDefinition()); string propertyName = property.Name; Label label = new Label(); label.Content = propertyName; label.SetValue(Grid.RowProperty, row); label.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(label); TextBox textBox = new TextBox(); textBox.Name = propertyName; textBox.SetValue(Grid.RowProperty, row); textBox.SetValue(Grid.ColumnProperty, 2); object value = property.GetValue(person); if (property.PropertyType.ToString() == "System.Guid") { textBox.Text = value.ToString(); textBox.Tag = property; grid.Children.Add(textBox); } else if (property.PropertyType.ToString() == "System.String") { if (value != null) { textBox.Text = value.ToString(); } textBox.Tag = property; grid.Children.Add(textBox); } else if (property.PropertyType.IsGenericType) { var valueList = value as List<Pair<Guid, Pair<string, string>>>; if (valueList.Count != 0) { foreach (var v in valueList) { row++; grid.RowDefinitions.Add(new RowDefinition()); TextBox subTextBoxName = new TextBox(); subTextBoxName.Name = "Name"; subTextBoxName.Text = v.Value.Value; subTextBoxName.Uid = v.Key.ToString(); subTextBoxName.Tag = property; subTextBoxName.SetValue(Grid.RowProperty, row); subTextBoxName.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(subTextBoxName); TextBox subTextBoxValue = new TextBox(); subTextBoxValue.Name = "Value"; subTextBoxValue.Text = v.Value.Key; subTextBoxValue.Uid = v.Key.ToString(); subTextBoxValue.Tag = property; subTextBoxValue.SetValue(Grid.RowProperty, row); subTextBoxValue.SetValue(Grid.ColumnProperty, 2); grid.Children.Add(subTextBoxValue); } } } row++; } row++; grid.RowDefinitions.Add(new RowDefinition()); Button buttonOK = new Button(); buttonOK.Name = "buttonOK"; buttonOK.Content = "OK"; buttonOK.Width = 75; buttonOK.Height = 25; buttonOK.PreviewMouseLeftButtonDown += buttonOKPreviewMouseLeftButtonDown; buttonOK.SetValue(Grid.RowProperty, row); buttonOK.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(buttonOK); Button buttonCancel = new Button(); buttonCancel.Name = "buttonCancel"; buttonCancel.Content = "Cancel"; buttonCancel.Width = 75; buttonCancel.Height = 25; buttonCancel.PreviewMouseLeftButtonDown += buttonCancelPreviewMouseLeftButtonDown; buttonCancel.SetValue(Grid.RowProperty, row); buttonCancel.SetValue(Grid.ColumnProperty, 2); grid.Children.Add(buttonCancel); // setup ui component switch (mode) { case EditMode.Info: { foreach (var item in grid.Children) { if (item is TextBox) { (item as TextBox).IsEnabled = false; } else if (item is Button) { Button button = item as Button; if (button.Name == "buttonOK") { button.IsEnabled = false; } } } } break; case EditMode.New: break; case EditMode.Update: break; default: break; } }
void CreateGroupHeader(StudentSubGroup[] groups) { int columnIndex = COLUMN_HEADER; foreach (StudentSubGroup group in groups) { Label groupLabel = new Label(); groupLabel.Content = group.NameGroup + "/" + group.NumberSubGroup; groupLabel.Height = CELL_HEIGHT; groupLabel.Width = CELL_WIDTH; groupLabel.BorderBrush = new SolidColorBrush(Color.FromRgb(255, 140, 0)); groupLabel.BorderThickness = new Thickness(1); groupLabel.SetValue(Grid.RowProperty, ROW_HEADER - 1); groupLabel.SetValue(Grid.ColumnProperty, columnIndex); groupLabel.FontSize = 12; groupLabel.HorizontalContentAlignment = HorizontalAlignment.Center; columnIndex++; gdData.Children.Add(groupLabel); } }
/// <summary> /// URL report /// </summary> /// <param name="url"></param> private async void ParseURLReportAsync(string url) { URLScan_Grid.Children.RemoveRange(3, URLScan_Grid.Children.Count - 1); urlReport = await App.GetUrlReportAsync(url); URLDetails_Stack.Visibility = Visibility.Visible; URLScorePanel.Visibility = Visibility.Visible; URLBigPicture.Visibility = Visibility.Collapsed; URLReportURLDetectedPositives_Lbl.Content = urlReport.Positives; URLReportURLDetectedTotalEngines_Lbl.Content = urlReport.Total; URLReportURLDetectedDate_Lbl.Content = urlReport.ScanDate; if (urlReport.Positives < 3) { URLScorePanel.Background = System.Windows.Media.Brushes.LightGreen; URLScore_Lbl.Content = "(Safe)"; URLScore_Icon.Source = safeIcon; } else if (urlReport.Positives < 5) { URLScorePanel.Background = System.Windows.Media.Brushes.Orange; URLScore_Lbl.Content = "(Be carefull)"; URLScore_Icon.Source = warningIcon; } else { URLScorePanel.Background = System.Windows.Media.Brushes.Red; URLScore_Lbl.Content = "(Dangerous)"; URLScore_Icon.Source = dangerIcon; } int row = 2; foreach (var item in urlReport.Scans) { if (item.Value.Detected) { System.Windows.Controls.Label name = new System.Windows.Controls.Label(); System.Windows.Controls.Label virus = new System.Windows.Controls.Label(); System.Windows.Controls.Label detail = new System.Windows.Controls.Label(); name.Content = item.Key; virus.Content = item.Value.Result; detail.Content = item.Value.Detail; name.SetValue(Grid.RowProperty, row); name.SetValue(Grid.ColumnProperty, 0); virus.SetValue(Grid.RowProperty, row); virus.SetValue(Grid.ColumnProperty, 1); detail.SetValue(Grid.RowProperty, row); detail.SetValue(Grid.ColumnProperty, 2); URLScan_Grid.Children.Add(name); URLScan_Grid.Children.Add(virus); URLScan_Grid.Children.Add(detail); ++row; } } }