public SyllableCard (string kana,TestPage root,int index) { progressLabel = new Label{Text=" ",TextColor=Color.Gray,XAlign=TextAlignment.Center}; Title = Character.getCategory(kana)+" Reading"; mCharacter = kana; mRoot = root; Grid grid = new Grid { HorizontalOptions=LayoutOptions.Fill, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition {Height = GridLength.Auto}, new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}, new RowDefinition {Height = GridLength.Auto}, } }; progressBar = new ProgressBar { Progress=0 }; //Setting the progress\ //double progress = (double)(mRoot.drillList.LastIndexOf/(double)mRoot.drillList.Count); double progress=0; if(root.GetType()==typeof(TestPage)) { progress = (double)(index/(double)StudyCard.initDrillCount); progressLabel.Text=index.ToString()+"/"+StudyCard.initDrillCount; progressBar.ProgressTo (progress, 10, Easing.Linear); } StackLayout layout = new StackLayout () { Orientation=StackOrientation.Vertical, Children = { progressLabel, progressBar } }; //Adding children to grid grid.Children.Add (layout,0,2); Button backButton = new Button{ Text = "→", HorizontalOptions= LayoutOptions.End, FontSize = 50 }; grid.Children.Add(backButton,0,0); grid.Children.Add (new Label { Text = kana.Replace('/','\n'), VerticalOptions = LayoutOptions.Center, XAlign=TextAlignment.Center, YAlign=TextAlignment.Center, FontSize = 100-15*kana.Split('/')[0].Length }, 0,1,0, 2); grid.Padding = new Thickness (10, Device.OnPlatform (10, 0, 0), 10, 10); Content = grid; backButton.Clicked+= BackButton_Clicked; }
public MessageView(ProgressBar progressBar) { InitializeComponent(); CustomInitial(); Controls controls = SetControls(progressBar); Device.BeginInvokeOnMainThread(() => { progressBar.ProgressTo(.5, 250, Easing.Linear); }); hubInitializer = new HubInitializer(controls); hubInitializer.HubInitial(); }
/// <summary> /// Initializes a new instance of the <see cref="SensusUI.ShareLocalDataStorePage"/> class. /// </summary> /// <param name="localDataStore">Local data store to display.</param> public ShareLocalDataStorePage(LocalDataStore localDataStore) { _cancellationTokenSource = new CancellationTokenSource(); Title = "Sharing Local Data Store"; StackLayout contentLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand }; Label statusLabel = new Label { FontSize = 20, HorizontalOptions = LayoutOptions.FillAndExpand }; contentLayout.Children.Add(statusLabel); ProgressBar progressBar = new ProgressBar { Progress = 0, HorizontalOptions = LayoutOptions.FillAndExpand }; contentLayout.Children.Add(progressBar); Button cancelButton = new Button { Text = "Cancel", FontSize = 20, HorizontalOptions = LayoutOptions.FillAndExpand }; cancelButton.Clicked += async (o, e) => { await Navigation.PopAsync(); }; contentLayout.Children.Add(cancelButton); new Thread(() => { string sharePath = SensusServiceHelper.Get().GetSharePath(".json"); bool errorWritingShareFile = false; try { // step 1: gather data. Device.BeginInvokeOnMainThread(() => statusLabel.Text = "Gathering data..."); List<Datum> localData = localDataStore.GetDataForRemoteDataStore(_cancellationTokenSource.Token, progress => { Device.BeginInvokeOnMainThread(() => { progressBar.ProgressTo(progress, 250, Easing.Linear); }); }); // step 2: write gathered data to file. if (!_cancellationTokenSource.IsCancellationRequested) { Device.BeginInvokeOnMainThread(() => { progressBar.ProgressTo(0, 0, Easing.Linear); statusLabel.Text = "Writing data to file..."; }); using (StreamWriter shareFile = new StreamWriter(sharePath)) { shareFile.WriteLine("["); int dataWritten = 0; foreach (Datum localDatum in localData) { if (_cancellationTokenSource.IsCancellationRequested) break; shareFile.Write((dataWritten++ == 0 ? "" : "," + Environment.NewLine) + localDatum.GetJSON(localDataStore.Protocol.JsonAnonymizer)); if (localData.Count >= 10 && (dataWritten % (localData.Count / 10)) == 0) Device.BeginInvokeOnMainThread(() => progressBar.ProgressTo(dataWritten / (double)localData.Count, 250, Easing.Linear)); } shareFile.WriteLine(Environment.NewLine + "]"); } } } catch (Exception ex) { errorWritingShareFile = true; string message = "Error writing share file: " + ex.Message; SensusServiceHelper.Get().FlashNotificationAsync(message); SensusServiceHelper.Get().Logger.Log(message, LoggingLevel.Normal, GetType()); } if (_cancellationTokenSource.IsCancellationRequested || errorWritingShareFile) { // always delete the file on cancel / error try { File.Delete(sharePath); } catch (Exception) { } // the only way to get a cancellation event is to back out of the window, so only pop if there was an error if(errorWritingShareFile) Device.BeginInvokeOnMainThread(async () => await Navigation.PopAsync()); } else { Device.BeginInvokeOnMainThread(async () => { await Navigation.PopAsync(); SensusServiceHelper.Get().ShareFileAsync(sharePath, "Sensus Data", "application/json"); }); } }).Start(); Content = new ScrollView { Content = contentLayout }; }
public ExampleCard (string key,string value, int index) { progressLabel = new Label{Text=" ",TextColor=Color.Gray,XAlign=TextAlignment.Center}; this.Title = key.Split(' ')[0]; if (kanaMode.Length > 0) this.Title = kanaMode.Split (' ') [1]+" Reading"; mKey = key; mValue = value; Grid grid = new Grid { HorizontalOptions=LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, RowDefinitions = { new RowDefinition {Height = GridLength.Auto}, new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}, new RowDefinition {Height = GridLength.Auto}, } }; Button backButton = new Button{ Text = "→", HorizontalOptions= LayoutOptions.End, FontSize = 50 }; grid.Children.Add(backButton,0,0); int fontSize1 = 40; if (Device.Idiom == TargetIdiom.Tablet) { fontSize1 = 80; } Label kanaLabel = new Label { Text = key.Split(' ')[0], VerticalOptions = LayoutOptions.Center, HorizontalOptions=LayoutOptions.Center, FontSize=fontSize1-key.Split(' ')[0].Length*2, }; grid.Children.Add (kanaLabel, 0, 1); progressBar = new ProgressBar { Progress=0 }; double progress=0; if (root.GetType () == typeof(CompMenu) || root.GetType () == typeof(TestPage)) { if(root.GetType()==typeof(CompMenu)) { progress = (double)(CompMenu.rrightCount/StudyCard.initDrillCount); progressLabel.Text=CompMenu.rrightCount.ToString()+"/"+StudyCard.initDrillCount.ToString(); } else if(root.GetType()==typeof(TestPage)) { progress = (double)(index/(double)StudyCard.initDrillCount); progressLabel.Text=index.ToString()+"/"+StudyCard.initDrillCount.ToString(); } progressBar.ProgressTo (progress, 10, Easing.Linear); StackLayout layout = new StackLayout () { Orientation=StackOrientation.Vertical, Children = { progressLabel, progressBar } }; grid.Children.Add (layout,0,2); } else grid.Children.Add (new Label (), 0, 2); Content = grid; grid.Padding = new Thickness (10, Device.OnPlatform (10, 0, 0), 10, 10); backButton.Clicked+= BackButton_Clicked; }
private void UpdateProgressBar(ProgressBar progressBar, float progressTo) { Device.BeginInvokeOnMainThread (() => { progressBar.ProgressTo(progressTo,250,Easing.Linear); }); }
/// <summary> /// Initializes a new instance of the <see cref="SensusUI.ShareLocalDataStorePage"/> class. /// </summary> /// <param name="localDataStore">Local data store to display.</param> public ShareLocalDataStorePage(LocalDataStore localDataStore) { _cancellationTokenSource = new CancellationTokenSource(); Title = "Sharing Local Data Store"; StackLayout contentLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand }; Label statusLabel = new Label { FontSize = 20, HorizontalOptions = LayoutOptions.FillAndExpand }; contentLayout.Children.Add(statusLabel); ProgressBar progressBar = new ProgressBar { Progress = 0, HorizontalOptions = LayoutOptions.FillAndExpand }; contentLayout.Children.Add(progressBar); Button cancelButton = new Button { Text = "Cancel", FontSize = 20, HorizontalOptions = LayoutOptions.FillAndExpand }; cancelButton.Clicked += async (o, e) => { await Navigation.PopAsync(); }; contentLayout.Children.Add(cancelButton); new Thread(() => { string sharePath = null; bool errorWritingShareFile = false; try { sharePath = SensusServiceHelper.Get().GetSharePath(".zip"); int numDataWritten = localDataStore.WriteDataToZipFile(sharePath, _cancellationTokenSource.Token, (message, progress) => { Device.BeginInvokeOnMainThread(async () => { uint duration = 250; if (message != null) { statusLabel.Text = message; duration = 0; } await progressBar.ProgressTo(progress, duration, Easing.Linear); }); }); if (numDataWritten == 0) throw new Exception("No data to share."); } catch (Exception ex) { errorWritingShareFile = true; string message = "Error sharing data: " + ex.Message; SensusServiceHelper.Get().FlashNotificationAsync(message); SensusServiceHelper.Get().Logger.Log(message, LoggingLevel.Normal, GetType()); } if (_cancellationTokenSource.IsCancellationRequested || errorWritingShareFile) { // always delete the file on cancel / error try { if (File.Exists(sharePath)) File.Delete(sharePath); } catch (Exception) { } // if the window has already been popped then the token will have been cancelled. pop the window if needed. if (!_cancellationTokenSource.IsCancellationRequested) Device.BeginInvokeOnMainThread(async () => await Navigation.PopAsync()); } else { Device.BeginInvokeOnMainThread(async () => { await Navigation.PopAsync(); SensusServiceHelper.Get().ShareFileAsync(sharePath, "Sensus Data: " + localDataStore.Protocol.Name, "application/zip"); }); } }).Start(); Content = new ScrollView { Content = contentLayout }; }
string kMode;//Used for checking the test status for changing the title public ExCardfront (string key,string value,int index) { kMode = kanaMode; progressLabel = new Label{Text=" ",TextColor=Color.Gray,XAlign=TextAlignment.Center}; mKey = key; mValue = value; var palleteFrame = BuildDrawingFrame (); gridView = new ContentView { Content = palleteFrame, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; string kana = key.Split(' ')[0]; string romaji = key.Substring (kana.Length); //Erase Button Button butErase = new Button { Text = " Erase ", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, BorderWidth=1, }; butErase.Clicked += ButErase_Clicked; grid= new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition {Height = GridLength.Auto}, new RowDefinition {Height = GridLength.Auto}, new RowDefinition {Height = new GridLength(2, GridUnitType.Star)}, new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}, new RowDefinition {Height = GridLength.Auto}, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, }, Children = { {new Label { Text="Tap outside writing field when done\nUse landscape view for maximum width (tablet only)", XAlign=TextAlignment.Center, YAlign=TextAlignment.Center, TextColor=Color.Gray, }, 0,0}, {butErase,0,1}, {gridView, 0,2}, {new Label { Text = romaji, XAlign=TextAlignment.Center, FontSize = 40, YAlign=TextAlignment.Center, },0,3 }, } }; progressBar = new ProgressBar { Progress=0 }; if (root.GetType () == typeof(CompMenu) || root.GetType () == typeof(TestPage)) { double progress=0; if(root.GetType()==typeof(CompMenu)) { progress = (double)(CompMenu.wrightCount/StudyCard.initDrillCount); progressLabel.Text = CompMenu.wrightCount.ToString () + "/" + StudyCard.initDrillCount.ToString (); } else if(root.GetType()==typeof(TestPage)) { progress = (double)(index/(double)StudyCard.initDrillCount); progressLabel.Text=index.ToString()+"/"+StudyCard.initDrillCount.ToString(); } progressBar.ProgressTo (progress, 10, Easing.Linear); StackLayout layout = new StackLayout () { Orientation=StackOrientation.Vertical, Children = { progressLabel, progressBar } }; grid.Children.Add (layout,0,4); } //backButton.Clicked += async BackButton_Clicked; Content = grid; // Accomodate iPhone status bar. Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 10); //NavigationPage.SetHasBackButton (this, false); Title="Writing"; // Set title to Katakana writing in test mode if (kanaMode.Length > 0) this.Title = kanaMode.Split (' ') [1]+" Writing"; var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped; this.Content.GestureRecognizers.Add (tapGestureRecognizer); }
public SyllableRCard (string kana,TestPage root,int index) { progressLabel = new Label{Text=" ",TextColor=Color.Gray,XAlign=TextAlignment.Center}; Title = Character.getCategory(kana)+" Writing"; string romaji = Character.kana_to_romaji (kana); mRoot = root; mKana = kana; ImageWithTouch DrawingImage; DrawingImage = new ImageWithTouch { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.White, CurrentLineColor = Color.Gray }; Button butErase = new Button { Text = " Erase ", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, BorderWidth=1, }; butErase.Clicked += ButErase_Clicked; DrawingImage.SetBinding (ImageWithTouch.CurrentLineColorProperty, "CurrentLineColor"); var palleteFrame = new Frame { BackgroundColor = Color.White, HasShadow = false, OutlineColor = Color.Black, Content = DrawingImage ,Padding=0 }; progressBar = new ProgressBar { Progress=0 }; double progress=0; if(root.GetType()==typeof(TestPage)) { progress = (double)(index/(double)StudyCard.initDrillCount); progressLabel.Text=index.ToString()+"/"+StudyCard.initDrillCount; } progressBar.ProgressTo (progress, 10, Easing.Linear); StackLayout layout = new StackLayout () { Orientation=StackOrientation.Vertical, Children = { progressLabel, progressBar } }; gridView = new ContentView { Content = palleteFrame, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; grid = new Grid { HorizontalOptions=LayoutOptions.Fill, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition {Height = GridLength.Auto}, new RowDefinition {Height = GridLength.Auto}, new RowDefinition {Height = new GridLength(2, GridUnitType.Star)}, new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}, new RowDefinition {Height = GridLength.Auto}, } }; grid.Children.Add(new Label { Text="Tap outside writing field when done\nUse landscape view for maximum width (tablet only)", XAlign=TextAlignment.Center, TextColor=Color.Gray} ,0,0); grid.Children.Add (new Label { Text = romaji.Replace('/','\n'), VerticalOptions = LayoutOptions.Center, XAlign=TextAlignment.Center, YAlign=TextAlignment.Center, FontSize = 50 }, 0, 3); grid.Children.Add (gridView, 0, 2); grid.Children.Add (butErase, 0, 1); grid.Children.Add (layout,0,4); Content = grid; Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 10); var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.Tapped+= TapGestureRecognizer_Tapped; this.Content.GestureRecognizers.Add (tapGestureRecognizer); }
public IEnumerable<ViewSample> BuildSamples() { var activityIndicator = new ActivityIndicator { IsEnabled = true, IsRunning = true }; var boxView = new BoxView { Color = Color.Red }; var button = new Button { Text = "Click Me" }; var buttonLabel = new Label { Text = "" }; button.Clicked += (sender, e) => { buttonLabel.Text = "I've been clicked!"; }; var buttonStack = new StackLayout { Children = { button, buttonLabel } }; var datePicker = new DatePicker (); var editor = new Editor { Text = "You can edit multiple lines of text here!" }; var entry = new Entry { Placeholder = "Enter a single line of text" }; var image = new Image { Source = ImageSource.FromUri(new Uri("http://placehold.it/350x150")) }; var label = new Label { Text = "Hello, I'm a label!" }; var picker = new Picker (); picker.Items.Add ("Red"); picker.Items.Add ("Green"); picker.Items.Add ("Purple"); picker.Items.Add ("Grey"); picker.Items.Add ("Black"); var progressBar = new ProgressBar { Progress = 0 }; var progressButton = new Button { Text = "Start Progressing" }; progressButton.Clicked += async (sender, e) => { await progressBar.ProgressTo(1.0, 500, Easing.Linear); }; var progressStack = new StackLayout { Children = { progressBar, progressButton } }; var searchBar = new SearchBar (); var slider = new Slider (); var stepper = new Stepper (); var @switch = new Switch (); var timePicker = new TimePicker (); var webView = new WebView { Source = new UrlWebViewSource { Url = "https://tutsplus.com/" }, VerticalOptions = LayoutOptions.FillAndExpand }; return new List<ViewSample> { new ViewSample { Name = "ActivityIndicator", View = activityIndicator }, new ViewSample { Name = "BoxView", View = boxView }, new ViewSample { Name = "Button", View = buttonStack }, new ViewSample { Name = "DatePicker", View = datePicker }, new ViewSample { Name = "Editor", View = editor }, new ViewSample { Name = "Entry", View = entry }, new ViewSample { Name = "Image", View = image }, new ViewSample { Name = "Label", View = label }, new ViewSample { Name = "Picker", View = picker }, new ViewSample { Name = "ProgressBar", View = progressStack }, new ViewSample { Name = "SearchBar", View = searchBar }, new ViewSample { Name = "Slider", View = slider }, new ViewSample { Name = "Stepper", View = stepper }, new ViewSample { Name = "Switch", View = @switch }, new ViewSample { Name = "TimePicker", View = timePicker }, new ViewSample { Name = "WebView", View = webView } }; }