Example #1
0
        public void Login()
        {
            // Login logic
            var credentials = new UserCredentials {
                Username = Username, Password = UserPassword
            };

            var resp = _unitRepository.AuthenticateUnit(credentials);

            if (resp == null)
            {
                return;
            }
            if (resp.IsValid)
            {
                IsLoginValid = true;
                LoggedInUnit = resp.Unit;
                TryClose();
            }
            else
            {
                var dialog = new MessageBoxViewModel(DialogType.Warning, DialogButton.Ok, "Login Failed", "Login Error: " + resp.InvalidReason);
                _windowManager.ShowDialog(dialog);
            }
        }
Example #2
0
        /// <summary>
        /// Replaces all matching items with the new text.
        /// </summary>
        public void ReplaceAll()
        {
            int replaceCount = MatchCount;

            if (replaceCount > 0)
            {
                int matchCount = replaceCount;
                while (matchCount > 1)
                {
                    Replace();
                    matchCount--;
                }

                var line   = Owner.CursorLine;
                var column = Owner.CursorColumn;
                Replace();


                if (MatchCount == 0)
                {
                    Owner.MoveCursorTo(line, column + SearchText.Text.Length, CodeEditorViewModel.MoveCursorFlags.None);
                }
                else
                {
                    replaceCount -= MatchCount;
                }
            }

            MessageBoxViewModel.ShowMessage(string.Format("Replaced {0} occurrances", replaceCount));

            Owner.IsFocusRequested = true;
        }
Example #3
0
        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = (Exception)e.ExceptionObject;
                Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                                                         "STF").Error("--- Unhandled exception ---");

                Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                                                         "STF").Error("Exception : " + ((ex.InnerException == null) ? ex.Message : ex.InnerException.ToString()));

                if (ex.TargetSite != null)
                {
                    Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                                                             "STF").Error("Exception Module : " + ex.TargetSite.Module.Name + " - Exception Method : " + ex.TargetSite.Name);
                }

                Views.MessageBox msgbox;
                ViewModels.MessageBoxViewModel mboxvmodel;
                msgbox     = new Views.MessageBox();
                mboxvmodel = new MessageBoxViewModel("Alert",
                                                     "StatTickerFive has encountered a problem. \nThe application will exit now, please contact your Administrator.",
                                                     msgbox, "Exception", Settings.GetInstance().Theme);
                msgbox.DataContext = mboxvmodel;
                msgbox.ShowDialog();
            }
            catch
            {
            }
        }
Example #4
0
        private void AutoMerge()
        {
            var confirm = new MessageBoxViewModel("vMerge: AutoMerge all changesets", "All changesets will be merged silently as long as no conflict arises. Are you really sure to proceed?", MessageBoxViewModel.MessageBoxButtons.None);
            var goOn    = new MessageBoxViewModel.MessageBoxButton("Merge silently");
            var cancel  = new MessageBoxViewModel.MessageBoxButton("Cancel");

            confirm.ConfirmButtons.Add(goOn);
            confirm.ConfirmButtons.Add(cancel);
            Repository.Instance.ViewManager.ShowModal(confirm);
            if (goOn.IsChecked)
            {
                Repository.Instance.BackgroundTaskManager.RunWithCancelDialog(
                    (progressParams) =>
                {
                    progressParams.TrackProgress.MaxProgress = ChangesetList.Where(item => item.CanBeMerged).Count();
                    foreach (var changeset in ChangesetList.Where(item => item.CanBeMerged).OrderBy(item => item.SourceCheckinId))
                    {
                        progressParams.TrackProgress.Increment();
                        progressParams.CancellationToken.ThrowIfCancellationRequested();

                        var copy = progressParams.CloneWithoutIncrements();
                        if (!PerformMerge(changeset, copy))
                        {
                            var cancelled = new MessageBoxViewModel("vMerge: AutoMerge all changesets", "AutoMerge has been cancelled. Please merge the remaining changesets manually.", MessageBoxViewModel.MessageBoxButtons.OK);
                            Repository.Instance.ViewManager.ShowModal(cancelled);
                        }
                    }
                }, "Merging changesets ...");

                LoadAllAssociatedChangesetsIncludingMerges(true);
            }
        }
Example #5
0
        void ProcessActivationTicket()
        {
            string activationTicket = string.Empty;

            if (HtmlPage.Document.QueryString.TryGetValue("activationTicket", out activationTicket))
            {
                SecurityContext.Current.ActivateUser(activationTicket, result =>
                {
                    if (!string.IsNullOrEmpty(result.Error))
                    {
                        MessageBoxViewModel message = new MessageBoxViewModel();
                        message.DisplayName         = AppStrings.ActivationUserWindowTitle;
                        message.Header       = AppStrings.FailedMessageHeader;
                        message.Message      = result.Error;
                        message.Buttons      = MessageBoxButtons.OK;
                        message.MessageLevel = MessageLevel.Exclamation;
                        Execute.OnUIThread(() => IoC.Get <IWindowManager>().ShowDialog(message));
                    }
                    else
                    {
                        var url = string.Format("http://{0}:{1}", Application.Current.Host.Source.Host, Application.Current.Host.Source.Port);
                        HtmlPage.Window.Navigate(new Uri(url));
                    }
                });
            }
        }
        public static WPFMessageBoxResult Show(string 息, string 詳細資訊, WPFMessageBoxButton 鍵樣式)
        {
            _MessageBox        = new WPFMessageBox();
            _MessageBox.Result = WPFMessageBoxResult.Close;
            if (詳細資訊 != "")
            {
                _MessageBox.Border.Height = 680;
                _MessageBox.Border.Width  = 540;
            }
            if (Local.MainForm != null)
            {
                Local.MainForm.Border_遮幕.Visibility = Visibility.Visible; //把主視窗變暗
            }
            MessageBoxViewModel ViewModel = new MessageBoxViewModel(_MessageBox, 息, 詳細資訊, 鍵樣式);

            _MessageBox.DataContext = ViewModel;
            try
            {
                _MessageBox.Owner = Local.MainForm;   //視窗綁在主視窗前
                _MessageBox.Border_背景.Background = new SolidColorBrush(Local.GetThemeColor("ImmersiveStartSelectionBackground"));
            }
            catch { }
            _MessageBox.ShowDialog();
            return(_MessageBox.Result);
        }
Example #7
0
        private void UpdateLocal()
        {
            var game = Game;

            if (game == null)
            {
                MessageBoxViewModel.ShowMessage("No game loaded");
                return;
            }

            if (game.Script.Editor.ErrorsToolWindow.References.Count > 0)
            {
                MessageBoxViewModel.ShowMessage("Cannot update while errors exist.");
                game.Script.Editor.ErrorsToolWindow.IsVisible = true;
                return;
            }

            if (String.IsNullOrEmpty(game.RACacheDirectory))
            {
                MessageBoxViewModel.ShowMessage("Could not identify local directory.");
                return;
            }

            var dialog = new UpdateLocalViewModel(game);

            dialog.ShowDialog();
        }
Example #8
0
 private void ShowMessage(string text, EventHandler confirmEventHandler)
 {
     MessageBoxViewModel            = new MessageBoxViewModel();
     MessageBoxViewModel.Text       = text;
     MessageBoxViewModel.Confirmed += confirmEventHandler;
     SetDialog?.Invoke(this, MessageBoxViewModel);
 }
 void OpenChangesetView(MergeSelection what)
 {
     try
     {
         if (!what.SourceBranch.IsSubBranch && !Repository.Instance.TfsBridgeProvider.CompleteBranchList.Any(branch => branch.Equals(what.SourceBranch)))
         {
             var mbvm = new MessageBoxViewModel("Active team project", "The branch you selected belongs to a team project which is currently not active.\nPlease switch to that project in the team explorer pane and try again", MessageBoxViewModel.MessageBoxButtons.OK);
             Repository.Instance.ViewManager.ShowModal(mbvm);
             return;
         }
         var settings = Repository.Instance.ProfileProvider.GetDefaultProfile();
         settings.CSSourceBranch = what.SourceBranch.Name;
         settings.CSTargetBranch = what.TargetBranch.Name;
         settings.DateFromFilter = null;
         settings.DateToFilter   = null;
         settings.CSQueryName    = null;
         settings.ChangesetExcludeCommentFilter = null;
         settings.ChangesetIncludeCommentFilter = null;
         ShowChangesetView();
     }
     catch (Exception ex)
     {
         SimpleLogger.Log(ex);
         throw;
     }
 }
        public ActionResult Message()
        {
            var user = this.users.GetById(User.Identity.GetUserId());
            var messages = new MessageBoxViewModel();
            var allMessages = new List<Message>();
            var squad = this.squads.GetById(user.SquadId.GetValueOrDefault());
            if (user.Squad != null)
            {
                allMessages = squad
                    .Messages
                    .ToList();
            }
            else
            {
                var platoon = this.platoons
                    .GetAll()
                    .FirstOrDefault(x => x.PlatoonCommanderId == user.Id);
                allMessages = platoon.Messages.ToList();
            }

            allMessages.Reverse();
            messages.Content = allMessages.ToList();
            @ViewBag.HeaderText = "Send message to commander";
            var data = new MessageIndexViewModel() { SendInput = new SendMessageViewModel(), MessageView = messages };
            return PartialView("_SendMessage", data);
        }
Example #11
0
 private void ShowMessage(string text)
 {
     MessageBoxViewModel            = new MessageBoxViewModel();
     MessageBoxViewModel.Text       = text;
     MessageBoxViewModel.Confirmed += delegate { HideDialog?.Invoke(this, null); };
     SetDialog?.Invoke(this, MessageBoxViewModel);
 }
        public bool ShowMessage(string title, string message, string acceptText = "Ok", bool hideCancel = false)
        {
            var messageBox = new MessageBoxViewModel(title, message, acceptText, hideCancel);
            var result     = ShowOverlayDialog(messageBox);

            return(result ?? false);
        }
Example #13
0
        public MessageBoxView()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                ExtendClientAreaToDecorationsHint  = true;
                ExtendClientAreaChromeHints        = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
                ExtendClientAreaTitleBarHeightHint = -1;

                var windowsTitleBar = this.FindControl <WindowsMsgBoxTitleBar>("windowsTitleBar");
                windowsTitleBar.IsVisible = true;
            }

            var vm = new MessageBoxViewModel(new MessageBoxParams
            {
                ContentMessage = "This is a test message box message that can go for long and long, " +
                                 "please read this message to understand what is happening in this message box." +
                                 "The brown fox jumps over the lazy dog",
                ContentTitle          = "Test nessage box",
                Icon                  = Common.MessageBox.Enums.Icon.Warning,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                MaxWidth              = 600,
                ButtonDefinitions     = ButtonEnum.Ok
            }, this);
            DataContext = vm;
        }
Example #14
0
        public MessageBoxView(string title, string text, ButtonEnum buttons, Icon icon)
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                ExtendClientAreaToDecorationsHint  = true;
                ExtendClientAreaChromeHints        = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
                ExtendClientAreaTitleBarHeightHint = -1;

                var windowsTitleBar = this.FindControl <WindowsMsgBoxTitleBar>("windowsTitleBar");
                windowsTitleBar.IsVisible = true;
                TextBlock systemChromeTitle = windowsTitleBar.FindControl <TextBlock>("SystemChromeTitle");
                systemChromeTitle.Text = title;
            }

            var vm = new MessageBoxViewModel(new MessageBoxParams
            {
                ContentMessage        = text,
                ContentTitle          = title,
                Icon                  = icon,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                MaxWidth              = 600,
                ButtonDefinitions     = buttons
            }, this);
            DataContext = vm;
            // Workaround a layout issue
            Width = 600;
        }
Example #15
0
        public static async Task <MessageBoxResult> Show(string message, string caption, MessageBoxType type)
        {
            var messageBox = new MessageBox();
            var viewModel  = new MessageBoxViewModel();

            viewModel.Caption = caption;
            viewModel.Message = message;

            switch (type)
            {
            case MessageBoxType.OK:
                viewModel.IsOkButtonVisible = true;
                break;

            case MessageBoxType.YesNo:
                viewModel.AreYesNoButtonsVisible = true;
                break;

            default:
                break;
            }

            messageBox.DataContext = viewModel;

            await messageBox.ShowDialog(MainWindow.Current);

            return(viewModel.Result);
        }
Example #16
0
        void Merge(object o)
        {
            try
            {
                var candidates = FilteredChangesets.Where(cs => cs.IsSelected).Select(cs => cs.TfsChangeset);

                if (!candidates.Any())
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "No changesets are currently selected.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else
                {
                    var mergeViewModel = new PrepareMergeViewModel(TfsItemCache, candidates);
                    var result         = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                    mergeViewModel.MergeSource = result != null ? result.SourceBranch : null;
                    mergeViewModel.MergeTarget = result != null ? result.TargetBranch : null;
                    mergeViewModel.PathFilter  = result != null ? result.PathFilter : null;
                    mergeViewModel.SetDefaults();

                    if (Repository.Instance.Settings.FetchSettings <bool>(Constants.Settings.PerformNonModalMergeKey))
                    {
                        vMergePackage.OpenMergeView(mergeViewModel);
                    }
                    else
                    {
                        Repository.Instance.ViewManager.ShowModal(mergeViewModel, "Modal");
                    }
                }
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true);
            }
        }
Example #17
0
        public bool?Show(string title, string msg, MessageBoxType type = MessageBoxType.None,
                         MessageBoxButtonSet buttons = MessageBoxButtonSet.Ok)
        {
            var vm = new MessageBoxViewModel(title, msg, type);

            switch (buttons)
            {
            case MessageBoxButtonSet.Ok:
                vm.AddButton(DialogButtonType.Ok);
                break;

            case MessageBoxButtonSet.OkCancel:
                vm.AddButton(DialogButtonType.Ok);
                vm.AddButton(DialogButtonType.Cancel);
                break;

            case MessageBoxButtonSet.YesNo:
                vm.AddButton(DialogButtonType.Yes);
                vm.AddButton(DialogButtonType.No);
                break;

            case MessageBoxButtonSet.YesNoCancel:
                vm.AddButton(DialogButtonType.Yes);
                vm.AddButton(DialogButtonType.No);
                vm.AddButton(DialogButtonType.Cancel);
                break;

            default:
                throw new ArgumentException("Unsupported buttons specified for Message Box");
            }

            return(_windowManager.ShowDialog(vm));
        }
Example #18
0
        private void _ShowMessage()
        {
            var vm = new MessageBoxViewModel
            {
                Title            = MessageBoxData.Title,
                Message          = MessageBoxData.Message,
                Icon             = MessageBoxData.Icon,
                ShowConfirm      = MessageBoxData.ShowConfirm,
                ConfirmText      = MessageBoxData.ConfirmText,
                ShowDecline      = MessageBoxData.ShowDecline,
                DeclineText      = MessageBoxData.DeclineText,
                ShowCancel       = MessageBoxData.ShowCancel,
                CancelText       = MessageBoxData.CancelText,
                DefaultAction    = MessageBoxData.DefaultAction,
                AllowNonResponse = MessageBoxData.AllowNonResponse
            };

            var view = new MessageBoxView
            {
                DataContext           = vm,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Owner = this
            };

            view.ShowDialog();
        }
Example #19
0
        private static bool ResolveConflicts(ITfsTemporaryWorkspace tempWorkspace, ref bool finished)
        {
            bool hadConflicts = false;

            while (tempWorkspace.Conflicts.Count != 0)
            {
                hadConflicts = true;
                int oldConflictsCount = tempWorkspace.Conflicts.Count;

                SimpleLogger.Checkpoint("PerformMerge: Resolving conflict ({0} remaining)", oldConflictsCount);
                //Repository.Instance.TfsUIInteractionProvider.ResolveConflictsInternally(tempWorkspace);
                //return false;
                Repository.Instance.TfsUIInteractionProvider.ResolveConflictsPerTF(tempWorkspace.MappedFolder);

                SimpleLogger.Checkpoint("PerformMerge: Finished resolving conflict ({0} remaining)", oldConflictsCount);
                tempWorkspace.RefreshConflicts();
                if (tempWorkspace.Conflicts.Count == oldConflictsCount)
                {
                    MessageBoxViewModel mbvm = new MessageBoxViewModel("Cancel merge?", "There are conflicts remaining to be resolved. Really cancel the merge?", MessageBoxViewModel.MessageBoxButtons.None);
                    var yesButton            = new MessageBoxViewModel.MessageBoxButton("_Yes");
                    mbvm.ConfirmButtons.Add(yesButton);
                    mbvm.ConfirmButtons.Add(new MessageBoxViewModel.MessageBoxButton("_No"));
                    Repository.Instance.ViewManager.ShowModal(mbvm);

                    if (yesButton.IsChecked)
                    {
                        finished = false;
                        break;
                    }
                }
            }
            return(hadConflicts);
        }
Example #20
0
 public void TestInitialize()
 {
     _message = "someMessage";
     _title   = "someTitle";
     _buttons = MessageBoxButton.YesNoCancel;
     _icon    = FontAwesomeIcon.Navicon;
     _isDependenciesButtonVisible = true;
     _isError    = false;
     _isInfo     = true;
     _isQuestion = false;
     _duplicates = new List <string>();
     _isDeleteAnywayButtonVisible = false;
     _applyToAll        = false;
     _changedProperties = new List <string>();
     _target            = new MessageBoxViewModel(
         _message,
         _title,
         _buttons,
         _icon,
         _isDependenciesButtonVisible,
         _isError,
         _isInfo,
         _isQuestion,
         _duplicates,
         _isDeleteAnywayButtonVisible,
         _applyToAll);
     _target.PropertyChanged += (sender, args) => { _changedProperties.Add(args.PropertyName); };
 }
Example #21
0
        void ProcessActivationTicket()
        {
            string activationTicket = string.Empty;

            if (HtmlPage.Document.QueryString.TryGetValue("activationTicket", out activationTicket))
            {
                SecurityContext.Current.ActivateUser(activationTicket, result =>
                    {
                        if (!string.IsNullOrEmpty(result.Error))
                        {
                            MessageBoxViewModel message = new MessageBoxViewModel();
                            message.DisplayName = AppStrings.ActivationUserWindowTitle;
                            message.Header = AppStrings.FailedMessageHeader;
                            message.Message = result.Error;
                            message.Buttons = MessageBoxButtons.OK;
                            message.MessageLevel = MessageLevel.Exclamation;
                            Execute.OnUIThread(() => IoC.Get<IWindowManager>().ShowDialog(message));
                        }
                        else
                        {
                            var url = string.Format("http://{0}:{1}", Application.Current.Host.Source.Host, Application.Current.Host.Source.Port);
                            HtmlPage.Window.Navigate(new Uri(url));
                        }
                    });
            }
        }
        public static void AutoClose(this MessageBoxViewModel vm)
        {
            // I feel dirty.
            MethodInfo dynMethod = vm.GetType().GetMethod("Close",
                                                          BindingFlags.NonPublic | BindingFlags.Instance);

            dynMethod.Invoke(vm, null);
        }
Example #23
0
 void MessageBoxView_Loaded(object sender, RoutedEventArgs e)
 {
     _model = this.DataContext as MessageBoxViewModel;
     if (_model == null)
         throw new Exception("Mode of type of MessageBoxViewModel is needed");
     ApplyButtons(_model.Buttons);
     _model.PropertyChanged += _model_PropertyChanged;
 }
Example #24
0
        /// <summary>
        ///     Shows a dialog.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="dialogButtons">The buttons to display.</param>
        /// <returns>
        ///     the dialog result.
        /// </returns>
        public DialogResult ShowDialog(string message, DialogButtons dialogButtons)
        {
            var viewModel = new MessageBoxViewModel(ApplicationInfo.ProductTitle, message, dialogButtons);

            this._windowManager.ShowDialog(viewModel);

            return(viewModel.DialogResult);
        }
Example #25
0
    private MessageBoxView()
    {
        InitializeComponent();
        MessageBoxViewModel dvm = new MessageBoxViewModel();

        dvm.PropertyChanged += (s, e) => this.PropertyChanged(s, e);
        DataContext          = dvm;
    }
        private MaterialMessageBox(string title, string description)
        {
            InitializeComponent();
            MessageBoxViewModel vm = DataContext as MessageBoxViewModel;

            vm.Title       = title;
            vm.Description = description;
        }
        public MessageBoxWindow()
        {
            InitializeComponent();

            var viewModel = new MessageBoxViewModel();

            this.DataContext = viewModel;
        }
Example #28
0
        void ReportException(Exception ex)
        {
            var mbvm = new MessageBoxViewModel("Exception during Merge occurred",
                                               "The following exception occurred during the merge operation:\r\n\r\n" +
                                               ex.ToString(), MessageBoxViewModel.MessageBoxButtons.OK);

            Repository.Instance.ViewManager.ShowModal(mbvm);
        }
Example #29
0
        /// <summary>
        /// Attempts to open an Access database.
        /// </summary>
        /// <param name="fileName">Path to the Access database.</param>
        public bool Connect(string fileName)
        {
            _logger.Write("Opening database: {0}", fileName);

            // try newer driver first
            string connectionString = "Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" + fileName;
            var    connection       = new OdbcConnection(connectionString);

            try
            {
                connection.Open();
            }
            catch (OdbcException ex)
            {
                _logger.Write("Failed to open database: " + ex.Message);

                if (ex.Message.Contains("[IM002]"))
                {
                    if (IntPtr.Size != 4 && File.Exists(fileName))
                    {
                        MessageBoxViewModel.ShowMessage("Access driver not found - assuming 64-bit access driver not installed");
                    }

                    // https://knowledge.autodesk.com/support/autocad/learn-explore/caas/sfdcarticles/sfdcarticles/How-to-install-64-bit-Microsoft-Database-Drivers-alongside-32-bit-Microsoft-Office.html
                    // * download AccessDatabaseEngine_X64.exe from https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=13255
                    // * run it with the /quiet option: > AccessDatabaseEngine_X64.exe /quiet
                    // * delete or rename the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Common\FilesPaths\mso.dll registry key
                }

                return(false);
            }
            catch (InvalidOperationException ex)
            {
                _logger.Write("Failed to open database: " + ex.Message);

                // then try older driver
                connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fileName;
                connection       = new OdbcConnection(connectionString);
                connection.Open();
            }

            while (connection.State == System.Data.ConnectionState.Connecting)
            {
                System.Threading.Thread.Sleep(100);
            }

            if (connection.State == System.Data.ConnectionState.Open)
            {
                _logger.Write("Database opened");
                _connection = connection;
            }
            else
            {
                _logger.Write("Failed to open database: " + connection.State);
            }

            return(connection.State == System.Data.ConnectionState.Open);
        }
        /// <summary>
        /// Initialized the control.
        /// </summary>
        /// <param name="viewModel">The view model</param>
        private MessageBoxWindow(MessageBoxViewModel viewModel)
        {
            ViewModel   = viewModel;
            DataContext = ViewModel;

            InitializeComponent();

            InitializeApplication();
        }
        private void Window_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            MessageBoxViewModel viewModel = this.DataContext as MessageBoxViewModel;

            if (viewModel != null)
            {
                viewModel.CloseAction = new Action(() => this.Close());
            }
        }
        public MessageBoxWindow(MessageBoxViewModel viewModel)
            : base(viewModel, DataWindowMode.Custom)
        {
            InitializeComponent();

            if (viewModel.Button == MessageButton.YesNo)
            {
                this.DisableCloseButton();
            }
        }
Example #33
0
 void MessageBoxView_Loaded(object sender, RoutedEventArgs e)
 {
     _model = this.DataContext as MessageBoxViewModel;
     if (_model == null)
     {
         throw new Exception("Mode of type of MessageBoxViewModel is needed");
     }
     ApplyButtons(_model.Buttons);
     _model.PropertyChanged += _model_PropertyChanged;
 }
        public MessageBoxWindow(MessageBoxViewModel viewModel)
            : base(viewModel, DataWindowMode.Custom)
        {
            InitializeComponent();

            if (viewModel.Button == MessageButton.YesNo)
            {
                this.DisableCloseButton();
            }
        }
Example #35
0
        public static void Handle(this Exception ex)
        {
            var model = new MessageBoxViewModel() { MessageLevel = MessageLevel.Error, Buttons = MessageBoxButtons.OK, Header = ErrorStrings.GenericErrorMessageHeader };
            if (ex is FaultException<ServerFault>)
            {
                FaultException<ServerFault> faultEx = (FaultException<ServerFault>)ex;
                if (faultEx.Detail.FaultCode == ServerFaultCode.Generic)
                {
                    model.Message = ErrorStrings.GenericServerErrorMessage;
                }
                else if (faultEx.Detail.FaultCode == ServerFaultCode.NotAuthroized)
                {
                    model.Message = ErrorStrings.NotAuthorizedServerErrorMessage;
                }
            }
            else
            {
                model.Message = ex.ToString(); //ErrorStrings.UnknownServerErrorMessage;
            }

            Execute.OnUIThread(() => IoC.Get<IWindowManager>().ShowDialog(model));
        }
        /// <summary>
        ///     Shows a dialog.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="dialogButtons">The buttons to display.</param>
        /// <returns>
        ///     the dialog result.
        /// </returns>
        public DialogResult ShowDialog(string message, DialogButtons dialogButtons)
        {
            var viewModel = new MessageBoxViewModel(ApplicationInfo.ProductTitle, message, dialogButtons);

            this._windowManager.ShowDialog(viewModel);

            return viewModel.DialogResult;
        }
Example #37
0
        public void SignIn()
        {
            RefreshBindingScope.Scope();
            if (this.Validator.HasErrors)
                return;
            IsBusy = true;
            SecurityContext.Current.SignIn(UserName, Password, KeepSignedIn, result =>
            {
                if (!result.Success)
                {
                    var messageBox = new MessageBoxViewModel()
                    {
                        MessageLevel = ViewModels.MessageLevel.Exclamation,
                        Buttons = MessageBoxButtons.OK,
                        Header = AppStrings.SignInFailedMessageHeader,
                        Message = result.Error,
                        DisplayName = AppStrings.SignInWindowTitle
                    };
                    IoC.Get<IWindowManager>().ShowDialog(messageBox);
                }
                else
                {
                    if (SignInSucceeded != null)
                        SignInSucceeded(this, EventArgs.Empty);
                }

                IsBusy = false;
            });
        }
		public bool? ConfirmOrCancel(string message, string title = "Confirm")
		{
			bool? result = null;
			SafeInvoke(() =>
				{
					var vm = new MessageBoxViewModel(MessageBoxType.YesNoCancel, MessageBoxIcon.YesNo)
								{
									Title = title,
									Message = message,
								};
					var dialog = new MessageBoxMetroWindow
									{
										Owner = (Window)ShellHandle,
										DataContext = vm
									};
					ShellHandle = dialog;
					dialog.ShowDialog();

					ShellHandle = dialog.Owner;
					result = vm.DialogResult;
				});
			return result;
		}
		public bool Confirm(string message, string title)
		{
			var result = false;

			SafeInvoke(() =>
				{
					var vm = new MessageBoxViewModel(MessageBoxType.YesNo, MessageBoxIcon.YesNo)
								{
									Title = title,
									Message = message,
								};
					var dialog = new MessageBoxMetroWindow
					{
						Owner = (Window)ShellHandle,
						DataContext = vm
					};
					ShellHandle = dialog;
					dialog.ShowDialog();

					ShellHandle = dialog.Owner;
					if (vm.DialogResult.HasValue)
					{
						result = vm.DialogResult.Value;
					}
				});
			return result;
		}
Example #40
0
        private void RegisterMessageBoxDialog()
        {
            _messenger.Register<DialogMessage>(this,
                x =>
                {
                    MessageBoxViewModel vm = new MessageBoxViewModel
                    {
                        Caption = x.Caption,
                        Message = x.Message,
                        Icon = x.Icon
                    };

                    IWindow w = _vs.ExecuteFunction<MessageBoxViewModel, IWindow>((IWindow) Current.MainWindow, vm);
                    w.ShowDialog();
                });
        }