public CofileType GetSelectedType() { CofileType type = CofileType.undefined; JToken jtok = GetSelectedConfigFile(); if (jtok != null) { try { type = (CofileType)Enum.Parse(typeof(CofileType), jtok["type"].ToString(), true); } catch (Exception e) { string message = "Check the Config type" + Environment.NewLine + e.Message; Log.PrintError(message, "UserControls.Cofile.SelectedType"); WindowMain.current.ShowMessageDialog("Config Error", message); } } return(type); }
public void ConfirmEncDec(IEnumerable <Object> selected_list, bool isEncrypt) { string title = "", message = ""; MessageDialogStyle dialog_style = MessageDialogStyle.AffirmativeAndNegative; WindowMain.CallBack affirmative_callback = delegate { //TextRange txt = new TextRange(Status.current.richTextBox_status.Document.ContentStart, Status.current.richTextBox_status.Document.ContentEnd); //txt.Text = ""; SSHController.SendNRecvCofileCommand(selected_list, isEncrypt, true); //LinuxTreeViewItem.Refresh(); }; WindowMain.CallBack negative_callback = null; MetroDialogSettings settings = null; message += GetFileListString(selected_list); message += "\n"; CofileType cofileType = this.GetSelectedType(); if (cofileType == CofileType.undefined) { return; } if (isEncrypt && cofileType == CofileType.tail && !CheckHaveDirectory(selected_list)) { SSHController.view_message_caption = "Encrypt"; title += Resources["String.MainDialog.Encrypt.Title"]; message += Resources["String.MainDialog.Encrypt.Message.Tail"]; dialog_style = MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary; negative_callback = delegate { SSHController.SendNRecvCofileCommand(selected_list, isEncrypt, false); }; settings = new MetroDialogSettings() { AffirmativeButtonText = "Yes" , NegativeButtonText = "No" , FirstAuxiliaryButtonText = "Cancel" //, ColorScheme = MetroDialogOptions.ColorScheme }; } else if (isEncrypt) { SSHController.view_message_caption = "Encrypt"; title += Resources["String.MainDialog.Encrypt.Title"]; message += Resources["String.MainDialog.Encrypt.Message"]; } else { SSHController.view_message_caption = "Decrypt"; title += Resources["String.MainDialog.Decrypt.Title"]; message += Resources["String.MainDialog.Decrypt.Message"]; } message += "\n [ Type = " + cofileType.ToString().ToUpper() + " ]"; WindowMain.current.ShowMessageDialog(title, message, dialog_style, affirmative_callback, negative_callback, settings: settings); }