Example #1
0
        private void AddImageButton_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //    if (_WorkingActorData == null)
            //   {
            //      MessageBox.Show("No Active Actor"); return;
            //    }

            if (GenericOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            string _ImageName = GenericOpenFileDialog.FileName.ToLower();

            if (_ImageName.EndsWith("png") || _ImageName.EndsWith("jpg"))
            {
                //     System.IO.File.Copy(_ImageName, _WorkingActorData.BaseDirectoryPath);
            }
            else
            {
                MessageBox.Show("Invalid File Selected (PNG,JPG)"); return;
            }

            //    _WorkingActorData.Images.Add(_ImageName.GetFileNameWithoutExtension(), _ImageName.GetFileNameFromFullPath());
            // REFRESH MAIN SCREEN
            //     MainImageList.Images.Add(Image.FromFile(_WorkingActorData.BaseDirectoryPath + _ImageName.GetFileNameFromFullPath()));
        }
Example #2
0
        /// <summary>
        /// Add File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ImagesTreeList.FocusedNode == null)
            {
                MessageBox.Show("Please Select A Group To Add the Image To.");
                return;
            }

            if (ImagesTreeList.FocusedNode.GetValue("ID").ToString() == "Root")
            {
                MessageBox.Show("You can only add images to groups not the parent container");
                return;
            }

            if (GenericOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            var _TmpReturn = InputBox.Show("Enter A Unique Image Name (This will be the Key)");

            if (_TmpReturn.ReturnCode == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            foreach (var f in GenericOpenFileDialog.FileNames)
            {
                try
                {
                    var _File = System.IO.File.ReadAllBytes(f);
                    int _TmpPosition;

                    try
                    {
                        System.Drawing.Image _IMG = System.Drawing.Image.FromStream(new System.IO.MemoryStream(_File));
                        MainImageList.Images.Add(_IMG);
                        _TmpPosition = MainImageList.Images.Count - 1;
                    }
                    catch
                    {
                        MessageBox.Show("Invalid Image");
                        return;
                    }

                    NG_Image _Image = new NG_Image();
                    _Image.ImageData = _File;
                    _Image.ImageName = f.GetFileNameWithoutExtension();
                    _Image.UID       = Guid.NewGuid();
                    _Image.Name      = _TmpReturn.Text;

                    Guid _GroupID;

                    if (ImagesTreeList.FocusedNode.GetValue("IsFolder").ToString() != "1")
                    {
                        _GroupID = new Guid(ImagesTreeList.FocusedNode.ParentNode.GetValue("ID").ToString());
                    }
                    else
                    {
                        if (ImagesTreeList.FocusedNode.GetValue("ID").ToString() != "Root")
                        {
                            _GroupID = new Guid(ImagesTreeList.FocusedNode.GetValue("ID").ToString());
                        }
                        else
                        {
                            return;
                        }
                    }

                    var _Group = _GroupCollection.GetGroupByID(_GroupID.ToString());

                    if (_Group == null)
                    {
                        MessageBox.Show("Odd Error Locating Group"); return;
                    }

                    _Image.ImageIndex = _TmpPosition;
                    _Group.Images.Add(_Image);

                    PopulateTreeView();
                }
                catch { }
            }
        }