Ejemplo n.º 1
1
 public BoilerplateEditorViewModel()
 {
     CancelCommand      = new RelayCommand <RoutedEventArgs>(Cancel_Pressed);
     OKCommand          = new RelayCommand <RoutedEventArgs>(OK_Pressed);
     _dialogCoordinator = DialogCoordinator.Instance;
     Cancel             = false;
     Exception          = null;
 }
Ejemplo n.º 2
0
        public PlayerViewModel(DialogCoordinator pCoordinator)
        {
            DialogCoordinator = pCoordinator;
            Tracks = new ObservableCollection<Track>();
            Tracks.CollectionChanged += Tracks_CollectionChanged;


            var errorSettings = new MetroDialogSettings();
            errorSettings.ColorScheme = MetroDialogColorScheme.Theme;

            TestCommand = new RelayCommand(() => ShowMessage("Error", "EIN FEHLER!", MessageDialogStyle.Affirmative, errorSettings));



            if (Properties.Settings.Default.ShouldScanForNewTracks)
            {
                foreach (var path in Properties.Settings.Default.TrackLocations)
                {
                    FileSystemWatcher fsw = new FileSystemWatcher(path);
                    fsw.Created += Fsw_Created;
                    fsw.Deleted += Fsw_Deleted;
                    fsw.EnableRaisingEvents = true;
                    fileSystemWatchers.Add(fsw);

                }

            }

        }
        private async Task <LoginDialogData> DisplayLoginDialog()
        {
            var dictionary = new ResourceDictionary
            {
                Source = new Uri(
                    "pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml")
            };

            var result =
                await
                DialogCoordinator.ShowLoginAsync(
                    this,
                    "Login",
                    string.Empty,
                    new LoginDialogSettings
            {
                //InitialUsername = UserSettings.Default.Username,
                EnablePasswordPreview      = true,
                UsernameWatermark          = "username",
                PasswordWatermark          = "Password",
                RememberCheckBoxVisibility = Visibility.Hidden,

                AnimateHide = false,
                SuppressDefaultResources = false,
                CustomResourceDictionary = dictionary,
                AnimateShow = true,
            });

            return(result);
        }
 public TabChangeRequestViewModel(Messenger messenger,
                                  DialogCoordinator dialogCoordinator,
                                  IDataAccess dataAccess)
     : this(messenger, dialogCoordinator, dataAccess,
            new ChangeRequest()
 {
     ID = 0,
     VersionImplemented = "",
     DetailedDescription = "",
     Justification = ""
 }, new Issue()
 {
     IssueID = 0,
     Description = "",
     UserCreated = Environment.UserName,
     UserClosed = "",
     DateCreated = DateTime.Now,
     DateClosed = DateTime.Now,
     PlantContact = "",
     IssueType = (int)eIssueType.Bug,
     IssueState = (int)eIssueState.Open,
     IssueResolution = (int)eIssueResolution.NA,
     Priority = (int)ePriority.Low,
     Severity = (int)eSeverity.Low
 })
 {
     IsDirty   = true;
     TabHeader = "New Change";
 }
        private void CloseTab(object p)
        {
            if (!(p is MainEditorViewModel))
            {
                return;
            }
            var removeView = _regionManager.Regions[Names.MainContentRegion].Views.Cast <FrameworkElement>().FirstOrDefault(v => v.DataContext == p);

            if (removeView == null)
            {
                return;
            }
            var needSave = ((MainEditorViewModel)p).IsNeedSave;

            if (needSave)
            {
                var result = DialogCoordinator.ShowMessageAsync(this, "Close", "Save project before closing?", MessageDialogStyle.AffirmativeAndNegative, ServiceLocator.GetInstance <MetroDialogSettings>());
                result.Wait();
                if (result.Result == MessageDialogResult.Affirmative)
                {
                    SaveProject();
                }
            }
            removeView.DataContext = null;
            _regionManager.Regions[Names.MainContentRegion].Remove(removeView);
            ((MainEditorViewModel)p).Dispose();
        }
Ejemplo n.º 6
0
 private void VerifyIfPlayerWonGame()
 {
     if (_numberOfLeftPawns == 0)
     {
         DialogCoordinator.ShowMessageAsync(this, "Congratulations", "You won game !!!");
     }
 }
Ejemplo n.º 7
0
 public TabBugViewModel(Messenger messenger,
                        DialogCoordinator dialogCoordinator,
                        IDataAccess dataAccess)
     : this(messenger, dialogCoordinator, dataAccess,
            new Bug()
 {
     ID = 0,
     VersionFound = "",
     VersionFixed = "",
     DetailedDescription = "",
     StepsToReproduce = "",
     Workaround = "",
     Fix = ""
 }, new Issue()
 {
     IssueID = 0,
     Description = "",
     UserCreated = Environment.UserName,
     UserClosed = "",
     DateCreated = DateTime.Now,
     DateClosed = DateTime.Now,
     PlantContact = "",
     IssueType = (int)eIssueType.Bug,
     IssueState = (int)eIssueState.Open,
     IssueResolution = (int)eIssueResolution.NA,
     Priority = (int)ePriority.Low,
     Severity = (int)eSeverity.Low
 })
 {
     IsDirty   = true;
     TabHeader = "New Bug";
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Open signin modal
        /// </summary>
        /// <returns>Task</returns>
        private async Task OpenSigninModal()
        {
            var signinDialog = new SigninDialog(new SigninDialogSettings());
            await DialogCoordinator.ShowMetroDialogAsync(this, signinDialog);

            var signinDialogResult = await signinDialog.WaitForButtonPressAsync();

            await DialogCoordinator.HideMetroDialogAsync(this, signinDialog);

            if (signinDialogResult == null)
            {
                return;
            }

            if (signinDialogResult.ShouldSignup)
            {
                var user = await OpenSignupModal();

                if (user == null)
                {
                    return;
                }
                await Signin(user);
            }
            else
            {
                var user = new Models.Account.User
                {
                    Username = signinDialogResult.Username,
                    Password = signinDialogResult.Password
                };

                await Signin(user);
            }
        }
        private async Task <string> GetBuildsSavePathAsync()
        {
            if (AppData.IsPortable)
            {
                return(AppData.ToRelativePath(AppData.GetFolder("Builds")));
            }

            // Ask user for path. Default: AppData.GetFolder("Builds")
            var dialogSettings = new FileSelectorDialogSettings
            {
                DefaultPath       = AppData.GetFolder("Builds"),
                IsFolderPicker    = true,
                ValidationSubPath = GetLongestRequiredSubpath(),
                IsCancelable      = false
            };

            if (!DeserializesBuildsSavePath)
            {
                dialogSettings.AdditionalValidationFunc =
                    path => Directory.Exists(path) && Directory.EnumerateFileSystemEntries(path).Any()
                        ? L10n.Message("Directory must be empty.")
                        : null;
            }
            return((await DialogCoordinator.ShowFileSelectorAsync(PersistentData,
                                                                  L10n.Message("Select build directory"),
                                                                  L10n.Message("Select the directory where builds will be stored.\n" +
                                                                               "It will be created if it does not yet exist. You can change it in the settings later."),
                                                                  dialogSettings)) !);
        }
Ejemplo n.º 10
0
        private async void CloseTab(object p)
        {
            var model = p as ICloseable;

            if (model == null)
            {
                return;
            }
            var removeView = RegionManager.Regions[Names.MainContentRegion].Views.Cast <FrameworkElement>().FirstOrDefault(v => v.DataContext == p);

            if (removeView == null)
            {
                return;
            }
            var needSave = model.IsNeedSave;

            if (needSave)
            {
                var result = await DialogCoordinator.ShowMessageAsync(this, "Close", "Save project before closing?", MessageDialogStyle.AffirmativeAndNegative, Container.GetInstance <MetroDialogSettings>());

                if (result == MessageDialogResult.Affirmative)
                {
                    SaveProject();
                }
            }
            removeView.DataContext = null;
            RegionManager.Regions[Names.MainContentRegion].Remove(removeView);
            model.Close();
        }
        private async Task <PoEBuild> ImportBuildAsync(Func <Task <XmlBuild> > supplier)
        {
            try
            {
                var xmlBuild = await supplier();

                var build = ConvertFromXmlBuild(xmlBuild);
                if (!CheckVersion(xmlBuild.Version))
                {
                    Log.Warn($"Build is of an old version and can't be imported (version {xmlBuild.Version})");
                    await DialogCoordinator.ShowWarningAsync(PersistentData,
                                                             L10n.Message("Build is of an old version and can't be imported"),
                                                             title : L10n.Message("Import failed"));

                    return(null);
                }
                return(build);
            }
            catch (Exception e)
            {
                Log.Error("Error while importing build", e);
                await DialogCoordinator.ShowErrorAsync(PersistentData, L10n.Message("Could not import build"),
                                                       e.Message, L10n.Message("Import failed"));

                return(null);
            }
        }
Ejemplo n.º 12
0
        private void ExecuteAdd()
        {
            string selectedJob;

            //Present a dialog for the user to select the type of job they want to add
            var dialog = new CustomDialog {
                Title = "Add New Job"
            };
            var panel = new StackPanel();

            panel.Children.Add(new RadioButton {
                Content = "Data Update", Margin = new Thickness(5), IsChecked = true
            });
            panel.Children.Add(new RadioButton {
                Content = "Economic Release Update", Margin = new Thickness(5), IsChecked = false
            });
            panel.Children.Add(new RadioButton {
                Content = "Dividend Update", Margin = new Thickness(5), IsChecked = false
            });

            var addBtn = new Button {
                Content = "Add"
            };

            addBtn.Click += (s, e) =>
            {
                DialogCoordinator.HideMetroDialogAsync(this, dialog);
                selectedJob = (string)panel.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked.HasValue && r.IsChecked.Value)?.Content;
                AddJob(selectedJob);
            };
            panel.Children.Add(addBtn);
            dialog.Content = panel;

            DialogCoordinator.ShowMetroDialogAsync(this, dialog);
        }
Ejemplo n.º 13
0
        private async void RestetGame(object obj)
        {
            var progressDialogController = DialogCoordinator.ShowMessageAsync(this, "Restart", "Restart game...");

            LoadGameSettings();
            ResetSettings();
            await progressDialogController;
        }
Ejemplo n.º 14
0
 /// <summary>
 ///     Show dialog with error message
 /// </summary>
 /// <param name="message">Message</param>
 protected void ShowErrorMessage(string message)
 {
     DialogCoordinator.ShowMessageAsync(this, "Error", message, MessageDialogStyle.Affirmative, new MetroDialogSettings
     {
         AnimateHide = false,
         AnimateShow = false
     });
 }
 public BoilerplateEditorViewModel()
 {
     CancelCommand = new RelayCommand<RoutedEventArgs>(Cancel_Pressed);
     OKCommand = new RelayCommand<RoutedEventArgs>(OK_Pressed);
     _dialogCoordinator = DialogCoordinator.Instance;
     Cancel = false;
     Exception = null;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 時間のかかる処理を実行します。
        /// </summary>
        /// <param name="method">時間のかかる処理</param>
        /// <param name="settings">設定情報</param>
        public async Task ShowProgressAsync(Func <ProgressDialogController, Task> method, MetroDialogSettings settings = null)
        {
            var pdc = await DialogCoordinator.ShowProgressAsync(this, null, null, false, settings);

            await method(pdc);

            await pdc.CloseAsync();
        }
Ejemplo n.º 17
0
        protected async Task <MessageDialogResult> ConfirmAsync(string title, string description,
                                                                CancellationToken ct = default)
        {
            var result = await DialogCoordinator.ShowMessageAsync(DialogContext, title,
                                                                  description, MessageDialogStyle.AffirmativeAndNegative, CreateDialog(ct));

            return(result);
        }
Ejemplo n.º 18
0
        public MainViewModel(IAccountProvider accountProvider)
        {
            _dialogCoordinator = DialogCoordinator.Instance;
            _accountProvider   = accountProvider;
            AddAccountCommand  = new RelayCommand(OnAddAccountCommand);

            StartCommand = new RelayCommand(OnStartCommand);
            StopCommand  = new RelayCommand(OnStopCommand);
        }
Ejemplo n.º 19
0
 protected override ISolver CreateSolver(SolverSettings settings)
 {
     if (!settings.Checked.Any())
     {
         DialogCoordinator.ShowInfoAsync(this,
                                         L10n.Message("Please tag non-skilled nodes by right-clicking them."));
         return(null);
     }
     return(new SteinerSolver(Tree, settings));
 }
Ejemplo n.º 20
0
        private async void SaveSettings(object obj)
        {
            var controller = DialogCoordinator.ShowMessageAsync(this, "Saving", "Saving");

            GameSettings.SelectedPawn = _chessPawnFactory.CreatePawn(_selectedPawn + 1);
            GameSettings.GameType     = _gameTypeFactory.CreateGameType(SelectedGameType, TimeMax, NumberOfMistakes, IsTipsEnabled);
            SettingsService.Save(GameSettings);
            Chessboard.ClearChessboard();

            await controller;
        }
        /// <summary>
        /// Imports the build located at <paramref name="buildPath"/>. <see cref="IPersistentData.SaveBuild"/> may be
        /// called by this method.
        /// </summary>
        public async Task ImportBuildFromFileAsync(string buildPath)
        {
            const string extension = SerializationConstants.BuildFileExtension;

            if (!File.Exists(buildPath) || Path.GetExtension(buildPath) != extension)
            {
                Log.Error($"Could not import build file from {buildPath}");
                var message = string.Format(
                    L10n.Message(
                        "Could not import build file, only existing files with the extension {0} can be imported."),
                    extension);
                await DialogCoordinator.ShowErrorAsync(PersistentData, message, title : L10n.Message("Import failed"));

                return;
            }

            var unifiedBuildsSavePath = PersistentData.Options.BuildsSavePath.Replace(Path.AltDirectorySeparatorChar,
                                                                                      Path.DirectorySeparatorChar);
            var unifiedPath = buildPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

            if (unifiedPath.StartsWith(unifiedBuildsSavePath))
            {
                // If BuildsSavePath is part of buildPath, just set it as current and selected build
                // Remove BuildsSavePath
                var relativePath = unifiedPath.Remove(0, unifiedBuildsSavePath.Length + 1);
                // Remove extension
                var path  = relativePath.Remove(relativePath.Length - extension.Length);
                var build = BuildForPath(path) as PoEBuild;
                if (build == null)
                {
                    Log.Warn($"Import failed, build with path {path} not found");
                    return;
                }

                PersistentData.CurrentBuild  = build;
                PersistentData.SelectedBuild = build;
            }
            else
            {
                // Else, proper import
                var build = await ImportBuildAsync(
                    async() => await SerializationUtils.XmlDeserializeFileAsync <XmlBuild>(buildPath));

                if (build != null)
                {
                    build.Name = Util.FindDistinctName(build.Name, PersistentData.RootBuild.Builds.Select(b => b.Name));
                    PersistentData.RootBuild.Builds.Add(build);
                    PersistentData.CurrentBuild  = build;
                    PersistentData.SelectedBuild = build;
                    PersistentData.SaveBuild(PersistentData.RootBuild);
                }
            }
        }
Ejemplo n.º 22
0
        protected override async Task <ISolver> CreateSolverAsync(SolverSettings settings)
        {
            if (!settings.Checked.Any())
            {
                // todo "this" as context is not registered when running without window
                await DialogCoordinator.ShowInfoAsync(DialogContext,
                                                      L10n.Message("Please tag non-skilled nodes by right-clicking them."));

                return(null);
            }
            return(new SteinerSolver(Tree, settings));
        }
Ejemplo n.º 23
0
        private async void StartBackup()
        {
            if (SavesToCompressedFile && CompressedFileUsesPassword && string.IsNullOrWhiteSpace(Utilities.SecureStringToString(Password)))
            {
                await DialogCoordinator.ShowMessageAsync(this, "Error!", "Your password cannot be blank",
                                                         MessageDialogStyle.Affirmative,
                                                         new MetroDialogSettings()
                {
                    AffirmativeButtonText = "OK",
                    ColorScheme           = MetroDialogColorScheme.Theme
                }
                                                         );
            }
            else if (SavesToCompressedFile && CompressedFileUsesPassword && Utilities.SecureStringToString(Password) != Utilities.SecureStringToString(ConfirmPassword))
            {
                await DialogCoordinator.ShowMessageAsync(this, "Error!", "Password and confirm password do not match",
                                                         MessageDialogStyle.Affirmative,
                                                         new MetroDialogSettings()
                {
                    AffirmativeButtonText = "OK",
                    ColorScheme           = MetroDialogColorScheme.Theme
                }
                                                         );
            }
            else
            {
                bool canProceed = true;
                if (SavesToCompressedFile && CompressedFileUsesPassword)
                {
                    var result = await DialogCoordinator.ShowMessageAsync(this, "Warning!", "This backup will be encrypted. " +
                                                                          "The backup cannot be recovered if you forget your password. " +
                                                                          "Are you sure you want to proceed? ",
                                                                          MessageDialogStyle.AffirmativeAndNegative,
                                                                          new MetroDialogSettings()
                    {
                        AffirmativeButtonText = "Yes",
                        NegativeButtonText    = "No",
                        ColorScheme           = MetroDialogColorScheme.Theme
                    }
                                                                          );

                    if (result != MessageDialogResult.Affirmative)
                    {
                        canProceed = false;
                    }
                }
                if (canProceed)
                {
                    PushViewModel(new BackupInProgressViewModel(ViewModelChanger, Items.ToList(), BackupLocation,
                                                                SavesToCompressedFile, CompressedFileUsesPassword ? Password : null));
                }
            }
        }
Ejemplo n.º 24
0
        public static async Task <MessageDialogResult> GetUserConfirmation(DialogCoordinator dialogCoordinator, ScreenBase tab)
        {
            MetroDialogSettings settings = new MetroDialogSettings()
            {
                AffirmativeButtonText    = "Save",
                NegativeButtonText       = "Discard",
                FirstAuxiliaryButtonText = "Cancel"
            };
            MessageDialogResult result = await dialogCoordinator.
                                         ShowMessageAsync(tab, "What do you want to do with your changes?", "", MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, settings);

            return(result);
        }
Ejemplo n.º 25
0
        public static async Task <MessageDialogResult> GetUserConfirmationOnClosing(DialogCoordinator dialogCoordinator, ScreenBase tab)
        {
            MetroDialogSettings settings = new MetroDialogSettings()
            {
                AffirmativeButtonText    = "   Save and close   ",
                NegativeButtonText       = "   Close without saving   ",
                FirstAuxiliaryButtonText = "Cancel"
            };
            MessageDialogResult result = await dialogCoordinator.
                                         ShowMessageAsync(tab, "There are some unsaved changes. What do you want to do?", "", MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, settings);

            return(result);
        }
Ejemplo n.º 26
0
        public static async Task<MessageDialogResult> GetUserConfirmation(DialogCoordinator dialogCoordinator, ScreenBase tab)
        {
            MetroDialogSettings settings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Save",
                NegativeButtonText = "Discard",
                FirstAuxiliaryButtonText = "Cancel"
            };
            MessageDialogResult result = await dialogCoordinator.
                    ShowMessageAsync(tab, "What do you want to do with your changes?", "", MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, settings);

            return result;
        }
Ejemplo n.º 27
0
        public static async Task<MessageDialogResult> GetUserConfirmationOnClosing(DialogCoordinator dialogCoordinator, ScreenBase tab)
        {
            MetroDialogSettings settings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "   Save and close   ",
                NegativeButtonText = "   Close without saving   ",
                FirstAuxiliaryButtonText = "Cancel"
            };
            MessageDialogResult result = await dialogCoordinator.
                    ShowMessageAsync(tab, "There are some unsaved changes. What do you want to do?", "", MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary, settings);

            return result;
        }
Ejemplo n.º 28
0
        public PrincipalViewModel(Usuario usuario, DialogCoordinator dialogCoordinator)
        {
            this.usuario = usuario;
            Logeado      = string.Format("USUARIO: {0}", this.usuario.Username).ToUpper();

            //NotificacionesVisible = false;
            //SNoNotificaciones = "0";
            aTimer          = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 300000;//se refrescara cada 5 min
            aTimer.Enabled  = true;

            _dialogCoordinator = dialogCoordinator;
            //MenuPrincipalVisible = false;
        }
Ejemplo n.º 29
0
        public async Task <bool> ShowMessageConfirm(object context, string title, string message)
        {
            IDialogCoordinator dialogCoodinator = new DialogCoordinator();

            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Yes",
                NegativeButtonText    = "No"
            };

            MessageDialogResult result = await dialogCoodinator.ShowMessageAsync(context, title, message,
                                                                                 MessageDialogStyle.AffirmativeAndNegative, mySettings);

            return(result == MessageDialogResult.Affirmative);
        }
Ejemplo n.º 30
0
        public DateRangeDialog(DialogCoordinator dialogCoordinator, object viewModel, string title, string description,
                               DialogDateRangeEnum rangeType, string dateFromLabel, string dateToLabel, DateTime?defaultDateFrom, DateTime?defaultDateTo,
                               bool closeWindow, int buttonsCount = 1)
        {
            InitializeComponent();

            _dialogCoordinator = dialogCoordinator;
            _viewModel         = viewModel;

            TitleLabel.Text       = title;
            TitleLabel.FontWeight = FontWeights.Bold;
            TitleLabel.FontSize   = DescriptionLabel.FontSize * 1.5;

            DescriptionLabel.Text = description;

            OneDateDockPanel.Visibility   = Visibility.Collapsed;
            DateRangeDockPanel.Visibility = Visibility.Collapsed;
            TwoDateDockPanel.Visibility   = Visibility.Collapsed;

            switch (rangeType)
            {
            case DialogDateRangeEnum.OneDate:
                OneDateDockPanel.Visibility = Visibility.Visible;
                OneDateStartLabel.Content   = dateFromLabel;
                OneDateFrom.SelectedDate    = defaultDateFrom;
                break;

            case DialogDateRangeEnum.DateRange:
                DateRangeDockPanel.Visibility = Visibility.Visible;
                DateRangeStartLabel.Content   = dateFromLabel;
                DateRangeFromTo.BeginDate     = defaultDateFrom;
                DateRangeFromTo.EndDate       = defaultDateTo;
                break;

            case DialogDateRangeEnum.TwoDate:
                TwoDateDockPanel.Visibility = Visibility.Visible;
                TwoDateStartLabel.Content   = dateFromLabel;
                TwoDateEndLabel.Content     = dateToLabel;
                TwoDateFrom.SelectedDate    = defaultDateFrom;
                TwoDateTo.SelectedDate      = defaultDateTo;
                break;
            }

            Buttons = new List <Button>();
            InitializeButtons(buttonsCount);

            _closeWindow = closeWindow;
        }
        private void InputDialog()
        {
            var metroDialogSettings = new MetroDialogSettings
            {
                CustomResourceDictionary =
                    new ResourceDictionary
                    {
                        Source = new Uri("pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.MahApps.Dialogs.xaml")
                    },
                NegativeButtonText = "CANCEL",                
                SuppressDefaultResources = true
            };

            DialogCoordinator d = new DialogCoordinator();
            DialogCoordinator.Instance.ShowInputAsync(this, "MahApps Dialog", "Using Material Design Themes", metroDialogSettings);
        }
        public TabChangeRequestViewModel(Messenger messenger,
                                         DialogCoordinator dialogCoordinator,
                                         IDataAccess dataAccess,
                                         ChangeRequest changeRequest,
                                         Issue issue)
            : base(issue)
        {
            this.messenger         = messenger;
            this.dialogCoordinator = dialogCoordinator;
            this.dataAccess        = dataAccess;
            this.ChangeRequest     = changeRequest;
            this.ID = changeRequest.ID;

            ShowCloseButton = true;
            TabHeader       = "Change #" + IssueID.ToString();
        }
Ejemplo n.º 33
0
        public TabBugViewModel(Messenger messenger,
                               DialogCoordinator dialogCoordinator,
                               IDataAccess dataAccess,
                               Bug bug,
                               Issue issue)
            : base(issue)
        {
            this.messenger         = messenger;
            this.dialogCoordinator = dialogCoordinator;
            this.dataAccess        = dataAccess;
            this.Bug = bug;
            this.ID  = bug.ID;

            ShowCloseButton = true;
            TabHeader       = "Bug #" + IssueID.ToString();
        }
Ejemplo n.º 34
0
        private void VerifyIfPlayerLoseGame()
        {
            if (!_isGameStarted)
            {
                return;
            }

            if (!_timerService.IsCountingFinished && TimeLimit != Timer && NumberOfPossibleMistakes >= NumberOfMistakes)
            {
                return;
            }

            DialogCoordinator.ShowMessageAsync(this, "Lose", "You lose game!!!");
            _isGameStarted = false;
            _timerService.Reset();
        }
Ejemplo n.º 35
0
        private async void CheckAndRemoveAllItems()
        {
            var result = await DialogCoordinator.ShowMessageAsync(this, "Warning!", "Are you sure you want to remove all items?",
                                                                  MessageDialogStyle.AffirmativeAndNegative,
                                                                  new MetroDialogSettings()
            {
                AffirmativeButtonText = "Yes",
                NegativeButtonText    = "No",
                ColorScheme           = MetroDialogColorScheme.Theme
            }
                                                                  );

            if (result == MessageDialogResult.Affirmative)
            {
                Items.Clear();
            }
        }
Ejemplo n.º 36
0
        public TabAllIssuesViewModel(Messenger messenger, DialogCoordinator dialogCoordinator, IDataAccess dataAccess)
        {
            this.messenger = messenger;
            this.dialogCoordinator = dialogCoordinator;
            this.dataAccess = dataAccess;

            ShowCloseButton = false;
            TabHeader = "All Issues";
            AllIssues = new List<IssueViewModel>();
            DropdownCommands = CreateListOfDropdownCommands();

            filterTimer = new System.Timers.Timer(1000);
            filterTimer.AutoReset = false;
            filterTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => RefreshTab();

            AllIssues = dataAccess.GetAllIssues(String.Empty);
        }
Ejemplo n.º 37
0
 public TabBugViewModel(Messenger messenger,
                        DialogCoordinator dialogCoordinator,
                        IDataAccess dataAccess)
     : this(messenger, dialogCoordinator, dataAccess,
     new Bug()
     {
         ID = 0,
         VersionFound = "",
         VersionFixed = "",
         DetailedDescription = "",
         StepsToReproduce = "",
         Workaround = "",
         Fix = ""
     }, new Issue()
     {
         IssueID = 0,
         Description = "",
         UserCreated = Environment.UserName,
         UserClosed = "",
         DateCreated = DateTime.Now,
         DateClosed = DateTime.Now,
         PlantContact = "",
         IssueType = (int)eIssueType.Bug,
         IssueState = (int)eIssueState.Open,
         IssueResolution = (int)eIssueResolution.NA,
         Priority = (int)ePriority.Low,
         Severity = (int)eSeverity.Low
     })
 {
     IsDirty = true;
     TabHeader = "New Bug";
 }
Ejemplo n.º 38
0
        public TabBugViewModel(Messenger messenger,
                               DialogCoordinator dialogCoordinator,
                               IDataAccess dataAccess,
                               Bug bug,
                               Issue issue)
            : base(issue)
        {
            this.messenger = messenger;
            this.dialogCoordinator = dialogCoordinator;
            this.dataAccess = dataAccess;
            this.Bug = bug;
            this.ID = bug.ID;

            ShowCloseButton = true;
            TabHeader = "Bug #" + IssueID.ToString();
        }
Ejemplo n.º 39
0
 public MainViewModel()
 {
     IsBrowserVisible = true;
     IsOptionsVisible = false;
     SelectedItemChangedCommand = new RelayCommand<RoutedPropertyChangedEventArgs<object>>(SelectedItemChanged);
     LoadedCommand = new RelayCommand<RoutedEventArgs>(Loaded);
     MarkAllReadCommand = new RelayCommand<RoutedEventArgs>(MarkAllRead);
     AddFeedCommand = new RelayCommand<RoutedEventArgs>(AddFeed);
     AddBoilerplateCommand = new RelayCommand<RoutedEventArgs>(AddBoilerplate);
     DeleteBoilerplateCommand = new RelayCommand<BoilerplateAnswer>(param => DeleteBoilerplate(param));
     DoubleClickBoilerplateCommand = new RelayCommand<BoilerplateAnswer>(param => EditBoilerplate(param));
     MarkFeedReadCommand = new RelayCommand<RoutedEventArgs>(MarkFeedRead);
     DeleteFeedCommand = new RelayCommand<RoutedEventArgs>(DeleteFeed);
     EditFeedCommand = new RelayCommand<RoutedEventArgs>(EditFeed);
     ShowOptionsCommand = new RelayCommand<RoutedEventArgs>(ShowOptions);
     ImportOPMLCommand = new RelayCommand<RoutedEventArgs>(ImportOPML);
     ExportOPMLCommand = new RelayCommand<RoutedEventArgs>(ExportOPML);
     BoilerplateAnswers = new ObservableCollection<BoilerplateAnswer>();
     VersionInfo = "ForumSurfer Version " + Assembly.GetEntryAssembly().GetName().Version.ToString();
     _dialogCoordinator = DialogCoordinator.Instance;
 }
Ejemplo n.º 40
0
        public AddInstrumentIbViewModel(DialogCoordinator dialogService)
        {
            _dialogService = dialogService;
            CreateCommands();

            Random r = new Random();
            _client = new IBClient();

            //random connection id for this one...
            _client.Connect(Properties.Settings.Default.ibClientHost, Properties.Settings.Default.ibClientPort, r.Next(1000, 200000));

            AddedInstruments = new List<Instrument>();

            _client.ContractDetails += _client_ContractDetails;
            _client.ContractDetailsEnd += _client_ContractDetailsEnd;

            Observable
                .FromEventPattern<ConnectionClosedEventArgs>(_client, "ConnectionClosed")
                .ObserveOnDispatcher()
                .Subscribe(e => _logger.Log(NLog.LogLevel.Warn, "IB Instrument Adder connection closed."));

            Observable
                .FromEventPattern<NextValidIdEventArgs>(_client, "NextValidId")
                .Subscribe(e => _nextRequestID = e.EventArgs.OrderId);

            Observable
                .FromEventPattern<ErrorEventArgs>(_client, "Error")
                .ObserveOnDispatcher()
                .Subscribe(e =>
                {
                    if (e.EventArgs.ErrorMsg != "No security definition has been found for the request")
                    {
                        _logger.Log(NLog.LogLevel.Error,
                            string.Format("{0} - {1}", e.EventArgs.ErrorCode, e.EventArgs.ErrorMsg));
                    }

                    Status = e.EventArgs.ErrorMsg;
                    SearchUnderway = false;
                });

            Exchanges = new ObservableCollection<string> { "All" };
            _exchanges = new Dictionary<string, Exchange>();

            using (var context = new MyDBContext())
            {
                _thisDS = context.Datasources.First(x => x.Name == "Interactive Brokers");

                foreach (Exchange e in context.Exchanges)
                {
                    Exchanges.Add(e.Name);
                    _exchanges.Add(e.Name, e);
                }
            }

            Instruments = new ObservableCollection<Instrument>();
            InstrumentTypes = new ObservableCollection<InstrumentType>();

            //list the available types from our enum
            var values = MyUtils.GetEnumValues<InstrumentType>();
            foreach (var val in values)
            {
                InstrumentTypes.Add(val);
            }
        }
Ejemplo n.º 41
0
        public ShellViewModel()
        {
            messenger = new Messenger();
            messenger.closeTab = CloseTab;
            messenger.openIssue = OpenOrLocateIssueInTabs;
            messenger.tabSaveStatusChanged = CurrentTabIsDirty;

            dialogCoordinator = DialogCoordinator.Instance;

            Application.Current.MainWindow.Closing += new CancelEventHandler(MainWindow_Closing);

            dataAccess = new SQLiteController();

            Settings = new SettingsViewModel(dataAccess);

            Tabs = new ObservableCollection<ScreenBase>();
            Tabs.Add(new TabAllIssuesViewModel(messenger, dialogCoordinator, dataAccess));
                        
            SelectedTab = Tabs[0];
        }