private void AddChildCommandExecute(object param) { var selectednode = ((this.SelectedItems as SelectorViewModel).Nodes as ObservableCollection <object>)[0] as OrganizationChartNodeVM; OrganizationChartNodeVM node = new OrganizationChartNodeVM() { ContentTemplate = selectednode.ContentTemplate as DataTemplate, CustomContentTemplate = selectednode.CustomContentTemplate, CustomContent = new CustomContent() { Image = "/syncfusion.diagrambuilder.wpf;component/Resources/male.png", ImageVisibility = 100 }, ID = id.ToString(), ParentID = selectednode.ID.ToString(), UnitWidth = 200, UnitHeight = 120, Annotations = new List <IAnnotation>() { new LabelVM() { Content = "Name", FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).TextHorizontalAlignment, TextVerticalAlignment = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).TextVerticalAlignment, Offset = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).Offset, LabelWidth = ((selectednode.Annotations as List <IAnnotation>)[0] as LabelVM).LabelWidth, }, new LabelVM() { FontSize = 12, WrapText = TextWrapping.Wrap, TextHorizontalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).TextHorizontalAlignment, TextVerticalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).TextVerticalAlignment, HorizontalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).HorizontalAlignment, VerticalAlignment = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).VerticalAlignment, Offset = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).Offset, LabelWidth = ((selectednode.Annotations as List <IAnnotation>)[1] as LabelVM).LabelWidth, }, } }; foreach (string labels in RoleAnnotation as List <string> ) { LabelVM anno = (node.Annotations as List <IAnnotation>)[1] as LabelVM; if (anno.Content != null) { anno.Content = anno.Content.ToString() + "\n" + labels; } else { anno.Content = labels; } } id++; (OrgNodeCollection as NodeVMCollection).Add(node); ((this.SelectedItems as SelectorViewModel).Nodes as ObservableCollection <object>).Clear(); node.IsSelected = true; this.LayoutManager.Layout.UpdateLayout(); }
public IActionResult Label(string id, string qid) { LabelVM model = new LabelVM(); try { Question res = null; if (!string.IsNullOrEmpty(qid) && long.TryParse(qid, out long _qid)) { res = SemEvalRepository.GetQuestionByQIDAsync(_qid).Result; model.Review = true; } else { res = SemEvalRepository.GetActiveQuestion(id).Result; model.Review = false; } if (res == null) { return(Redirect("/")); } model.UserId = res.UserId.Value; model.Q = res; return(View(model)); } catch (Exception ex) { model.ErrMsg = ex.Message; return(View(model)); } }
private void EditCommandExecute(object param) { List <string> contents = new List <string>(); OrganizationChartNodeVM firstnode = (NodeCollection as ObservableCollection <OrganizationChartNodeVM>).First(); LabelVM firstlabel = (firstnode.Annotations as List <IAnnotation>)[0] as LabelVM; foreach (string labels in RoleAnnotation as List <string> ) { contents.Add(labels); } AdditionalInformationWindow window = new AdditionalInformationWindow(); window.Annotations = contents; window.Annotation = firstlabel.Content.ToString(); window.ShowDialog(); List <String> Annotations = window.Annotations; string Annotation = window.Annotation; foreach (OrganizationChartNodeVM node in NodeCollection as ObservableCollection <OrganizationChartNodeVM> ) { LabelVM label = (node.Annotations as List <IAnnotation>).ElementAt(0) as LabelVM; label.Content = Annotation.ToString(); } if (Annotations.Count > 0) { RoleAnnotation = Annotations; foreach (OrganizationChartNodeVM node in NodeCollection as ObservableCollection <OrganizationChartNodeVM> ) { LabelVM label = (node.Annotations as List <IAnnotation>).ElementAt(1) as LabelVM; label.Content = null; foreach (string labels in Annotations as List <string> ) { if (label.Content != null) { label.Content = label.Content.ToString() + "\n" + labels; } else { label.Content = labels; } } } } else { foreach (OrganizationChartNodeVM node in NodeCollection as ObservableCollection <OrganizationChartNodeVM> ) { LabelVM label = (node.Annotations as List <IAnnotation>).ElementAt(1) as LabelVM; label.Content = null; label.ReadOnly = false; } } this.LayoutManager.Layout.UpdateLayout(); }
/// <summary> /// The annotation_ property changed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void Annotation_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName.Equals("Mode")) { LabelVM annotation = sender as LabelVM; if (annotation != null && annotation.Mode == ContentEditorMode.View) { TextBlock textblock = new TextBlock(); textblock.RenderTransformOrigin = new Point(0.5, 0.5); textblock.Width = this.UnitWidth; textblock.Text = annotation.Content.ToString(); textblock.TextWrapping = annotation.WrapText; textblock.FontStyle = annotation.FontStyle; textblock.FontSize = annotation.FontSize; textblock.Foreground = annotation.LabelForeground; textblock.FontWeight = annotation.FontWeight; textblock.FontFamily = annotation.Font; textblock.HorizontalAlignment = annotation.HorizontalAlignment; textblock.VerticalAlignment = annotation.VerticalAlignment; textblock.TextAlignment = annotation.TextHorizontalAlignment; textblock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); if (this.Type.Equals("root")) { if (this.ShapeName.Equals("Line")) { double height = textblock.DesiredSize.Height + 20; this.UnitHeight = Math.Max(96, textblock.DesiredSize.Height + 20); } else { this.UnitHeight = Math.Max(96, textblock.DesiredSize.Height); } } else { if (this.ShapeName.Equals("Line")) { double height = textblock.DesiredSize.Height + 20; this.UnitHeight = Math.Max(30, textblock.DesiredSize.Height + 20); } else { this.UnitHeight = Math.Max(30, textblock.DesiredSize.Height); } } } } }
private void OnQuickShapeExecute(object obj) { foreach (OrganizationChartNodeVM node in this.Nodes as ObservableCollection <OrganizationChartNodeVM> ) { string template = null; if (obj.ToString().Contains("Belt")) { template = "Belt"; node.UnitHeight = 120; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.5, 0.8); anno1.LabelWidth = 180; anno1.TextHorizontalAlignment = TextAlignment.Center; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.5, 0.65); anno2.HorizontalAlignment = HorizontalAlignment.Left; anno2.VerticalAlignment = VerticalAlignment.Bottom; anno2.LabelWidth = 85; anno2.TextHorizontalAlignment = TextAlignment.Left; } } } else if (obj.ToString().Contains("Notch")) { template = "Notch"; node.UnitHeight = 120; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.65, 0.30); anno1.TextHorizontalAlignment = TextAlignment.Left; anno1.LabelWidth = 120; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.65, 0.40); anno2.TextHorizontalAlignment = TextAlignment.Left; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 120; } } } else if (obj.ToString().Contains("Pip")) { template = "Pip"; node.UnitHeight = 140; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.65, 0.35); anno1.TextHorizontalAlignment = TextAlignment.Left; anno1.LabelWidth = 120; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.65, 0.43); anno2.TextHorizontalAlignment = TextAlignment.Left; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 120; } } } else if (obj.ToString().Contains("Shapetacular")) { template = "Shapetacular"; node.UnitHeight = 120; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.65, 0.30); anno1.TextHorizontalAlignment = TextAlignment.Right; anno1.LabelWidth = 130; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.65, 0.40); anno2.TextHorizontalAlignment = TextAlignment.Right; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 130; } } } else if (obj.ToString().Contains("Bound")) { template = "Bound"; node.UnitHeight = 120; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.72, 0.30); anno1.TextHorizontalAlignment = TextAlignment.Left; anno1.LabelWidth = 100; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.72, 0.38); anno2.TextHorizontalAlignment = TextAlignment.Left; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 100; } } } else if (obj.ToString().Contains("Coin")) { template = "Coin"; node.UnitHeight = 200; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.5, 0.70); anno1.TextHorizontalAlignment = TextAlignment.Center; anno1.LabelWidth = 140; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.5, 0.78); anno2.TextHorizontalAlignment = TextAlignment.Center; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 125; } } } else if (obj.ToString().Contains("Panel")) { template = "Panel"; node.UnitHeight = 220; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.60, 0.62); anno1.TextHorizontalAlignment = TextAlignment.Right; anno1.LabelWidth = 130; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.60, 0.66); anno2.TextHorizontalAlignment = TextAlignment.Right; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 130; } } } else if (obj.ToString().Contains("Petals")) { template = "Petals"; node.UnitHeight = 160; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.50, 0.70); anno1.TextHorizontalAlignment = TextAlignment.Left; anno1.LabelWidth = 80; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.75, 0.12); anno2.TextHorizontalAlignment = TextAlignment.Right; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 80; } } } else if (obj.ToString().Contains("Stone")) { template = "Stone"; node.UnitHeight = 140; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.40, 0.35); anno1.TextHorizontalAlignment = TextAlignment.Right; anno1.LabelWidth = 100; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.40, 0.43); anno2.TextHorizontalAlignment = TextAlignment.Right; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 100; } } } else if (obj.ToString().Contains("Perspective")) { template = "Perspective"; node.UnitHeight = 120; for (int i = 0; i <= 1; i++) { if (i == 0) { LabelVM anno1 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno1.Offset = new Point(0.45, 0.25); anno1.TextHorizontalAlignment = TextAlignment.Left; anno1.LabelWidth = 80; } if (i == 1) { LabelVM anno2 = (node.Annotations as List <IAnnotation>)[i] as LabelVM; anno2.Offset = new Point(0.45, 0.33); anno2.TextHorizontalAlignment = TextAlignment.Left; anno2.HorizontalAlignment = HorizontalAlignment.Center; anno2.VerticalAlignment = VerticalAlignment.Top; anno2.LabelWidth = 80; } } } if (template != null) { ResourceDictionary resourceDictionary = new ResourceDictionary() { Source = new Uri(@"/syncfusion.diagrambuilder.Wpf;component/OrganizationChart/Theme/OrganizationChartUI.xaml", UriKind.RelativeOrAbsolute) }; node.ContentTemplate = resourceDictionary[template.ToString()] as DataTemplate; node.CustomContentTemplate = template.ToString(); } } this.LayoutManager.Layout.UpdateLayout(); }
/// <summary> /// The on property changed. /// </summary> /// <param name="name"> /// The name. /// </param> protected override void OnPropertyChanged(string name) { base.OnPropertyChanged(name); if (name.Equals("Annotations")) { // if (Annotations is List<IAnnotation> && (Annotations as AnnotationCollection).Count > 0 // && (Annotations as AnnotationCollection)[0] is TextAnnotationViewModel) // { // TextAnnotationViewModel annotation = (Annotations as AnnotationCollection)[0] as TextAnnotationViewModel; // annotation.PropertyChanged += Annotation_PropertyChanged; // } if (this.Annotations is List <IAnnotation> && (this.Annotations as List <IAnnotation>).Count > 0) { LabelVM annotation = (this.Annotations as List <IAnnotation>)[0] as LabelVM; annotation.PropertyChanged += this.Annotation_PropertyChanged; } } else if (name.Equals("ShapeName")) { INodeInfo nodeInfo = (INodeInfo)this.Info; LabelVM annotation = ((List <IAnnotation>) this.Annotations)[0] as LabelVM; ObservableCollection <IPort> ports = (ObservableCollection <IPort>) this.Ports; if (this.ShapeName.Equals("Line")) { this.Shape = null; this.ContentTemplate = Application.Current.Resources["LineShapeTemplate"] as DataTemplate; this.Content = this; annotation.TextVerticalAlignment = VerticalAlignment.Stretch; annotation.LabelForeground = Brushes.Black; if (this.Ports != null) { if (nodeInfo.InConnectors != null && nodeInfo.InConnectors.Any()) { foreach (IConnector connector in nodeInfo.InConnectors.ToList()) { if (this.Type.Contains("left")) { connector.TargetPort = ports[3]; } else if (this.Type.Contains("right")) { connector.TargetPort = ports[0]; } } } if (nodeInfo.OutConnectors != null && nodeInfo.OutConnectors.Any()) { foreach (IConnector connector in nodeInfo.OutConnectors.ToList()) { if (this.Type.Contains("left")) { connector.SourcePort = ports[0]; } else if (this.Type.Contains("right")) { connector.SourcePort = ports[3]; } } } } } else { this.Shape = Application.Current.Resources[this.ShapeName]; this.ContentTemplate = null; this.Content = null; annotation.TextVerticalAlignment = VerticalAlignment.Center; if (this.ShapeName.Equals("Freehand")) { annotation.LabelForeground = Brushes.Black; } else { this.OnThemeStyleIdChanged(); } if (this.ShapeName.Equals("Wave")) { if (this.Ports != null) { if (nodeInfo.InConnectors != null && nodeInfo.InConnectors.Any()) { foreach (IConnector connector in nodeInfo.InConnectors.ToList()) { if (this.Type.Contains("left")) { connector.TargetPort = ports[2]; } else if (this.Type.Contains("right")) { connector.TargetPort = ports[1]; } } } if (nodeInfo.OutConnectors != null && nodeInfo.OutConnectors.Any()) { foreach (IConnector connector in nodeInfo.OutConnectors.ToList()) { if (this.Type.Contains("left")) { connector.SourcePort = ports[1]; } else { connector.SourcePort = ports[2]; } } } } } else { if (this.Info != null) { if (nodeInfo.InConnectors != null && nodeInfo.InConnectors.Any()) { foreach (IConnector connector in nodeInfo.InConnectors.ToList()) { connector.TargetPort = null; } } if (nodeInfo.OutConnectors != null && nodeInfo.OutConnectors.Any()) { foreach (IConnector connector in nodeInfo.OutConnectors.ToList()) { connector.SourcePort = null; } } } } } } }
//[Route("[action]")] //public async Task<ActionResult<FileVM>> PostImage(FileVM UploadedImage) public async Task <IActionResult> PostImage(FileVM UploadedImage) { byte[] bytes = Convert.FromBase64String(UploadedImage.FileAsBase64); var credentials = new BasicAWSCredentials("AKIAYFOXPUFXRIBLXF4O", "kt30oEKBt35RZRxXD6rLRd2uxITL0aYX24qFXnox"); var config = new AmazonS3Config { RegionEndpoint = Amazon.RegionEndpoint.USEast1 }; var image = new Image(); using (var client = new AmazonS3Client(credentials, config)) { using (var newMemoryStream = new MemoryStream(bytes)) { //file.CopyTo(newMemoryStream); var uploadRequest = new TransferUtilityUploadRequest { InputStream = newMemoryStream, Key = UploadedImage.FileName, BucketName = "quickquoteitem", CannedACL = S3CannedACL.PublicRead }; var fileTransferUtility = new TransferUtility(client); try { await fileTransferUtility.UploadAsync(uploadRequest); } catch (Exception err) { throw err; } } } AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(credentials, Amazon.RegionEndpoint.USEast1); DetectLabelsRequest detectlabelsRequest = new DetectLabelsRequest() { Image = new Image() { S3Object = new S3Object() { Name = UploadedImage.FileName, Bucket = "quickquoteitem" }, }, MaxLabels = 10, MinConfidence = 75F }; try { var Labels = new List <LabelVM>(); DetectLabelsResponse detectLabelsResponse = await rekognitionClient.DetectLabelsAsync(detectlabelsRequest); //Console.WriteLine("Detected labels for " + photo); foreach (Label label in detectLabelsResponse.Labels) { var item = new LabelVM(); item.LabelName = label.Name; item.LabelConfidence = label.Confidence.ToString(); Labels.Add(item); } return(Ok(Labels)); //Console.WriteLine("{0}: {1}", label.Name, label.Confidence); } catch (Exception e) { Console.WriteLine(e.Message); } //return CreatedAtAction("GetQuote", new { id = quote.QuoteID }, quote); return(Ok()); }