Ejemplo n.º 1
0
        public void AcceptImages()
        {
            var isSliced = false;

            if (buttonSprite != null)
            {
                var border = buttonSprite.border;
                isSliced = border.x > 0 || border.y > 0 || border.z > 0 || border.w > 0;
            }

            MainImage.sprite   = buttonSprite;
            ShadowImage.sprite = buttonSprite;

            if (isSliced)
            {
                ShadowTrs.sizeDelta = MainTrs.sizeDelta;
                SetAllDirty();
            }
            else
            {
                MainImage.SetNativeSize();
                ShadowImage.SetNativeSize();
            }

            ShadowImage.color = shadowColor;

            ShadowTrs.localPosition = new Vector2(MainTrs.localPosition.x, MainTrs.localPosition.y - PressingDown);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Создание меню создаваемых файлов
        /// </summary>
        /// <param name="col">Список для добавления</param>
        private void AddCreationMenuItems(ToolStripItemCollection col)
        {
            // Папка
            col.Add(ControlStrings.InspectorContextFolder, ShadowImage.CompiledFromImage(InspectorIcons.Folder, 16, 1), (sndr, args) => {
                Project.Dir d        = projectInspector.Tag as Project.Dir;
                CreateItemDialog dlg = new CreateItemDialog(ControlStrings.InspectorContextFolder);
                dlg.ExistingNames    = d.UsedNames;
                DialogResult dr      = dlg.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    localFileEvent = true;
                    NSDirectoryInspector.Entry en = new NSDirectoryInspector.Entry();
                    en.IsDirectory = true;
                    en.Name        = dlg.SpecifiedName;
                    en.Tag         = Project.CreateDir(dlg.SpecifiedName, d);
                    projectInspector.Entries.Add(en);
                    projectInspector.SelectedEntry = en;
                    localFileEvent = false;
                }
            });

            if (Editor.CreatableList.Length > 0)
            {
                col.Add(new ToolStripSeparator());
                foreach (Editor.FileCreator fc in Editor.CreatableList)
                {
                    col.Add(fc.Name, ShadowImage.CompiledFromImage(fc.Icon, 16, 1), (sndr, args) => {
                        Project.Dir cd       = projectInspector.Tag as Project.Dir;
                        Editor.FileCreator f = fc;
                        if (cd != null)
                        {
                            CreateItemDialog dlg = new CreateItemDialog(fc.Name);
                            dlg.Extension        = f.Extension;
                            dlg.ExistingNames    = cd.UsedNames;
                            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                localFileEvent   = true;
                                Project.Entry ce = Project.CreateEntry(dlg.SpecifiedName, cd);
                                NSDirectoryInspector.Entry en = new NSDirectoryInspector.Entry();
                                en.IsDirectory = false;
                                en.Name        = System.IO.Path.GetFileNameWithoutExtension(dlg.SpecifiedName);
                                en.Icon        = ce.Icon;
                                en.Tag         = (object)ce;
                                projectInspector.Entries.Add(en);
                                projectInspector.SelectedEntry = en;
                                localFileEvent = false;
                            }
                        }
                    });
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Создание меню создаваемых файлов
 /// </summary>
 /// <param name="col">Список для добавления</param>
 private void AddCreationMenuItems(ToolStripItemCollection col)
 {
     // Папка
     col.Add(ControlStrings.InspectorContextFolder, ShadowImage.CompiledFromImage(InspectorIcons.Folder, 16, 1), (sndr, args) => {
     });
     if (Editor.CreatableList.Length > 0)
     {
         col.Add(new ToolStripSeparator());
         foreach (Editor.FileCreator fc in Editor.CreatableList)
         {
             col.Add(fc.Name, ShadowImage.CompiledFromImage(fc.Icon, 16, 1), (sndr, args) => {
             });
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Отрисовка формы
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.Clear(Color.FromArgb(50, 50, 50));

            if (hasError)
            {
                if (icon == null)
                {
                    icon = new ShadowImage(ControlImages.dialogerror);
                }
                icon.Draw(g, new Rectangle(12, 72, 24, 24), 1);
                g.DrawString(errorText, Font, Brushes.Black, 43, 78);
                g.DrawString(errorText, Font, Brushes.White, 42, 77);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Конструктор диалога
        /// </summary>
        MessageDialog(string caption, string text, string[] buttons, DialogResult[] results, ShadowImage icon)
        {
            InitializeComponent();
            Font = new Font("Tahoma", 10f);

            Text          = caption;
            boxIcon       = icon;
            buttonResults = results;
            labelText     = text;

            // Создаём графику
            Graphics g = Graphics.FromImage(new Bitmap(1, 1));

            textSize = g.MeasureString(text, Font, 300);
            Size nsz = ClientSize;

            nsz.Height   = 50 + (int)textSize.Height;
            textLocation = 30;
            if (nsz.Height < 120)
            {
                nsz.Height   = 120;
                textLocation = 60 - (int)(textSize.Height / 2f);
            }
            nsz.Height += buttonPanel.Height;
            ClientSize  = nsz;

            // Создаём кнопки
            int ps = ClientSize.Width - 8 - 100;

            for (int i = buttons.Length - 1; i >= 0; i--)
            {
                NSButton btn = new NSButton();
                btn.Text     = buttons[i];
                btn.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
                btn.Tag      = i;
                btn.Location = new Point(ps, 19);
                btn.Size     = new Size(100, 23);
                btn.Click   += ButtonClicked;
                buttonPanel.Controls.Add(btn);
                ps -= 108;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Вывод полностью собственного окна
        /// </summary>
        /// <param name="caption">Заголовок</param>
        /// <param name="text">Текст</param>
        /// <param name="buttons">Массив имён кнопок</param>
        /// <param name="results">Массив результатов кнопок</param>
        /// <param name="icon">Иконка</param>
        /// <returns>Состояние окна</returns>
        public static DialogResult ShowCustom(string caption, string text, string[] buttons, DialogResult[] results, ShadowImage icon)
        {
            MessageDialog d = new MessageDialog(caption, text, buttons, results, icon);

            return(d.ShowDialog());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Вывод окна с сообщением
        /// </summary>
        /// <param name="caption">Заголовок</param>
        /// <param name="text">Текст</param>
        /// <param name="buttonGroup">Тип кнопок</param>
        /// <param name="iconType">Тип иконки</param>
        /// <returns>Состояние окна</returns>
        public static DialogResult Show(string caption, string text, MessageBoxButtons buttonGroup = MessageBoxButtons.OK, MessageBoxIcon iconType = MessageBoxIcon.Information)
        {
            // Данные для вывода
            string[]       buttons;
            DialogResult[] results;
            ShadowImage    icon;

            // Выбор кнопок
            switch (buttonGroup)
            {
            case MessageBoxButtons.AbortRetryIgnore:
                buttons = new string[] {
                    ControlStrings.DialogAbortButton, ControlStrings.DialogRetryButton, ControlStrings.DialogIgnoreButton
                };
                results = new DialogResult[] {
                    DialogResult.Abort, DialogResult.Retry, DialogResult.Ignore
                };
                break;

            case MessageBoxButtons.OKCancel:
                buttons = new string[] {
                    ControlStrings.DialogOKButton, ControlStrings.DialogCancelButton
                };
                results = new DialogResult[] {
                    DialogResult.OK, DialogResult.Cancel
                };
                break;

            case MessageBoxButtons.RetryCancel:
                buttons = new string[] {
                    ControlStrings.DialogRetryButton, ControlStrings.DialogCancelButton
                };
                results = new DialogResult[] {
                    DialogResult.Retry, DialogResult.Cancel
                };
                break;

            case MessageBoxButtons.YesNo:
                buttons = new string[] {
                    ControlStrings.DialogYesButton, ControlStrings.DialogNoButton
                };
                results = new DialogResult[] {
                    DialogResult.Yes, DialogResult.No
                };
                break;

            case MessageBoxButtons.YesNoCancel:
                buttons = new string[] {
                    ControlStrings.DialogYesButton, ControlStrings.DialogNoButton, ControlStrings.DialogCancelButton
                };
                results = new DialogResult[] {
                    DialogResult.Yes, DialogResult.No, DialogResult.Cancel
                };
                break;

            default:
                buttons = new string[] {
                    ControlStrings.DialogOKButton
                };
                results = new DialogResult[] {
                    DialogResult.OK
                };
                break;
            }

            // Выбор иконки
            switch (iconType)
            {
            case MessageBoxIcon.Asterisk:
                icon = new ShadowImage(ControlImages.dialoginfo);
                System.Media.SystemSounds.Asterisk.Play();
                break;

            case MessageBoxIcon.Error:
                icon = new ShadowImage(ControlImages.dialogerror);
                System.Media.SystemSounds.Hand.Play();
                break;

            case MessageBoxIcon.Exclamation:
                icon = new ShadowImage(ControlImages.dialogwarning);
                System.Media.SystemSounds.Exclamation.Play();
                break;

            case MessageBoxIcon.Question:
                icon = new ShadowImage(ControlImages.dialogquestion);
                System.Media.SystemSounds.Question.Play();
                break;

            default:
                icon = new ShadowImage(ControlImages.dialogok);
                System.Media.SystemSounds.Asterisk.Play();
                break;
            }

            // Открываем диалог
            MessageDialog d = new MessageDialog(caption, text, buttons, results, icon);

            return(d.ShowDialog());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Клик по файлу в инспекторе
        /// </summary>
        private void projectInspector_MouseClick(object sender, MouseEventArgs e)
        {
            NSDirectoryInspector.Entry en = projectInspector.SelectedEntry;
            bool free = false;

            if (en != null)
            {
                free = Project.OperableFile(en.Tag);
            }
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                NSContextMenu cm = new NSContextMenu();
                if (en != null)
                {
                    // Открытие файла
                    cm.Items.Add(ControlStrings.InspectorContextOpen, ShadowImage.CompiledFromImage(InspectorIcons.MenuOpen, 16, 1), (sndr, args) => {
                        if (en != null)
                        {
                            if (en.IsDirectory)
                            {
                                Project.Dir dr = en.Tag as Project.Dir;
                                if (dr != null)
                                {
                                    PopulateManager(dr);
                                }
                            }
                            else
                            {
                                OpenEditor(en.Tag as Project.Entry);
                            }
                        }
                    });
                }

                // Создание файла
                ToolStripMenuItem crItem = new ToolStripMenuItem(ControlStrings.InspectorContextCreate, ShadowImage.CompiledFromImage(InspectorIcons.MenuAdd, 16, 1));
                crItem.DropDown = new NSContextMenu();
                AddCreationMenuItems(crItem.DropDown.Items);
                cm.Items.Add(crItem);

                // Разделитель
                cm.Items.Add(new ToolStripSeparator());

                if (en != null)
                {
                    // Смена имени
                    cm.Items.Add(new ToolStripMenuItem(ControlStrings.InspectorContextRename, ShadowImage.CompiledFromImage(InspectorIcons.MenuRename, 16, 1), (sndr, args) => {
                        string[] used;
                        string ext = "";
                        if (en.IsDirectory)
                        {
                            used = (en.Tag as Project.Dir).UsedNames;
                        }
                        else
                        {
                            used = (en.Tag as Project.Entry).Parent.UsedNames;
                            ext  = System.IO.Path.GetExtension((en.Tag as Project.Entry).Name);
                        }

                        RenameItemDialog rd = new RenameItemDialog(en.Name);
                        rd.SpecifiedName    = en.Name;
                        rd.Extension        = ext;
                        rd.ExistingNames    = used;
                        needProjectRescan   = false;
                        if (rd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (en.IsDirectory)
                            {
                                Project.RenameItem(en.Tag as Project.Dir, rd.SpecifiedName);
                            }
                            else
                            {
                                Project.RenameItem(en.Tag as Project.Entry, rd.SpecifiedName);
                            }
                        }
                    })
                    {
                        Enabled = free
                    });

                    // Копирование
                    cm.Items.Add(new ToolStripMenuItem(ControlStrings.InspectorContextCopy, ShadowImage.CompiledFromImage(InspectorIcons.MenuCopy, 16, 1), (sndr, args) => {
                        if (en != null)
                        {
                            copyingDir   = null;
                            copyingEntry = null;
                            if (en.IsDirectory)
                            {
                                copyingDir = en.Tag as Project.Dir;
                            }
                            else
                            {
                                copyingEntry = en.Tag as Project.Entry;
                            }
                        }
                    })
                    {
                        Enabled = free
                    });
                }

                // Вставка
                ToolStripMenuItem ps = new ToolStripMenuItem(ControlStrings.InspectorContextPaste, ShadowImage.CompiledFromImage(InspectorIcons.MenuPaste, 16, 1), (sndr, args) => {
                    Project.Dir bd    = (Project.Dir)projectInspector.Tag;
                    localFileEvent    = true;
                    needProjectRescan = false;
                    if (copyingDir != null)
                    {
                        Project.Dir cd = Project.CopyDir(copyingDir, bd);
                        NSDirectoryInspector.Entry fen = new NSDirectoryInspector.Entry();
                        fen.IsDirectory = true;
                        fen.Name        = cd.ShortName;
                        fen.Tag         = (object)cd;
                        projectInspector.Entries.Add(fen);
                        projectInspector.SelectedEntry = fen;
                    }
                    else if (copyingEntry != null)
                    {
                        Project.Entry ce = Project.CopyEntry(copyingEntry, bd);
                        NSDirectoryInspector.Entry fen = new NSDirectoryInspector.Entry();
                        fen.IsDirectory = false;
                        fen.Name        = System.IO.Path.GetFileNameWithoutExtension(ce.Name);
                        fen.Icon        = ce.Icon;
                        fen.Tag         = (object)ce;
                        projectInspector.Entries.Add(fen);
                        projectInspector.SelectedEntry = fen;
                    }
                    localFileEvent = false;
                });
                ps.Enabled = copyingDir != null || copyingEntry != null;
                cm.Items.Add(ps);

                if (en != null)
                {
                    // Удаление
                    cm.Items.Add(new ToolStripMenuItem(ControlStrings.InspectorContextDelete, ShadowImage.CompiledFromImage(InspectorIcons.MenuDelete, 16, 1), (sndr, args) => {
                        if (en != null)
                        {
                            RemoveEntry(en);
                        }
                    })
                    {
                        Enabled = free
                    });
                }

                cm.Show(inspectorPopupLocation);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Клик по файлу в инспекторе
        /// </summary>
        private void projectInspector_MouseClick(object sender, MouseEventArgs e)
        {
            NSDirectoryInspector.Entry en = projectInspector.SelectedEntry;
            bool free = false;

            if (en != null)
            {
                free = Project.LegalFile(en.Tag);
            }
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                NSContextMenu cm = new NSContextMenu();
                if (en != null)
                {
                    // Открытие файла
                    cm.Items.Add(ControlStrings.InspectorContextOpen, ShadowImage.CompiledFromImage(InspectorIcons.MenuOpen, 16, 1), (sndr, args) => {
                        if (en != null)
                        {
                            if (en.IsDirectory)
                            {
                                Project.Dir dr = en.Tag as Project.Dir;
                                if (dr != null)
                                {
                                    PopulateManager(dr);
                                }
                            }
                            else
                            {
                                OpenEditor(en.Tag as Project.Entry);
                            }
                        }
                    });
                }

                // Создание файла
                ToolStripMenuItem crItem = new ToolStripMenuItem(ControlStrings.InspectorContextCreate, ShadowImage.CompiledFromImage(InspectorIcons.MenuAdd, 16, 1));
                crItem.DropDown = new NSContextMenu();
                AddCreationMenuItems(crItem.DropDown.Items);
                cm.Items.Add(crItem);

                // Разделитель
                cm.Items.Add(new ToolStripSeparator());

                if (en != null)
                {
                    // Смена имени
                    cm.Items.Add(new ToolStripMenuItem(ControlStrings.InspectorContextRename, ShadowImage.CompiledFromImage(InspectorIcons.MenuRename, 16, 1), (sndr, args) => {
                    })
                    {
                        Enabled = free
                    });

                    // Копирование
                    cm.Items.Add(new ToolStripMenuItem(ControlStrings.InspectorContextCopy, ShadowImage.CompiledFromImage(InspectorIcons.MenuCopy, 16, 1), (sndr, args) => {
                        if (en != null)
                        {
                            copyingDir   = null;
                            copyingEntry = null;
                            if (en.IsDirectory)
                            {
                                copyingDir = en.Tag as Project.Dir;
                            }
                            else
                            {
                                copyingEntry = en.Tag as Project.Entry;
                            }
                        }
                    })
                    {
                        Enabled = free
                    });
                }

                // Вставка
                ToolStripMenuItem ps = new ToolStripMenuItem(ControlStrings.InspectorContextPaste, ShadowImage.CompiledFromImage(InspectorIcons.MenuPaste, 16, 1), (sndr, args) => {
                });
                ps.Enabled = copyingDir != null || copyingEntry != null;
                cm.Items.Add(ps);

                if (en != null)
                {
                    // Удаление
                    cm.Items.Add(new ToolStripMenuItem(ControlStrings.InspectorContextDelete, ShadowImage.CompiledFromImage(InspectorIcons.MenuDelete, 16, 1), (sndr, args) => {
                        if (en.IsDirectory)
                        {
                            if (Project.DeleteDir(en.Tag as Project.Dir))
                            {
                                projectInspector.SelectedEntry = null;
                                projectInspector.Entries.Remove(en);
                            }
                        }
                        else
                        {
                            if (Project.DeleteEntry(en.Tag as Project.Entry))
                            {
                                projectInspector.SelectedEntry = null;
                                projectInspector.Entries.Remove(en);
                            }
                        }
                        projectRemove.Enabled = false;
                    })
                    {
                        Enabled = free
                    });
                }

                cm.Show(inspectorPopupLocation);
            }
        }