Exemplo n.º 1
0
 public DialogsViewModel()
 {
     //Sample 4
     OpenSample4DialogCommand   = new AnotherCommandImplementation(OpenSample4Dialog);
     AcceptSample4DialogCommand = new AnotherCommandImplementation(AcceptSample4Dialog);
     CancelSample4DialogCommand = new AnotherCommandImplementation(CancelSample4Dialog);
 }
Exemplo n.º 2
0
 public DocumentationLink(DocumentationLinkType type, string url, string label)
 {
     Label = label ?? type.ToString();
     Url   = url;
     Type  = type;
     Open  = new AnotherCommandImplementation(Execute);
 }
Exemplo n.º 3
0
        public IconPackViewModel(ISnackbarMessageQueue snackbarMessageQueue)
        {
            _snackbarMessageQueue = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue));

            OpenDotComCommand      = new AnotherCommandImplementation(OpenDotCom);
            SearchCommand          = new AnotherCommandImplementation(Search);
            CopyToClipboardCommand = new AnotherCommandImplementation(CopyToClipboard);
            _packIconKinds         = new Lazy <IEnumerable <PackIconKind> >(() =>
                                                                            Enum.GetValues(typeof(PackIconKind)).OfType <PackIconKind>()
                                                                            .OrderBy(k => k.ToString(), StringComparer.InvariantCultureIgnoreCase).ToList()
                                                                            );
        }
Exemplo n.º 4
0
        public TreesViewModel()
        {
            MovieCategories = new ObservableCollection <MovieCategory>
            {
                new MovieCategory("Action",
                                  new Movie("Predator", "John McTiernan"),
                                  new Movie("Alien", "Ridley Scott"),
                                  new Movie("Prometheus", "Ridley Scott")),
                new MovieCategory("Comedy",
                                  new Movie("EuroTrip", "Jeff Schaffer"),
                                  new Movie("EuroTrip", "Jeff Schaffer")
                                  )
            };

            AddCommand = new AnotherCommandImplementation(
                _ =>
            {
                if (!MovieCategories.Any())
                {
                    MovieCategories.Add(new MovieCategory(GenerateString(15)));
                }
                else
                {
                    var index = new Random().Next(0, MovieCategories.Count);

                    MovieCategories[index].Movies.Add(
                        new Movie(GenerateString(15), GenerateString(20)));
                }
            });

            RemoveSelectedItemCommand = new AnotherCommandImplementation(
                _ =>
            {
                var movieCategory = SelectedItem as MovieCategory;
                if (movieCategory != null)
                {
                    MovieCategories.Remove(movieCategory);
                }
                else
                {
                    var movie = SelectedItem as Movie;
                    if (movie == null)
                    {
                        return;
                    }
                    MovieCategories.FirstOrDefault(v => v.Movies.Contains(movie))?.Movies.Remove(movie);
                }
            },
                _ => SelectedItem != null);
        }
Exemplo n.º 5
0
 public Buttons()
 {
     InitializeComponent();
     FloatingActionDemoCommand = new AnotherCommandImplementation(Execute);
 }
Exemplo n.º 6
0
        public ButtonsViewModel()
        {
            var autoStartingActionCountdownStart = DateTime.Now;
            var demoRestartCountdownComplete     = DateTime.Now;
            var dismissRequested = false;

            DismissComand     = new AnotherCommandImplementation(_ => dismissRequested = true);
            ShowDismissButton = true;

            #region DISMISS button demo control
            //just some demo code for the DISMISS button...it's up to you to set
            //up the progress on the button as it would be with a progress bar.
            //and then hide the button, do whatever action you want to do
            new DispatcherTimer(
                TimeSpan.FromMilliseconds(100),
                DispatcherPriority.Normal,
                new EventHandler((o, e) =>
            {
                if (dismissRequested)
                {
                    ShowDismissButton            = false;
                    dismissRequested             = false;
                    demoRestartCountdownComplete = DateTime.Now.AddSeconds(3);
                    DismissButtonProgress        = 0;
                }

                if (ShowDismissButton)
                {
                    var totalDuration   = autoStartingActionCountdownStart.AddSeconds(5).Ticks - autoStartingActionCountdownStart.Ticks;
                    var currentDuration = DateTime.Now.Ticks - autoStartingActionCountdownStart.Ticks;
                    var autoCountdownPercentComplete = 100.0 / totalDuration * currentDuration;
                    DismissButtonProgress            = autoCountdownPercentComplete;

                    if (DismissButtonProgress >= 100)
                    {
                        demoRestartCountdownComplete = DateTime.Now.AddSeconds(3);
                        ShowDismissButton            = false;
                        UpdateDemoRestartCountdownText(demoRestartCountdownComplete, out _);
                    }
                }
                else
                {
                    UpdateDemoRestartCountdownText(demoRestartCountdownComplete, out bool isComplete);
                    if (isComplete)
                    {
                        autoStartingActionCountdownStart = DateTime.Now;
                        ShowDismissButton = true;
                    }
                }
            }), Dispatcher.CurrentDispatcher);
            #endregion

            IncrementOrClickMeCountCommand = new AnotherCommandImplementation(_ => OrClickMeCount += 1);
            OrClickMeCount = 0;

            //just some demo code for the SAVE button
            SaveComand = new AnotherCommandImplementation(_ =>
            {
                if (IsSaveComplete == true)
                {
                    IsSaveComplete = false;
                    return;
                }

                if (SaveProgress != 0)
                {
                    return;
                }

                var started = DateTime.Now;
                IsSaving    = true;

                new DispatcherTimer(
                    TimeSpan.FromMilliseconds(50),
                    DispatcherPriority.Normal,
                    new EventHandler((o, e) =>
                {
                    var totalDuration          = started.AddSeconds(3).Ticks - started.Ticks;
                    var currentProgress        = DateTime.Now.Ticks - started.Ticks;
                    var currentProgressPercent = 100.0 / totalDuration * currentProgress;

                    SaveProgress = currentProgressPercent;

                    if (SaveProgress >= 100)
                    {
                        IsSaveComplete = true;
                        IsSaving       = false;
                        SaveProgress   = 0;
                        ((DispatcherTimer)o).Stop();
                    }
                }), Dispatcher.CurrentDispatcher);
            });
        }