private void AddButtons() { if (string.IsNullOrWhiteSpace(size1.Text)) size = 10; else size = Int32.Parse(size1.Text);// * Int32.Parse(size1.Text); for (int k = 0; k < size; k++) { grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.RowDefinitions.Add(new RowDefinition()); } bs = new Button[size, size]; // grid_buttons = new List<List<Button>>(); for (int i = 0; i < grid.RowDefinitions.Count; ++i) { for (int j = 0; j < grid.ColumnDefinitions.Count; ++j) { button = new Button(); button.SetValue(Grid.RowProperty, i); button.SetValue(Grid.ColumnProperty, j); button.Background = new SolidColorBrush(Colors.White); button.Click += ChangeState; button.Focusable = false; grid.Children.Add(button); // grid_buttons[i][j] = button; bs[i, j] = button; } } }
public GridWindow() { Title = "Grid window"; Height = 400; Width = 400; FontSize = 20; Grid grid = new Grid(); this.Content = grid; grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Button btn = new Button { Content = "Click Me", FontSize = 15, }; grid.Children.Add(btn); // Add button to grid btn.SetValue(Grid.RowProperty, 1); // Register button to Row and Column dependency properties btn.SetValue(Grid.ColumnProperty, 1); }
private void CreateAndAddButton(int row, int column, Type controlType) { var button = new Button(); button.SetValue(Grid.RowProperty, row); button.SetValue(Grid.ColumnProperty, column); button.Content = controlType.Name; MainGrid.Children.Add(button); WireEvents(button, controlType); }
Int32 turns = 0; // 0 if it is my turn, 1 if the opponent's #endregion Fields #region Constructors // Constructs the UserControl GreenGUI // _quatro: this object holds all of the game data the can be queried public GreenGUI() { InitializeComponent(); // Load images for (int i = 0; i < 16; i++) { Image im = new Image(); im.Source = new BitmapImage(new Uri(@"Images/piece-" + i + ".png", UriKind.Relative)); images[i] = im; } imageEmpty = new Image(); imageEmpty.Source = new BitmapImage(new Uri(@"Images/empty.png", UriKind.Relative)); imageUnknown = new Image(); imageUnknown.Source = new BitmapImage(new Uri(@"Images/unknown.png", UriKind.Relative)); // Create buttons (area) for (int i = 0; i < 16; i++) { Button b = new Button(); b.Click += BtPut_Click; b.Tag = i; gameArea.Children.Add(b); Image im = new Image(); im.Source = imageEmpty.Source; b.Content = im; b.SetValue(Grid.RowProperty, i/4); b.SetValue(Grid.ColumnProperty, i%4); area[i/4,i%4] = b; } // Create buttons (available) for (int i = 0; i < 16; i++) { Button b = new Button(); b.Click += BtChoose_Click; b.Tag = i; gameArea.Children.Add(b); Image im = new Image(); im.Source = images[i].Source; b.Content = im; b.SetValue(Grid.RowProperty, i / 4); b.SetValue(Grid.ColumnProperty, i % 4); available[i/4,i%4] = b; } // Set the two player string players = new String[2] { "You", "Opponent" }; // Displays who turns next ShowNextEvent(); }
public void LoadArea(int fieldId) { AreaCanvas.Children.Clear(); AreaInfoStackPanel.Visibility = Visibility.Collapsed; Task<List<QuestAreaMaster>> task = new Task<List<QuestAreaMaster>>(() => { return DAL.ToList<QuestAreaMaster>(string.Format("SELECT * FROM QUEST_AREA_MASTER WHERE parent_field_id={0} ORDER BY ID", fieldId)); }); task.ContinueWith(t => { if (t.Exception != null) { Utility.ShowException(t.Exception); return; } foreach (var qam in t.Result) { var btn = new Button() { Width = qam.icon_col_w * SCALE_PARAMETER, Height = qam.icon_col_h * SCALE_PARAMETER, Content = new TextBlock() { Text = qam.name, TextWrapping = TextWrapping.Wrap }, }; btn.SetValue(Canvas.LeftProperty, (qam.icon_pos_x - qam.icon_col_w/2)*SCALE_PARAMETER + LEFT_OFFSET); btn.SetValue(Canvas.TopProperty, (qam.icon_pos_y - qam.icon_col_h/2)*SCALE_PARAMETER + TOP_OFFSET); btn.SetValue(Grid.ZIndexProperty, 128); btn.Click += (e, s) => { LoadAreaInfo(qam); if (qam.move_field_id > 0) { LoadArea((int)qam.move_field_id); } }; AreaCanvas.Children.Add(btn); QuestAreaMaster nextQam = t.Result.Find(o => o.id == qam.connect_area_id); if (nextQam != null) { AreaCanvas.Children.Add(GetAreaLine(qam, nextQam)); } } }, MainWindow.UiTaskScheduler); //this Task work on ui thread task.Start(); }
public void LoadField(int worldId) { Task<List<QuestFieldMaster>> task = new Task<List<QuestFieldMaster>>(() => { return DAL.ToList<QuestFieldMaster>(string.Format("SELECT * FROM QUEST_FIELD_MASTER WHERE parent_world_id={0} ORDER BY ID", worldId)); }); task.ContinueWith(t => { if (t.Exception != null) { Utility.ShowException(t.Exception); return; } FieldCanvas.Children.Clear(); foreach (var qfm in t.Result) { //Add field var btn = new Button() { Width = qfm.icon_col_w * SCALE_PARAMETER, Height = qfm.icon_col_h * SCALE_PARAMETER, Content = new TextBlock() { Text = qfm.name_short, TextWrapping = TextWrapping.Wrap }, }; btn.Click += (sender, e) => { Area.LoadArea((int)qfm.id); LoadFieldInfo(qfm); }; btn.SetValue(Canvas.LeftProperty, (double)qfm.icon_pos_x * SCALE_PARAMETER + LEFT_OFFSET); btn.SetValue(Canvas.TopProperty, (double)qfm.icon_pos_y * SCALE_PARAMETER + TOP_OFFSET); FieldCanvas.Children.Add(btn); //Add line between field if (qfm.arrow_type > 0) { var lineCanvas = GetArrowCanvas(qfm.arrow_type, qfm.arrow_rotate, qfm.arrow_reverse); lineCanvas.SetValue(Canvas.LeftProperty, qfm.arrow_pos_x * SCALE_PARAMETER + LEFT_OFFSET + 25); //use magic number 25, hope won't break in 17 years lineCanvas.SetValue(Canvas.TopProperty, qfm.arrow_pos_y * SCALE_PARAMETER + TOP_OFFSET); lineCanvas.SetValue(Grid.ZIndexProperty, 128); FieldCanvas.Children.Add(lineCanvas); } } }, MainWindow.UiTaskScheduler); //this Task work on ui thread task.Start(); }
public DockAroundTheBlock() { Title = "Dock Around the Block"; // 1. �г� ���� �� �ʱ�ȭ DockPanel dock = new DockPanel(); Content = dock; // 2. ���ϴ� �ڽ� ��ü(�̹���, ��Ʈ��, �г�..) for (int i = 0; i < 17; i++) { Button btn = new Button(); btn.Content = "Button No. " + (i + 1); //------------------------------------------------- dock.Children.Add(btn); btn.SetValue(DockPanel.DockProperty, (Dock)(i % 4)); DockPanel.SetDock(btn, (Dock)(i % 4)); //------------------------------------------------- } // dock.LastChildFill = true; dock.LastChildFill = false; }
public void Bug484164() { Button b = new Button { Content = "Button" }; string n = "Bob"; b.SetValue(FrameworkElement.NameProperty, n); TestPanel.Children.Add(b); Assert.IsNotNull(b.FindName(n)); }
private Grid PopulateBottomRow(int row, Grid grid) { var cancelButton = new Button(); cancelButton.Content = "Cancel"; cancelButton.Click += CloseWindow; grid.Children.Add(cancelButton); cancelButton.SetValue(Grid.RowProperty, row); return grid; }
public void CreateUserControlElements() { Button myEndTestButton = new Button(); Button myNextButton = new Button(); Button myPreviousButton = new Button(); myEndTestButton.Content = "Закночить тестирование"; myEndTestButton.Click += EndTestClick; myEndTestButton.SetValue(Grid.ColumnProperty, 1); userControlGrid.Children.Add(myEndTestButton); }
public void Bug484164b() { Button b = new Button { Content = "Button" }; string n = "Bob"; b.SetValue(FrameworkElement.NameProperty, n); TestPanel.Children.Add(b); EnqueueDelay(TimeSpan.FromSeconds(.2)); EnqueueCallback(() => Assert.IsNotNull(b.FindName(n))); EnqueueTestComplete(); }
public void Button_Click(object sender, RoutedEventArgs e) { int BT_ID = -1; System.Windows.Controls.Button bt = null; if (sender is System.Windows.Controls.Button) { bt = sender as System.Windows.Controls.Button; if (Grid.GetColumn(bt) == 8) //Si Scene Launch { BT_ID = Grid.GetRow(bt) + 81; } else //si Matrice RGB { BT_ID = 39 - ((7 - Grid.GetColumn(bt)) + ((Grid.GetRow(bt) - 1) * 8)); } } Log.writeLine("Appui Bouton IHM -> ID : " + BT_ID); if (is_BT_selected(BT_ID)) { bt.SetValue(BackgroundProperty, Brushes.White); SelectedBT.Remove(BT_ID); } else { bt.SetValue(BackgroundProperty, Brushes.LightBlue); SelectedBT.Add(BT_ID); } if (BT_click != null) { this.BT_click(this, new BTClickEventArgs { BT_ID = BT_ID, IS_Selected = is_BT_selected(BT_ID) }); } }
private void Button_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.Button bt = sender as System.Windows.Controls.Button; int BT_ID; bool Is_BT_system; if (Grid.GetRow(bt) == 1) { BT_ID = Grid.GetColumn(bt); Is_BT_system = true; if (is_BT_selected(selectedSystemBT, BT_ID)) { bt.SetValue(BackgroundProperty, Brushes.Gray); selectedSystemBT.Remove(BT_ID); } else { bt.SetValue(BackgroundProperty, Brushes.LightBlue); selectedSystemBT.Add(BT_ID); } } else { BT_ID = Grid.GetColumn(bt) + ((Grid.GetRow(bt) - 2) * 16); Is_BT_system = false; if (is_BT_selected(selectedBT, BT_ID)) { bt.SetValue(BackgroundProperty, Brushes.White); selectedBT.Remove(BT_ID); } else { bt.SetValue(BackgroundProperty, Brushes.LightBlue); selectedBT.Add(BT_ID); } } if (this.BT_Click != null) { this.BT_Click(this, e); } }
private void Button_Click(object sender, RoutedEventArgs e) { Button btn = new Button(); btn.Width = 160; btn.Height = 80; btn.Content = "后台添加的"; btn.SetValue(Canvas.ZIndexProperty, 1); btn.RenderTransform = new CompositeTransform(); btn.ManipulationDelta += textBlock_ManipulationDelta; LayoutRoot.Children.Add(btn); }
private void AddButtons() { for (int i = 0; i < 25; ++i) { Button button = new Button(); button.SetValue(Grid.ColumnProperty, i); button.Background = new SolidColorBrush(Colors.White); grid_neigh.Children.Add(button); button.Click += ChangeState; button.Focusable = false; buttons.Add(button); } }
public DockAroundTheBlock() { Title = "Dock Around the Block"; DockPanel dock = new DockPanel(); Content = dock; for (int i = 0; i < 17; i++) { Button btn = new Button(); btn.Content = "Button No. " + (i+1); dock.Children.Add(btn); btn.SetValue(DockPanel.DockProperty, (Dock)(i%4)); } }
public void SetRecentItems() { try { recentProjects.Items.Clear(); BindingList <License> lics = UIContext.GetLatestLicenses(); SeparatorTabItem separator = new SeparatorTabItem(); separator.Header = "Recent Projects"; recentProjects.Items.Add(separator); foreach (var license in lics) { TabItem tb = new TabItem(); tb.Header = license.Name; tb.Name = string.Format("License_{0}", license.LicenseId.ToString()); tb.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(b_MouseDoubleClick); Grid g = new Grid(); g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); g.RowDefinitions.Add(new RowDefinition()); g.RowDefinitions.Add(new RowDefinition()); g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); TextBlock tb1 = new TextBlock { Text = string.Format("Project Name: {0}", license.Name) }; tb1.SetValue(Grid.RowProperty, 0); g.Children.Add(tb1); System.Windows.Controls.Button b = new System.Windows.Controls.Button(); b.Content = "Open This Project"; b.Name = string.Format("License_{0}", license.LicenseId.ToString()); b.Click += new System.Windows.RoutedEventHandler(btn_Click); b.SetValue(Grid.RowProperty, 3); g.Children.Add(b); tb.Content = g; recentProjects.Items.Add(tb); } } catch (Exception ex) { } }
private void Add_Click(object sender, RoutedEventArgs e) { Button b = new Button(); b.Content = DateTime.Now.Millisecond; b.Padding = new Thickness(5); b.SetValue(ComponentFactory.Quicksilver.Layout.CanvasLayout.LeftProperty, (double)_random.Next(300)); b.SetValue(ComponentFactory.Quicksilver.Layout.CanvasLayout.TopProperty, (double)_random.Next(300)); b.SetValue(ComponentFactory.Quicksilver.Layout.DockLayout.DockProperty, (Dock)_random.Next(4)); b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.ColumnProperty, _random.Next(16)); b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.RowProperty, _random.Next(16)); b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.ColumnSpanProperty, _random.Next(2) + 1); b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.RowSpanProperty, _random.Next(2) + 1); TargetPanel.Children.Insert(_random.Next(TargetPanel.Children.Count), b); }
public void CanExecuteChangedMakesButtonRequeryCommandAndSetsIsEnabledAppropriately() { var mockCommand = new MockCommand(); var button = new Button(); button.IsEnabled = true; button.SetValue(CommandProperties.CommandProperty, mockCommand); mockCommand.CanExecuteReturnValue = false; mockCommand.RaiseCanExecuteChanged(); Assert.IsFalse(button.IsEnabled); mockCommand.CanExecuteReturnValue = true; mockCommand.RaiseCanExecuteChanged(); Assert.IsTrue(button.IsEnabled); }
public static void ReportUnexpectedException(Exception e) { Window w = new Window() { Title = "Unexpected exception occured", Width = 500, Height = 400, Background = new SolidColorBrush(Color.FromRgb(0xF0, 0xF0, 0xF0)) }; Grid g = new Grid(); g.RowDefinitions.Add(new RowDefinition()); g.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); FlowDocumentScrollViewer f = new FlowDocumentScrollViewer() { HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, BorderBrush = Brushes.Black, BorderThickness = new Thickness(0, 0, 0, 1), }; f.SetValue(Grid.RowProperty, 0); f.Document = buildExceptionMessage(new FlowDocument() { Background = Brushes.White, TextAlignment = TextAlignment.Left, FontFamily = new FontFamily("Sans Serif") }, e, 4); g.Children.Add(f); Button b = new Button() { Padding = new Thickness(10, 2, 10, 2), Margin = new Thickness(10), Content = "Ok", HorizontalAlignment = HorizontalAlignment.Center, IsDefault = true, }; b.SetValue(Grid.RowProperty, 1); b.Click += delegate { w.Close(); }; g.Children.Add(b); w.Content = g; w.ShowDialog(); }
private void InitChannelList(ChannelListRoot clr) { foreach (ChannelList cl in clr.result) { PivotItem pi = new PivotItem(); this.MainPivot.Items.Add(pi); pi.Header = cl.title; if (cl.channellist.Count == 0) return; Grid g = CreateChannelGrid(cl.channellist.Count); ScrollViewer sv = new ScrollViewer(); sv.Content = g; pi.Content = sv; for (int i = 0; i < cl.channellist.Count; i++) { Channel c = cl.channellist[i]; Button btn = new Button(); g.Children.Add(btn); btn.Content = c.name; btn.SetValue(Grid.ColumnProperty, i%2); btn.SetValue(Grid.RowProperty, i/2); btn.Click += BtnSelChannelClick; btn.Tag = c; ImageBrush ib = new ImageBrush(); String url = c.thumb; if (url == null) { url = c.avatar; } if (url == null) { //default img continue; } ib.ImageSource = Utils.GetImgFromUri(new Uri(url, UriKind.Absolute), null); ib.Stretch = Stretch.None; ib.AlignmentY = 0;//AlignmentY.Top btn.VerticalContentAlignment = System.Windows.VerticalAlignment.Bottom; btn.Background = ib; btn.BorderBrush = null; btn.Padding = new Thickness(2); } } }
private DrawingSurfaceBackgroundGrid BuildGrid() { var grid = new DrawingSurfaceBackgroundGrid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); var label = new TextBlock { Text = "Count: " + (count++) }; var button = new Button { Content = "Switch" }; button.Click += HandleButtonClick; grid.Children.Add(label); grid.Children.Add(button); button.SetValue(Grid.RowProperty, 1); Content = grid; return grid; }
public Class1() { Title = "Dock Aound the Block"; // Ÿ��Ʋ���� DockPanel dock = new DockPanel(); // ��ŷ ��ü �ϳ� ���� Content = dock; // Content ������Ƽ�� �ִ´�. for (int i = 0; i < 5; i++) // �� 5�� ���ư��� { Button btn = new Button(); btn.Content = "Button No." + (i + 1); // ��ư�� ���� dock.Children.Add(btn); // ��ư�� ��ŷ ���ϵ�� �־��ش�. // btn.HorizontalAlignment = HorizontalAlignment.Center; // �������� // btn.VerticalAlignment = VerticalAlignment.Center; // �������� btn.SetValue(DockPanel.DockProperty, (Dock)(i % 4)); // 0 ���� 1 �� 2 ������ 4�Ʒ� } //dock.LastChildFill = false; ������������ ä��°� ��� ���Ѵ�. }
public override void AddConfigUI(System.Windows.Controls.Grid grid) { base.AddConfigUI(grid); #region Layer name grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); TextBlock layerName = new TextBlock() { Text = Resources.Strings.LabelLayerName, Margin = new Thickness(2), VerticalAlignment = System.Windows.VerticalAlignment.Center }; layerName.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); grid.Children.Add(layerName); TextBox labelTextBox = new TextBox() { Text = LayerName == null ? string.Empty : LayerName, Margin = new Thickness(2), HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, }; labelTextBox.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); labelTextBox.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(labelTextBox); labelTextBox.TextChanged += (s, e) => { LayerName = labelTextBox.Text; }; #endregion #region Renderer grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); TextBlock label2 = new TextBlock() { Text = Resources.Strings.LabelRenderer, Margin = new Thickness(2), VerticalAlignment = System.Windows.VerticalAlignment.Center }; label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); grid.Children.Add(label2); Button rendererButton = null; if (GeometryType == Core.GeometryType.Unknown) { TextBlock tb = new TextBlock() { Text = Resources.Strings.NotAvailable, VerticalAlignment = VerticalAlignment.Center }; ToolTipService.SetToolTip(tb, Resources.Strings.GeometryTypeIsNotKnown); tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); tb.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(tb); } else { rendererButton = new Button() { Content = new Image() { Source = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/ColorScheme16.png", UriKind.Relative)), Stretch = Stretch.None, VerticalAlignment = System.Windows.VerticalAlignment.Center, HorizontalAlignment = System.Windows.HorizontalAlignment.Center }, Width = 22, HorizontalAlignment = HorizontalAlignment.Left, Style = Application.Current.Resources["SimpleButtonStyle"] as Style, IsEnabled = (Mode == InputMode.SketchLayer), }; ToolTipService.SetToolTip(rendererButton, Resources.Strings.ConfigureRenderer); rendererButton.Click += rendererButton_Click; rendererButton.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); rendererButton.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(rendererButton); } #endregion #region Popup Config grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); label2 = new TextBlock() { Text = Resources.Strings.LabelPopUps, Margin = new Thickness(2), VerticalAlignment = System.Windows.VerticalAlignment.Center }; label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); grid.Children.Add(label2); Button popupButton = null; if (Layer == null) { TextBlock tb = new TextBlock() { Text = Resources.Strings.NotAvailable, VerticalAlignment = VerticalAlignment.Center }; ToolTipService.SetToolTip(tb, Resources.Strings.FieldInformationIsNotKnown); tb.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); tb.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(tb); } else { popupButton = new Button() { Content = new Image() { Source = new BitmapImage(new Uri("/ESRI.ArcGIS.Mapping.GP;component/Images/Show_Popup16.png", UriKind.Relative)), Stretch = Stretch.None, VerticalAlignment = System.Windows.VerticalAlignment.Center, HorizontalAlignment = System.Windows.HorizontalAlignment.Center }, Width = 22, HorizontalAlignment = HorizontalAlignment.Left, Style = Application.Current.Resources["SimpleButtonStyle"] as Style, IsEnabled = (Mode == InputMode.SketchLayer), }; ToolTipService.SetToolTip(popupButton, Resources.Strings.ConfigurePopupFieldAliasesAndVisibility); popupButton.Click += popupButton_Click; popupButton.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); popupButton.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(popupButton); } #endregion #region Transparency grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); label2 = new TextBlock() { Text = Resources.Strings.LabelTransparency, Margin = new Thickness(2), VerticalAlignment = System.Windows.VerticalAlignment.Top }; label2.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); grid.Children.Add(label2); ContentControl slider = new ContentControl() { DataContext = this, IsEnabled = (Mode == InputMode.SketchLayer), Style = ResourceUtility.LoadEmbeddedStyle("Themes/HorizontalTransparencySlider.xaml", "TransparencySliderStyle") }; //Slider slider = new Slider() //{ // DataContext = this, // IsEnabled = (Mode == InputMode.SketchLayer), // Orientation = Orientation.Horizontal, // Width = 145, // Minimum = 0, // Maximum = 1 //}; //slider.SetBinding(Slider.ValueProperty, // new System.Windows.Data.Binding("Opacity") { Mode = System.Windows.Data.BindingMode.TwoWay }); slider.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); slider.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(slider); #endregion if (Input) { #region Input Mode grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); TextBlock label = new TextBlock() { Text = Resources.Strings.LabelInputFeatures, Margin = new Thickness(2), VerticalAlignment = System.Windows.VerticalAlignment.Center }; label.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); grid.Children.Add(label); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); StackPanel panel = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical, Margin = new Thickness(15, 0, 0, 0), }; panel.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1); panel.SetValue(Grid.ColumnSpanProperty, 2); RadioButton interactive = new RadioButton() { Content = Resources.Strings.Interactively, IsChecked = (Mode == InputMode.SketchLayer), Margin = new Thickness(2), Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush }; panel.Children.Add(interactive); RadioButton selection = new RadioButton() { Content = Resources.Strings.BySelectingLayerFromMap, IsChecked = (Mode == InputMode.SelectExistingLayer), Margin = new Thickness(2), Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush }; panel.Children.Add(selection); RadioButton fromExtent = null; if (GeometryType == Core.GeometryType.Polygon) { fromExtent = new RadioButton() { Content = Resources.Strings.FromMapExtent, IsChecked = (Mode == InputMode.CurrentExtent), Margin = new Thickness(2), Foreground = Application.Current.Resources["DesignHostBackgroundTextBrush"] as Brush }; panel.Children.Add(fromExtent); } interactive.Checked += (a, b) => { Mode = InputMode.SketchLayer; selection.IsChecked = false; if (fromExtent != null) fromExtent.IsChecked = false; if (popupButton != null) popupButton.IsEnabled = true; if (rendererButton != null) rendererButton.IsEnabled = true; //if (slider != null) // slider.IsEnabled = true; }; selection.Checked += (a, b) => { Mode = InputMode.SelectExistingLayer; interactive.IsChecked = false; if (fromExtent != null) fromExtent.IsChecked = false; if (popupButton != null) popupButton.IsEnabled = false; if (rendererButton != null) rendererButton.IsEnabled = false; //if (slider != null) // slider.IsEnabled = false; }; if (fromExtent != null) { fromExtent.Checked += (a, b) => { Mode = InputMode.CurrentExtent; interactive.IsChecked = false; selection.IsChecked = false; if (popupButton != null) popupButton.IsEnabled = false; if (rendererButton != null) rendererButton.IsEnabled = false; //if (slider != null) // slider.IsEnabled = false; }; } grid.Children.Add(panel); #endregion } }
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"); } }
private void OtherAction(DataResult result) { isSelect = false; this.selectDataresult = result; NextStateCode = result.AppState; System.Windows.Controls.Window winSelector = new System.Windows.Controls.Window(); winSelector.Unloaded += new RoutedEventHandler(winSelector_Unloaded); winSelector.Height = 250; winSelector.Width = 400; winSelector.TitleContent = "确认审核人"; Grid gridSelector = new Grid(); RowDefinition r1 = new RowDefinition(); RowDefinition r2 = new RowDefinition(); RowDefinition r3 = new RowDefinition(); r1.Height = new GridLength(20, GridUnitType.Auto); r2.Height = new GridLength(1, GridUnitType.Star); r3.Height = new GridLength(20, GridUnitType.Auto); gridSelector.RowDefinitions.Add(r1); gridSelector.RowDefinitions.Add(r2); gridSelector.RowDefinitions.Add(r3); TextBlock tb = new TextBlock(); tb.Text = "不能确定下一审核人, 请重新选择一个审核人,并按确认提交"; tb.SetValue(Grid.RowProperty, 0); ScrollViewer scrollp = new ScrollViewer(); scrollp.SetValue(Grid.RowProperty, 1); StackPanel sp = new StackPanel(); sp.Margin = new Thickness(15, 5, 0, 0); sp.Orientation = Orientation.Vertical; for (int i = 0; i < result.UserInfo.Count; i++) { RadioButton rbtn = new RadioButton(); //rbtn.Content = result.UserInfo[i].UserName; rbtn.Content = result.UserInfo[i].UserName + "(" + result.UserInfo[i].CompanyName + "->" + result.UserInfo[i].DepartmentName + "->" + result.UserInfo[i].PostName + ")"; rbtn.DataContext = result.UserInfo[i]; rbtn.GroupName = "User"; sp.Children.Add(rbtn); } scrollp.Content = sp; Button btnOK = new Button(); btnOK.Height = 26; btnOK.Width = 80; btnOK.Content = Utility.GetResourceStr("lblConfirm"); btnOK.HorizontalAlignment = HorizontalAlignment.Right; btnOK.Margin = new Thickness(0, 0, 5, 10); btnOK.SetValue(Grid.RowProperty, 2); btnOK.Click += (e, o) => { this.isSelect = true; UIElement element = sp.Children.FirstOrDefault(item => { RadioButton rb = item as RadioButton; return rb.IsChecked == true; }); if (element == null) { this.isSelect = false; ComfirmWindow.ConfirmationBox("警告", "请先选择一个审核人!", Utility.GetResourceStr("CONFIRMBUTTON")); //MessageBox.Show("请先选择一个审核人"); } else { RadioButton rbSelect = element as RadioButton; UserInfo otherUser = rbSelect.DataContext as UserInfo; NextCompanyID = otherUser.CompanyID; NextDepartmentID = otherUser.DepartmentID; NextPostID = otherUser.PostID; NextUserID = otherUser.UserID; NextUserName = otherUser.UserName; InnerHandIn(currAuditOperation, curAuditAction); winSelector.Close(); } }; ContentControl parent = new ContentControl(); parent.Content = gridSelector; winSelector.Content = parent; gridSelector.Children.Add(tb); gridSelector.Children.Add(scrollp); gridSelector.Children.Add(btnOK); FrameworkElement fe = SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot; // Window.Show("", "", Guid.NewGuid().ToString(), true, false, parent, null); winSelector.Show<string>(DialogMode.Default, fe, "", (resulta) => { }); }
private void CounterAction(DataResult result) { this.isSelect = false; this.selectDataresult = result; NextStateCode = result.AppState; List<Rule_UserInfoViewModel> listviewmodel = new List<Rule_UserInfoViewModel>(); result.DictCounterUser.Keys.ForEach(key => { Rule_UserInfoViewModel vm = new Rule_UserInfoViewModel(key, result.DictCounterUser[key].ToList()); listviewmodel.Add(vm); }); //this.ListCountersign.ItemsSource = listviewmodel; //AuditEventArgs args = new AuditEventArgs(AuditEventArgs.AuditResult.Error, result); //args.StartDate = this.AuditEntity.StartDate; //args.EndDate = System.DateTime.Now; //OnAuditCompleted(this, args); //this.BindingData(); DataTemplate CountersignTemplate = this.Resources["CountersignTemplate"] as DataTemplate; Style listboxStyle = this.Resources["ListBoxItemStyle1"] as Style; System.Windows.Controls.Window winSelector = new System.Windows.Controls.Window(); winSelector.Unloaded += new RoutedEventHandler(winSelector_Unloaded); winSelector.MinHeight = 400; winSelector.Width = 400; //winSelector.Resources.Add("UserInfoTemplate", this.Resources["UserInfoTemplate"]); //winSelector.Resources.Add("ListBoxItemStyle1", this.Resources["ListBoxItemStyle1"]); //winSelector.Resources.Add("CountersignTemplate", this.Resources["CountersignTemplate"]); //winSelector.Width = 400; winSelector.TitleContent = "确认审核人"; Grid gridSelector = new Grid(); RowDefinition r1 = new RowDefinition(); RowDefinition r2 = new RowDefinition(); RowDefinition r3 = new RowDefinition(); r1.Height = new GridLength(50, GridUnitType.Auto); r2.Height = new GridLength(30, GridUnitType.Auto); r3.Height = new GridLength(50, GridUnitType.Auto); gridSelector.RowDefinitions.Add(r1); gridSelector.RowDefinitions.Add(r2); gridSelector.RowDefinitions.Add(r3); TextBlock tb = new TextBlock(); tb.Height = 26; tb.VerticalAlignment = System.Windows.VerticalAlignment.Center; if (result.CountersignType == "0") { tb.Text = "请为每个角色至少选择一人,并按确认提交。"; } else { tb.Text = "请至少选择一人,并按确认提交。"; } tb.SetValue(Grid.RowProperty, 0); ScrollViewer sp = new ScrollViewer(); ListBox listboxCountersign = new ListBox(); listboxCountersign.ItemTemplate = CountersignTemplate; listboxCountersign.ItemContainerStyle = listboxStyle; listboxCountersign.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; listboxCountersign.VerticalAlignment = System.Windows.VerticalAlignment.Top; sp.SetValue(Grid.RowProperty, 1); listviewmodel.ForEach(item => { item.ListUserInfo.ForEach(ent => { ent.UserInfo.CompanyName = ent.UserInfo.UserName + "(" + ent.UserInfo.CompanyName + "->" + ent.UserInfo.DepartmentName + "->" + ent.UserInfo.PostName + ")"; }); }); listboxCountersign.ItemsSource = listviewmodel; sp.Height = 300; sp.Width = 400; //listboxCountersign. //listboxCountersign.ScrollIntoView(listviewmodel); listboxCountersign.UpdateLayout(); sp.Content=listboxCountersign; Button btnOK = new Button(); btnOK.Content = "确认"; btnOK.Margin = new Thickness(0, 0, 5, 10); btnOK.VerticalAlignment = System.Windows.VerticalAlignment.Center; btnOK.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; btnOK.Width = 80; btnOK.Height = 26; btnOK.SetValue(Grid.RowProperty, 2); btnOK.Click += (o, e) => { this.isSelect = true; #region #region Check this.DictCounterUser = new Dictionary<Role_UserType, ObservableCollection<UserInfo>>(); if (result.CountersignType == "0") { foreach (var viewModel in listviewmodel) { bool bUser = false; ObservableCollection<UserInfo> listuserinfo = new ObservableCollection<UserInfo>(); viewModel.ListUserInfo.ForEach(user => { if (user.IsCheck) { bUser = true; listuserinfo.Add(user.UserInfo); } }); if (!bUser) { this.isSelect = false; ComfirmWindow.ConfirmationBox("警告", "请选择角色" + viewModel.Role_UserType.Remark + "的审核人", Utility.GetResourceStr("CONFIRMBUTTON")); //MessageBox.Show("请选择角色" + viewModel.Role_UserType.RoleNameName + "的审核人"); return; } this.DictCounterUser[viewModel.Role_UserType] = listuserinfo; } } else { bool bUser = false; foreach (var viewModel in listviewmodel) { ObservableCollection<UserInfo> listuserinfo = new ObservableCollection<UserInfo>(); viewModel.ListUserInfo.ForEach(user => { if (user.IsCheck) { bUser = true; listuserinfo.Add(user.UserInfo); } }); this.DictCounterUser[viewModel.Role_UserType] = listuserinfo; } if (!bUser) { this.isSelect = false; ComfirmWindow.ConfirmationBox("警告", "至少选择一个审核人", Utility.GetResourceStr("CONFIRMBUTTON")); //MessageBox.Show("至少选择一个审核人"); return; } } #endregion InnerHandIn(currAuditOperation, curAuditAction); winSelector.Close(); #endregion }; ContentControl parent = new ContentControl(); parent.Content = gridSelector; winSelector.Content = parent; gridSelector.Children.Add(tb); gridSelector.Children.Add(sp); gridSelector.Children.Add(btnOK); FrameworkElement fe = SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot; // Window.Show("", "", Guid.NewGuid().ToString(), true, false, parent, null); winSelector.Show<string>(DialogMode.Default, fe, "", (resulta) => { }); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { //OnNextStep += new OnNextStepHandler(setStep); for (int i = 0; i < height; i++) { ColumnDefinition c = new ColumnDefinition(); c.Name = "c" + i.ToString(); c.Width = new GridLength(1, GridUnitType.Star); RowDefinition r = new RowDefinition(); r.Name = "r" + i.ToString(); r.Height = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(c); grid.RowDefinitions.Add(r); } for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Button a = new Button(); a.SetValue(Grid.RowProperty, i); a.SetValue(Grid.ColumnProperty, j); a.Click += btn_Click; if (i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0) { setBackground(a, name0); } else if (i % 2 == 0 && j % 2 != 0 || i % 2 != 0 && j % 2 == 0) { setBackground(a, name1); } grid.Children.Add(a); } } }
private void CreateDockPanel() { Button okBtn = new Button(); okBtn.Content = "确定"; Button cancelBtn = new Button(); cancelBtn.Content = "取消"; okBtn.SetValue(DockPanel.DockProperty, Dock.Right); okBtn.Height = 30; okBtn.Width = 40; okBtn.Padding = new Thickness(2); okBtn.Background = Brushes.LightGreen; okBtn.Click += new RoutedEventHandler(okBtn_Click); m_dockPanel.Children.Add(okBtn); cancelBtn.SetValue(DockPanel.DockProperty, Dock.Left); cancelBtn.Height = 30; cancelBtn.Width = 50; cancelBtn.Padding = new Thickness(2); cancelBtn.Background = Brushes.LightGreen; cancelBtn.Click += new RoutedEventHandler(cancelBtn_Click); m_dockPanel.Children.Add(cancelBtn); m_dockPanel.Margin = new Thickness(5); m_dockPanel.SetValue(TopProperty, Mouse.GetPosition(this).Y); m_dockPanel.SetValue(LeftProperty, Mouse.GetPosition(this).X - 90); this.Children.Add(m_dockPanel); Cursor = Cursors.Arrow; }
public static void SetPopupToControl(Button button, Popup value) { button.SetValue(PopupToControlProperty, value); }
public static void SetPopupAction(Button button, PopupAction value) { button.SetValue(PopupActionProperty, value); }
private void Init() { var detail = this; foreach (var propertyInfo in TypeObj.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)) { detail.Children.Add(new TextBlock { Text = SeparateCapitalWords(propertyInfo.Name) }); FrameworkElement element; var binding = new Binding(propertyInfo.Name); if (propertyInfo.CanWrite) { binding.Mode = BindingMode.TwoWay; if (typeof(DateTime).IsAssignableFrom(propertyInfo.PropertyType)) { var dtp = new DatePicker(); dtp.SetBinding(DatePicker.SelectedDateProperty, binding); element = new CoverControl { Control = dtp, Name = propertyInfo.Name }; } else if (typeof(Enum).IsAssignableFrom(propertyInfo.PropertyType)) { var cb = new ComboBox(); cb.SetBinding(Selector.SelectedItemProperty, binding); var propertyInfo1 = propertyInfo; Utilities.FillEnums(cb, propertyInfo1.PropertyType); element = new CoverControl { Control = cb, Name = propertyInfo.Name }; } else if (typeof(Persistent).IsAssignableFrom(propertyInfo.PropertyType)) { var cb = new ComboBox(); cb.SetBinding(Selector.SelectedItemProperty, binding); var propertyInfo1 = propertyInfo; dropdowns[cb] = propertyInfo1.PropertyType; element = new CoverControl { Control = cb, Name = propertyInfo.Name }; } else { var tb = new TextBox(); tb.SetBinding(TextBox.TextProperty, binding); element = new CoverControl { Control = tb, Name = propertyInfo.Name }; } } else { binding.Mode = BindingMode.OneWay; var tb = new TextBlock(); tb.SetBinding(TextBlock.TextProperty, binding); element = tb; } detail.Children.Add(element); } var grid = new Grid { Margin = new Thickness(0, 50, 0, 0) }; grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); var b = new Button { Content = "Delete" }; b.Click += DeleteOnClick; b.SetValue(Grid.ColumnProperty, 2); grid.Children.Add(b); detail.Children.Add(grid); }
/// <summary> /// Génere une ligne de plat ou aliment /// comportant son nom et son bouton pouvant l'Ajouter ou le supprimer /// </summary> /// <param name="plus">Parametre qui permet de determiner si la méthode /// est appelé pour faire une ligne avec un bouton plus ou un bouton moins</param> /// <param name="obj">Plat ou Aliment</param> /// <returns></returns> Button FormerListeLignePlatAliment(bool? plus, Object obj, List<int?> lstIdPresent) { // Les plats seront positif et les aliment, négatif Plat plat; Aliment aliment; Button btnControl = new Button(); bool EstPlat = false; if (obj.GetType().ToString() == "Nutritia.Plat") EstPlat = true; // Si c'est un plat que l'on recoit, alors on définnit aliment a null et on crée une instance de plat // Sinon, le contraire plat = (EstPlat ? (Plat)obj : null); aliment = (!EstPlat ? (Aliment)obj : null); // Si la liste est null (On n'apelle pas cette fonction dans le contexte du plateau) alors on rentre dans le bloc // Sinon si la liste d'id ne contient pas déja l'id du plat actuelle, alors on rentre pour ajouter ce plat/aliment // Sinon, si la liste d'id contient déja l'id du plat actuelle, alors on ne rentre pas car on ne veut pas mettre 2 plats // Aussi : Pour les aliments, on utilise le contraire de son id afin de retrouver dans la liste la partie des aliments (id * -1) if (lstIdPresent != null ? (!lstIdPresent.Contains((EstPlat ? plat.IdPlat : aliment.IdAliment * -1))) : true) { // On a pas besoin d'ajouter l'id lorsque le contexte d'apelle n'est pas pour le plateau (Seul place avec un compteur) if (lstIdPresent != null) { // On définnit que l'on à dessiner le plat if (EstPlat) lstIdPresent.Add(plat.IdPlat); else lstIdPresent.Add(aliment.IdAliment * -1); } // Création du bouton pour supprimer ou ajouter un Plat/Aliment btnControl.HorizontalContentAlignment = HorizontalAlignment.Left; if (plus == null) { // On veut un margin pour décaller Thickness margin = btnControl.Margin; margin.Left = 20; btnControl.Margin = margin; // On ne veut pas pouvoir cliquer sur le bouton btnControl.IsEnabled = false; btnControl.SetValue(ToolTipService.ShowOnDisabledProperty, true); } btnControl.Height = 32; if (plus != null) { if ((bool)plus) btnControl.Click += AjoutItem_Click; else if ((bool)!plus) { btnControl.Click += BtnControlSupprimer_Click; btnControl.MouseRightButtonDown += BtnControlDerouler_Click; } btnControl.Uid = (EstPlat ? plat.IdPlat : aliment.IdAliment * -1).ToString(); btnControl.Cursor = Cursors.Hand; } StackPanel stackLigne = new StackPanel(); stackLigne.Orientation = Orientation.Horizontal; stackLigne.HorizontalAlignment = HorizontalAlignment.Left; stackLigne.Width = 275; if (plus != null) { // Image de bouton Image imgBouton = new Image(); imgBouton.Source = new BitmapImage(new Uri("pack://application:,,,/UI/Images/" + ((bool)plus ? "plusIcon" : "minusIcon") + ".png")); imgBouton.Width = 15; imgBouton.Height = 15; stackLigne.Children.Add(imgBouton); } // Génération du Label comportant le nom du Plat/Aliment Label lblNom = new Label(); lblNom.FontSize = 12; lblNom.Width = 230; if (EstPlat) { int nbrMemePlat = PlateauPlat.Count(x => x.IdPlat == plat.IdPlat); // Si on passe null a lstIdPresent, c'est qu'on ne veut pas reproduire ce plat if (lstIdPresent == null) nbrMemePlat = 0; lblNom.Content = (nbrMemePlat > 0 && lstIdPresent != null ? nbrMemePlat.ToString() + " " : "") + plat.Nom; stackLigne.Children.Add(lblNom); } else { int nbrMemeAliment = PlateauAliment.Count(x => x.IdAliment == aliment.IdAliment); if (lstIdPresent == null) nbrMemeAliment = 0; lblNom.Content = (nbrMemeAliment > 0 ? nbrMemeAliment.ToString() + " " : "") + aliment.Nom; stackLigne.Children.Add(lblNom); } // Image pour détérminer si c'est un plat ou un aliment Image imgTypeElement = new Image(); imgTypeElement.Source = new BitmapImage(new Uri("pack://application:,,,/UI/Images/" + (EstPlat ? "PlatIcon" : "IngredientsIcon") + ".png")); imgTypeElement.Height = 15; stackLigne.Children.Add(imgTypeElement); // Insertion d'un hover tooltip sur le StackPanel if (EstPlat) btnControl.ToolTip = GenererToolTipValeursNutritive(plat); else btnControl.ToolTip = GenererToolTipValeursNutritive(aliment); btnControl.Content = stackLigne; } else btnControl = null; return btnControl; }