Example #1
0
        private Button GetEvent(Event eventItem, DateTime start)
        {
            var leftTime = eventItem.Start - start;
            var leftMargin = (leftTime.TotalMinutes / 30) * TimeWidth;

            var widthTime = eventItem.End - eventItem.Start;
            var width = (widthTime.TotalMinutes / 30) * TimeWidth;

            return new Button
            {
                DataContext = eventItem,
                Margin = new Thickness(leftMargin, 0, 0, 0),
                Width = width + 1,
                Style = (Style)Application.Current.Resources["EventButtonStyle"]
            };
        }
Example #2
0
        async void ShowEventInfo_Click(object sender, RoutedEventArgs e)
        {
            _activeEventItem = (Event) ((FrameworkElement) sender).DataContext;

            string favoriteButton = "Favoritt";

            if (viewModel.Favorites.Any(s => s == _activeEventItem.Title))
                favoriteButton = "Fjern favoritt";


            DataTransferManager.GetForCurrentView().DataRequested += OnDataRequested;
            var dialog = new MessageDialog(string.Format("{0:HH:mm} - {1:HH:mm}\r\n\r\n{2}", _activeEventItem.Start, _activeEventItem.End, _activeEventItem.Description), _activeEventItem.Title);
            dialog.Commands.Add(new UICommand(favoriteButton, command =>
            {
                DataTransferManager.GetForCurrentView().DataRequested -= OnDataRequested;
                var favList = viewModel.Favorites.ToList();

                if (!viewModel.Favorites.Any(s => s == _activeEventItem.Title))
                    favList.Add(_activeEventItem.Title);
                else
                    favList.Remove(_activeEventItem.Title);

                    viewModel.Favorites = favList;
                    App.SaveFavorites(favList);
            }));
            dialog.Commands.Add(new UICommand("Del", OnCLickShare));
            dialog.Commands.Add(new UICommand("Lukk", command =>
            {
                DataTransferManager.GetForCurrentView().DataRequested -= OnDataRequested;
            }));

            dialog.DefaultCommandIndex = 2;

            await dialog.ShowAsync();
        }