public NewItemDialog(IEnumerator <ContentItemTemplate> enums, string dir) { InitializeComponent(); _errInvalidName = "The following characters are not allowed:"; for (int i = 0; i < Global.NotAllowedCharacters.Length; i++) { _errInvalidName += " " + Global.NotAllowedCharacters[i]; } _dir = dir; while (enums.MoveNext()) { var ret = new ImageListItem { Text = enums.Current.Label + " (" + Path.GetExtension(enums.Current.TemplateFile) + ")", Tag = enums.Current }; list1.Items.Add(ret); } if (list1.Items.Count > 0) { list1.SelectedIndex = 0; } textBox1.Text = "File"; }
public new void Hide() { ClickedId = -1; SelectedItem = new ImageListItem(); Visible = false; ResetScrollPosition(); }
public FolderDetail GetFolderById(int id) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Folders .Single(e => e.FolderID == id); List <ImageListItem> imageListItems = new List <ImageListItem>(); foreach (var image in entity.ImagesInFolder) { var meme = new ImageListItem() { ImageID = image.ImageID, Title = image.Image.Title, ImagePath = image.Image.ImagePath, ImageFile = image.Image.ImageFile, TopText = image.Image.TopText, BottomText = image.Image.BottomText }; imageListItems.Add(meme); } var image1 = new FolderDetail { FolderID = entity.FolderID, Name = entity.Name, ImagesInFolder = imageListItems, }; return(image1); } }
private int AddItem(string key, ImageListItem item) { int itemIndex; int index; if (this.handleCreated) { itemIndex = AddItemInternal(item); } else { // Image strips are counted as a single item in the return // value of Add and AddStrip until handle is created. itemIndex = list.Add(item); this.count += item.ImageCount; } if ((item.Flags & ItemFlags.ImageStrip) == 0) { keys.Add(key); } else { for (index = 0; index < item.ImageCount; index++) { keys.Add(null); } } return(itemIndex); }
public NewItemDialog(IEnumerator <ContentItemTemplate> enums, string dir) { InitializeComponent(); _errInvalidName = "The following characters are not allowed:"; for (int i = 0; i < Global.NotAllowedCharacters.Length; i++) { _errInvalidName += " " + Global.NotAllowedCharacters[i]; } _dir = dir; while (enums.MoveNext()) { var ret = new ImageListItem(); ret.Text = enums.Current.Label; ret.Tag = enums.Current; try { ret.Image = new Bitmap(new Bitmap(Path.Combine(Path.GetDirectoryName(enums.Current.TemplateFile), enums.Current.Icon)), 16, 16); } catch { } list1.Items.Add(ret); } if (list1.Items.Count > 0) { list1.SelectedIndex = 0; } textBox1.Text = "File"; }
private IEnumerator UpdateListCoroutine(FileInfo[] files) { StashItems(); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; //try getting an item from the pool first ImageListItem imageListItem = _imageListItemsPool.Get(); if (imageListItem == null) { imageListItem = Instantiate(_imageListItemPrefab, _scrollViewContent); } else { //move to the end of the parent's hierarchy to make sure the order of files is followed imageListItem.transform.SetAsLastSibling(); } _currentImageListItems.Add(imageListItem); imageListItem.PreInitialize(file.Name, file.CreationTime.ToString()); StartCoroutine(LoadTextureCoroutine(file.FullName, imageListItem)); } yield return(null); }
public ImageListBoxEventArgs(int id, string name, int parentFormId, int parentScreenId, ImageListItem selectedItem) { this._id = id; this._name = name; this._parentFormId = parentFormId; this._parentScreenId = parentScreenId; this._selectedItem = selectedItem; }
protected override void Dispose(bool disposing) { foreach (object obj in Items) { ImageListItem imageItem = (ImageListItem)obj; imageItem.Dispose(); } base.Dispose(disposing); }
public ImageItem Adapt(ImageListItem item) { if (item == null || item.Image == null) { throw new ArgumentNullException("item", "ImageAdapter.Adapt(ImageListItem) failed. Item was null, or referenced a null image."); } return(new ImageItem { Image = item.Image }); }
void generateStatistics(IList <EntryObjectDTO> trainingEntries) { List <IGrouping <Tuple <SuplementDTO, string>, SuplementItemDTO> > supplementsGroup = trainingEntries.Cast <SuplementsEntryDTO>().SelectMany(x => x.Items).GroupBy(x => new Tuple <SuplementDTO, string>(x.Suplement, x.Name)).ToList(); Dictionary <string, SupplementStatisticItem> supplementsAmout = new Dictionary <string, SupplementStatisticItem>(); //foreach (SuplementsEntryDTO entry in trainingEntries) //{ // foreach (var item in entry.Items) // { // string key = item.Suplement.GlobalId.ToString() + item.DosageType; // if (!supplementsAmout.ContainsKey(key)) // { // var tmp = new SupplementStatisticItem(); // tmp.Supplement = item.Suplement; // tmp.DosageType = item.DosageType; // supplementsAmout.Add(key, tmp); // } // supplementsAmout[key].TotalAmount += item.Dosage; // } //} foreach (var entry in supplementsGroup) { foreach (var item in entry) { string name = item.Suplement.Name; if (!string.IsNullOrEmpty(entry.Key.Item2)) { name = entry.Key.Item2; } string key = name + item.DosageType; if (!supplementsAmout.ContainsKey(key)) { var tmp = new SupplementStatisticItem(); tmp.Supplement = name; tmp.DosageType = item.DosageType; supplementsAmout.Add(key, tmp); } supplementsAmout[key].TotalAmount += item.Dosage; } } Statistics.Clear(); foreach (var statisticItem in supplementsAmout) { ImageListItem <string> item = new ImageListItem <string>(string.Format("usrSupplementsCyclePreview_generateStatistics_Item".TranslateSupple(), statisticItem.Value.Supplement, statisticItem.Value.TotalAmount.ToString("0.##"), EnumLocalizer.Default.Translate(statisticItem.Value.DosageType)), null, null); Statistics.Add(item); } }
public void IsClicked(MouseState state, Vector2 cursorPos) { if (Visible) { HoverId = -1; if (!ImageScroll.IsClicked(state, cursorPos, Visible)) { if (ListBoxArea.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { for (int i = 0; i < Items.Count; i++) { Rectangle tmpRect = new Rectangle((int)CurrentPosition.X, (int)CurrentPosition.Y + (i * (16 * Scale)) + _offsetY, Width, (16 * Scale)); if (!Clicked && state.LeftButton == ButtonState.Pressed) { if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { Clicked = true; } } else if (Clicked && state.LeftButton == ButtonState.Released) { if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { ClickedId = i; SelectedItem = Items[i]; ImageListBoxEventArgs args = new ImageListBoxEventArgs(this.Id, this.Name, this.ParentForm.Id, this.ParentScreen.Id, Items[i]); OnClick(args); Clicked = false; } } if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { HoverId = i; } } } else { Clicked = false; } } } }
public void Move(int oldIndex, int newIndex) { if (ucImageListView != null) { if (newIndex < 0 || newIndex >= BindingSource.Count) { return; } ImageListItem item = ucImageListView.Items[oldIndex]; ucImageListView.Items.Move(item, newIndex); if (item != null && ucImageListView.IsItemVisible(item) == ItemVisibility.NotVisible) { ucImageListView.EnsureVisible(item.Index); } } }
private IEnumerator LoadTextureCoroutine(string path, ImageListItem imageListItem) { //start a request for loading the file using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(path)) { FileInfo fileInfo = new FileInfo(path); if (_fakeLoadingProgress) { request.SendWebRequest(); while (!request.isDone) { float progress = request.downloadedBytes / (float)fileInfo.Length; yield return(new WaitForSeconds(progress)); } } else { yield return(request.SendWebRequest()); } if (request.isNetworkError || request.isHttpError) { Warning.Show(request.error); Debug.LogError(request.error); } else { //get the texture, since the request was successful Texture2D texture = DownloadHandlerTexture.GetContent(request); try { imageListItem.SetImage(texture); } catch (Exception e) { Warning.Show(e.Message); Debug.LogError(e); } yield return(texture); } } }
public object this[int index] { get { var item = new ImageListItem { Text = "Item " + index }; if (UseVariableImages) { item.Image = index % 2 == 0 ? image1 : image2; } else { item.Image = image1; } return(item); } set { } }
public void AddItem(string value, Texture2D display, float displayRotation = 0f) { if (string.IsNullOrWhiteSpace(value) || display == null) { throw new ArgumentNullException(); } var container = new ImageListItem() { DisplayItem = display, Value = value, DisplayRotation = displayRotation }; if (MustHaveItemSelected && SelectedIndex == -1) { SelectedIndex = 0; } m_contentItems.Add(container); }
private int AddItemInternal(ImageListItem item) { if (Changed != null) Changed (this, EventArgs.Empty); if (item.Image is Icon) { int imageWidth; int imageHeight; Bitmap bitmap; Graphics graphics; bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb); graphics = Graphics.FromImage(bitmap); graphics.DrawIcon((Icon)item.Image, new Rectangle(0, 0, imageWidth, imageHeight)); graphics.Dispose(); ReduceColorDepth(bitmap); return list.Add(bitmap); } else if ((item.Flags & ItemFlags.ImageStrip) == 0) return list.Add(CreateImage((Image)item.Image, (item.Flags & ItemFlags.UseTransparentColor) == 0 ? this.transparentColor : item.TransparentColor)); else { int imageX; int width; int imageWidth; int imageHeight; int index; Image image; Bitmap bitmap; Graphics graphics; Rectangle imageRect; ImageAttributes imageAttributes; // When ImageSize was changed after adding image strips // Count will return invalid values based on old ImageSize // but when creating handle either ArgumentException will // be thrown or image strip will be added according to the // new ImageSize. This can result in image count // difference that can result in exceptions in methods // that use Count before creating handle. In addition this // can result in the loss of sync with keys. When doing // the same after handle was created there are no problems // as handle will be recreated after changing ImageSize // that results in the loss of images added previously. if ((width = (image = (Image)item.Image).Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0) throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value"); if (image.Height != (imageHeight = this.imageSize.Height)) throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value"); imageRect = new Rectangle(0, 0, imageWidth, imageHeight); if (this.transparentColor.A == 0) imageAttributes = null; else { imageAttributes = new ImageAttributes(); imageAttributes.SetColorKey(this.transparentColor, this.transparentColor); } index = list.Count; for (imageX = 0; imageX < width; imageX += imageWidth) { bitmap = new Bitmap(imageWidth, imageHeight, PixelFormat.Format32bppArgb); graphics = Graphics.FromImage(bitmap); graphics.DrawImage(image, imageRect, imageX, 0, imageWidth, imageHeight, GraphicsUnit.Pixel, imageAttributes); graphics.Dispose(); ReduceColorDepth(bitmap); list.Add(bitmap); } if (imageAttributes != null) imageAttributes.Dispose(); return index; } }
private int AddItem(string key, ImageListItem item) { int itemIndex; int index; if (this.handleCreated) itemIndex = AddItemInternal(item); else { // Image strips are counted as a single item in the return // value of Add and AddStrip until handle is created. itemIndex = list.Add(item); this.count += item.ImageCount; } if ((item.Flags & ItemFlags.ImageStrip) == 0) keys.Add(key); else for (index = 0; index < item.ImageCount; index++) keys.Add(null); return itemIndex; }
private int AddItemInternal(ImageListItem item) { if (Changed != null) { Changed(this, EventArgs.Empty); } if (item.Image is Icon) { int imageWidth; int imageHeight; Bitmap bitmap; Graphics graphics; bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb); graphics = Graphics.FromImage(bitmap); graphics.DrawIcon((Icon)item.Image, new Rectangle(0, 0, imageWidth, imageHeight)); graphics.Dispose(); ReduceColorDepth(bitmap); return(list.Add(bitmap)); } else if ((item.Flags & ItemFlags.ImageStrip) == 0) { return(list.Add(CreateImage((Image)item.Image, (item.Flags & ItemFlags.UseTransparentColor) == 0 ? this.transparentColor : item.TransparentColor))); } else { int imageX; int width; int imageWidth; int imageHeight; int index; Image image; Bitmap bitmap; Graphics graphics; Rectangle imageRect; ImageAttributes imageAttributes; // When ImageSize was changed after adding image strips // Count will return invalid values based on old ImageSize // but when creating handle either ArgumentException will // be thrown or image strip will be added according to the // new ImageSize. This can result in image count // difference that can result in exceptions in methods // that use Count before creating handle. In addition this // can result in the loss of sync with keys. When doing // the same after handle was created there are no problems // as handle will be recreated after changing ImageSize // that results in the loss of images added previously. if ((width = (image = (Image)item.Image).Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0) { throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value"); } if (image.Height != (imageHeight = this.imageSize.Height)) { throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value"); } imageRect = new Rectangle(0, 0, imageWidth, imageHeight); if (this.transparentColor.A == 0) { imageAttributes = null; } else { imageAttributes = new ImageAttributes(); imageAttributes.SetColorKey(this.transparentColor, this.transparentColor); } index = list.Count; for (imageX = 0; imageX < width; imageX += imageWidth) { bitmap = new Bitmap(imageWidth, imageHeight, PixelFormat.Format32bppArgb); graphics = Graphics.FromImage(bitmap); graphics.DrawImage(image, imageRect, imageX, 0, imageWidth, imageHeight, GraphicsUnit.Pixel, imageAttributes); graphics.Dispose(); ReduceColorDepth(bitmap); list.Add(bitmap); } if (imageAttributes != null) { imageAttributes.Dispose(); } return(index); } }
private int AddItem(string key, ImageListItem item)
/// <summary> /// Updates the intellisense box's elements to show the right object list. /// </summary> /// <param name="forceNextLevel"></param> /// <param name="word"></param> /// <param name="justRead"></param> /// <returns></returns> public bool UpdateIntellisense(bool forceNextLevel, string word, string justRead) { //Clear all elements m_CodeTextBox.IntellisenseBox.Items.Clear(); //Get the actual line if (word == "") { word = RichTextboxHelper.GetLastWord(m_CodeTextBox); } if (justRead == "\b") { if (!String.IsNullOrEmpty(word)) { word = word.Substring(0, word.Length - 1); } } else { word += justRead; } //Get subwords string[] words = word.Split( m_CodeTextBox.CodeWords_ScopeOperators.ToArray <string>(), StringSplitOptions.None); //if none, return... if (words.Length < 1) { //Hide intellisense... return(false); } string lastWord = words[words.Length - 1]; if (words.Length == 1 && !forceNextLevel) { #region Search in the root level foreach (TreeNode n in m_CodeTextBox.IntellisenseTree.Nodes) { if (!Like(n, lastWord)) { continue; } ImageListItem li = new ImageListItem(); li.Text = n.Name; li.Image = AssociateImage(n); m_CodeTextBox.IntellisenseBox.Items.Add(li); } //Not show, when no elements available... if (m_CodeTextBox.IntellisenseBox.Items.Count > 0) { m_CodeTextBox.IntellisenseBox.SelectedIndex = 0; return(true); } return(false); #endregion } int i = 1; TreeNode node = null; //Find the root node node = m_CodeTextBox.IntellisenseTree.Nodes[words[0]]; //Search the tree for the last node - before the one we actually type in while (node != null && i < words.Length - 1) { node = node.Nodes[words[i]]; i++; } //Couldn't find one of the sub words... if (node == null) { return(false); } if (forceNextLevel) { lastWord = ""; } //Add it's nodes to the intellisense list foreach (TreeNode n in node.Nodes) { if (!Like(n, lastWord)) { continue; } ImageListItem li = new ImageListItem(); li.Text = n.Name; li.Image = AssociateImage(n); m_CodeTextBox.IntellisenseBox.Items.Add(li); } //Show box ShowIntellisenseBoxWithoutUpdate(); return(true); }
public bool RemoveImageListItem(ImageListItem item) { _logger.LogTrace($"AppService.RemoveImageListItem({item}) invoked."); _logger.LogTrace($"AppService.RemoveImageListItem({item}) finished."); return(_imageList.Remove(item)); }
private void BindingSource_ListChanged(object sender, ListChangedEventArgs e) { switch (e.ListChangedType) { case ListChangedType.ItemMoved: if (ucImageListView != null) { ucImageListView.Items.Move(ucImageListView.Items[e.OldIndex], e.NewIndex); var item = ucImageListView.Items[e.NewIndex]; if (item != null && ucImageListView.IsItemVisible(item) == ItemVisibility.NotVisible) { ucImageListView.EnsureVisible(item.Index); } } break; case ListChangedType.Reset: // if (ucImageListView != null) ucImageListView.Items.Clear(); break; case ListChangedType.ItemAdded: if (ucImageListView != null) { var img = BindingSource[e.NewIndex] as ImageDocument; ImageListItem ImgItm = null; if (Path.IsPathRooted(img.Description) && File.Exists(img.Description)) { ImgItm = new ImageListItem(img.Description); } else { ImgItm = new ImageListItem(img); if (img.GUid != Guid.Empty) { ImgItm.FileName = img.GUid.ToString(); } else { ImgItm.FileName = Guid.NewGuid().ToString(); } } ImgItm.Tag = img; ImgItm.Text = img.OrderInDocument.ToString(); ImgItm.ZOrder = img.OrderInDocument; // var ii = BindingSource.IndexOf(img); if (ucImageListView.Items.Count == 0) //زمانی که اولین تصویر افزوده می شود مقدار طول و عرض از روی آن مشخص می شود { if (sbnPictureBox1.CurrentImage != null) { ucImageListView.ThumbnailSize = new Size((int)((sbnPictureBox1.CurrentImage.Width - 30) * sbnPictureBox1.Zoom), (int)(sbnPictureBox1.CurrentImage.Height * sbnPictureBox1.Zoom)); } else { if (img.Width > 100 && img.Height > 100) { ucImageListView.ThumbnailSize = new Size((int)((img.Width - 30) * sbnPictureBox1.Zoom), (int)(img.Height * sbnPictureBox1.Zoom)); } } } ucImageListView.Items.Insert(BindingSource.IndexOf(img), ImgItm); //.Add(ImgItm); } break; case ListChangedType.ItemDeleted: if (ucImageListView != null) { foreach (var item in ucImageListView.Items) { if (item.Tag is ImageDocument) { if (!BindingSource.Contains(item.Tag as ImageDocument)) { ucImageListView.Items.Remove(item); break; } } } } break; default: break; } }