<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomSlider"
x:Class="CustomSlider.MainPage">
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Vertical" >
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<Label x:Name="SeverityleftValue" VerticalOptions="Start" Text="0" FontSize="20" />
<Label Text="-" VerticalOptions="Center" FontSize="20" />
<Label x:Name="SeverityrightValue" VerticalOptions="End" Text="10" FontSize="20" />
</StackLayout>
<local:RangeSlider x:Name="rsldrSeverity" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" ActiveColorValue="#00A0D4" NormalColorValue="#95D0E7"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<Label x:Name="DurationleftValue" VerticalOptions="Start" Text="0" FontSize="20" />
<Label Text="-" VerticalOptions="Center" FontSize="20" />
<Label x:Name="DurationrightValue" VerticalOptions="End" Text="25" FontSize="20" />
</StackLayout>
<local:RangeSlider x:Name="rsldrDuraton" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" ActiveColorValue="#06A330" NormalColorValue="#CEEBD1"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace CustomSlider
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
rsldrSeverity.LowerValue = 0;
rsldrSeverity.UpperValue = 10;
rsldrSeverity.MinimumValue = 0;
rsldrSeverity.MaximumValue = 10;
rsldrSeverity.TextSize = 20;
rsldrSeverity.BarHeight = 10;
rsldrDuraton.BarHeight = 10;
rsldrDuraton.SliderNameValue = "IsDuration";
rsldrSeverity.SliderNameValue = "IsSeverity";
//rsldrDuraton.ActiveColorValue = Color.FromRgb(6, 163, 48);
//rsldrDuraton.NormalColorValue = Color.FromRgb(206,235,209);
rsldrDuraton.LowerValue = 0;
rsldrDuraton.UpperValue = 25;
rsldrDuraton.MinimumValue = 0;
rsldrDuraton.MaximumValue = 25;
rsldrDuraton.TextSize = 20;
//rangeSlider.ShowTextAboveThumbs = true;
rsldrSeverity.LowerValueChanged += RangeSlider_LowerValueChanged;
rsldrSeverity.UpperValueChanged += RangeSlider_UpperValueChanged;
rsldrDuraton.LowerValueChanged += RsldrDuraton_LowerValueChanged;
rsldrDuraton.UpperValueChanged += RsldrDuraton_UpperValueChanged;
}
private void RangeSlider_UpperValueChanged(object sender, EventArgs e)
{
int myIntRight = (int)Math.Ceiling(((sender as RangeSlider).UpperValue));
SeverityrightValue.Text = myIntRight.ToString();
}
private void RangeSlider_LowerValueChanged(object sender, EventArgs e)
{
int myIntLeft = (int)Math.Ceiling(((sender as RangeSlider).LowerValue));
SeverityleftValue.Text = myIntLeft.ToString();
}
void RsldrDuraton_UpperValueChanged(object sender, EventArgs e)
{
int myIntRightDuration = (int)Math.Ceiling(((sender as RangeSlider).UpperValue));
DurationrightValue.Text = myIntRightDuration > 24 ? "24+" : myIntRightDuration.ToString();
}
void RsldrDuraton_LowerValueChanged(object sender, EventArgs e)
{
int myIntLeftDuration = (int)Math.Ceiling(((sender as RangeSlider).LowerValue));
DurationleftValue.Text = myIntLeftDuration.ToString();
}
}
}
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomSlider"
x:Class="CustomSlider.MainPage">
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Vertical" >
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<Label x:Name="SeverityleftValue" VerticalOptions="Start" Text="0" FontSize="20" />
<Label Text="-" VerticalOptions="Center" FontSize="20" />
<Label x:Name="SeverityrightValue" VerticalOptions="End" Text="10" FontSize="20" />
</StackLayout>
<local:RangeSlider x:Name="rsldrSeverity" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" ActiveColorValue="#00A0D4" NormalColorValue="#95D0E7"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<Label x:Name="DurationleftValue" VerticalOptions="Start" Text="0" FontSize="20" />
<Label Text="-" VerticalOptions="Center" FontSize="20" />
<Label x:Name="DurationrightValue" VerticalOptions="End" Text="25" FontSize="20" />
</StackLayout>
<local:RangeSlider x:Name="rsldrDuraton" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" ActiveColorValue="#06A330" NormalColorValue="#CEEBD1"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace CustomSlider
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
rsldrSeverity.LowerValue = 0;
rsldrSeverity.UpperValue = 10;
rsldrSeverity.MinimumValue = 0;
rsldrSeverity.MaximumValue = 10;
rsldrSeverity.TextSize = 20;
rsldrSeverity.BarHeight = 10;
rsldrDuraton.BarHeight = 10;
rsldrDuraton.SliderNameValue = "IsDuration";
rsldrSeverity.SliderNameValue = "IsSeverity";
//rsldrDuraton.ActiveColorValue = Color.FromRgb(6, 163, 48);
//rsldrDuraton.NormalColorValue = Color.FromRgb(206,235,209);
rsldrDuraton.LowerValue = 0;
rsldrDuraton.UpperValue = 25;
rsldrDuraton.MinimumValue = 0;
rsldrDuraton.MaximumValue = 25;
rsldrDuraton.TextSize = 20;
//rangeSlider.ShowTextAboveThumbs = true;
rsldrSeverity.LowerValueChanged += RangeSlider_LowerValueChanged;
rsldrSeverity.UpperValueChanged += RangeSlider_UpperValueChanged;
rsldrDuraton.LowerValueChanged += RsldrDuraton_LowerValueChanged;
rsldrDuraton.UpperValueChanged += RsldrDuraton_UpperValueChanged;
}
private void RangeSlider_UpperValueChanged(object sender, EventArgs e)
{
int myIntRight = (int)Math.Ceiling(((sender as RangeSlider).UpperValue));
SeverityrightValue.Text = myIntRight.ToString();
}
private void RangeSlider_LowerValueChanged(object sender, EventArgs e)
{
int myIntLeft = (int)Math.Ceiling(((sender as RangeSlider).LowerValue));
SeverityleftValue.Text = myIntLeft.ToString();
}
void RsldrDuraton_UpperValueChanged(object sender, EventArgs e)
{
int myIntRightDuration = (int)Math.Ceiling(((sender as RangeSlider).UpperValue));
DurationrightValue.Text = myIntRightDuration > 24 ? "24+" : myIntRightDuration.ToString();
}
void RsldrDuraton_LowerValueChanged(object sender, EventArgs e)
{
int myIntLeftDuration = (int)Math.Ceiling(((sender as RangeSlider).LowerValue));
DurationleftValue.Text = myIntLeftDuration.ToString();
}
}
}
No comments:
Post a Comment