private void ulvPrintSeries_DragOver(object sender, DragEventArgs e) { UltraListView listView = sender as UltraListView; Point clientPos = listView.PointToClient(new Point(e.X, e.Y)); if (this.dragItem != null) { this.dropItem = listView.ItemFromPoint(clientPos); //e.Effect = this.dropItem != null && this.dropItem != this.dragItem ? DragDropEffects.Move : DragDropEffects.None; } e.Effect = DragDropEffects.Move; int dragScrollAreaHeight = 8; Rectangle displayRect = listView.DisplayRectangle; Rectangle topScrollArea = displayRect; topScrollArea.Height = (dragScrollAreaHeight * 2); Rectangle bottomScrollArea = displayRect; bottomScrollArea.Y = bottomScrollArea.Bottom - dragScrollAreaHeight; bottomScrollArea.Height = dragScrollAreaHeight; ISelectionManager selectionManager = listView as ISelectionManager; if (topScrollArea.Contains(clientPos) || bottomScrollArea.Contains(clientPos)) { selectionManager.DoDragScrollVertical(0); } }
void ulvForms_MouseDown(object sender, MouseEventArgs e) { //this.pnlPrintSeriesPanel.Visible = false; if (e.Button == MouseButtons.Left) { this.lastMouseDown = e.Location; } else if (e.Button == MouseButtons.Right) { Point cursorPos = new Point(e.X, e.Y); UltraListView listView = sender as UltraListView; UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true); if (itemAtPoint != null) { Infragistics.Win.ISelectionManager selectionManager = listView as Infragistics.Win.ISelectionManager; selectionManager.SelectItem(itemAtPoint, true); itemAtPoint.Activate(); contextMenuStrip1.Enabled = true; contextMenuStrip1.Show(listView, new Point(e.X, e.Y)); } else { contextMenuStrip1.Enabled = false; } } else { this.lastMouseDown = new Point(); } }
private void ulvForms_MouseMove(object sender, MouseEventArgs e) { UltraListView listView = sender as UltraListView; // If the mouse has moved outside the area in which it was pressed, // start a drag operation if (!this.lastMouseDown.IsEmpty && e.Button == MouseButtons.Left) { Size dragSize = SystemInformation.DragSize; Rectangle dragRect = new Rectangle(this.lastMouseDown, dragSize); dragRect.X -= dragSize.Width / 2; dragRect.Y -= dragSize.Height / 2; if (!dragRect.Contains(e.Location)) { UltraListViewItem itemAtPoint = listView.ItemFromPoint(e.Location); if (itemAtPoint != null) { this.lastMouseDown = new Point(); this.dragItem = itemAtPoint; listView.DoDragDrop(this.dragItem, DragDropEffects.Move); } } } }
private void ulvUserData_DragOver(object sender, DragEventArgs e) { UltraListView listView = sender as UltraListView; Point clientPos = listView.PointToClient(new Point(e.X, e.Y)); if (dragItem != null) { dropItem = listView.ItemFromPoint(clientPos); e.Effect = dropItem != null && dropItem != dragItem ? DragDropEffects.Move : DragDropEffects.None; } // If the cursor is within {dragScrollAreaHeight} pixels // of the top or bottom edges of the control, scroll int dragScrollAreaHeight = 8; Rectangle displayRect = listView.DisplayRectangle; Rectangle topScrollArea = displayRect; topScrollArea.Height = (dragScrollAreaHeight * 2); Rectangle bottomScrollArea = displayRect; bottomScrollArea.Y = bottomScrollArea.Bottom - dragScrollAreaHeight; bottomScrollArea.Height = dragScrollAreaHeight; ISelectionManager selectionManager = listView; if (topScrollArea.Contains(clientPos) || bottomScrollArea.Contains(clientPos)) { selectionManager.DoDragScrollVertical(0); } }
/// <summary> /// Called as we click a mouse button within the list view. If this is the right button then we should /// select (any) item which the mouse is over /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ulvUserData_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { lastMouseDown = e.Location; } else { lastMouseDown = null; } UltraListView listViewDrag = sender as UltraListView; UltraListViewItem itemAtPoint = listViewDrag.ItemFromPoint(e.X, e.Y, true); if (itemAtPoint != null) { lastMouseDownLocation = new Point(e.X, e.Y); if (e.Button == MouseButtons.Right) { ulvUserData.SelectedItems.Clear(); ulvUserData.SelectedItems.Add(itemAtPoint); } } else { lastMouseDownLocation = null; } }
private void ulvUserData_MouseMove(object sender, MouseEventArgs e) { UltraListView listView = sender as UltraListView; // If the mouse has moved outside the area in which it was pressed, // start a drag operation if (lastMouseDown.HasValue) { Size dragSize = SystemInformation.DragSize; Rectangle dragRect = new Rectangle(lastMouseDown.Value, dragSize); dragRect.X -= dragSize.Width / 2; dragRect.Y -= dragSize.Height / 2; if (!dragRect.Contains(e.Location)) { UltraListViewItem itemAtPoint = listView.ItemFromPoint(e.Location); if (itemAtPoint != null) { lastMouseDown = null; dragItem = itemAtPoint; listView.DoDragDrop(dragItem, DragDropEffects.Move); } } } }
/// <summary> /// Key processor for the list view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ulvLocations_KeyDown(object sender, KeyEventArgs e) { UltraListView listView = sender as UltraListView; if (listView.ActiveItem != null && listView.ActiveItem.IsInEditMode == false) { // If the delete key is pressed, call the context menu item event handler code, so that // the same logic gets precessed as would for a context menu delete if (e.KeyData == Keys.Delete) { //miDeleteLocation_Click(sender, null); //e.Handled = true; DeleteListLocation(); } // The insert key will create a new location else if (e.KeyCode == Keys.Insert) { miNewLocation_Click(sender, null); e.Handled = true; } } // If we have handled the keystroke, the KeyPress event can still fire so set a flag that will // prevent that. if (e.Handled) { this.eatNextKeyPress = true; } }
private void ulvDETemplates_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { // Change this to false if you want to maintain // the existing selection. //bool clearExisting = false; Point cursorPos = new Point(e.X, e.Y); UltraListView listView = sender as UltraListView; // Use the UltraListView's 'ItemFromPoint' method to hit test for an // UltraListViewItem. Note that we specify true for the 'selectableAreaOnly' // parameter, so that we only get a hit when the cursor is over the text // or image area of the item. UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true); // If we got a reference to an item, populate the context menu // accordingly and return if (itemAtPoint != null) { //this.ulvMethodsList.ContextMenuStrip = null; Infragistics.Win.ISelectionManager selectionManager = listView as Infragistics.Win.ISelectionManager; selectionManager.SelectItem(itemAtPoint, true); itemAtPoint.Activate(); contextMenuStrip1.Enabled = true; } else { contextMenuStrip1.Enabled = false; //this.ulvMethodsList.ContextMenuStrip = cmsListViewStyle; } } }
public ExplorerHelper(UltraListView _ulv) { ulv = _ulv; appPdf = ulv.Appearances.Add("pdf"); appPdf.Image = Resources.pdf; appWord = ulv.Appearances.Add("Word"); appWord.Image = Resources.word; }
private void ulvUserData_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { UltraListView listView = sender as UltraListView; // Cancel the drag operation if the escape key was pressed if (e.EscapePressed) { OnDragEnd(listView, true); e.Action = DragAction.Cancel; } }
private void OnDragEnd(UltraListView listView, bool canceled) { if (canceled == false && this.dragItem != null) { VWA4Common.DataObject.Formx f = FormDAO.DAO.Load(Convert.ToInt32(dragItem.Key)); UltraListViewItem i = new UltraListViewItem(); List <FormFormSeries> allffs = new List <FormFormSeries>(); allffs.AddRange(FormFormSeriesDAO.DAO.GetAllByFormSeriesId(this.activePrintSeriesId)); allffs.AddRange(this.newFfs); foreach (FormFormSeries ffs in allffs) { if (ffs.FormId == f.Id && ffs.FormSeriesId == this.activePrintSeriesId) { MessageBox.Show("Duplicate forms cannot be added to the same series.", "Manage Forms"); return; } } try { FormFormSeries ffs = new FormFormSeries { Id = FormFormSeriesDAO.DAO.GetNextId() + this.newFfs.Count, FormId = f.Id, FormSeriesId = this.activePrintSeriesId, Enabled = true, NumberOfCopies = 1, SortOrder = (dropItem == null) ? 0 : dropItem.Index + 1 }; i.Key = ffs.Id.ToString(); i.Value = f.Name; ulvPrintSeries.Items.Insert((dropItem == null) ? 0 : dropItem.Index + 1, i); this.newFfs.Add(ffs); } catch (Exception ex) { throw ex; } i.CheckState = CheckState.Checked; i.SubItems[0].Value = 1; i.SubItems[1].Value = f.Id; } this.dragItem = this.dropItem = null; this.lastMouseDown = new Point(); }
public FrmPricture(UltraListView selectedFilePath) { InitializeComponent(); if (selectedFilePath.SelectedItems.First.Tag != null) { byte[] item = ImageConverter.GetBytes(selectedFilePath.SelectedItems.First.Tag.ToString()); string image = Convert.ToBase64String(item); pictureBox1.Image = ImageConverter.Base64ToImage(image); } else { pictureBox1.ImageLocation = selectedFilePath.SelectedItems.First.Key; } pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; Size = pictureBox1.Size; }
private void CheckIfCanImport(UltraListView listView) { using (logX.loggerX.InfoCall()) { if (listView != null) { foreach (var item in listView.Items) { if (item.CheckState == CheckState.Checked) { ultraButton_OK.Enabled = true; return; } } ultraButton_OK.Enabled = false; } } }
private void OnDragEnd(UltraListView listView, bool canceled) { if (canceled == false && dragItem != null && dropItem != null) { listView.BeginUpdate(); int index = dropItem.Index; listView.Items.Remove(dragItem); listView.Items.Insert(index, dragItem); listView.EndUpdate(); UpdateFieldsTabOrder(); RefreshTab(); } dragItem = dropItem = null; lastMouseDown = null; }
void ulvFormSeries_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point cursorPos = new Point(e.X, e.Y); UltraListView listView = sender as UltraListView; UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true); if (itemAtPoint != null) { Infragistics.Win.ISelectionManager selectionManager = listView as Infragistics.Win.ISelectionManager; selectionManager.SelectItem(itemAtPoint, true); itemAtPoint.Activate(); contextMenuStrip2.Enabled = true; contextMenuStrip2.Show(listView, new Point(e.X, e.Y)); } else { contextMenuStrip2.Enabled = false; } } else if (e.Button == MouseButtons.Left) { Point cursorPos = new Point(e.X, e.Y); UltraListView listView = sender as UltraListView; UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true); if (itemAtPoint != null) { Infragistics.Win.ISelectionManager selectionManager = listView as Infragistics.Win.ISelectionManager; selectionManager.SelectItem(itemAtPoint, true); itemAtPoint.Activate(); FormSeries fs = FormSeriesDAO.DAO.Load(Convert.ToInt32(listView.SelectedItems[0].Key)); this.pnlPrintSeriesPanel.Visible = true; this.lblPrintSeriesName.Text = fs.Name + " Series"; this.loadPrintSeries(fs); } } }
void ulvPrintSeries_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point cursorPos = new Point(e.X, e.Y); UltraListView listView = sender as UltraListView; UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true); if (itemAtPoint != null) { Infragistics.Win.ISelectionManager selectionManager = listView as Infragistics.Win.ISelectionManager; selectionManager.SelectItem(itemAtPoint, true); itemAtPoint.Activate(); contextMenuStrip3.Enabled = true; contextMenuStrip3.Show(listView, new Point(e.X, e.Y)); } else { contextMenuStrip3.Enabled = false; } } }
private void ulvPrintSeries_DragDrop(object sender, DragEventArgs e) { UltraListView listView = sender as UltraListView; this.OnDragEnd(listView, false); }
public frmSeriesProperties(FormSeries fs) { InitializeComponent(); updateProductUI(); this.lblNameValue.Text += fs.Name; this.lblDateCreatedValue.Text += fs.CreateDate.ToShortDateString(); this.lblLastModifiedDateValue.Text += fs.ModifiedDate.ToShortDateString(); UltraListView ulvForms = new UltraListView(); ulvForms.Reset(); ulvForms.Width = 306; ulvForms.Height = 236; ulvForms.View = UltraListViewStyle.Details; ulvForms.ItemSettings.Appearance.Image = imageList1.Images[0]; ulvForms.ViewSettingsDetails.SubItemColumnsVisibleByDefault = true; ulvForms.ViewSettingsDetails.AutoFitColumns = AutoFitColumns.ResizeAllColumns; ulvForms.ItemSettings.SubItemsVisibleInToolTipByDefault = false; ulvForms.ItemSettings.SelectionType = SelectionType.Single; UltraListViewMainColumn mainColumn = ulvForms.MainColumn; mainColumn.Text = "Form Name"; mainColumn.Width = 120; mainColumn.DataType = typeof(System.Int32); UltraListViewSubItemColumn cDocType = new UltraListViewSubItemColumn(); cDocType.Text = "Type"; cDocType.Width = 50; cDocType.VisibleInDetailsView = DefaultableBoolean.True; cDocType.DataType = typeof(String); UltraListViewSubItemColumn cDataEntryTemplate = new UltraListViewSubItemColumn(); cDataEntryTemplate.Text = "Data Entry Template"; cDataEntryTemplate.Width = 136; cDataEntryTemplate.VisibleInDetailsView = DefaultableBoolean.True; cDataEntryTemplate.DataType = typeof(Int32); ulvForms.SubItemColumns.Add(cDocType); ulvForms.SubItemColumns.Add(cDataEntryTemplate); ValueList docType = new ValueList(); ValueList dataEntryTemplate = new ValueList(); foreach (VWA4Common.DataObject.Formx f in FormDAO.DAO.GetAllBySeriesId(fs.Id)) { docType.ValueListItems.Add(f.DocumentType, f.DocumentType); dataEntryTemplate.ValueListItems.Add(f.DataEntryTemplateId, VWA4Common.DB.Retrieve(string.Format("select DETName from DataEntryTemplates where ID={0}", f.DataEntryTemplateId)).Rows[0]["DETName"].ToString()); UltraListViewItem i = ulvForms.Items.Add(Guid.NewGuid().ToString(), f.Name); i.SubItems[0].Value = f.DocumentType; i.SubItems[1].Value = f.DataEntryTemplateId; } ulvForms.SubItemColumns[0].ValueList = docType; ulvForms.SubItemColumns[1].ValueList = dataEntryTemplate; this.pnlFormsInSeries.Controls.Add(ulvForms); }
private static List<byte[]> GetAttachments(UltraListView ultraListView) { var aList = new List<byte[]>(); foreach (UltraListViewItem item in ultraListView.Items) { try { aList.Add(File.ReadAllBytes(item.Key)); } catch (Exception) { aList.Add(ImageConverter.GetBytes(item.Tag.ToString())); } } return aList; }
private void ulvUserData_DragDrop(object sender, DragEventArgs e) { UltraListView listView = sender as UltraListView; OnDragEnd(listView, false); }
private void OnDragEnd( UltraListView listView, bool canceled) { if (isFormClosing) { return; } if (canceled == false && _data != null) { listView.BeginUpdate(); // listView.Items.Remove((UltraListViewItem) data); int index = 0; if (listView.Items.Count > 0) { index = listView.Items.Count; } //Create Unique GUID From Filename string myUniqueFileName = ""; try { myUniqueFileName = string.Format ( ((string[]) (_data))[0], Guid.NewGuid()); } catch (Exception) { myUniqueFileName = string.Format ( "Image " + DateTime.Now, Guid.NewGuid()); } try { using (var item = new UltraListViewItem(_data.ToString()) { Tag = ((string[]) (_data))[0], Key = myUniqueFileName }) { const int thumbSize = 256; Bitmap thumbnail = WindowsThumbnailProvider.GetThumbnail ( ((string[]) (_data))[0], thumbSize, thumbSize, ThumbnailOptions.BiggerSizeOk); if (bmp != null) { item.Appearance.ImageBackground = bmp; item.Appearance.Image = bmp; } else { item.Appearance.ImageBackground = thumbnail; item.Appearance.Image = thumbnail; } if (!listView.Items.Contains(myUniqueFileName)) { listView.Items.Insert ( index, item); } } } catch (Exception) { var b = new Bitmap((Bitmap) _data); var i = (Image) b; try { string result = ImageConverter.GetString ( ImageConverter.ImageToBase64Byte ( i, ImageFormat.Bmp)); try { listView.Items.Insert ( index, new UltraListViewItem(myUniqueFileName) { Tag = result }); } catch (Exception) { listView.Items.Add ( new UltraListViewItem(myUniqueFileName) { Tag = result }); } UltraListViewItem selected = listView.Items[index]; selected.Appearance.ImageBackground = i; selected.Appearance.Image = b; } catch (Exception e) { //Do Nothing } } listView.EndUpdate(); } _dragItem = _dropItem = null; _lastMouseDown = null; }