Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Medifirst2000.Framework.Converter;
- using Medifirst2000.MainMenu.ViewModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace Medifirst2000.MainMenu
- {
- /// <summary>
- /// Interaction logic for PicGigiSeri.xaml
- /// </summary>
- public partial class PicGigiSeri : UserControl
- {
- public OdontoDetailViewModel Context { get => DataContext as OdontoDetailViewModel; }
- public PicGigiSeri()
- {
- InitializeComponent();
- MouseLeftButtonUp += PicGigiTaringMouseLeftButtonUp;
- PAtas.MouseLeftButtonUp += PAtasMouseLeftButtonUp;
- PBawah.MouseLeftButtonUp += PBawahMouseLeftButtonUp;
- PKiri.MouseLeftButtonUp += PKiriMouseLeftButtonUp;
- PKanan.MouseLeftButtonUp += PKananMouseLeftButtonUp;
- }
- public void SetDataOdonto(OdontoDetailViewModel odonto)
- {
- var properties = odonto.GetType().GetProperties().Where(n => n.PropertyType == typeof(bool));
- foreach (var properti in properties)
- {
- var ya = Convert.ToBoolean(properti.GetValue(odonto));
- if (ya)
- {
- switch (properti.Name)
- {
- case "KavitasKiri":
- case "KavitasKanan":
- case "KavitasAtas":
- case "KavitasBawah":
- case "KavitasTengah":
- CurrentSymbolOdonto.Current = SymbolOdonto.Kavitas;
- break;
- case "TambalanKiri":
- case "TambalanKanan":
- case "TambalanAtas":
- case "TambalanBawah":
- case "TambalanTengah":
- CurrentSymbolOdonto.Current = SymbolOdonto.Tambalan;
- break;
- case "Tidak Ada":
- CurrentSymbolOdonto.Current = SymbolOdonto.TidakAda;
- break;
- case "Pulpitis":
- CurrentSymbolOdonto.Current = SymbolOdonto.Pulpitis;
- break;
- case "Ganggren Pulpae":
- CurrentSymbolOdonto.Current = SymbolOdonto.GanggrenPurpae;
- break;
- case "Radix":
- CurrentSymbolOdonto.Current = SymbolOdonto.Radix;
- break;
- case "Granuloom":
- CurrentSymbolOdonto.Current = SymbolOdonto.Granuloom;
- break;
- case "Kyste":
- CurrentSymbolOdonto.Current = SymbolOdonto.Kyste;
- break;
- case "Pyorrhoe":
- CurrentSymbolOdonto.Current = SymbolOdonto.Pyorrhoe;
- break;
- case "Karies Media":
- CurrentSymbolOdonto.Current = SymbolOdonto.KariesMedia;
- break;
- case "Karsinoma":
- CurrentSymbolOdonto.Current = SymbolOdonto.Karsinoma;
- break;
- }
- var findSymbolPolygon = GridPola.Children.OfType<Polygon>().FirstOrDefault(n => CurrentSymbolOdonto.Current + "" + n.Tag.ToString() == properti.Name);
- if (findSymbolPolygon != null)
- {
- CreateBlok(findSymbolPolygon);
- return;
- }
- var findSymbolHuruf = WpSymbol.Children.OfType<TextBlock>().FirstOrDefault(n => n.Tag.ToString() == properti.Name);
- if (findSymbolHuruf != null)
- {
- SetVisibilityText(findSymbolHuruf);
- return;
- }
- var findSymbolViewboxWpSymbol = WpSymbol.Children.OfType<Viewbox>().FirstOrDefault(n => n.Tag.ToString() == properti.Name);
- if (findSymbolViewboxWpSymbol != null)
- {
- SetVisibilityView(findSymbolViewboxWpSymbol);
- return;
- }
- if (SymTidakAda.Tag.ToString() == properti.Name)
- {
- SetVisibilityText(SymTidakAda);
- }
- }
- }
- }
- public void Clear()
- {
- foreach (var pola in GridPola.Children.OfType<Polygon>())
- {
- Clear(pola);
- }
- foreach (var text in WpSymbol.Children.OfType<TextBlock>())
- {
- Clear(text);
- }
- foreach (var viewBox in WpSymbol.Children.OfType<Viewbox>())
- {
- Clear(viewBox);
- }
- Clear(SymTidakAda);
- }
- private void Clear(Viewbox viewBox)
- {
- viewBox.Visibility = Visibility.Collapsed;
- }
- private void Clear(TextBlock textBlock)
- {
- textBlock.Visibility = Visibility.Collapsed;
- }
- private void Clear(Polygon polygon)
- {
- polygon.StrokeThickness = 1;
- polygon.Fill = new SolidColorBrush(Colors.White);
- }
- private void PKananMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- CreateBlok(sender);
- }
- private void PKiriMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- CreateBlok(sender);
- }
- private void PBawahMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- CreateBlok(sender);
- }
- private void PAtasMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- CreateBlok(sender);
- }
- private void CreateBlok(object sender)
- {
- var blok = sender as Polygon;
- switch (CurrentSymbolOdonto.Current)
- {
- case SymbolOdonto.Kavitas:
- SetKavitas(blok);
- break;
- case SymbolOdonto.Tambalan:
- SetTambalan(blok);
- break;
- }
- }
- private void SetKavitas(Polygon blok)
- {
- var joinTag = CurrentSymbolOdonto.Current + blok.Tag.ToString();
- var properti = Context.GetType().GetProperty(joinTag);
- if (properti != null)
- {
- var propertySummary = Context.GetType().GetProperty("Summary");
- var summary = propertySummary.GetValue(Context)?.ToString();
- if (blok.StrokeThickness == 1)
- {
- blok.StrokeThickness = 3;
- summary = SetSummary(joinTag, properti, summary);
- }
- else
- {
- blok.StrokeThickness = 1;
- summary = ReplaceSummary(joinTag, properti, summary);
- }
- propertySummary.SetValue(Context, summary);
- }
- }
- private string ReplaceSummary(string tag, PropertyInfo properti, string summary)
- {
- properti.SetValue(Context, false);
- if (string.IsNullOrEmpty(summary))
- summary = summary.Replace(tag.ToSentence(), "");
- else
- {
- if (summary.Contains("-" + tag.ToSentence()))
- summary = summary.Replace("-" + tag.ToSentence(), "");
- else
- summary = summary.Replace(tag.ToSentence(), "");
- }
- return summary;
- }
- private string SetSummary(string tag, PropertyInfo properti, string summary)
- {
- properti.SetValue(Context, true);
- if (string.IsNullOrEmpty(summary))
- summary += tag.ToSentence();
- else
- summary += "-" + tag.ToSentence();
- return summary;
- }
- private void SetTambalan(Polygon blok)
- {
- var joinTag = CurrentSymbolOdonto.Current + blok.Tag.ToString();
- var properti = Context.GetType().GetProperty(joinTag);
- if (properti != null)
- {
- var propertySummary = Context.GetType().GetProperty("Summary");
- var summary = propertySummary.GetValue(Context)?.ToString();
- var getColor = blok.Fill as SolidColorBrush;
- if (Colors.White.Equals(getColor.Color))
- {
- blok.Fill = new SolidColorBrush(Colors.Gray);
- summary = SetSummary(joinTag, properti, summary);
- }
- else
- {
- blok.Fill = new SolidColorBrush(Colors.White);
- summary = ReplaceSummary(joinTag, properti, summary);
- }
- propertySummary.SetValue(Context, summary);
- }
- }
- private void PicGigiTaringMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- switch (CurrentSymbolOdonto.Current)
- {
- case SymbolOdonto.TidakAda:
- SetVisibilityText(SymTidakAda);
- break;
- case SymbolOdonto.Pulpitis:
- SetVisibilityText(SymPulpitis);
- break;
- case SymbolOdonto.GanggrenPurpae:
- SetVisibilityText(SymGanggrenPulpae);
- break;
- case SymbolOdonto.Radix:
- SetVisibilityText(SymRadix);
- break;
- case SymbolOdonto.Granuloom:
- SetVisibilityText(SymGranuloom);
- break;
- case SymbolOdonto.Kyste:
- SetVisibilityView(SymKyste);
- break;
- case SymbolOdonto.Pyorrhoe:
- SetVisibilityText(SymPyorrhoe);
- break;
- case SymbolOdonto.KariesMedia:
- SetVisibilityText(SymKariesMedia);
- break;
- case SymbolOdonto.Karsinoma:
- SetVisibilityText(SymKarsinoma);
- break;
- }
- }
- private void SetVisibilityText(TextBlock text)
- {
- var properti = Context.GetType().GetProperty(text.Tag.ToString());
- if (properti != null)
- {
- var propertySummary = Context.GetType().GetProperty("Summary");
- var summary = propertySummary.GetValue(Context)?.ToString();
- if (text.Visibility == Visibility.Collapsed)
- {
- text.Visibility = Visibility.Visible;
- summary = SetSummary(text.Tag.ToString(), properti, summary);
- }
- else
- {
- text.Visibility = Visibility.Collapsed;
- summary = ReplaceSummary(text.Tag.ToString(), properti, summary);
- }
- propertySummary.SetValue(Context, summary);
- }
- }
- private void SetVisibilityView(Viewbox viewBox)
- {
- var properti = Context.GetType().GetProperty(viewBox.Tag.ToString());
- if (properti != null)
- {
- var propertySummary = Context.GetType().GetProperty("Summary");
- var summary = propertySummary.GetValue(Context)?.ToString();
- if (viewBox.Visibility == Visibility.Collapsed)
- {
- viewBox.Visibility = Visibility.Visible;
- summary = SetSummary(viewBox.Tag.ToString(), properti, summary);
- }
- else
- {
- viewBox.Visibility = Visibility.Collapsed;
- summary = ReplaceSummary(viewBox.Tag.ToString(), properti, summary);
- }
- propertySummary.SetValue(Context, summary);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement