public DocumentationLink(DocumentationLinkType type, string url, string?label)
 {
     Label = label ?? type.ToString();
     Url   = url;
     Type  = type;
     Open  = new AnotherCommandImplementation(Execute);
 }
 public DialogsViewModel()
 {
     //Sample 4
     OpenSample4DialogCommand   = new AnotherCommandImplementation(OpenSample4Dialog);
     AcceptSample4DialogCommand = new AnotherCommandImplementation(AcceptSample4Dialog);
     CancelSample4DialogCommand = new AnotherCommandImplementation(CancelSample4Dialog);
 }
예제 #3
0
        public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue)
        {
            _allItems = GenerateDemoItems(snackbarMessageQueue);
            FilterItems(null);

            MovePrevCommand = new AnotherCommandImplementation(
                _ =>
            {
                if (!string.IsNullOrWhiteSpace(SearchKeyword))
                {
                    SearchKeyword = string.Empty;
                }

                SelectedIndex--;
            },
                _ => SelectedIndex > 0);

            MoveNextCommand = new AnotherCommandImplementation(
                _ =>
            {
                if (!string.IsNullOrWhiteSpace(SearchKeyword))
                {
                    SearchKeyword = string.Empty;
                }

                SelectedIndex++;
            },
                _ => SelectedIndex < _allItems.Count - 1);
        }
예제 #4
0
        public MainWindowViewModel()
        {
            DemoItems = new ObservableCollection <DemoItem>(new[]
            {
                new DemoItem(
                    "Home",
                    typeof(Home),
                    new[]
                {
                    new DocumentationLink(
                        DocumentationLinkType.Wiki,
                        $"{ConfigurationManager.AppSettings["GitHub"]}/wiki",
                        "WIKI"),
                    DocumentationLink.DemoPageLink <Home>()
                }
                    )
            });

            foreach (var item in GenerateDemoItems().OrderBy(i => i.Name))
            {
                DemoItems.Add(item);
            }

            _demoItemsView        = CollectionViewSource.GetDefaultView(DemoItems);
            _demoItemsView.Filter = DemoItemsFilter;

            HomeCommand = new AnotherCommandImplementation(
                _ =>
            {
                SearchKeyword = string.Empty;
                SelectedIndex = 0;
            });

            MovePrevCommand = new AnotherCommandImplementation(
                _ =>
            {
                if (!string.IsNullOrWhiteSpace(SearchKeyword))
                {
                    SearchKeyword = string.Empty;
                }

                SelectedIndex--;
            },
                _ => SelectedIndex > 0);

            MoveNextCommand = new AnotherCommandImplementation(
                _ =>
            {
                if (!string.IsNullOrWhiteSpace(SearchKeyword))
                {
                    SearchKeyword = string.Empty;
                }

                SelectedIndex++;
            },
                _ => SelectedIndex < DemoItems.Count - 1);
        }
        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);
        }
예제 #6
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 <PackIconKindGroup> >(() =>
                                                                         Enum.GetNames(typeof(PackIconKind))
                                                                         .GroupBy(k => (PackIconKind)Enum.Parse(typeof(PackIconKind), k))
                                                                         .Select(g => new PackIconKindGroup(g))
                                                                         .OrderBy(x => x.Kind)
                                                                         .ToList());
        }
        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<PackIconKindGroup>>(() =>
                Enum.GetNames(typeof(PackIconKind))
                    .GroupBy(k => (PackIconKind)Enum.Parse(typeof(PackIconKind), k))
                    .Select(g => new PackIconKindGroup(g))
                    .OrderBy(x => x.Kind)
                    .ToList());

            var helper = new PaletteHelper();
            if (helper.GetThemeManager() is { } themeManager)
            {
                themeManager.ThemeChanged += ThemeManager_ThemeChanged;
            }
            SetDefaultIconColors();
        }
예제 #8
0
        public ButtonsViewModel()
        {
            FloatingActionDemoCommand = new AnotherCommandImplementation(FloatingActionDemo);

            var autoStartingActionCountdownStart = DateTime.Now;
            var demoRestartCountdownComplete     = DateTime.Now;
            var dismissRequested = false;

            DismissCommand    = 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
            SaveCommand = 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;
                        if (o is DispatcherTimer timer)
                        {
                            timer.Stop();
                        }
                    }
                }), Dispatcher.CurrentDispatcher);
            });
        }