Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/xamarin forms 3 1 #2

Merged
merged 2 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions MyGet.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorPicker.NS", "src\ColorPicker.NS.csproj", "{A0B72722-3B20-4970-BFE6-0E8B02DF0DF7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A0B72722-3B20-4970-BFE6-0E8B02DF0DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0B72722-3B20-4970-BFE6-0E8B02DF0DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0B72722-3B20-4970-BFE6-0E8B02DF0DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0B72722-3B20-4970-BFE6-0E8B02DF0DF7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D45162BA-C5BD-4AC7-A194-6C289E48177B}
EndGlobalSection
EndGlobal
16 changes: 10 additions & 6 deletions src/ColorPickerDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ protected async override Task<View> BuildContent()
TextColor = settings.TextColor,
EditorsColor = settings.EditorsColor,
ColorPreviewBorderColor = settings.ColorPreviewBorderColor,
SliderWidth = settings.SliderWidth,
ARGBEditorsWidth = settings.ARGBEditorsWidth,
ColorEditorWidth = settings.ColorEditorWidth,
EditAlpha = settings.EditAlfa,
};
colorEditor.Color = originalColor;
Expand Down Expand Up @@ -96,9 +93,6 @@ public class ColorDialogSettings : DialogSettings
{
public Color EditorsColor { get; set; } = Color.White;
public Color ColorPreviewBorderColor { get; set; }
public double SliderWidth { get; set; } = 256;
public double ARGBEditorsWidth { get; set; } = 65;
public double ColorEditorWidth { get; set; } = 120;
public bool EditAlfa { get; set; } = true;
}

Expand Down Expand Up @@ -185,6 +179,16 @@ protected async Task Initialize()
Padding = new Thickness(16),
HasShadow = true,
};

switch(Device.Idiom)
{
case TargetIdiom.Tablet:
case TargetIdiom.Desktop:
MainFrame.WidthRequest = 300;
break;
}


Children.Add(MainFrame);

MainConteiner = new StackLayout() { Orientation = StackOrientation.Vertical };
Expand Down
106 changes: 55 additions & 51 deletions src/ColorPickerMixer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
x:Class="Amporis.Xamarin.Forms.ColorPicker.ColorPickerMixer"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Amporis.Xamarin.Forms.ColorPicker">
xmlns:local="clr-namespace:Amporis.Xamarin.Forms.ColorPicker"
x:Name="pContent">
<ContentView.Content>
<Grid x:Name="gMain" Padding="0">

<Grid
x:Name="gMain"
Padding="0"
VerticalOptions="StartAndExpand">
<Grid.Resources>
<ResourceDictionary>
<local:ByteToStrConverter x:Key="cnvNumber" />
Expand All @@ -28,72 +31,73 @@
</Grid.Resources>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="120" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Frame
x:Name="fMixerPreview"
Grid.Row="0"
Grid.RowSpan="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0"
BackgroundColor="{Binding ColorVal.Value}"
BorderColor="{Binding ColorVal.Value}"
HorizontalOptions="FillAndExpand"
OutlineColor="{Binding ColorVal.Value}"
VerticalOptions="FillAndExpand" />

<Slider
Grid.Row="1"
Grid.Column="0"
IsVisible="{Binding EditAlpha}"
MaximumTrackColor="LightGray"
MinimumTrackColor="Black"
ThumbColor="Black"
Value="{Binding ColorVal.A, Mode=TwoWay}" />

<Slider
Grid.Row="2"
Grid.Column="0"
MaximumTrackColor="LightGray"
MinimumTrackColor="Red"
ThumbColor="Red"
Value="{Binding ColorVal.R, Mode=TwoWay}" />

<Slider
Grid.Row="3"
Grid.Column="0"
MaximumTrackColor="LightGray"
MinimumTrackColor="Green"
ThumbColor="Green"
Value="{Binding ColorVal.G, Mode=TwoWay}" />

<Slider
Grid.Row="4"
Grid.Column="0"
MaximumTrackColor="LightGray"
MinimumTrackColor="Blue"
ThumbColor="Blue"
Value="{Binding ColorVal.B, Mode=TwoWay}" />

<StackLayout
Grid.Row="5"
x:Name="sMixerControl"
Grid.Row="1"
Grid.RowSpan="1"
Grid.Column="0"
HorizontalOptions="Fill"
Orientation="Horizontal">
<Label Text="#" />
<Entry
x:Name="eColor"
HorizontalOptions="Start"
Text="{Binding ColorVal.Hexa, Mode=TwoWay}"
WidthRequest="{Binding ColorEditorWidth}" />
Grid.ColumnSpan="2"
HorizontalOptions="FillAndExpand"
Spacing="0"
VerticalOptions="StartAndExpand">
<Slider
Margin="0,10,0,10"
IsVisible="{Binding EditAlpha}"
MaximumTrackColor="LightGray"
MinimumTrackColor="Black"
ThumbColor="Black"
Value="{Binding ColorVal.A, Mode=TwoWay}" />
<Slider
Margin="0,10,0,10"
MaximumTrackColor="LightGray"
MinimumTrackColor="Red"
ThumbColor="Red"
Value="{Binding ColorVal.R, Mode=TwoWay}" />
<Slider
Margin="0,10,0,10"
MaximumTrackColor="LightGray"
MinimumTrackColor="Green"
ThumbColor="Green"
Value="{Binding ColorVal.G, Mode=TwoWay}" />
<Slider
Margin="0,10,0,10"
MaximumTrackColor="LightGray"
MinimumTrackColor="Blue"
ThumbColor="Blue"
Value="{Binding ColorVal.B, Mode=TwoWay}" />
<StackLayout
Margin="0,10,0,10"
HorizontalOptions="Fill"
Orientation="Horizontal">
<Label Text="#" />
<Entry
x:Name="eColor"
HorizontalOptions="Start"
Text="{Binding ColorVal.Hexa, Mode=TwoWay}"
WidthRequest="{Binding ColorEditorWidth}" />
</StackLayout>
</StackLayout>
</Grid>
</ContentView.Content>
Expand Down
20 changes: 5 additions & 15 deletions src/ColorPickerMixer.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

using XF = Xamarin.Forms;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

Expand All @@ -23,6 +15,7 @@ public ColorPickerMixer()
InitializeComponent();
eColor.Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeSentence);
gMain.BindingContext = this;

ColorVal.PropertyChanged += (s, e) =>
{
switch (e.PropertyName)
Expand All @@ -40,19 +33,16 @@ public ColorPickerMixer()

#region Settings

private Color textColor = XF.Color.Black;
private Color editorsColor = XF.Color.White;
private Color colorPreviewBorderColor = XF.Color.Black;
private Color textColor = Color.Black;
private Color editorsColor = Color.White;
private Color colorPreviewBorderColor = Color.Black;
private double sliderWidth = 256;
private double aRGBEditorsWidth = 65;
private double colorEditorWidth = 120;

public Color TextColor { get => textColor; set { textColor = value; ValueChanged(); } }
public Color EditorsColor { get => editorsColor; set { editorsColor = value; ValueChanged(); } }
public Color ColorPreviewBorderColor { get => colorPreviewBorderColor; set { colorPreviewBorderColor = value; ValueChanged(); } }
public double SliderWidth { get => sliderWidth; set { sliderWidth = value; ValueChanged(); } }
public double ARGBEditorsWidth { get => aRGBEditorsWidth; set { aRGBEditorsWidth = value; ValueChanged(); } }
public double ColorEditorWidth { get => colorEditorWidth; set { colorEditorWidth = value; ValueChanged(); } }
public bool EditAlpha { get => ColorVal.EditAlpha; set { ColorVal.EditAlpha = value; ColorVal.EditAlpha = value; ValueChanged(); } }

#endregion
Expand Down