示例#1
0
        private async void StoreNewEntry(object sender, RoutedEventArgs e)
        {
            newEditOk.Click -= StoreNewEntry;
            newDelete.Click -= CancelNewEntry;
            cumulatedData    = await StorageInterface.ReadFromLocalFolder("ToDo.list");

            cumulatedData = newOverview.Text + INTRASPLIT + newDetails.Text + INTERSPLIT + cumulatedData;
            await StorageInterface.WriteToLocalFolder("ToDo.list", cumulatedData);

            await Upload();
            await Refresh();
        }
示例#2
0
        private async void Download()
        {
            String Token = await StorageInterface.ReadFromLocalFolder("Storage.Garfield.token");

            if (Token == null || Token.Equals(""))
            {
                await UserInteraction.ShowDialogAsync("INFORMATION", "You will now be prompted to chose a Folder in which to save the Comic. This App will create a new Folder within the Folder you selected, called \"Garfield\", which will be used to store the images (in order not to confuse them with your files). The App will remember the location you have picked and will use this location until you change it in the Settings.");

                Token = await StorageInterface.PickExternalStorageFolder();

                await StorageInterface.WriteToLocalFolder("Storage.Garfield.token", Token);
            }
            try
            {
                await StorageInterface.WriteBytesToKnownFolder("Garfield/Garfield_" + date.ToString("yyyy_MM_dd") + ".gif", await NetworkInterface.DownloadGarfield(date), Token);
            }
            catch (Exception e)
            {
                e.PrintStackTrace();
                UserInteraction.ShowToast("ERROR! Could not save file.", "Garfield");
                return;
            }
            UserInteraction.ShowToast("Comic has successfully been saved", "Garfield");
        }
示例#3
0
        private async Task Refresh()
        {
            Stack.Children.Clear();
            Init();
            await Download();

            cumulatedData = await StorageInterface.ReadFromLocalFolder("ToDo.list");

            if (cumulatedData == null)
            {
                await StorageInterface.WriteToLocalFolder("ToDo.list", "");
                await Upload();
            }
            String[] entries = cumulatedData.Split(INTERSPLIT);

            index = entries.Length;

            border     = new Border[index];
            grid       = new Grid[index];
            left       = new ColumnDefinition[index];
            right      = new ColumnDefinition[index];
            leftPanel  = new StackPanel[index];
            overview   = new TextBox[index];
            details    = new TextBox[index];
            rightPanel = new StackPanel[index];
            delete     = new AppBarButton[index];
            editOk     = new AppBarButton[index];
            isEditing  = new Boolean[index];

            for (int i = 0; i < index; i++)
            {
                if (entries[i].Equals(""))
                {
                    continue;
                }
                if (!entries[i].Contains(INTRASPLIT))
                {
                    entries[i] += INTRASPLIT + " ";
                }
                if (entries[i].EndsWith(INTRASPLIT))
                {
                    entries[i] += " ";
                }
                String[] X = entries[i].Split(INTRASPLIT);

                /*for(int j = 0; j < X.Length; j++)
                 * {
                 *  if (X[j].Equals(""))
                 *  {
                 *      X[j] = " ";
                 *  }
                 * }*/



                border[i] = new Border()
                {
                    BorderThickness = new Thickness(2),
                    BorderBrush     = new SolidColorBrush(Colors.LightGray),
                    CornerRadius    = new CornerRadius(15),
                    Padding         = new Thickness(5),
                    Margin          = new Thickness(5)
                };

                grid[i] = new Grid();

                left[i] = new ColumnDefinition();

                right[i] = new ColumnDefinition()
                {
                    Width = GridLength.Auto
                };

                leftPanel[i] = new StackPanel();

                overview[i] = new TextBox()
                {
                    IsHitTestVisible = false,
                    IsReadOnly       = true,
                    FontSize         = 20,
                    //BorderThickness = new Thickness(0),
                    Text = X[0]
                };

                details[i] = new TextBox()
                {
                    IsHitTestVisible = false,
                    AcceptsReturn    = true,
                    TextWrapping     = TextWrapping.Wrap,
                    Text             = X[1]
                };

                rightPanel[i] = new StackPanel();

                delete[i] = new AppBarButton()
                {
                    Icon    = new SymbolIcon(Symbol.Delete),
                    Content = "Erledigt"
                };

                editOk[i] = new AppBarButton()
                {
                    Icon    = new SymbolIcon(Symbol.Edit),
                    Content = "Bearbeiten"
                };

                Stack.Children.Add(border[i]);

                border[i].Child = grid[i];

                grid[i].ColumnDefinitions.Add(left[i]);
                grid[i].ColumnDefinitions.Add(right[i]);

                grid[i].Children.Add(leftPanel[i]);

                leftPanel[i].Children.Add(overview[i]);
                leftPanel[i].Children.Add(details[i]);
                leftPanel[i].SetValue(Grid.ColumnProperty, 0);

                grid[i].Children.Add(rightPanel[i]);

                rightPanel[i].Children.Add(delete[i]);
                rightPanel[i].Children.Add(editOk[i]);
                rightPanel[i].SetValue(Grid.ColumnProperty, 1);

                delete[i].Click += Delete_Click;

                editOk[i].Click += EditOk_Click;
            }
        }