diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-05-12 08:52:51 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-05-12 08:52:51 +0300 |
| commit | d66c5e376f12aff4cd69e09dbe629a5a069392cc (patch) | |
| tree | a4ef8062195249612d4353d8880991cb9666fc33 | |
| parent | 04078aa1cce858187cd4c87fd1472b3c816597df (diff) | |
| download | Tango-d66c5e376f12aff4cd69e09dbe629a5a069392cc.tar.gz Tango-d66c5e376f12aff4cd69e09dbe629a5a069392cc.zip | |
Implemented About screens on TCC.
Implemented 2D and 3D card emulations on color capture module.
56 files changed, 1087 insertions, 89 deletions
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java index 63852f2bc..fbb524754 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ApplicationComponent.java @@ -6,7 +6,9 @@ import com.twine.colorcapture.dialogs.processing.ProcessingDialog; import com.twine.colorcapture.dialogs.progress.ProgressDialog; import com.twine.colorcapture.dialogs.success.SuccessDialog; import com.twine.colorcapture.dialogs.welcome.WelcomeDialog; +import com.twine.colorcapture.views.about.AboutFragment; import com.twine.colorcapture.views.capture.CaptureFragment; +import com.twine.colorcapture.views.card.CardFragment; import com.twine.colorcapture.views.mycolors.MyColorsFragment; import com.twine.colorcapture.views.loading.LoadingActivity; import com.twine.colorcapture.views.main.MainActivity; @@ -15,6 +17,7 @@ import com.twine.colorcapture.views.rename.RenameFragment; import com.twine.colorcapture.views.result.ResultFragment; import com.twine.colorcapture.views.sendtoemail.SendToEmailFragment; import com.twine.colorcapture.views.sendtomachine.SendToMachineFragment; +import com.twine.colorcapture.views.twine.TwineFragment; import javax.inject.Singleton; @@ -57,4 +60,10 @@ public interface ApplicationComponent void inject(RenameFragment renameFragment); void inject(SendToEmailFragment sendToEmailFragment); + + void inject(AboutFragment aboutFragment); + + void inject(TwineFragment twineFragment); + + void inject(CardFragment cardFragment); } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java index 8b43a5cec..0a161bd7b 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/dagger/ViewModelsModule.java @@ -9,7 +9,9 @@ import com.twine.colorcapture.dialogs.success.SuccessDialogVM; import com.twine.colorcapture.dialogs.welcome.WelcomeDialogVM; import com.twine.colorcapture.navigation.INavigationProvider; import com.twine.colorcapture.notification.INotificationProvider; +import com.twine.colorcapture.views.about.AboutFragmentVM; import com.twine.colorcapture.views.capture.CaptureFragmentVM; +import com.twine.colorcapture.views.card.CardFragmentVM; import com.twine.colorcapture.views.loading.LoadingActivityVM; import com.twine.colorcapture.views.mycolors.MyColorsFragmentVM; import com.twine.colorcapture.views.main.MainActivityVM; @@ -18,6 +20,7 @@ import com.twine.colorcapture.views.rename.RenameFragmentVM; import com.twine.colorcapture.views.result.ResultFragmentVM; import com.twine.colorcapture.views.sendtoemail.SendToEmailFragmentVM; import com.twine.colorcapture.views.sendtomachine.SendToMachineFragmentVM; +import com.twine.colorcapture.views.twine.TwineFragmentVM; import com.twine.colorcapture.web.ITCCService; import javax.inject.Singleton; @@ -105,6 +108,27 @@ public class ViewModelsModule @Provides @Singleton + public AboutFragmentVM provideAboutFragmentVM() + { + return new AboutFragmentVM(); + } + + @Provides + @Singleton + public TwineFragmentVM provideTwineFragmentVM() + { + return new TwineFragmentVM(); + } + + @Provides + @Singleton + public CardFragmentVM provideCardFragmentVM(INavigationProvider navigationProvider) + { + return new CardFragmentVM(navigationProvider); + } + + @Provides + @Singleton public ProgressDialogVM provideProgressDialogVM() { return new ProgressDialogVM(); diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java index 0d54f2bf4..64b7ba9f9 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/navigation/NavigationFragment.java @@ -14,4 +14,12 @@ public enum NavigationFragment @PreventHistory @HideHeader SendToEmail, + @PreventHistory + About, + @PreventHistory + Twine, + @PreventHistory + Card, + @PreventHistory + CardOrder, } diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/AboutFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/AboutFragment.java new file mode 100644 index 000000000..bdd82b50e --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/AboutFragment.java @@ -0,0 +1,30 @@ +package com.twine.colorcapture.views.about; + +import android.app.Fragment; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.FragmentAboutBinding; +import com.twine.colorcapture.mvvm.FragmentBase; + +public class AboutFragment extends FragmentBase<FragmentAboutBinding,AboutFragmentVM> implements IAboutFragment +{ + + @Override + protected int getLayoutId() + { + return R.layout.fragment_about; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } + + @Override + public String getTitle() + { + return "About"; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/AboutFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/AboutFragmentVM.java new file mode 100644 index 000000000..d7e4a6704 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/AboutFragmentVM.java @@ -0,0 +1,53 @@ +package com.twine.colorcapture.views.about; + +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.net.Uri; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.mvvm.DependencyProperty; +import com.twine.colorcapture.mvvm.RelayCommand; +import com.twine.colorcapture.mvvm.ViewModelBase; +import com.twine.colorcapture.navigation.TabState; +import com.twine.colorcapture.navigation.TabStateManager; + +public class AboutFragmentVM extends ViewModelBase<IAboutFragment> +{ + public RelayCommand contactCommand; + public RelayCommand termsOfUseCommand; + public RelayCommand privacyPolicyCommand; + + public DependencyProperty<String> version; + + public AboutFragmentVM() + { + contactCommand = new RelayCommand(() -> openBrowser("http://twine-s.com/contact/contact-us")); + termsOfUseCommand = new RelayCommand(() -> openBrowser("http://twine-s.com/privacy-policy")); + privacyPolicyCommand = new RelayCommand(() -> openBrowser("http://twine-s.com/privacy-policy")); + version = new DependencyProperty<>(""); + + try + { + PackageInfo pInfo = App.getContext().getPackageManager().getPackageInfo(App.getContext().getPackageName(), 0); + version.set(Integer.toString(pInfo.versionCode)); + } + catch (PackageManager.NameNotFoundException e) + { + e.printStackTrace(); + } + } + + private void openBrowser(String url) + { + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + App.getContext().startActivity(browserIntent); + } + + @Override + protected void onNavigatedTo() + { + super.onNavigatedTo(); + TabStateManager.getInstance().state.set(TabState.More); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/IAboutFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/IAboutFragment.java new file mode 100644 index 000000000..2343421c3 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/about/IAboutFragment.java @@ -0,0 +1,7 @@ +package com.twine.colorcapture.views.about; + +import com.twine.colorcapture.mvvm.IView; + +public interface IAboutFragment extends IView +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/CardFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/CardFragment.java new file mode 100644 index 000000000..bdcac205d --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/CardFragment.java @@ -0,0 +1,29 @@ +package com.twine.colorcapture.views.card; + +import android.app.Fragment; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.FragmentCardBinding; +import com.twine.colorcapture.mvvm.FragmentBase; + +public class CardFragment extends FragmentBase<FragmentCardBinding,CardFragmentVM> implements ICardFragment +{ + @Override + protected int getLayoutId() + { + return R.layout.fragment_card; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } + + @Override + public String getTitle() + { + return "Card"; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/CardFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/CardFragmentVM.java new file mode 100644 index 000000000..357a94e23 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/CardFragmentVM.java @@ -0,0 +1,15 @@ +package com.twine.colorcapture.views.card; + +import com.twine.colorcapture.mvvm.ViewModelBase; +import com.twine.colorcapture.navigation.INavigationProvider; + +import javax.inject.Inject; + +public class CardFragmentVM extends ViewModelBase<ICardFragment> +{ + @Inject + public CardFragmentVM(INavigationProvider navigationProvider) + { + + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/ICardFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/ICardFragment.java new file mode 100644 index 000000000..464bf4fab --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/card/ICardFragment.java @@ -0,0 +1,8 @@ +package com.twine.colorcapture.views.card; + +import com.twine.colorcapture.mvvm.IView; + +public interface ICardFragment extends IView +{ + +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java index c7c8eb7a1..72a088fa2 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/main/MainActivityVM.java @@ -32,6 +32,8 @@ public class MainActivityVM extends ViewModelBase<IMainActivity> public RelayCommand moreCommand; public RelayCommand howToUseCommand; + public RelayCommand aboutCommand; + public RelayCommand aboutTwineCommand; @Inject public MainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider) @@ -44,6 +46,8 @@ public class MainActivityVM extends ViewModelBase<IMainActivity> navigationProvider.addFragmentNavigationListener(this::onNavigation); howToUseCommand = new RelayCommand(this::handleHowToUseCommand); + aboutCommand = new RelayCommand(this::handleAboutCommand); + aboutTwineCommand = new RelayCommand(this::handleAboutTwineCommand); captureCommand = new RelayCommand(this::handleCaptureCommand); myColorsCommand = new RelayCommand(this::handleMyColorsCommand); @@ -81,7 +85,21 @@ public class MainActivityVM extends ViewModelBase<IMainActivity> private void handleHowToUseCommand() { view.closeMenu(); - notificationProvider.showDialog(new WelcomeDialog(), (vm) -> { }); + notificationProvider.showDialog(new WelcomeDialog(), (vm) -> + { + }); + } + + private void handleAboutCommand() + { + view.closeMenu(); + navigationProvider.navigateTo(NavigationFragment.About, true, false); + } + + private void handleAboutTwineCommand() + { + view.closeMenu(); + navigationProvider.navigateTo(NavigationFragment.Twine, true, false); } private void onNavigation(NavigationFragment navigationFragment) diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/ITwineFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/ITwineFragment.java new file mode 100644 index 000000000..f915eb8e3 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/ITwineFragment.java @@ -0,0 +1,7 @@ +package com.twine.colorcapture.views.twine; + +import com.twine.colorcapture.mvvm.IView; + +public interface ITwineFragment extends IView +{ +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/TwineFragment.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/TwineFragment.java new file mode 100644 index 000000000..5f2c722df --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/TwineFragment.java @@ -0,0 +1,29 @@ +package com.twine.colorcapture.views.twine; + +import android.app.Fragment; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.R; +import com.twine.colorcapture.databinding.FragmentTwineBinding; +import com.twine.colorcapture.mvvm.FragmentBase; + +public class TwineFragment extends FragmentBase<FragmentTwineBinding,TwineFragmentVM> implements ITwineFragment +{ + @Override + protected int getLayoutId() + { + return R.layout.fragment_twine; + } + + @Override + protected void inject() + { + App.getComponent().inject(this); + } + + @Override + public String getTitle() + { + return "Twine"; + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/TwineFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/TwineFragmentVM.java new file mode 100644 index 000000000..2afe56b0d --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/twine/TwineFragmentVM.java @@ -0,0 +1,33 @@ +package com.twine.colorcapture.views.twine; + +import android.content.Intent; +import android.net.Uri; + +import com.twine.colorcapture.App; +import com.twine.colorcapture.mvvm.RelayCommand; +import com.twine.colorcapture.mvvm.ViewModelBase; +import com.twine.colorcapture.navigation.TabState; +import com.twine.colorcapture.navigation.TabStateManager; + +public class TwineFragmentVM extends ViewModelBase<ITwineFragment> +{ + public RelayCommand contactCommand; + + public TwineFragmentVM() + { + contactCommand = new RelayCommand(() -> openBrowser("http://twine-s.com/contact/contact-us")); + } + + private void openBrowser(String url) + { + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + App.getContext().startActivity(browserIntent); + } + + @Override + protected void onNavigatedTo() + { + super.onNavigatedTo(); + TabStateManager.getInstance().state.set(TabState.More); + } +} diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png Binary files differindex 5920654e4..35367194d 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/logo_twine.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/logo_twine.png Binary files differnew file mode 100644 index 000000000..363924f69 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-hdpi/logo_twine.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png Binary files differindex f0889f9a3..27b1e5f35 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/logo_twine.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/logo_twine.png Binary files differnew file mode 100644 index 000000000..7df280515 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-mdpi/logo_twine.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/icon.png Binary files differindex 40e46cd1f..6bc4398b2 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/icon.png +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/logo_twine.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/logo_twine.png Binary files differnew file mode 100644 index 000000000..633caaad5 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-sw600dp-mdpi/logo_twine.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png Binary files differindex 40e46cd1f..6bc4398b2 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/logo_twine.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/logo_twine.png Binary files differnew file mode 100644 index 000000000..633caaad5 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xhdpi/logo_twine.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png Binary files differindex 968ebf639..4247642f9 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/logo_twine.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/logo_twine.png Binary files differnew file mode 100644 index 000000000..011679c81 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxhdpi/logo_twine.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png Binary files differindex 25650a2ff..3c0905522 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/icon.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/logo_twine.png b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/logo_twine.png Binary files differnew file mode 100644 index 000000000..955e28e25 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable-xxxhdpi/logo_twine.png diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/dark_gradient.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/dark_gradient.xml new file mode 100644 index 000000000..336cd7f4b --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/drawable/dark_gradient.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <gradient + android:type="linear" + android:angle="-90" + android:startColor="#0e2340" + android:endColor="#07101e" /> +</shape>
\ No newline at end of file diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml index 9830c53db..cfe7878ff 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/activity_main.xml @@ -28,7 +28,8 @@ <LinearLayout android:id="@+id/header" android:layout_width="match_parent" - android:layout_height="80dp" + android:layout_height="wrap_content" + android:paddingBottom="10dp" android:background="@color/colorPrimaryBackground" android:gravity="center_vertical" android:elevation="20dp" diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_error.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_error.xml index 4e172c584..64bfee94d 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_error.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_error.xml @@ -19,6 +19,7 @@ android:layout_height="@dimen/dialog_height" android:layout_centerVertical="true" android:layout_centerHorizontal="true" + android:elevation="10dp" android:background="@drawable/border_primary_background"> <FrameLayout diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_progress.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_progress.xml index b0cd8215a..0bd706518 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_progress.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_progress.xml @@ -18,6 +18,7 @@ android:layout_width="@dimen/dialog_width" android:layout_height="@dimen/dialog_height" android:layout_centerVertical="true" + android:elevation="10dp" android:layout_centerHorizontal="true" android:background="@drawable/border_primary_background"> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_success.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_success.xml index 8e6bfb3fc..4c099af9f 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_success.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_success.xml @@ -18,6 +18,7 @@ android:layout_width="@dimen/dialog_width" android:layout_height="@dimen/dialog_height" android:layout_centerVertical="true" + android:elevation="10dp" android:layout_centerHorizontal="true" android:background="@drawable/border_primary_background"> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml index 44bc25f51..e9dc5d0b9 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/dialog_welcome.xml @@ -25,6 +25,7 @@ android:background="@drawable/welcome_dialog_border" android:foregroundGravity="center" android:layout_marginLeft="30dp" + android:layout_marginRight="30dp" android:layout_marginTop="50dp" android:layout_marginBottom="100dp" diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_about.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_about.xml new file mode 100644 index 000000000..923feca18 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_about.xml @@ -0,0 +1,173 @@ +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + <data> + + <variable + name="vm" + type="com.twine.colorcapture.views.about.AboutFragmentVM" /> + </data> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorDarkBackground" + android:layoutDirection="ltr" + android:paddingLeft="20dp" + android:paddingRight="20dp" + tools:context="com.twine.colorcapture.views.about.AboutFragment"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_gravity="center" + android:layout_marginTop="15dp" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.07" + android:text="About SnapMatch" + android:textSize="@dimen/large_font_size" /> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/txtTitle" + android:layout_centerHorizontal="true" + android:layout_marginTop="40dp" + android:lineSpacingExtra="4dp" + android:fontFamily="@font/flexo_light" + android:gravity="center" + android:letterSpacing="0.07" + android:text="@string/about_info" + android:textAlignment="center" + android:textSize="@dimen/medium_font_size" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_margin="20dp" + android:orientation="vertical"> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="2dp" + android:background="@drawable/accent_gradient" /> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_margin="20dp" + android:fontFamily="@font/flexo_medium" + android:letterSpacing="0.06" + android:text="Terms of use" + android:textSize="@dimen/medium_font_size" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="2dp" + android:background="@drawable/accent_gradient" /> + + </LinearLayout> + + <Button + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/button_transparent_fill_ripple" + bind:command="@{vm.termsOfUseCommand}"/> + </FrameLayout> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_margin="20dp" + android:fontFamily="@font/flexo_medium" + android:letterSpacing="0.06" + android:text="Privacy Policy" + android:textSize="@dimen/medium_font_size" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="2dp" + android:background="@drawable/accent_gradient" /> + + </LinearLayout> + + <Button + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/button_transparent_fill_ripple" + bind:command="@{vm.privacyPolicyCommand}"/> + </FrameLayout> + + </LinearLayout> + + + <com.twine.colorcapture.controls.CircleActionButton + android:layout_width="@dimen/result_button_width" + android:layout_centerHorizontal="true" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_marginLeft="40dp" + android:layout_marginRight="40dp" + android:layout_marginBottom="60dp" + bind:text=" Contact us" + bind:textSize="@dimen/medium_font_size" + bind:src="@drawable/email" + bind:command="@{vm.contactCommand}" + android:clickable="true" /> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:layout_margin="20dp" + android:layout_gravity="center" + android:orientation="horizontal"> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/flexo_medium" + android:textColor="@color/text_gray" + android:letterSpacing="0.06" + android:text="Version" + android:textSize="@dimen/small_font_size" /> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/flexo_medium" + android:layout_marginLeft="10dp" + android:letterSpacing="0.06" + android:textColor="@color/text_gray" + android:text="@{vm.version}" + android:textSize="@dimen/small_font_size" /> + + </LinearLayout> + + </RelativeLayout> +</layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_card.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_card.xml new file mode 100644 index 000000000..04160c140 --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_card.xml @@ -0,0 +1,50 @@ +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + <data> + + <variable + name="vm" + type="com.twine.colorcapture.views.card.CardFragmentVM" /> + </data> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorDarkBackground" + android:layoutDirection="ltr" + android:paddingLeft="20dp" + android:paddingRight="20dp" + tools:context="com.twine.colorcapture.views.card.CardFragment"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_gravity="center" + android:layout_marginTop="15dp" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.07" + android:text="Get a twine TTC™ card " + android:textSize="@dimen/large_font_size" /> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtPro" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/txtTitle" + android:layout_centerHorizontal="true" + android:layout_marginTop="40dp" + android:lineSpacingExtra="4dp" + android:fontFamily="@font/flexo_light" + android:gravity="center" + android:letterSpacing="0.07" + android:text="@string/order_card_pro" + android:textAlignment="center" + android:textSize="@dimen/medium_font_size" /> + + + </RelativeLayout> +</layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_twine.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_twine.xml new file mode 100644 index 000000000..02b15004f --- /dev/null +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/fragment_twine.xml @@ -0,0 +1,104 @@ +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bind="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + <data> + + <variable + name="vm" + type="com.twine.colorcapture.views.twine.TwineFragmentVM" /> + </data> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/dark_gradient" + android:layoutDirection="ltr" + android:paddingLeft="20dp" + android:paddingRight="20dp" + tools:context="com.twine.colorcapture.views.twine.TwineFragment"> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txtTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_gravity="center" + android:layout_marginTop="15dp" + android:fontFamily="@font/flexo_bold" + android:letterSpacing="0.07" + android:text="About Twine" + android:textSize="@dimen/large_font_size" /> + + <ImageView + android:id="@+id/img" + android:layout_below="@id/txtTitle" + android:layout_centerHorizontal="true" + android:layout_marginTop="40dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/logo_twine"/> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txt_desc" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/img" + android:layout_centerHorizontal="true" + android:layout_marginTop="40dp" + android:lineSpacingExtra="4dp" + android:fontFamily="@font/flexo_light" + android:gravity="center" + android:letterSpacing="0.07" + android:text="@string/about_twine" + android:textAlignment="center" + android:textSize="@dimen/medium_font_size" /> + + <android.support.v7.widget.AppCompatTextView + android:id="@+id/txt3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/txt_desc" + android:layout_centerHorizontal="true" + android:layout_marginTop="40dp" + android:lineSpacingExtra="4dp" + android:fontFamily="@font/flexo_light" + android:gravity="center" + android:letterSpacing="0.07" + android:text="To learn more visit us at:" + android:textAlignment="center" + android:textSize="@dimen/medium_font_size" /> + + <android.support.v7.widget.AppCompatTextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/txt3" + android:layout_marginTop="5dp" + android:layout_centerHorizontal="true" + android:lineSpacingExtra="4dp" + android:fontFamily="@font/flexo_light" + android:gravity="center" + android:letterSpacing="0.07" + android:textColorLink="@color/white" + android:text="http://twine-s.com" + android:textAlignment="center" + android:autoLink="web" + android:textSize="@dimen/medium_font_size" /> + + + <com.twine.colorcapture.controls.CircleActionButton + android:layout_width="@dimen/result_button_width" + android:layout_centerHorizontal="true" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_marginLeft="40dp" + android:layout_marginRight="40dp" + android:layout_marginBottom="60dp" + bind:text=" Contact us" + bind:textSize="@dimen/medium_font_size" + bind:src="@drawable/email" + bind:command="@{vm.contactCommand}" + android:clickable="true" /> + + </RelativeLayout> +</layout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/side_menu.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/side_menu.xml index 3ee18a1b7..e5e15f4b7 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/layout/side_menu.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/layout/side_menu.xml @@ -75,6 +75,7 @@ <Button android:layout_width="match_parent" android:layout_height="match_parent" + bind:command="@{vm.aboutTwineCommand}" android:background="@drawable/button_transparent_fill_ripple"/> </FrameLayout> @@ -120,6 +121,7 @@ <Button android:layout_width="match_parent" android:layout_height="match_parent" + bind:command="@{vm.aboutCommand}" android:background="@drawable/button_transparent_fill_ripple"/> </FrameLayout> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml index f3be907a5..22828c302 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/values/colors.xml @@ -12,7 +12,7 @@ <color name="colorPrimaryBackground">#0e2340</color> <color name="colorDarkBackground">#07101e</color> - <color name="colorBlueMask">#EB09172A</color> + <color name="colorBlueMask">#EB071220</color> <color name="colorWhiteMask">#B71D3150</color> <color name="colorGradientAccent1">#26d440</color> diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/values/sizes.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/values/sizes.xml index 825ac5312..6b64e2eb1 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/values/sizes.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/values/sizes.xml @@ -3,6 +3,6 @@ <dimen name="dialog_width">313.9dp</dimen> <dimen name="dialog_height">202.6dp</dimen> <dimen name="progress_size">80dp</dimen> - <dimen name="result_color_size">67dp</dimen> - <dimen name="result_button_width">-1</dimen> + <dimen name="result_color_size">63dp</dimen> + <dimen name="result_button_width">-1px</dimen> </resources>
\ No newline at end of file diff --git a/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml b/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml index ebb9cfd4c..f187544db 100644 --- a/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml +++ b/Software/Android_Studio/ColorCapture/app/src/main/res/values/strings.xml @@ -17,4 +17,20 @@ <string name="my_color">My Color</string> <string name="have_a_twine_system"><u>Have a Twine system?</u></string> + + <string name="about_info"> + <![CDATA[SnapMatch is a simple and easy to use color matching application based on Twine’s TCC™ technology. Just place the card on an object and it will match the color!]]> + </string> + + <string name="about_twine"> + <![CDATA[Twine is revolutionizing the textile industry with its digital thread technology.]]> + </string> + + <string name="order_card_pro"> + <![CDATA[For optimal color matching, we highly recommend to order an official Twine TTC™ card]]> + </string> + + <string name="order_card_home"> + <![CDATA[Want to use the application right away? No problem. You can print the card using your office/home color printer.]]> + </string> </resources> diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf Binary files differindex 820bcbc61..9cc3cbf08 100644 --- a/Software/DB/TCC/TCC.mdf +++ b/Software/DB/TCC/TCC.mdf diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf Binary files differindex 8a6641c03..ad5e3250a 100644 --- a/Software/DB/TCC/TCC_log.ldf +++ b/Software/DB/TCC/TCC_log.ldf diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex c15b35e54..2cc411b99 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 0444fe826..a2d8d9b19 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/CaptureMode.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/CaptureMode.cs new file mode 100644 index 000000000..389bff178 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/CaptureMode.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.ColorCapture +{ + public enum CaptureMode + { + Camera, + Emulated2D, + Emulated3D + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Contracts/IMainView.cs new file mode 100644 index 000000000..3c0a5ecca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Contracts/IMainView.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ColorCapture.Contracts +{ + public interface IMainView : IView + { + void SetCardSource(BitmapSource source); + BitmapSource GetViewportImage(); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Converters/CaptureModeToVisibilityConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Converters/CaptureModeToVisibilityConverter.cs new file mode 100644 index 000000000..8a134eb35 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Converters/CaptureModeToVisibilityConverter.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.MachineStudio.ColorCapture.Converters +{ + public class CaptureModeToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var mode1 = (CaptureMode)value; + var mode2 = (CaptureMode)parameter; + return mode1 == mode2 ? Visibility.Visible : Visibility.Hidden; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj index a38db1b53..1c04917c0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj @@ -32,6 +32,15 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="AForge"> + <HintPath>..\..\..\Referenced Assemblies\AForge\AForge.dll</HintPath> + </Reference> + <Reference Include="AForge.Imaging"> + <HintPath>..\..\..\Referenced Assemblies\AForge\AForge.Imaging.dll</HintPath> + </Reference> + <Reference Include="AForge.Math"> + <HintPath>..\..\..\Referenced Assemblies\AForge\AForge.Math.dll</HintPath> + </Reference> <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> </Reference> @@ -41,6 +50,15 @@ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="HelixToolkit"> + <HintPath>..\..\..\Referenced Assemblies\Helix\HelixToolkit.dll</HintPath> + </Reference> + <Reference Include="HelixToolkit.Wpf"> + <HintPath>..\..\..\Referenced Assemblies\Helix\HelixToolkit.Wpf.dll</HintPath> + </Reference> + <Reference Include="HelixToolkit.Wpf.Input"> + <HintPath>..\..\..\Referenced Assemblies\Helix\HelixToolkit.Wpf.Input.dll</HintPath> + </Reference> <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath> </Reference> @@ -96,10 +114,13 @@ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="CaptureMode.cs" /> <Compile Include="ColorCaptureSettings.cs" /> <Compile Include="ColorCaptureModule.cs" /> + <Compile Include="Contracts\IMainView.cs" /> <Compile Include="Controls\ColorMatrixControl.cs" /> <Compile Include="Controls\IndexedUniformGrid.cs" /> + <Compile Include="Converters\CaptureModeToVisibilityConverter.cs" /> <Compile Include="Models\BenchmarkItem.cs" /> <Compile Include="Models\CaptureConfig.cs" /> <Compile Include="Models\CaptureItem.cs" /> @@ -150,6 +171,10 @@ <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> <Name>Tango.BL</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.BrushPicker\Tango.BrushPicker.csproj"> + <Project>{40085232-aced-4cbe-945b-90ba8153c151}</Project> + <Name>Tango.BrushPicker</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.CircularGauge\Tango.CircularGauge.csproj"> <Project>{6efd5895-177b-4bbb-af52-29f4d53b3fbd}</Project> <Name>Tango.CircularGauge</Name> @@ -182,6 +207,10 @@ <Project>{9652f972-2bd1-4283-99cb-fc6240434c17}</Project> <Name>Tango.Video</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Visuals\Tango.Visuals.csproj"> + <Project>{cf7c0ff4-9440-42cf-83b8-c060772792d4}</Project> + <Name>Tango.Visuals</Name> + </ProjectReference> <ProjectReference Include="..\..\..\TCC\Tango.TCC.BL\Tango.TCC.BL.csproj"> <Project>{f209fae8-73f9-441b-97f4-0844a0279390}</Project> <Name>Tango.TCC.BL</Name> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs index 2f8d421cd..38c86c297 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs @@ -1,4 +1,7 @@ -using ColorMine.ColorSpaces; +using AForge; +using AForge.Imaging.Filters; +using AForge.Math.Random; +using ColorMine.ColorSpaces; using ColorMine.ColorSpaces.Comparisons; using Microsoft.Win32; using Microsoft.WindowsAPICodePack.Dialogs; @@ -14,11 +17,15 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; using Tango.Core; using Tango.Core.Commands; +using Tango.Core.Threading; using Tango.CSV; using Tango.Logging; +using Tango.MachineStudio.ColorCapture.Contracts; using Tango.MachineStudio.ColorCapture.Models; +using Tango.MachineStudio.ColorCapture.Views; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.Video; @@ -29,7 +36,7 @@ using Tango.Video.DirectCapture; namespace Tango.MachineStudio.ColorCapture.ViewModels { - public class MainViewVM : StudioViewModel + public class MainViewVM : StudioViewModel<IMainView> { private INotificationProvider _notification; private CardDetector _cardDetector; @@ -40,6 +47,8 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels private byte[] templateBitmap; private DeltaEComparisons _lastDeltaEComparison; private IColorSpaceComparison _deltaEComparison; + private ActionTimer _emulatedActionTimer; + private DispatcherTimer _timer3D; public IVideoCaptureProvider VideoProvider { get; set; } @@ -155,11 +164,11 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels set { _barcode = value; RaisePropertyChangedAuto(); } } - private bool _isEmulated; - public bool IsEmulated + private CaptureMode _captureMode; + public CaptureMode CaptureMode { - get { return _isEmulated; } - set { _isEmulated = value; RaisePropertyChangedAuto(); } + get { return _captureMode; } + set { _captureMode = value; RaisePropertyChangedAuto(); OnCaptureModeChanged(); } } private int emulatedR; @@ -183,6 +192,58 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels set { emulatedB = value; RaisePropertyChangedAuto(); OnEmulatedColorChanged(); } } + private Color _emulatedColor; + public Color EmulatedColor + { + get { return _emulatedColor; } + set + { + _emulatedColor = value; RaisePropertyChangedAuto(); + emulatedR = _emulatedColor.R; + emulatedG = _emulatedColor.G; + emulatedB = _emulatedColor.B; + RaisePropertyChanged(nameof(EmulatedR)); + RaisePropertyChanged(nameof(EmulatedG)); + RaisePropertyChanged(nameof(EmulatedB)); + OnEmulatedColorChanged(); + } + } + + private double _brightness; + public double Brightness + { + get { return _brightness; } + set { _brightness = value; RaisePropertyChangedAuto(); OnEmulatedColorChanged(); } + } + + private double _contrast; + public double Contrast + { + get { return _contrast; } + set { _contrast = value; RaisePropertyChangedAuto(); OnEmulatedColorChanged(); } + } + + private double _saturation; + public double Saturation + { + get { return _saturation; } + set { _saturation = value; RaisePropertyChangedAuto(); OnEmulatedColorChanged(); } + } + + private double _noise; + public double Noise + { + get { return _noise; } + set { _noise = value; RaisePropertyChangedAuto(); OnEmulatedColorChanged(); } + } + + private BitmapSource _emulatedImage; + public BitmapSource EmulatedImage + { + get { return _emulatedImage; } + set { _emulatedImage = value; RaisePropertyChangedAuto(); } + } + public RelayCommand ImportBenchmarksCommand { get; set; } public RelayCommand ExportBenchmarksCommand { get; set; } @@ -197,9 +258,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels public RelayCommand SelectTemplateFileCommand { get; set; } - public RelayCommand LiveCommand { get; set; } - - public RelayCommand EmulatedCommand { get; set; } + public RelayCommand<CaptureMode> CaptureModeCommand { get; set; } public MainViewVM() { @@ -223,8 +282,13 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels SelectSamplesFolderCommand = new RelayCommand(SelectSamplesFolder); SelectBenchmarksFileCommand = new RelayCommand(SelectBenchmarkFile); SelectTemplateFileCommand = new RelayCommand(SelectTemplateFile); - LiveCommand = new RelayCommand(() => IsEmulated = false); - EmulatedCommand = new RelayCommand(() => IsEmulated = true); + CaptureModeCommand = new RelayCommand<CaptureMode>((mode) => CaptureMode = mode); + _emulatedActionTimer = new ActionTimer(TimeSpan.FromMilliseconds(100)); + + _timer3D = new DispatcherTimer(); + _timer3D.Interval = TimeSpan.FromSeconds(1); + _timer3D.Tick += _timer3D_Tick; + _timer3D.Start(); } public MainViewVM(IVideoCaptureProvider videoProvider, INotificationProvider notificationProvider) : this() @@ -234,6 +298,14 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels SelectedVideoDevice = videoProvider.AvailableCaptureDevices.FirstOrDefault(); } + private void OnCaptureModeChanged() + { + if (CaptureMode == CaptureMode.Emulated2D || CaptureMode == CaptureMode.Emulated3D) + { + OnEmulatedColorChanged(); + } + } + private void SelectTemplateFile() { OpenFileDialog dlg = new OpenFileDialog(); @@ -445,7 +517,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels private void OnVideoFrameReceived(object sender, Video.DirectShow.EventArguments.FrameReceivedEventArgs args) { - if (_abort || IsPaused || IsEmulated) return; + if (_abort || IsPaused || CaptureMode != CaptureMode.Camera) return; PerformDetection(args.BitmapSource); } @@ -604,57 +676,106 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels { if (EmulatedColors != null && EmulatedColors.Count > Config.TargetIndex) { + var colors = EmulatedColors.ToList(); + Color color = Color.FromRgb((byte)EmulatedR, (byte)EmulatedG, (byte)EmulatedB); - EmulatedColors[Config.TargetIndex] = color; + colors[Config.TargetIndex] = color; - if (IsEmulated) + if (CaptureMode == CaptureMode.Emulated2D) { - DetectionOutput output = new DetectionOutput(); - output.ColorMatrix.AddRange(EmulatedColors.Select(x => new DetectionColor() + _emulatedActionTimer.ResetReplace(() => { - R = x.R, - G = x.G, - B = x.B, - })); - output.ProcessedColor = new DetectionColor() - { - R = EmulatedR, - G = EmulatedG, - B = EmulatedB, - }; + DetectionOutput output = new DetectionOutput(); + output.ColorMatrix.AddRange(colors.ToList().Select(x => new DetectionColor() + { + R = x.R, + G = x.G, + B = x.B, + })); + output.ProcessedColor = new DetectionColor() + { + R = EmulatedR, + G = EmulatedG, + B = EmulatedB, + }; - var bitmap = ColorDetector.DetectionOutputToImage(new DetectionInput() - { - Columns = Config.Columns, - Rows = Config.Rows, - TargetIndex = Config.TargetIndex + var bitmap = ColorDetector.DetectionOutputToImage(new DetectionInput() + { + Columns = Config.Columns, + Rows = Config.Rows, + TargetIndex = Config.TargetIndex - }, output, Config.SampleWidth, Config.SampleHeight, true, true, false); + }, output, Config.SampleWidth, Config.SampleHeight, true, true, false); - float rectWidth = (bitmap.Width / Config.Columns) - 4; - float rectHeight = (bitmap.Height / Config.Rows) - 4; + bitmap = bitmap.ConvertTo24Bit(); - using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) - { - g.DrawImage(Properties.Resources.topleft, new System.Drawing.RectangleF(0, 0, rectWidth, rectHeight)); - g.DrawImage(Properties.Resources.topRight, new System.Drawing.RectangleF(bitmap.Width - rectWidth, 0, rectWidth, rectHeight)); + //Apply filters. - g.DrawImage(Properties.Resources.bottomLeft, new System.Drawing.RectangleF(0, bitmap.Height - rectHeight, rectWidth, rectHeight)); - g.DrawImage(Properties.Resources.bottomRight, new System.Drawing.RectangleF(bitmap.Width - rectWidth, bitmap.Height - rectHeight, rectWidth, rectHeight)); - } + if (Brightness != 0) + { + BrightnessCorrection brightness = new BrightnessCorrection((int)Brightness); + brightness.ApplyInPlace(bitmap); + } + if (Contrast > 0) + { + ContrastCorrection contrast = new ContrastCorrection((int)Contrast); + contrast.ApplyInPlace(bitmap); + } + if (Saturation != 0) + { + SaturationCorrection saturation = new SaturationCorrection((float)Saturation); + saturation.ApplyInPlace(bitmap); + } + if (Noise > 0) + { + IRandomNumberGenerator generator = new UniformGenerator(new Range((int)-Noise, (int)Noise)); + AdditiveNoise noise = new AdditiveNoise(generator); + noise.ApplyInPlace(bitmap); + } - var bitmapContainer = new System.Drawing.Bitmap(640, 480); - using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmapContainer)) - { - g.Clear(System.Drawing.Color.White); - g.DrawImageUnscaled(bitmap, (bitmapContainer.Width / 2) - bitmap.Width / 2, (bitmapContainer.Height / 2) - bitmap.Height / 2); - } - bitmap.Dispose(); + float rectWidth = (bitmap.Width / Config.Columns) - 4; + float rectHeight = (bitmap.Height / Config.Rows) - 4; + + using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) + { + g.DrawImage(Properties.Resources.topleft, new System.Drawing.RectangleF(0, 0, rectWidth, rectHeight)); + g.DrawImage(Properties.Resources.topRight, new System.Drawing.RectangleF(bitmap.Width - rectWidth, 0, rectWidth, rectHeight)); + + g.DrawImage(Properties.Resources.bottomLeft, new System.Drawing.RectangleF(0, bitmap.Height - rectHeight, rectWidth, rectHeight)); + g.DrawImage(Properties.Resources.bottomRight, new System.Drawing.RectangleF(bitmap.Width - rectWidth, bitmap.Height - rectHeight, rectWidth, rectHeight)); + } + + var bitmapContainer = new System.Drawing.Bitmap(640, 480); + using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmapContainer)) + { + g.Clear(System.Drawing.Color.White); + g.DrawImageUnscaled(bitmap, (bitmapContainer.Width / 2) - bitmap.Width / 2, (bitmapContainer.Height / 2) - bitmap.Height / 2); + } + + InvokeUI(() => + { + EmulatedImage = bitmap.ToBitmapSource(); + bitmap.Dispose(); + View.SetCardSource(EmulatedImage); + }); - PerformDetection(bitmapContainer.ToBitmapSource()); + PerformDetection(bitmapContainer.ToBitmapSource()); - bitmapContainer.Dispose(); + bitmapContainer.Dispose(); + }); + } + } + } + + private void _timer3D_Tick(object sender, EventArgs e) + { + if (CaptureMode == CaptureMode.Emulated3D) + { + if (EmulatedColors != null) + { + var source = View.GetViewportImage(); + PerformDetection(source); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml index 616bdcfed..e11ae3fa3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml @@ -8,13 +8,17 @@ xmlns:gauge="clr-namespace:Tango.CircularGauge;assembly=Tango.CircularGauge" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.ColorCapture.ViewModels" + xmlns:visuals="clr-namespace:Tango.Visuals;assembly=Tango.Visuals" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:controls="clr-namespace:Tango.MachineStudio.ColorCapture.Controls" + xmlns:localConverters="clr-namespace:Tango.MachineStudio.ColorCapture.Converters" xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:tcc="clr-namespace:Tango.TCC.BL;assembly=Tango.TCC.BL" xmlns:realtimeGraphX="clr-namespace:RealTimeGraphX.WPF;assembly=RealTimeGraphX.WPF" xmlns:global="clr-namespace:Tango.MachineStudio.ColorCapture" + xmlns:helix="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf" + xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" xmlns:local="clr-namespace:Tango.MachineStudio.ColorCapture.Views" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="#202020" Foreground="#BBBBBB" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -39,6 +43,7 @@ <SolidColorBrush x:Key="LightBackground" Color="#303030" /> <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <localConverters:CaptureModeToVisibilityConverter x:Key="CaptureModeToVisibilityConverter" /> </ResourceDictionary> </UserControl.Resources> @@ -165,7 +170,7 @@ </DockPanel> </Grid> - <Grid Visibility="{Binding IsEmulated,Converter={StaticResource BoolToVisConverter}}"> + <Grid Visibility="{Binding CaptureMode,Converter={StaticResource CaptureModeToVisibilityConverter},ConverterParameter={x:Static global:CaptureMode.Emulated2D}}"> <Grid.RowDefinitions> <RowDefinition Height="60"/> <RowDefinition Height="1*"/> @@ -177,33 +182,112 @@ <Grid Background="{StaticResource LightBackground}" Grid.Row="1" Margin="1"> <Border HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="1" BorderBrush="{StaticResource Accent}" Padding="20" Background="{StaticResource Background}"> - <StackPanel Orientation="Horizontal"> - <Border BorderThickness="1" BorderBrush="{StaticResource Accent}"> - <controls:ColorMatrixControl Colors="{Binding EmulatedColors,Mode=OneWay}" Width="200" Height="210" Columns="10" Rows="11" Background="{StaticResource LightBackground}" /> - </Border> + <StackPanel> + <StackPanel + Orientation="Horizontal"> + <Border BorderThickness="1" BorderBrush="{StaticResource Accent}" Width="200" Height="210"> + <!--<controls:ColorMatrixControl Colors="{Binding EmulatedColors,Mode=OneWay}" Columns="10" Rows="11" Background="{StaticResource LightBackground}" />--> + <Image Source="{Binding EmulatedImage}" Stretch="Fill" /> + </Border> - <UniformGrid Columns="3" Width="150" Height="200" Margin="40 0 0 0"> - <DockPanel> - <TextBlock Foreground="{StaticResource Red}" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 0 0 5" Text="{Binding EmulatedR,FallbackValue=0}"></TextBlock> - <TextBlock Foreground="{StaticResource Red}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 5 0 0">R</TextBlock> - <Slider Foreground="{StaticResource Red}" Orientation="Vertical" HorizontalAlignment="Center" Minimum="0" IsSnapToTickEnabled="True" TickFrequency="1" Maximum="255" Value="{Binding EmulatedR,Mode=TwoWay}"></Slider> - </DockPanel> - <DockPanel> - <TextBlock Foreground="{StaticResource Green}" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 0 0 5" Text="{Binding EmulatedG,FallbackValue=0}"></TextBlock> - <TextBlock Foreground="{StaticResource Green}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 5 0 0">G</TextBlock> - <Slider Foreground="{StaticResource Green}" Orientation="Vertical" HorizontalAlignment="Center" Minimum="0" IsSnapToTickEnabled="True" TickFrequency="1" Maximum="255" Value="{Binding EmulatedG,Mode=TwoWay}"></Slider> - </DockPanel> - <DockPanel> - <TextBlock Foreground="{StaticResource Blue}" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 0 0 5" Text="{Binding EmulatedB,FallbackValue=0}"></TextBlock> - <TextBlock Foreground="{StaticResource Blue}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 5 0 0">B</TextBlock> - <Slider Foreground="{StaticResource Blue}" Orientation="Vertical" HorizontalAlignment="Center" Minimum="0" IsSnapToTickEnabled="True" TickFrequency="1" Maximum="255" Value="{Binding EmulatedB,Mode=TwoWay}"></Slider> - </DockPanel> - </UniformGrid> + <UniformGrid Columns="3" Width="150" Height="200" Margin="40 0 0 0"> + <DockPanel> + <TextBlock Foreground="{StaticResource Red}" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 0 0 5" Text="{Binding EmulatedR,FallbackValue=0}"></TextBlock> + <TextBlock Foreground="{StaticResource Red}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 5 0 0">R</TextBlock> + <Slider Foreground="{StaticResource Red}" Orientation="Vertical" HorizontalAlignment="Center" Minimum="0" IsSnapToTickEnabled="True" TickFrequency="1" Maximum="255" Value="{Binding EmulatedR,Mode=TwoWay}"></Slider> + </DockPanel> + <DockPanel> + <TextBlock Foreground="{StaticResource Green}" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 0 0 5" Text="{Binding EmulatedG,FallbackValue=0}"></TextBlock> + <TextBlock Foreground="{StaticResource Green}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 5 0 0">G</TextBlock> + <Slider Foreground="{StaticResource Green}" Orientation="Vertical" HorizontalAlignment="Center" Minimum="0" IsSnapToTickEnabled="True" TickFrequency="1" Maximum="255" Value="{Binding EmulatedG,Mode=TwoWay}"></Slider> + </DockPanel> + <DockPanel> + <TextBlock Foreground="{StaticResource Blue}" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 0 0 5" Text="{Binding EmulatedB,FallbackValue=0}"></TextBlock> + <TextBlock Foreground="{StaticResource Blue}" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 5 0 0">B</TextBlock> + <Slider Foreground="{StaticResource Blue}" Orientation="Vertical" HorizontalAlignment="Center" Minimum="0" IsSnapToTickEnabled="True" TickFrequency="1" Maximum="255" Value="{Binding EmulatedB,Mode=TwoWay}"></Slider> + </DockPanel> + </UniformGrid> + + <brushPicker:BrushPicker BrushTypeVisibility="Collapsed" Height="220" Margin="20 8 0 0" Width="240" Background="Transparent" BorderThickness="0" Color="{Binding EmulatedColor,Mode=TwoWay}" /> + </StackPanel> + + <UniformGrid Columns="4" Margin="0 10 0 0"> + <StackPanel> + <visuals:Knob x:Name="knobBrightness" ToolTip="{Binding Brightness}" PreviewMouseDoubleClick="OnResetBrightness" Value="{Binding Brightness,Mode=TwoWay}" Minimum="-100" Maximum="100" Width="80" TicksHeight="5" TicksHighlightBrush="{StaticResource Accent}" /> + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Brightness</TextBlock> + </StackPanel> + + <StackPanel> + <visuals:Knob x:Name="knobContrast" ToolTip="{Binding Contrast}" PreviewMouseDoubleClick="knobContrast_PreviewMouseDoubleClick" Value="{Binding Contrast,Mode=TwoWay}" Minimum="0" Maximum="100" Width="80" TicksHeight="5" TicksHighlightBrush="{StaticResource Accent}" /> + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Contrast</TextBlock> + </StackPanel> + <StackPanel> + <visuals:Knob x:Name="knobSaturation" ToolTip="{Binding Saturation}" PreviewMouseDoubleClick="knobSaturation_PreviewMouseDoubleClick" Value="{Binding Saturation,Mode=TwoWay}" Minimum="-1" Maximum="1" Width="80" TicksHeight="5" TicksHighlightBrush="{StaticResource Accent}" /> + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Saturation</TextBlock> + </StackPanel> + + <StackPanel> + <visuals:Knob x:Name="knobNoise" ToolTip="{Binding Noise}" PreviewMouseDoubleClick="knobNoise_PreviewMouseDoubleClick" Value="{Binding Noise,Mode=TwoWay}" Minimum="0" Maximum="100" Width="80" TicksHeight="5" TicksHighlightBrush="{StaticResource Accent}" /> + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Noise</TextBlock> + </StackPanel> + </UniformGrid> </StackPanel> </Border> </Grid> </Grid> + + <Grid Visibility="{Binding CaptureMode,Converter={StaticResource CaptureModeToVisibilityConverter},ConverterParameter={x:Static global:CaptureMode.Emulated3D}}"> + <Grid.RowDefinitions> + <RowDefinition Height="60"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid Background="{StaticResource Background}"> + + </Grid> + + <Grid Grid.Row="1" Background="{StaticResource Background}" Margin="1"> + <helix:HelixViewport3D x:Name="viewport" ShowCoordinateSystem="True" ShowViewCube="False"> + <helix:DefaultLights ShowLights="True" /> + <helix:RectangleVisual3D DivWidth="30" DivLength="30"> + <helix:RectangleVisual3D.BackMaterial> + <DiffuseMaterial Brush="Gray"></DiffuseMaterial> + </helix:RectangleVisual3D.BackMaterial> + <helix:RectangleVisual3D.Material> + <MaterialGroup x:Name="material"> + <DiffuseMaterial> + <DiffuseMaterial.Brush> + <VisualBrush> + <VisualBrush.Visual> + <Border Padding="40" Background="White"> + <Image Stretch="Fill" /> + </Border> + </VisualBrush.Visual> + </VisualBrush> + </DiffuseMaterial.Brush> + </DiffuseMaterial> + <SpecularMaterial Brush="White" SpecularPower="30"></SpecularMaterial> + </MaterialGroup> + </helix:RectangleVisual3D.Material> + </helix:RectangleVisual3D> + </helix:HelixViewport3D> + + <Grid> + <UniformGrid Rows="4" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20"> + <StackPanel> + <visuals:Knob Minimum="-100" Maximum="100" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" /> + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Light</TextBlock> + </StackPanel> + + <StackPanel Margin="0 10 0 0"> + <visuals:Knob Minimum="0" Maximum="100" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" /> + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Spectural</TextBlock> + </StackPanel> + </UniformGrid> + </Grid> + </Grid> + </Grid> </Grid> </Border> @@ -496,15 +580,15 @@ </Grid> </Grid> - <UniformGrid VerticalAlignment="Top" HorizontalAlignment="Left" Width="200" Columns="2" Margin="300 -35 0 0"> - <Button Command="{Binding LiveCommand}" Height="35" Style="{StaticResource MaterialDesignFlatButton}" BorderThickness="0" Padding="5"> + <UniformGrid VerticalAlignment="Top" HorizontalAlignment="Left" Width="340" Columns="3" Margin="200 -35 0 0"> + <Button Command="{Binding CaptureModeCommand}" CommandParameter="{x:Static global:CaptureMode.Camera}" Height="35" Style="{StaticResource MaterialDesignFlatButton}" BorderThickness="0" Padding="5"> <StackPanel Orientation="Horizontal"> <StackPanel.Style> <Style TargetType="StackPanel"> - <Setter Property="TextElement.Foreground" Value="{StaticResource Accent}"></Setter> + <Setter Property="TextElement.Foreground" Value="#808080"></Setter> <Style.Triggers> - <DataTrigger Binding="{Binding IsEmulated}" Value="True"> - <Setter Property="TextElement.Foreground" Value="#808080"></Setter> + <DataTrigger Binding="{Binding CaptureMode}" Value="{x:Static global:CaptureMode.Camera}"> + <Setter Property="TextElement.Foreground" Value="{StaticResource Accent}"></Setter> </DataTrigger> </Style.Triggers> </Style> @@ -513,20 +597,36 @@ <TextBlock Margin="5 0 0 0">Camera</TextBlock> </StackPanel> </Button> - <Button Command="{Binding EmulatedCommand}" Height="35" Style="{StaticResource MaterialDesignFlatButton}" BorderThickness="0" Padding="5"> + <Button Command="{Binding CaptureModeCommand}" CommandParameter="{x:Static global:CaptureMode.Emulated2D}" Height="35" Style="{StaticResource MaterialDesignFlatButton}" BorderThickness="0" Padding="5"> <StackPanel Orientation="Horizontal"> <StackPanel.Style> <Style TargetType="StackPanel"> <Setter Property="TextElement.Foreground" Value="#808080"></Setter> <Style.Triggers> - <DataTrigger Binding="{Binding IsEmulated}" Value="True"> + <DataTrigger Binding="{Binding CaptureMode}" Value="{x:Static global:CaptureMode.Emulated2D}"> <Setter Property="TextElement.Foreground" Value="{StaticResource Accent}"></Setter> </DataTrigger> </Style.Triggers> </Style> </StackPanel.Style> <materialDesign:PackIcon Kind="Image" VerticalAlignment="Center" /> - <TextBlock Margin="5 0 0 0">Emulated</TextBlock> + <TextBlock Margin="5 0 0 0">Emulated 2D</TextBlock> + </StackPanel> + </Button> + <Button Command="{Binding CaptureModeCommand}" CommandParameter="{x:Static global:CaptureMode.Emulated3D}" Height="35" Style="{StaticResource MaterialDesignFlatButton}" BorderThickness="0" Padding="5"> + <StackPanel Orientation="Horizontal"> + <StackPanel.Style> + <Style TargetType="StackPanel"> + <Setter Property="TextElement.Foreground" Value="#808080"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding CaptureMode}" Value="{x:Static global:CaptureMode.Emulated3D}"> + <Setter Property="TextElement.Foreground" Value="{StaticResource Accent}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </StackPanel.Style> + <materialDesign:PackIcon Kind="Cube" VerticalAlignment="Center" /> + <TextBlock Margin="5 0 0 0">Emulated 3D</TextBlock> </StackPanel> </Button> </UniformGrid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs index aa7ff5d49..0bd0efe31 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs @@ -1,5 +1,7 @@ -using System; +using HelixToolkit.Wpf; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,8 +12,11 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Media.Media3D; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Core.DI; +using Tango.MachineStudio.ColorCapture.Contracts; using Tango.MachineStudio.ColorCapture.ViewModels; namespace Tango.MachineStudio.ColorCapture.Views @@ -19,17 +24,75 @@ namespace Tango.MachineStudio.ColorCapture.Views /// <summary> /// Interaction logic for MainView.xaml /// </summary> - public partial class MainView : UserControl + public partial class MainView : UserControl, IMainView { private MainViewVM _vm; public MainView() { InitializeComponent(); - Loaded += (_, __) => + Loaded += (_, __) => { _vm = DataContext as MainViewVM; + + //viewport.CameraController.ShowGridLines = true; }; + + viewport.RotateGesture = new MouseGesture(MouseAction.LeftClick); + viewport.PanGesture = new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control); + viewport.ChangeFieldOfViewGesture = new MouseGesture(MouseAction.LeftClick, ModifierKeys.Shift); + + TangoIOC.Default.Register<IMainView>(this); + } + + private void OnResetBrightness(object sender, MouseButtonEventArgs e) + { + knobBrightness.Value = 0; + } + + private void knobContrast_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + knobContrast.Value = 0; + } + + private void knobSaturation_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + knobSaturation.Value = 0; + } + + private void knobNoise_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + knobNoise.Value = 0; + } + + public void SetCardSource(BitmapSource source) + { + material.Children[0] = new DiffuseMaterial() + { + Brush = new VisualBrush() + { + Visual = new Border() + { + Padding = new Thickness(40), + Background = new SolidColorBrush(Colors.White), + Child = new Image() + { + Source = source, + Stretch = Stretch.Fill, + }, + }, + }, + }; + } + + public BitmapSource GetViewportImage() + { + MemoryStream ms = new MemoryStream(); + Viewport3DHelper.SaveBitmap(viewport.Viewport, ms, null, 1, BitmapExporter.OutputFormat.Bmp); + ms.Position = 0; + var source = ms.ToArray().ToBitmapSource(); + ms.Dispose(); + return source; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj index 8a6c16067..b1e6c05da 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Tango.MachineStudio.ColorLab.csproj @@ -192,7 +192,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.Imaging.dll b/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.Imaging.dll Binary files differnew file mode 100644 index 000000000..150e87d42 --- /dev/null +++ b/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.Imaging.dll diff --git a/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.Math.dll b/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.Math.dll Binary files differnew file mode 100644 index 000000000..bdc5e5ba6 --- /dev/null +++ b/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.Math.dll diff --git a/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.dll b/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.dll Binary files differnew file mode 100644 index 000000000..311cfe5a9 --- /dev/null +++ b/Software/Visual_Studio/Referenced Assemblies/AForge/AForge.dll diff --git a/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.Wpf.Input.dll b/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.Wpf.Input.dll Binary files differnew file mode 100644 index 000000000..c4e551b44 --- /dev/null +++ b/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.Wpf.Input.dll diff --git a/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.Wpf.dll b/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.Wpf.dll Binary files differnew file mode 100644 index 000000000..e270fe951 --- /dev/null +++ b/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.Wpf.dll diff --git a/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.dll b/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.dll Binary files differnew file mode 100644 index 000000000..47d5bab7d --- /dev/null +++ b/Software/Visual_Studio/Referenced Assemblies/Helix/HelixToolkit.dll |
