Beispiel #1
0
 static DataLogView()
 {
     question = new QuestionMessage();
     question.Buttons.Add(Command.No);
     question.Buttons.Add(Command.Yes);
     question.Buttons.Add(Command.Cancel);
 }
Beispiel #2
0
 //设置问题排列
 private void BuildRadom(QuestionMessage question)
 {
     DataModel.QID   = question.QuestionId;
     DataModel.Title = question.Title;
     m_arraryRandoms = StochasticWithoutRepetitionNum(3, 0);
     if (question.Answer.Count != 4)
     {
         Logger.Error(string.Format("question.Answer.Count ={0} "), question.Answer.Count);
         return;
     }
     for (var i = 0; i < m_arraryRandoms.Length; i++)
     {
         if (m_arraryRandoms[i] == 0)
         {
             DataModel.Option[i].Name = question.Answer[0];
             m_iCorrectId             = i;
         }
         else
         {
             DataModel.Option[i].Name = question.Answer[m_arraryRandoms[i]];
         }
     }
     for (var i = 0; i < DataModel.Option.Count; i++)
     {
         DataModel.Option[i].State    = 0;
         DataModel.Option[i].TipState = 0;
     }
 }
		public override void DeleteMultipleItems ()
		{
			QuestionMessage msg = new QuestionMessage ();
			msg.SecondaryText = GettextCatalog.GetString ("The Delete option permanently removes the file from your hard disk. Click Remove from Solution if you only want to remove it from your current solution.");
			AlertButton removeFromSolution = new AlertButton (GettextCatalog.GetString ("_Remove from Solution"), Gtk.Stock.Remove);
			msg.Buttons.Add (AlertButton.Delete);
			msg.Buttons.Add (AlertButton.Cancel);
			msg.Buttons.Add (removeFromSolution);
			msg.AllowApplyToAll = true;

			foreach (ITreeNavigator nav in CurrentNodes) {
				SolutionFolderFileNode file = (SolutionFolderFileNode) nav.DataItem;
				if (file.Parent.IsRoot)
					msg.Text = GettextCatalog.GetString ("Are you sure you want to remove the file {0} from the solution folder {1}?", file.FileName.FileName, file.Parent.Name);
				else
					msg.Text = GettextCatalog.GetString ("Are you sure you want to remove the file {0} from the solution {1}?", file.FileName.FileName, file.Parent.ParentSolution.Name);
				AlertButton result = MessageService.AskQuestion (msg);
				if (result == AlertButton.Cancel)
					return;
				
				file.Parent.Files.Remove (file.FileName);
				
				if (result == AlertButton.Delete) {
					FileService.DeleteFile (file.FileName);
				}
			}
		}
Beispiel #4
0
        internal static bool CheckUserSettings()
        {
            var hasRefactoringSettings = IdeApp.ProjectOperations.CurrentSelectedSolution == null ||
                                         IdeApp.ProjectOperations.CurrentSelectedSolution.UserProperties.HasValue(EnableRefactorings);

            if (!hasRefactoringSettings)
            {
                var useRefactoringsButton = new AlertButton(GettextCatalog.GetString("Use refactorings on this solution"));
                var text = GettextCatalog.GetString(
                    @"WARNING: The Xamarin Studio refactoring operations do not yet support C# 6.

You may continue to use refactoring operations with C# 6, however you should check the results carefully to make sure that they have not made incorrect changes to your code. In particular, the ""?."" null propagating dereference will be changed to ""."", a simple dereference, which can cause unexpected NullReferenceExceptions at runtime.");
                var message = new QuestionMessage(text);
                message.Buttons.Add(useRefactoringsButton);
                message.Buttons.Add(AlertButton.Cancel);
                message.Icon          = Gtk.Stock.DialogWarning;
                message.DefaultButton = 1;

                var result = MessageService.AskQuestion(message);
                if (result == AlertButton.Cancel)
                {
                    return(false);
                }
                ShowFixes = result == useRefactoringsButton;
            }
            return(ShowFixes);
        }
        private void loginCommandExecute()
        {
            AuthEngine eng = new AuthEngine();

            this.Ok = eng.Check(this.Username, this.Password);

            if (this.Ok == true)
            {
                var msg = new OpenNewViewMessage();
                msg.ViewName = "MainMenu";
                msg.Modal    = false;
                Messenger.Default.Send <OpenNewViewMessage>(msg);
            }
            else
            {
                var msg = new QuestionMessage
                              ("Errore!", "Login fallito! Vuoi ritentare?");
                msg.Yes = () => {
                    this.Ok       = null;
                    this.Password = string.Empty;
                };
                msg.No = () => {
                    Messenger.Default.Send <CloseApplicationMessage>(
                        CloseApplicationMessage.Empty);
                };

                Messenger.Default.Send <QuestionMessage>(msg);
            }
        }
Beispiel #6
0
                #pragma warning restore VSTHRD002 // Avoid problematic synchronous waits

        static MessageActionItem ShowMessageInternal(ShowMessageRequestParams message)
        {
            if (message.Actions == null || !message.Actions.Any())
            {
                ShowMessageInternal((ShowMessageParams)message);
                return(null);
            }

            var questionMessage = new QuestionMessage(message.Message);

            foreach (MessageActionItem action in message.Actions)
            {
                questionMessage.Buttons.Add(new AlertButton(action.Title));
            }

            questionMessage.Icon = GetIcon(message.MessageType);

            questionMessage.Buttons.Add(AlertButton.Cancel);
            questionMessage.DefaultButton = questionMessage.Buttons.Count - 1;

            AlertButton button = MessageService.AskQuestion(questionMessage);

            int index = questionMessage.Buttons.IndexOf(button);

            if (index < message.Actions.Length)
            {
                return(message.Actions [index]);
            }

            return(null);
        }
        private void ask(QuestionMessage obj)
        {
            ConfirmWindow wnd = new ConfirmWindow();

            wnd.Title = obj.Message;
            bool result = wnd.ShowDialog().GetValueOrDefault();

            obj.Parameter = wnd.sldValue.Value;

            if (result)
            {
                obj.Yes?.Invoke();
            }
            else
            {
                obj.No?.Invoke();
            }

            //MessageBoxResult result = MessageBox.Show(obj.Message, obj.Title,
            //    MessageBoxButton.YesNo, MessageBoxImage.Question);

            //if (result == MessageBoxResult.Yes)
            //{
            //    obj.Yes?.Invoke();
            //}
            //else
            //{
            //    obj.No?.Invoke();
            //}
        }
Beispiel #8
0
        public Task <Result> Execute(CommandMetadata metadata)
        {
            QuestionMessage message = new QuestionMessage("Are you sure you wish to delete personal data? This is a permanent action and cannot be undone.", async() => {
                ParentPlugin.GuildHandler.Plugins.DeleteUserData(metadata.AuthorID);
                await metadata.Message.Channel.SendMessageAsync("Stored data linked to your ID has succesfully been deleted. Keep in mind some plugins may require to keep track of your ID to function, so they may immidiately store your ID again.");
            }, async() => await metadata.Message.Channel.SendMessageAsync("Data deletion cancelled."));

            return(TaskResult(message, string.Empty));
        }
Beispiel #9
0
 public override void UpdateEvent()
 {
     if (chatMessage == null)
     {
         Character chatTarget = getTargetSelf(0);
         chatMessage = new QuestionMessage(chatTarget.identity.icon, message, respones);
         UIChatMenu.SendQuestionMessage(chatMessage);
     }
 }
Beispiel #10
0
        //回答题目 result=0:错误 1:正确
        public ErrorCodes AnswerQuestion(CharacterController character, bool result, QuestionMessage msg)
        {
            var hour = DateTime.Now.Hour;

            if (hour < AnswerQuestions.BeginTime || hour >= AnswerQuestions.EndTime)
            {
                return(ErrorCodes.Error_AnswerNotTime);
            }

            var qIndex = character.GetExData(436); //当前题目索引

            if (qIndex >= AnswerQuestions.MaxQuestionCount)
            {
                msg.QuestionId = -1;
                return(ErrorCodes.OK);
            }

            if (result)
            {
                character.AddExData(437, 1);
                //正确奖励
                var addExp =
                    (int)
                    (AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.ExpParam *
                     Table.GetLevelData(character.GetLevel()).DynamicExp);
                character.AddExData(66, addExp);
                character.mBag.AddItem(1, addExp, eCreateItemType.AnswerQuestion);
                var addMoney = (int)(AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.MoneyCount);
                character.AddExData(67, addMoney);
                character.mBag.AddItem(2, addMoney, eCreateItemType.AnswerQuestion);
            }
            else
            {
                //错误奖励
                var addExp =
                    (int)
                    (AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.ExpParam *
                     Table.GetLevelData(character.GetLevel()).DynamicExp *AnswerQuestions.ErrorResCount);
                character.AddExData(66, addExp);
                character.mBag.AddItem(1, addExp, eCreateItemType.AnswerQuestion);
                var addMoney =
                    (int)
                    (AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.MoneyCount * AnswerQuestions.ErrorResCount);
                character.AddExData(67, addMoney);
                character.mBag.AddItem(2, addMoney, eCreateItemType.AnswerQuestion);
            }
            qIndex = qIndex + 1;
            character.SetExData(436, qIndex); //当前题目索引+1
            var nextExdataId = qIndex - 1 + 459;
            var nextQ        = RandomQuestion(character, qIndex);

            //int nextQ = character.RandomQuestion(qIndex);
            character.SetExData(nextExdataId, nextQ);
            GetQuestionData(msg, nextQ);
            return(ErrorCodes.OK);
        }
		static bool ConfirmTrustCertificate (CertificateCheckResult checkResult)
		{
			QuestionMessage message = CreateConfirmMessage (checkResult);

			message.Buttons.Add (AlertButton.Yes);
			message.Buttons.Add (AlertButton.No);

			AlertButton result = MessageService.AskQuestion (message);
			return result == AlertButton.Yes;
		}
Beispiel #12
0
        async void OnOKClicked(object sender, EventArgs e)
        {
            var properties = Properties;

            ((Widget)this).Destroy();
            try {
                var changes = await this.rename(properties);

                ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor(Title, null);


                if (ChangedDocuments != null)
                {
                    AlertButton result = null;
                    var         msg    = new QuestionMessage();
                    msg.Buttons.Add(AlertButton.MakeWriteable);
                    msg.Buttons.Add(AlertButton.Cancel);
                    msg.AllowApplyToAll = true;

                    foreach (var path in ChangedDocuments)
                    {
                        try {
                            var attr = File.GetAttributes(path);
                            if (attr.HasFlag(FileAttributes.ReadOnly))
                            {
                                msg.Text          = GettextCatalog.GetString("File {0} is read-only", path);
                                msg.SecondaryText = GettextCatalog.GetString("Would you like to make the file writable?");
                                result            = MessageService.AskQuestion(msg);

                                if (result == AlertButton.Cancel)
                                {
                                    return;
                                }
                                else if (result == AlertButton.MakeWriteable)
                                {
                                    try {
                                        File.SetAttributes(path, attr & ~FileAttributes.ReadOnly);
                                    } catch (Exception ex) {
                                        MessageService.ShowError(ex.Message);
                                        return;
                                    }
                                }
                            }
                        } catch (Exception ex) {
                            MessageService.ShowError(ex.Message);
                            return;
                        }
                    }
                }
                RefactoringService.AcceptChanges(monitor, changes);
            } catch (Exception ex) {
                MessageService.ShowError(GettextCatalog.GetString("Error while renaming symbol {0}", this.symbol.Name), ex);
                LoggingService.LogError("Error while renaming symbol " + this.symbol.Name, ex);
            }
        }
Beispiel #13
0
        private void DeleteCommandExecute()
        {
            QuestionMessage msg = new QuestionMessage();

            msg.Title   = "Conferma!";
            msg.Message = $"Sei sicuro di voler eliminare:\r\n{this.SelectedPerson.FirstName} {this.SelectedPerson.LastName} ?";
            msg.Yes     = () => this.Items.Remove(this.SelectedPerson);
            msg.No      = null;

            Messenger.Default.Send(msg);
        }
Beispiel #14
0
    private void sendQuestionMessage(QuestionMessage chatMessage, Action <TopicQuestion> selectionCallback = null)
    {
        questionPanel.gameObject.SetActive(true);

        chatPanelCharacter.gameObject.SetActive(false);
        chatPanelTalker.gameObject.SetActive(false);
        chatPanelNoIcon.gameObject.SetActive(false);

        questionPanel.selectionCallback = selectionCallback;
        questionPanel.message           = chatMessage;
    }
Beispiel #15
0
        public static bool Question(string txt)
        {
            Program.Loggers.Log.Add(() => "user question: " + txt);

            if (QuestionMessage != null)
            {
                return(QuestionMessage.ShowMessage(txt));
            }

            return(false);
        }
Beispiel #16
0
 public void TryQuestionReponse(bool r)
 {
     if (activeBoard.id == 1)
     {
         QuestionMessage qm = (QuestionMessage)activeBoard;
         qm.Response(r);
     }
     else
     {
         activeBoard.Dismissed = true;
     }
 }
Beispiel #17
0
        private async void questionToTheUser(QuestionMessage obj)
        {
            var answer = await this.DisplayAlert(obj.Title, obj.Message, "Sì", "No");

            if (answer)
            {
                obj.Yes?.Invoke();
            }
            else
            {
                obj.No?.Invoke();
            }
        }
Beispiel #18
0
        private static void ProcessNewQuestionsInternal(Func <ApplicationDbContext, IQueryable <UserRepresentativeQuestion> > queryFunc)
        {
            try
            {
                using (var context = ApplicationDbContext.Create())
                {
                    var questions = queryFunc(context).Include(x => x.AnswerToken)
                                    .Include(x => x.Representative)
                                    .Include(x => x.Question.Law)
                                    .ToList();

                    using (var sender = new Mail.EmailSender())
                        foreach (var question in questions)
                        {
                            Mail.Message message = null;
                            if (question.Question.Law != null)
                            {
                                message = GenerateLawMessage(question);
                            }
                            else
                            {
                                message = GenerateDirectMessage(question);
                            }

                            // AnswerToken.Processed should be removed in near future
                            question.AnswerToken.Processed = true;

                            var questionMessage = new QuestionMessage
                            {
                                AnswerToken        = question.AnswerToken,
                                MessageCreatedTime = DateTime.UtcNow,
                                Recipients         = message.To,
                                Subject            = message.Subject
                            };
                            var sent = sender.SendMessage(message);
                            if (sent)
                            {
                                questionMessage.MessageSentTime = DateTime.UtcNow;
                            }

                            context.QuestionMessages.Add(questionMessage);

                            context.SaveChanges();
                        }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Failed to send comm emails = " + ex.ToString());
            }
        }
Beispiel #19
0
        private async void askToTheUser(QuestionMessage obj)
        {
            bool accept = await Application.Current.MainPage.DisplayAlert
                              (obj.Title, obj.Text, obj.Ok, obj.Cancel);

            if (accept)
            {
                obj.Yes?.Invoke();
            }
            else
            {
                obj.No?.Invoke();
            }
        }
Beispiel #20
0
        static bool ConfirmDelete(FilePath folder)
        {
            var question = new QuestionMessage {
                Text          = GettextCatalog.GetString("Are you sure you want to remove directory {0}?", folder),
                SecondaryText = GettextCatalog.GetString("The directory and any files it contains will be permanently removed from your hard disk.")
            };

            question.Buttons.Add(AlertButton.Delete);
            question.Buttons.Add(AlertButton.Cancel);

            AlertButton result = MessageService.AskQuestion(question);

            return(result == AlertButton.Delete);
        }
Beispiel #21
0
        public List <Document> CreateDocuments(Template template, Document parent)
        {
            var documents = new List <Document>();
            var fileNames = new List <string>();
            var question  = new QuestionMessage();

            question.Buttons.Add(Command.No);
            question.Buttons.Add(Command.Yes);
            question.Text = "New Document";
            if (template.IsFile.Value)
            {
                ofDialog.Title = "New " + template.Name;
                if (parent != null)
                {
                    ofDialog.Title += $" ({parent})";
                }
                if (ofDialog.Run(ParentWindow))
                {
                    var dr = Command.Save;
                    foreach (string fileName in ofDialog.FileNames)
                    {
                        string name = System.IO.Path.GetFileName(fileName);
                        var    drow = DocumentData.DBTable.LoadByCode(name, DocumentData.DBTable.ParseProperty(nameof(DocumentData.FileName)), DBLoadParam.Load);
                        if (drow != null)
                        {
                            if (dr == Command.Save)
                            {
                                question.SecondaryText = "Document whith number '" + name + "' exist\nCreate new?";
                                dr = MessageDialog.AskQuestion(ParentWindow, question);
                            }
                            if (dr == Command.Yes)
                            {
                                fileNames.Add(fileName);
                            }
                            else if (dr == Command.Cancel)
                            {
                                return(documents);
                            }
                        }
                        else
                        {
                            fileNames.Add(fileName);
                        }
                    }
                }
            }

            documents.Add(template.CreateDocument(parent, fileNames.ToArray()));
            return(documents);
        }
Beispiel #22
0
        private async void makeQuestion(QuestionMessage msg)
        {
            bool answer = await this.MainPage.DisplayAlert
                              (msg.Title, msg.Message, msg.Caption, msg.CancelCaption);

            if (answer)
            {
                msg.Yes?.Invoke();
            }
            else
            {
                msg.No?.Invoke();
            }
        }
Beispiel #23
0
        public List <Document> CreateDocuments(Template template, Document parent, List <Document> references)
        {
            var documents            = new List <Document>();
            var commandCreateSeveral = new Command("Several", $"Create {references.Count}");
            var commandCreateOne     = new Command("One", $"Create One");
            var command = commandCreateOne;

            if (references.Count > 1)
            {
                var question = new QuestionMessage("New Document", $"Create one {template} or several?");
                question.Buttons.Add(commandCreateOne);
                question.Buttons.Add(commandCreateSeveral);
                question.Buttons.Add(Command.Cancel);
                command = MessageDialog.AskQuestion(ParentWindow, question);
            }
            if (command == Command.Cancel)
            {
                return(documents);
            }
            else if (command == commandCreateSeveral)
            {
                foreach (var reference in references)
                {
                    var buffer = CreateDocuments(template, parent ?? reference);
                    if (parent != null)
                    {
                        foreach (var document in buffer)
                        {
                            document.CreateReference(reference, null);
                        }
                    }
                    documents.AddRange(buffer);
                }
            }
            else
            {
                documents = CreateDocuments(template, parent);
                foreach (var reference in references)
                {
                    foreach (var document in documents)
                    {
                        if (!document.ContainsReference(reference))
                        {
                            document.CreateReference(reference, null);
                        }
                    }
                }
            }
            return(documents);
        }
        private void askQuestion(QuestionMessage obj)
        {
            var result = MessageBox.Show(obj.Text, obj.Title,
                                         MessageBoxButton.YesNo,
                                         MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                obj.Yes?.Invoke();
            }
            else
            {
                obj.No?.Invoke();
            }
        }
Beispiel #25
0
    private void ApplyMessage(MessageType mt)
    {
        switch (mt.id)
        {
        case 0:
            activeBoard = GetBoard(mt.id);
            activeBoard.Apply(mt, speed);
            break;

        case 1:
            QuestionMessage qm = new QuestionMessage(GetBoard(mt.id));
            qm.Apply(mt, speed);
            activeBoard = qm;
            break;
        }
    }
        private void ClearArticlesCommandExecute()
        {
            QuestionMessage msg = new QuestionMessage();

            msg.Cancel = "No";
            msg.Ok     = "Sì";
            msg.Text   = "Sei sicuro?";
            msg.Title  = "Conferma!";
            //msg.Yes = cosaFareInCasoDiSì;
            msg.Yes = () =>
            {
                FakeRepository.Clear();
                this.Articles.Clear();
            };

            Messenger.Default.Send <QuestionMessage>(msg);
        }
Beispiel #27
0
 protected override void OnToolRefreshClick(object sender, EventArgs e)
 {
     if (Table.IsEdited)
     {
         var question = new QuestionMessage(Locale.Get("TableEditor", "Continue Rejecting?"), "Check");
         question.Buttons.Add(Command.No);
         question.Buttons.Add(Command.Yes);
         if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
         {
             Table.RejectChanges(GuiEnvironment.User);
         }
     }
     else if (Table.IsSynchronized)
     {
         Table.IsSynchronized = false;
     }
 }
Beispiel #28
0
        public override void DeleteMultipleItems()
        {
            var             modifiedSolutionsToSave = new HashSet <Solution> ();
            QuestionMessage msg = new QuestionMessage();

            msg.SecondaryText = GettextCatalog.GetString("The Delete option permanently removes the file from your hard disk. Click Remove from Solution if you only want to remove it from your current solution.");
            AlertButton removeFromSolution = new AlertButton(GettextCatalog.GetString("_Remove from Solution"), Gtk.Stock.Remove);

            msg.Buttons.Add(AlertButton.Delete);
            msg.Buttons.Add(AlertButton.Cancel);
            msg.Buttons.Add(removeFromSolution);
            msg.AllowApplyToAll = true;

            foreach (ITreeNavigator nav in CurrentNodes)
            {
                SolutionFolderFileNode file = (SolutionFolderFileNode)nav.DataItem;
                if (file.Parent.IsRoot)
                {
                    msg.Text = GettextCatalog.GetString("Are you sure you want to remove the file {0} from the solution folder {1}?", file.FileName.FileName, file.Parent.Name);
                }
                else
                {
                    msg.Text = GettextCatalog.GetString("Are you sure you want to remove the file {0} from the solution {1}?", file.FileName.FileName, file.Parent.ParentSolution.Name);
                }
                AlertButton result = MessageService.AskQuestion(msg);
                if (result == AlertButton.Cancel)
                {
                    return;
                }

                file.Parent.Files.Remove(file.FileName);

                if (result == AlertButton.Delete)
                {
                    FileService.DeleteFile(file.FileName);
                }

                if (file.Parent != null && file.Parent.ParentSolution != null)
                {
                    modifiedSolutionsToSave.Add(file.Parent.ParentSolution);
                }
            }

            IdeApp.ProjectOperations.SaveAsync(modifiedSolutionsToSave);
        }
Beispiel #29
0
        private void RemoveCommandExecute(int id)
        {
            QuestionMessage msg = new QuestionMessage();

            msg.Message = "Sei sicuro di voler eliminare?";
            msg.Yes     = () =>
            {
                var taxi = this.Items.FirstOrDefault(i => i.Id == id);

                if (taxi != null)
                {
                    this.Items.Remove(taxi);
                }
            };

            msg.No = null;

            Messenger.Default.Send <QuestionMessage>(msg);
        }
Beispiel #30
0
        public TableEditor() : base(new TableLayoutList())
        {
            toolInsert.Remove();
            //toolInsertLine = new ToolMenuItem(OnToolInsertLineClick) { Name = "Insert Line", Glyph = GlyphType.ChevronCircleRight };
            //toolAdd.DropDownItems.Add(toolInsertLine);

            toolReference = new ToolDropDown()
            {
                Name = "References", Visible = false, DisplayStyle = ToolItemDisplayStyle.Text, DropDown = new Menubar {
                    Name = "References"
                }
            };
            toolMerge = new ToolMenuItem(OnToolMergeClick)
            {
                Name = "Merge", Glyph = GlyphType.PaperPlane
            };
            toolReport = new ToolMenuItem(ToolReportClick)
            {
                Name = "Report", Glyph = GlyphType.FileExcelO
            };
            toolParam = new ToolDropDown(toolMerge, toolReport)
            {
                Name = "Parameters", Glyph = GlyphType.GearAlias
            };

            loader       = new TableLoader();
            toolProgress = new ToolTableLoader {
                Loader = loader
            };

            Bar.Items.Add(toolReference);
            Bar.Items.Add(toolParam);
            Bar.Items.Add(toolProgress);

            List.CellValueWrite += FieldsCellValueChanged;
            Name = "TableEditor";

            question = new QuestionMessage {
                Text = "Checkout"
            };
            question.Buttons.Add(Command.No);
            question.Buttons.Add(Command.Yes);
        }
Beispiel #31
0
 public bool Closing()
 {
     if (Document != null && (Document.UpdateState & DBUpdateState.Delete) != DBUpdateState.Delete && EditorState != DocumentEditorState.Readonly && Document.IsChanged)
     {
         var question = new QuestionMessage(Locale.Get(nameof(DocumentEditor), "On Close"), Locale.Get(nameof(DocumentEditor), "Save changes?"));
         question.Buttons.Add(Command.No);
         question.Buttons.Add(Command.Yes);
         question.Buttons.Add(Command.Cancel);
         var dr = MessageDialog.AskQuestion(ParentWindow, question);
         if (dr == Command.Cancel)
         {
             return(false);
         }
         else if (dr == Command.Yes)
         {
             Document.Save();
         }
     }
     return(true);
 }
        public override void DeleteMultipleItems()
        {
            var projects = new Set<SolutionEntityItem> ();
            var folders = new List<ProjectFolder> ();
            foreach (ITreeNavigator node in CurrentNodes)
                folders.Add ((ProjectFolder) node.DataItem);

            var removeButton = new AlertButton (GettextCatalog.GetString ("_Remove from Project"), Gtk.Stock.Remove);
            var question = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString (
                "The Delete option permanently removes the directory and any files it contains from your hard disk. " +
                "Click Remove from Project if you only want to remove it from your current solution.")
            };
            question.Buttons.Add (AlertButton.Cancel);
            question.Buttons.Add (AlertButton.Delete);
            question.Buttons.Add (removeButton);

            var deleteOnlyQuestion = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString ("The directory and any files it contains will be permanently removed from your hard disk. ")
            };
            deleteOnlyQuestion.Buttons.Add (AlertButton.Cancel);
            deleteOnlyQuestion.Buttons.Add (AlertButton.Delete);

            foreach (var folder in folders) {
                var project = folder.Project;

                AlertButton result;

                if (project == null) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result == AlertButton.Delete) {
                        DeleteFolder (folder);
                        continue;
                    } else
                        break;
                }

                var folderRelativePath = folder.Path.ToRelative (project.BaseDirectory);
                var files = project.Files.GetFilesInVirtualPath (folderRelativePath).ToList ();
                var folderPf = project.Files.GetFileWithVirtualPath (folderRelativePath);
                bool isProjectFolder = files.Count == 0 && folderPf == null;

                //if the parent directory has already been removed, there may be nothing to do
                if (isProjectFolder) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result != AlertButton.Delete)
                        break;
                }
                else {
                    question.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0} from project {1}?",
                        folder.Name, project.Name);
                    result = MessageService.AskQuestion (question);
                    if (result != removeButton && result != AlertButton.Delete)
                        break;

                    projects.Add (project);

                    //remove the files and link files in the directory
                    foreach (var f in files)
                        project.Files.Remove (f);

                    // also remove the folder's own ProjectFile, if it exists
                    // FIXME: it probably was already in the files list
                    if (folderPf != null)
                        project.Files.Remove (folderPf);
                }

                if (result == AlertButton.Delete) {
                    DeleteFolder (folder);
                } else {
                    //explictly remove the node from the tree, since it currently only tracks real folder deletions
                    folder.Remove ();
                }

                if (isProjectFolder && folder.Path.ParentDirectory != project.BaseDirectory) {
                    // If it's the last item in the parent folder, make sure we keep a reference to the parent
                    // folder, so it is not deleted from the tree.
                    var inParentFolder = project.Files.GetFilesInVirtualPath (folderRelativePath.ParentDirectory);
                    if (!inParentFolder.Skip (1).Any ()) {
                        project.Files.Add (new ProjectFile (folder.Path.ParentDirectory) {
                            Subtype = Subtype.Directory,
                        });
                    }
                }
            }
            IdeApp.ProjectOperations.Save (projects);
        }