예제 #1
0
        void ButtonClicked(object sender, EventArgs e)
        {
            CheckProject();

            var dialog = new ProjectFileSelectorDialog(Project, null, DefaultFilter);

            try {
                if (DialogTitle != null)
                {
                    dialog.Title = DialogTitle;
                }
                int response = MessageService.RunCustomDialog(dialog);
                if (response == (int)Gtk.ResponseType.Ok && dialog.SelectedFile != null)
                {
                    entry.Text = dialog.SelectedFile.ProjectVirtualPath;
                }
            } finally {
                dialog.Destroy();
            }
        }
        protected override void OnClicked()
        {
            base.OnClicked();
            if (project == null)
            {
                return;
            }

            var formats = string.Join("|", SupportedFormats.Select(f => "*." + f));
            var dialog  = new ProjectFileSelectorDialog(project, "All Images", formats);

            try
            {
                if (AcceptedSize.IsEmpty)
                {
                    dialog.Title = GettextCatalog.GetString("Select image...");
                }
                else
                {
                    dialog.Title = GettextCatalog.GetString("Select image ({0}x{1})...", RecommendedSize.Width, RecommendedSize.Height);
                }
                while (MessageService.RunCustomDialog(dialog) == (int)Gtk.ResponseType.Ok && dialog.SelectedFile != null)
                {
                    var path = dialog.SelectedFile.FilePath;
                    if (!CheckImage(path))
                    {
                        continue;
                    }

                    SelectedProjectFile = dialog.SelectedFile.ProjectVirtualPath;
                    OnChanged(EventArgs.Empty);
                    break;
                }
            }
            finally
            {
                dialog.Destroy();
            }
        }