private void OnRowClick(object sender, EventArgs e) { for (int i = 0; i < contentPanel.Controls.Count; i++) { RoundedControl child = contentPanel.Controls[i] as RoundedControl; if (sender == child) { if (selected != i) { AdornUnselectedRow(selected); AdornSelectedRow(i); selected = i; } } } }
/// <summary> /// Shows the forms recently downloaded /// </summary> /// <param name="infos"></param> public void ShowRecentForms(FormInfo[] infos) { //Clear rows foreach (Control child in contentPanel.Controls) { child.Click -= OnRowClick; child.Dispose(); } contentPanel.Controls.Clear(); offset = baseOffset; dataSets = infos; foreach (FormInfo info in dataSets) { RoundedControl row = new RoundedControl() { Width = contentPanel.Width, Height = 40, CornerRadius = 4, BorderSize = 0, BorderColor = Color.FromArgb(146, 146, 146), BackColor = Color.Transparent, Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right }; row.Top = offset; row.Click += OnRowClick; offset += row.Height; Image iconImage = Mobile.Properties.Resources.FormNotifiedIcon; if (info.Status == FormStatus.Downloaded) { iconImage = Mobile.Properties.Resources.FormDownloadedIcon; } if (info.Status == FormStatus.Opened) { iconImage = Mobile.Properties.Resources.FormOpenedIcon; } PictureBox icon = new PictureBox() { Image = iconImage, Width = 20, Height = 20, Location = new Point(5, 10), SizeMode = PictureBoxSizeMode.StretchImage, Anchor = AnchorStyles.Top | AnchorStyles.Left }; Label nameLabel = new Label() { Text = info.Name == null? "(" + info.RequestInfo.CompilationRequestId + ")" : info.Name, Height = 16, Width = 90, Location = new Point(30, 5), Font = new Font("Tahoma", 8, FontStyle.Bold) }; Label sourceLabel = new Label() { Text = info.Source == null ? "No source" : info.Source, Height = 16, Width = 90, Location = new Point(30, 21), Font = new Font("Tahoma", 8, FontStyle.Regular) }; Label dateLabel = new Label() { Text = info.DownloadTime.Year == 1 ? "" : info.DownloadTime.ToString(ResourceManager.Instance.Culture), Height = 16, Width = 80, TextAlign = ContentAlignment.TopRight, Location = new Point(row.Width - 85, 5), Font = new Font("Tahoma", 8, FontStyle.Regular), Anchor = AnchorStyles.Top | AnchorStyles.Right }; row.Controls.Add(icon); row.Controls.Add(nameLabel); row.Controls.Add(sourceLabel); row.Controls.Add(dateLabel); contentPanel.Controls.Add(row); } if (infos.Length > 0) { selected = 0; AdornSelectedRow(0); } }
/// <summary> /// Initializes a new instance of the <see cref="SequenceBoxController2"/> class. /// </summary> /// <param name="element">The element representig the related <see cref="SequenceBoxController2"/></param> /// <param name="enabled">True if the <see cref="SequenceBoxController2"/> is modifiable, false otherwise</param> public SequenceBoxController(SequenceBox element, bool enabled) : base(enabled) { this.element = element; cache = new SequenceBox(element.TypeName, element.FieldName, element.Schema); cache.ParsePresentation(element.FieldsPresentation); mainPanel = new RoundedControl() { BorderColor = Color.FromArgb(146, 146, 146), BorderSize = 1, CornerRadius = 4, BackColor = Color.FromArgb(235, 235, 235) }; list = new ListView() { View = View.Details, CheckBoxes = enabled, Height = 120, Font = new Font("Tahoma", 8, FontStyle.Regular) }; list.Columns.Add("Item", 150, System.Windows.Forms.HorizontalAlignment.Left); list.FullRowSelect = true; list.HeaderStyle = ColumnHeaderStyle.None; list.Activation = ItemActivation.OneClick; foreach (Field child in element.Fields) { cache.AddNew(); cache.Fields[cache.Fields.Length - 1].FromXml(child.ToXml()); ((cache.Fields[cache.Fields.Length - 1]) as GroupBox).Annotation = (child as GroupBox).Annotation; list.Items.Add(new ListViewItem(((cache.Fields[cache.Fields.Length - 1]) as GroupBox).Annotation)); } if (enabled) { createButton = new RoundedButton() { Width = 38, Height = 18, Top = 0, Left = 3, BackColor = Color.FromArgb(236, 236, 236), BorderColor = Color.FromArgb(146, 146, 146), ClickedBackColor = Color.FromArgb(186, 186, 186), Text = ResourceManager.Instance.GetString("New"), Font = new Font("Tahoma", 8, FontStyle.Regular), ForeColor = Color.FromArgb(90, 90, 90), BorderSize = 1, CornerRadius = 4 }; createButton.Click += OnNewButtonClick; deleteButton = new RoundedButton() { Width = 44, Height = 18, Top = 0, Left = 1, BackColor = Color.FromArgb(236, 236, 236), BorderColor = Color.FromArgb(146, 146, 146), ClickedBackColor = Color.FromArgb(186, 186, 186), Text = ResourceManager.Instance.GetString("delete"), Font = new Font("Tahoma", 8, FontStyle.Regular), ForeColor = Color.FromArgb(90, 90, 90), BorderSize = 1, CornerRadius = 4 }; deleteButton.Click += OnDeleteButtonClick; buttonPanel = new Panel() { Height = deleteButton.Height, BackColor = Color.FromArgb(228, 228, 228) }; buttonPanel.Controls.Add(deleteButton); buttonPanel.Controls.Add(createButton); buttonPanel.Location = new Point(mainPanel.BorderSize + mainPanel.CornerRadius, mainPanel.BorderSize + 4); createButton.Location = new Point(0, 0); deleteButton.Location = new Point(createButton.Width + 3, 0); mainPanel.Controls.Add(buttonPanel); } if (enabled) { list.Location = new Point(mainPanel.BorderSize + mainPanel.CornerRadius, buttonPanel.Top + buttonPanel.Height + 4); } else { list.Location = new Point(mainPanel.BorderSize + mainPanel.CornerRadius, mainPanel.BorderSize + mainPanel.CornerRadius); } mainPanel.Controls.Add(list); //Create context menu ContextMenu menu = new ContextMenu(); if (enabled) { MenuItem deleteItem = new MenuItem() { Text = ExitString }; MenuItem editItem = new MenuItem() { Text = EditString }; MenuItem sortItem = new MenuItem() { Text = MoveString }; MenuItem sortUpItem = new MenuItem() { Text = UpString }; MenuItem sortDownItem = new MenuItem() { Text = DownString }; sortItem.MenuItems.Add(sortUpItem); sortItem.MenuItems.Add(sortDownItem); menu.MenuItems.Add(editItem); menu.MenuItems.Add(deleteItem); menu.MenuItems.Add(sortItem); editItem.Click += OnEditMenuItemClick; deleteItem.Click += OnDeleteMenuItemClick; sortUpItem.Click += OnSortUpMenuItemClick; sortDownItem.Click += OnSortDownMenuItemClick; } else { MenuItem viewItem = new MenuItem() { Text = ViewString }; menu.MenuItems.Add(viewItem); viewItem.Click += OnViewMenuItemClick; } mainPanel.Top = mainPanel.BorderSize; mainPanel.Height = list.Height + (buttonPanel == null ? 0 : buttonPanel.Height) + (2 * mainPanel.BorderSize) + 12; this.Height = mainPanel.Height + (2 * mainPanel.BorderSize); mainPanel.Width = this.Width; list.Width = mainPanel.Width - 2 * (mainPanel.BorderSize + mainPanel.CornerRadius); list.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top; if (buttonPanel != null) { buttonPanel.Width = mainPanel.Width - 2 * (mainPanel.BorderSize + mainPanel.CornerRadius); buttonPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; } list.ContextMenu = menu; list.SelectedIndexChanged += OnSelectedIndexChange; list.Columns[0].Width = list.Width - 4; mainPanel.Resize += OnPanelSizeChanged; Content = mainPanel; Title = element.Name; Description = element.Description; }