private void SetPose(ImageListViewItem sel) { var animFileName = Path.GetFileNameWithoutExtension(sel.Text) + ".obj"; var animPath = Path.Combine(Application.StartupPath, "Stages", "Poses", ManType.Child.GetCaption(), animFileName); if (currentPose == animPath) return; currentPose = animPath; ProgramCore.MainForm.ctrlRenderControl.PoseMorphing = ProgramCore.MainForm.ctrlRenderControl.pickingController.LoadPartsMorphInfo(currentPose, ProgramCore.MainForm.ctrlRenderControl.headMeshesController.RenderMesh); trackBarPose.Enabled = true; trackBarPose.Value = 100; SetPosePosition(); }
public void InitializeListView() { #region Backgrounds imageListBackgrounds.AllowDuplicateFileNames = true; imageListBackgrounds.SetRenderer(new ImageListViewRenderers.DefaultRenderer()); imageListBackgrounds.Columns.Add(ColumnType.Name); imageListBackgrounds.Columns.Add(ColumnType.FileSize); imageListBackgrounds.ThumbnailSize = new Size(96, 96); imageListBackgrounds.Items.Clear(); imageListBackgrounds.SuspendLayout(); try { var directoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "Abalone", "Stages", "Backgrounds"); var di = new DirectoryInfo(directoryPath); if (!di.Exists) return; foreach (var p in di.GetFiles("*.jpg")) imageListBackgrounds.Items.Add(p.FullName); } finally { imageListBackgrounds.ResumeLayout(); } #endregion #region Poses currentPose = string.Empty; imageListPoses.AllowDuplicateFileNames = true; imageListPoses.SetRenderer(new ImageListViewRenderers.DefaultRenderer()); imageListPoses.Columns.Add(ColumnType.Name); imageListPoses.Columns.Add(ColumnType.FileSize); imageListPoses.ThumbnailSize = new Size(96, 96); imageListPoses.Items.Clear(); imageListPoses.SuspendLayout(); try { var exts = new List<string> { ".jpg", ".png" }; var directoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "Abalone", "Stages", "Poses", ProgramCore.Project.ManType.GetCaption()); var di = new DirectoryInfo(directoryPath); if (di.Exists) { foreach (var p in GetFilesByExtensions(di, exts)) { var item = new ImageListViewItem(p.FullName) { Tag = PoseType.Pose }; imageListPoses.Items.Add(item); } } } finally { imageListPoses.ResumeLayout(); } #endregion }
public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds) { Clip = false; Size itemPadding = new Size(4, 4); Rectangle imageBounds = bounds; string text = Path.GetFileNameWithoutExtension(item.Text); Size szt = TextRenderer.MeasureText(text, ImageListView.Font); int textWidth = szt.Width + (itemPadding.Width * 2); if ((state & ItemState.Hovered) != ItemState.None && textWidth > bounds.Width) { bounds = new Rectangle(bounds.X + (bounds.Width / 2) - (textWidth / 2), bounds.Y, textWidth, bounds.Height); } // Paint background if (ImageListView.Enabled) { using (Brush bItemBack = new SolidBrush(ImageListView.Colors.BackColor)) { g.FillRectangle(bItemBack, bounds); } } else { using (Brush bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor)) { g.FillRectangle(bItemBack, bounds); } } if ((state & ItemState.Disabled) != ItemState.None) // Paint background Disabled { using (Brush bDisabled = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.DisabledColor1, ImageListView.Colors.DisabledColor2, LinearGradientMode.Vertical)) { g.FillRectangle(bDisabled, bounds); } } else if ((ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) || (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None))) // Paint background Selected { using (Brush bSelected = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical)) { g.FillRectangle(bSelected, bounds); } } else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) // Paint background unfocused { using (Brush bGray64 = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.UnFocusedColor1, ImageListView.Colors.UnFocusedColor2, LinearGradientMode.Vertical)) { g.FillRectangle(bGray64, bounds); } } // Paint background Hovered if ((state & ItemState.Hovered) != ItemState.None) { using (Brush bHovered = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.HoverColor1, ImageListView.Colors.HoverColor2, LinearGradientMode.Vertical)) { g.FillRectangle(bHovered, bounds); } } // Draw the image Image img = item.GetCachedImage(CachedImageType.Thumbnail); if (img != null) { Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(imageBounds.Location + itemPadding, ImageListView.ThumbnailSize)); g.DrawImage(img, pos); } // Draw item text Color foreColor = ImageListView.Colors.ForeColor; if ((state & ItemState.Disabled) != ItemState.None) { foreColor = ImageListView.Colors.DisabledForeColor; } else if ((state & ItemState.Selected) != ItemState.None) { if (ImageListView.Focused) { foreColor = ImageListView.Colors.SelectedForeColor; } else { foreColor = ImageListView.Colors.UnFocusedForeColor; } } Rectangle rt = new Rectangle(bounds.Left, bounds.Top + (2 * itemPadding.Height) + ImageListView.ThumbnailSize.Height, bounds.Width, szt.Height); TextFormatFlags flags; if ((state & ItemState.Hovered) != ItemState.None) { flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.NoClipping; } else { flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis; } TextRenderer.DrawText(g, text, ImageListView.Font, rt, foreColor, flags); }
public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds) { Region oldClip = g.Clip; g.Clip = new Region(ClientBounds); // Paint background if ((state & ItemState.Selected) != ItemState.None) { if ((state & ItemState.Hovered) != ItemState.None) { using (Brush bSelected = new SolidBrush(hoveredSelectedColor)) { g.FillRectangle(bSelected, bounds); } using (Pen pSelected = new Pen(hoveredSelectedBorderColor)) { g.DrawRectangle(pSelected, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); } } else if (!ImageListView.Focused) { using (Brush bSelected = new SolidBrush(unfocusedSelectedColor)) { g.FillRectangle(bSelected, bounds); } } else { using (Brush bSelected = new SolidBrush(focusedSelectedColor)) { g.FillRectangle(bSelected, bounds); } } } else if ((state & ItemState.Hovered) != ItemState.None) { using (Brush bHovered = new SolidBrush(hoveredColor)) { g.FillRectangle(bHovered, bounds); } } // Draw the image Image img = item.GetCachedImage(CachedImageType.Thumbnail); if (img != null) { Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(bounds.Location + itemPadding, ImageListView.ThumbnailSize)); g.DrawImage(img, pos); } // Draw item text Color foreColor = ImageListView.Colors.ForeColor; if ((state & ItemState.Disabled) != ItemState.None) { foreColor = ImageListView.Colors.DisabledForeColor; } else if ((state & ItemState.Selected) != ItemState.None) { if (ImageListView.Focused) { foreColor = ImageListView.Colors.SelectedForeColor; } else { foreColor = ImageListView.Colors.UnFocusedForeColor; } } Size szt = System.Windows.Forms.TextRenderer.MeasureText(item.Text, ImageListView.Font); Rectangle rt = new Rectangle(bounds.Left + itemPadding.Width, bounds.Top + 2 * itemPadding.Height + ImageListView.ThumbnailSize.Height - 5, ImageListView.ThumbnailSize.Width, szt.Height); System.Windows.Forms.TextRenderer.DrawText(g, item.Text, ImageListView.Font, rt, foreColor, System.Windows.Forms.TextFormatFlags.EndEllipsis | System.Windows.Forms.TextFormatFlags.HorizontalCenter | System.Windows.Forms.TextFormatFlags.VerticalCenter | System.Windows.Forms.TextFormatFlags.SingleLine); g.Clip = oldClip; }
public ImageListView.GroupInfo GetGroupInfo(ImageListViewItem item) { var text = item.SubItems["Type"].Text; return(new ImageListView.GroupInfo(text, TypeDict[text])); }
public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds) { Clip = (ImageListView.View == View.Details); if (ImageListView.View == View.Details) { base.DrawItem(g, item, state, bounds); } else { Rectangle _controlBounds = ClientBounds; // Get item image Image _img = null; if ((state & ItemState.Hovered) != ItemState.None) { _img = GetImageAsync(item, new Size(bounds.Width - 8, bounds.Height - 8)); } if (_img == null) { _img = item.GetCachedImage(CachedImageType.Thumbnail); } if (_img != null) { // Calculate image bounds Rectangle _pos = Utility.GetSizedImageBounds(_img, Rectangle.Inflate(bounds, -4, -4)); int _imageWidth = _pos.Width; int _imageHeight = _pos.Height; int _imageX = _pos.X; int _imageY = _pos.Y; // Paint background if (ImageListView.Enabled) { using (Brush _bItemBack = new SolidBrush(ImageListView.Colors.BackColor)) { g.FillRectangle(_bItemBack, bounds); } } else { using (Brush _bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor)) { g.FillRectangle(_bItemBack, bounds); } } if ((ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) || (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None))) { using ( Brush _bSelected = new LinearGradientBrush(bounds, ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical)) { Utility.FillRoundedRectangle(g, _bSelected, bounds, 5); } } else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) { using ( Brush _bGray64 = new LinearGradientBrush(bounds, ImageListView.Colors.UnFocusedColor1, ImageListView.Colors.UnFocusedColor2, LinearGradientMode.Vertical)) { Utility.FillRoundedRectangle(g, _bGray64, bounds, 5); } } if (((state & ItemState.Hovered) != ItemState.None)) { using ( Brush _bHovered = new LinearGradientBrush(bounds, ImageListView.Colors.HoverColor1, ImageListView.Colors.HoverColor2, LinearGradientMode.Vertical)) { Utility.FillRoundedRectangle(g, _bHovered, bounds, 5); } } // Draw the image g.DrawImage(_img, _imageX, _imageY, _imageWidth, _imageHeight); // Draw image border if (Math.Min(_imageWidth, _imageHeight) > 32) { using (Pen _pOuterBorder = new Pen(ImageListView.Colors.ImageOuterBorderColor)) { g.DrawRectangle(_pOuterBorder, _imageX, _imageY, _imageWidth, _imageHeight); } if (Math.Min(_imageWidth, _imageHeight) > 32) { using (Pen _pInnerBorder = new Pen(ImageListView.Colors.ImageInnerBorderColor)) { g.DrawRectangle(_pInnerBorder, _imageX + 1, _imageY + 1, _imageWidth - 2, _imageHeight - 2); } } } } else { // Paint background if (ImageListView.Enabled) { using (Brush _bItemBack = new SolidBrush(ImageListView.Colors.BackColor)) { g.FillRectangle(_bItemBack, bounds); } } else { using (Brush _bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor)) { g.FillRectangle(_bItemBack, bounds); } } } // Item border using (Pen _pWhite128 = new Pen(Color.FromArgb(128, ImageListView.Colors.ControlBackColor))) { Utility.DrawRoundedRectangle(g, _pWhite128, bounds.Left + 1, bounds.Top + 1, bounds.Width - 3, bounds.Height - 3, 4); } if (ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) { using (Pen _pHighlight128 = new Pen(ImageListView.Colors.SelectedBorderColor)) { Utility.DrawRoundedRectangle(g, _pHighlight128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4); } } else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) { using (Pen _pGray128 = new Pen(ImageListView.Colors.UnFocusedBorderColor)) { Utility.DrawRoundedRectangle(g, _pGray128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4); } } else if ((state & ItemState.Selected) == ItemState.None) { using (Pen _pGray64 = new Pen(ImageListView.Colors.BorderColor)) { Utility.DrawRoundedRectangle(g, _pGray64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4); } } if (ImageListView.Focused && ((state & ItemState.Hovered) != ItemState.None)) { using (Pen _pHighlight64 = new Pen(ImageListView.Colors.HoverBorderColor)) { Utility.DrawRoundedRectangle(g, _pHighlight64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4); } } if (item.Tag != null) { if (item.Tag is ImageViewItemTAG) { string _type = (item.Tag as ImageViewItemTAG).Type; if (_type == "Medium" || _type == "Loading") { g.FillRectangle(Brushes.OrangeRed, bounds.Left + 2, bounds.Top + 2, 1, 1); } } if (item.Tag is EditModePhotoType) { EditModePhotoType _type = (EditModePhotoType)item.Tag; if (_type == EditModePhotoType.NewAdd) { g.DrawString("+", new Font("Tahoma", 9, FontStyle.Bold), Brushes.Red, bounds.Left + 1, bounds.Top + 1); } } } } }
public void InitializeListView() { #region Backgrounds imageListBackgrounds.AllowDuplicateFileNames = true; imageListBackgrounds.SetRenderer(new ImageListViewRenderers.DefaultRenderer()); imageListBackgrounds.Columns.Add(ColumnType.Name); imageListBackgrounds.Columns.Add(ColumnType.FileSize); imageListBackgrounds.ThumbnailSize = new Size(96, 96); imageListBackgrounds.Items.Clear(); imageListBackgrounds.SuspendLayout(); try { var directoryPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Libraries", "Backgrounds"); var di = new DirectoryInfo(directoryPath); if (!di.Exists) { return; } foreach (var p in di.GetFiles("*.jpg")) { imageListBackgrounds.Items.Add(p.FullName); } } finally { imageListBackgrounds.ResumeLayout(); } #endregion #region Poses currentPose = string.Empty; imageListPoses.AllowDuplicateFileNames = true; imageListPoses.SetRenderer(new ImageListViewRenderers.DefaultRenderer()); imageListPoses.Columns.Add(ColumnType.Name); imageListPoses.Columns.Add(ColumnType.FileSize); imageListPoses.ThumbnailSize = new Size(96, 96); imageListPoses.Items.Clear(); imageListPoses.SuspendLayout(); try { var exts = new List <string> { ".jpg", ".png" }; var directoryPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Libraries", "Poses", ProgramCore.Project.ManType.GetCaption()); var di = new DirectoryInfo(directoryPath); if (di.Exists) { foreach (var p in GetFilesByExtensions(di, exts)) { var item = new ImageListViewItem(p.FullName) { Tag = PoseType.Pose }; imageListPoses.Items.Add(item); } } } finally { imageListPoses.ResumeLayout(); } #endregion }
/// <summary> /// Initializes a new instance of the ItemCollectionChangedEventArgs class. /// </summary> /// <param name="action">The type of action causing the change.</param> /// <param name="item">The item that is the target of this event. This parameter will be null /// if the collection is cleared.</param> public ItemCollectionChangedEventArgs(CollectionChangeAction action, ImageListViewItem item) { Action = action; Item = item; }
/// <summary> /// Initializes a new instance of the ThumbnailCachingEventArgs class. /// </summary> /// <param name="item">The item that is the target of this event.</param> /// <param name="size">The size of the thumbnail request.</param> public ThumbnailCachingEventArgs(ImageListViewItem item, Size size) { Item = item; Size = size; }
/// <summary> /// Initializes a new instance of the ItemEventArgs class. /// </summary> /// <param name="item">The item that is the target of this event.</param> public ItemEventArgs(ImageListViewItem item) { Item = item; }
/// <summary> /// Initializes a new instance of the CacheErrorEventArgs class. /// </summary> /// <param name="item">The ImageListViewItem that is associated with this error.</param> /// <param name="error">The error that occurred during an asynchronous operation.</param> /// <param name="cacheThread">The thread raising the error.</param> public CacheErrorEventArgs(ImageListViewItem item, Exception error, CacheThread cacheThread) { Item = item; Error = error; CacheThread = cacheThread; }