Exemplo n.º 1
0
        /// <summary>
        /// Добавление нового энтри в проект
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void projectAdd_Click(object sender, EventArgs e)
        {
            NSContextMenu cm = new NSContextMenu();

            AddCreationMenuItems(cm.Items);
            cm.Show(projectAdd, new Point(0, projectAdd.Height));
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
            }
        }