예제 #1
0
        private void ActionEditImageExecute(object sender, EventArgs e)
        {
            TRibbonImage  image;
            ImageEditForm dialog;

            if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0] != null)
            {
                image = (TRibbonImage)listView.SelectedItems[0].Tag;
            }
            else
            {
                return;
            }

            if (image == null)
            {
                return;
            }

            dialog = new ImageEditForm(image, _flags);
            try
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    SetImageItem(listView.SelectedItems[0], image);
                }
            }
            finally
            {
                dialog.Close();
            }
        }
예제 #2
0
        private void ActionAddImageExecute(object sender, EventArgs e)
        {
            TRibbonImage  image;
            ImageEditForm dialog;
            ListViewItem  item;

            if (string.IsNullOrEmpty(_command.Owner.Filename))
            {
                if (MessageBox.Show(RS_NEED_SAVE_MESSAGE, RS_NEED_SAVE_HEADER, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
                    == DialogResult.No)
                {
                    return;
                }

                MainForm.FormMain._actionSaveAs.PerformClick();
                if (string.IsNullOrEmpty(_command.Owner.Filename))
                {
                    return;
                }
            }

            if ((ImageFlags.Large & _flags) != 0)
            {
                if ((ImageFlags.HighContrast & _flags) != 0)
                {
                    image = _command.AddLargeHighContrastImage();
                }
                else
                {
                    image = _command.AddLargeImage();
                }
            }
            else if ((ImageFlags.HighContrast & _flags) != 0)
            {
                image = _command.AddSmallHighContrastImage();
            }
            else
            {
                image = _command.AddSmallImage();
            }

            dialog = new ImageEditForm(image, _flags);
            try
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    item = listView.Items.Add(new ListViewItem());
                    SetImageItem(item, image);
                    listView.Items[item.Index].Selected = true;
                    item.Focused = true;
                }
                else
                {
                    _command.RemoveImage(image);
                }
            }
            finally
            {
                dialog.Close();
            }
        }
예제 #3
0
        private void ActionAddImageExecute(object sender, EventArgs e)
        {
            TRibbonImage  image;
            ImageEditForm dialog;
            ListViewItem  item;

            if (string.IsNullOrEmpty(_command.Owner.Filename))
            {
                if (MessageBox.Show(RS_NEED_SAVE_MESSAGE, RS_NEED_SAVE_HEADER, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
                    == DialogResult.No)
                {
                    return;
                }

                MainForm.FormMain._actionSaveAs.PerformClick();
                if (string.IsNullOrEmpty(_command.Owner.Filename))
                {
                    return;
                }
            }

            if ((ImageFlags.Large & _flags) != 0)
            {
                if ((ImageFlags.HighContrast & _flags) != 0)
                {
                    image = _command.AddLargeHighContrastImage();
                }
                else
                {
                    image = _command.AddLargeImage();
                }
            }
            else if ((ImageFlags.HighContrast & _flags) != 0)
            {
                image = _command.AddSmallHighContrastImage();
            }
            else
            {
                image = _command.AddSmallImage();
            }

            if (image == null) //to many images defined (>= TRibbonCommand.MaxImages, 4)
            {
                return;
            }

            dialog = new ImageEditForm(image, _flags);
            try
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    _command.SortImages(_images);
                    int index = -1;
                    foreach (TRibbonImage image1 in _images)
                    {
                        index++;
                        if (image == image1)
                        {
                            break;
                        }
                    }
                    ShowImages(_command, _flags);
                    item          = listView.Items[index];
                    item.Selected = true;
                    item.Focused  = true;
                    item.EnsureVisible();
                    //item = listView.Items.Add(new ListViewItem());
                    //SetImageItem(item, image);
                    //listView.Items[item.Index].Selected = true;
                    //item.Focused = true;
                }
                else
                {
                    _command.RemoveImage(image);
                }
            }
            finally
            {
                dialog.Close();
            }
        }