Esempio n. 1
0
        public void Initialize()
        {
            AutoCloseCb.Checked = true;
            Text              = Root.Local.FormClipartsTitle;
            InsertBtn.Text    = Root.Local.ButtonInsertText;
            CancelBtn.Text    = Root.Local.ButtonCancelText;
            FromClpBtn.Text   = Root.Local.ButtonFromClipBText;
            LoadImageBtn.Text = Root.Local.ButtonLoadImageText;
            DelBtn.Text       = Root.Local.ButtonDeleteText;
            FillingCombo.Items.Clear();
            FillingCombo.Items.AddRange(Root.Local.ListFillingsText.Split(';'));
            FillingCombo.Text = (string)FillingCombo.Items[Root.ImageStampFilling + 1];

            ParamsToBeSavedCb.Checked = false;
            ParamsToBeSavedCb.Text    = Root.Local.PatternStoreParamTxt;

            AutoCloseCb.Text = Root.Local.CheckBoxAutoCloseText;
            ImageListViewer.Items.Clear();
            ImageListViewer.LargeImageList.Images.Clear();
            Originals.Clear();
            Animations.Clear();
            for (int i = 0; i < Root.StampFileNames.Count; i++)
            {
                try
                {
                    LoadImage(Root.StampFileNames[i]);
                }
                catch //(Exception ex)
                {
                    MessageBox.Show("Error Loading ClipArt image:\n" + Root.StampFileNames[i], "ppInk", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            ImageListViewer.LargeImageList.ImageSize = new Size(Root.StampSize, Root.StampSize);
            ImageListViewer.Select();
        }
Esempio n. 2
0
        private void LoadImageBtn_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = Global.ProgramFolder;
                openFileDialog.Filter           = "Images(*.png;*.bmp;*.jpg;*.jpeg;*.gif;*.ico)|*.png;*.bmp;*.jpg;*.jpeg;*.gif;*.ico|All files (*.*)|*.*";
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    String fn = openFileDialog.FileName;

                    ImageListViewer.Items.Add(new ListViewItem(Path.GetFileNameWithoutExtension(fn), fn));
                    Image img = Image.FromFile(fn);
                    ImageListViewer.LargeImageList.Images.Add(fn, img);
                    int j = ImageListViewer.LargeImageList.Images.IndexOfKey(fn);
                    Originals.Add(fn, (Image)(img.Clone()));
                    ImgSizes[j].X = img.Width;
                    ImgSizes[j].Y = img.Height;
                    ImageListViewer.Items[ImageListViewer.Items.Count - 1].EnsureVisible();
                    ImageListViewer.SelectedIndices.Clear();
                    ImageListViewer.SelectedIndices.Add(ImageListViewer.Items.Count - 1);
                    ImageListViewer.Select();
                }
            }
        }
Esempio n. 3
0
        private void FromClipB_Click(object sender, EventArgs e)
        {
            Bitmap img = null;

            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Dib))
            {
                var dib    = ((System.IO.MemoryStream)Clipboard.GetData(DataFormats.Dib)).ToArray();
                var width  = BitConverter.ToInt32(dib, 4);
                var height = BitConverter.ToInt32(dib, 8);
                var bpp    = BitConverter.ToInt16(dib, 14);
                if (bpp == 32)
                {
                    var gch = GCHandle.Alloc(dib, GCHandleType.Pinned);
                    try
                    {
                        var ptr = new IntPtr((long)gch.AddrOfPinnedObject() + 40);
                        img = new Bitmap(width, height, width * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, ptr);
                        img.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    }
                    catch
                    {
                        return;
                    }
                    gch.Free();
                }
                else
                {
                    img = (Bitmap)Clipboard.GetImage();
                }
            }
            else if (Clipboard.ContainsImage())
            {
                img = (Bitmap)Clipboard.GetImage();
            }
            else
            {
                return;
            }
            if (OpaqueCorner(img, 0, 0))
            {
                img.MakeTransparent(img.GetPixel(0, 0));
                Console.WriteLine("transp " + img.PixelFormat.ToString());
            }
            string st = "ClipBoard" + ((int)((DateTime.Now - DateTime.Today).TotalSeconds * 100)).ToString(); // ImageListViewer.Items.Count.ToString();

            ImageListViewer.Items.Add(new ListViewItem("Clipboard", st));
            ImageListViewer.LargeImageList.Images.Add(st, img);
            int j = ImageListViewer.LargeImageList.Images.IndexOfKey(st);

            Originals.Add(st, (Image)(img.Clone()));
            ImgSizes[j].X = img.Width;
            ImgSizes[j].Y = img.Height;
            ImageListViewer.Items[ImageListViewer.Items.Count - 1].EnsureVisible();
            ImageListViewer.SelectedIndices.Clear();
            ImageListViewer.SelectedIndices.Add(ImageListViewer.Items.Count - 1);
            ImageListViewer.Select();
        }
Esempio n. 4
0
        private void LoadImageBtn_Click(object sender, EventArgs e)
        {
            //using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = Global.ProgramFolder;
                openFileDialog.Filter           = "Images(*.png;*.bmp;*.jpg;*.jpeg;*.gif;*.ico;*.apng)|*.png;*.bmp;*.jpg;*.jpeg;*.gif;*.ico;*.apng|All files (*.*)|*.*";
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    LoadImage(openFileDialog.FileName);

                    ImageListViewer.Items[ImageListViewer.Items.Count - 1].EnsureVisible();
                    ImageListViewer.SelectedIndices.Clear();
                    ImageListViewer.SelectedIndices.Add(ImageListViewer.Items.Count - 1);
                    ImageListViewer.Select();
                }
            }
        }
Esempio n. 5
0
        public ImageLister(Root rt)
        {
            Root = rt;

            InitializeComponent();
            AutoCloseCb.Checked = true;
            Text              = Root.Local.FormClipartsTitle;
            InsertBtn.Text    = Root.Local.ButtonInsertText;
            CancelBtn.Text    = Root.Local.ButtonCancelText;
            FromClpBtn.Text   = Root.Local.ButtonFromClipBText;
            LoadImageBtn.Text = Root.Local.ButtonLoadImageText;
            DelBtn.Text       = Root.Local.ButtonDeleteText;
            FillingCombo.Items.Clear();
            FillingCombo.Items.AddRange(Root.Local.ListFillingsText.Split(';'));
            FillingCombo.Text = (string)FillingCombo.Items[Root.ImageStampFilling + 1];
            AutoCloseCb.Text  = Root.Local.CheckBoxAutoCloseText;
            for (int i = 0; i < Root.StampFileNames.Count; i++)
            {
                try
                {
                    ImageListViewer.Items.Add(new ListViewItem(Path.GetFileNameWithoutExtension(Root.StampFileNames[i]), Root.StampFileNames[i]));
                    Image img = Image.FromFile(Root.StampFileNames[i]);
                    img.Tag = img.Width * 10000 + img.Height;
                    ImageListViewer.LargeImageList.Images.Add(Root.StampFileNames[i], img);
                    int j = ImageListViewer.LargeImageList.Images.IndexOfKey(Root.StampFileNames[i]);
                    Originals.Add(Root.StampFileNames[i], (Image)(img.Clone()));
                    //ImgSize[ImageListViewer.LargeImageList.Images.IndexOfKey(Root.StampFileNames[i])] = new Point(img.Width,img.Height);
                    ImgSizes[j].X = img.Width;
                    ImgSizes[j].Y = img.Height;
                }
                catch
                {
                    MessageBox.Show("Error Loading ClipArt image:\n" + Root.StampFileNames[i], "ppInk", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            ImageListViewer.LargeImageList.ImageSize = new Size(Root.StampSize, Root.StampSize);
            ImageListViewer.Select();
        }