/// <summary> /// Switch the view displayed in the window. /// </summary> /// <param name="newDisplay">Display to switch the window to.</param> void UpdateDisplayMode(Display newDisplay) { m_ActivePage?.RemoveFromHierarchy(); m_ActivePage?.SetActive(false); m_ViewContainer.Clear(); // Get new page to display switch (newDisplay) { case Display.Add: m_ActivePage = m_StartView; break; case Display.Error: m_ActivePage = m_ErrorPageView; break; case Display.Main: m_ActivePage = m_MainView; break; default: throw new ArgumentOutOfRangeException(); } m_ActivePage.SetActive(true); m_ViewContainer.Add(m_ActivePage); }
public void Setup() { _tenant = new AppTenant("Treeze", "localhost:43500", null, null); _pageComponent = new PageComponent("Minha Página"); _customForms = new List <CustomForm>(); _customFields = new List <CustomField>(); _customFieldOptions = new List <CustomFieldOption>(); _formPageComponents = new List <FormPageComponent>(); _customFormAnswers = new List <CustomFormAnswer>(); _mockCustomFormRepository = new Mock <ICustomFormRepository>(); _mockCustomFieldRepository = new Mock <ICustomFieldRepository>(); _mockCustomFieldOptionRepository = new Mock <ICustomFieldOptionRepository>(); _mockFormPageComponentRepository = new Mock <IFormPageComponentRepository>(); _mockCustomFormAnswerRepository = new Mock <ICustomFormAnswerRepository>(); _mockCustomFormRepository.Setup(mr => mr.Save(It.IsAny <CustomForm>())).Callback((CustomForm target) => { _customForms.Add(target); if (target.Fields == null) { return; } foreach (var targetField in target.Fields) { _customFields.Add(targetField); if (targetField.Options == null) { continue; } foreach (var targetFieldOption in targetField.Options) { _customFieldOptions.Add(targetFieldOption); } } }); _mockCustomFieldRepository.Setup(mr => mr.Save(It.IsAny <CustomField>())).Callback((CustomField target) => { _customFields.Add(target); }); _mockCustomFieldRepository.Setup(mr => mr.Get(It.IsAny <Guid>())).Returns((Guid id) => _customFields.FirstOrDefault(x => x.Id == id && x.TenantId == _tenant.Id)); _mockCustomFieldOptionRepository.Setup(mr => mr.Save(It.IsAny <CustomFieldOption>())).Callback((CustomFieldOption target) => { _customFieldOptions.Add(target); }); _mockFormPageComponentRepository.Setup(mr => mr.Save(It.IsAny <FormPageComponent>())).Callback((FormPageComponent target) => { _formPageComponents.Add(target); }); _mockCustomFormAnswerRepository.Setup(mr => mr.Save(It.IsAny <CustomFormAnswer>())).Callback((CustomFormAnswer target) => { _customFormAnswers.Add(target); }); _customFormRepository = _mockCustomFormRepository.Object; _customFieldRepository = _mockCustomFieldRepository.Object; _customFieldOptionRepsitory = _mockCustomFieldOptionRepository.Object; _formPageComponentRepository = _mockFormPageComponentRepository.Object; _customFormAnswerRepository = _mockCustomFormAnswerRepository.Object; _handler = new CustomFormsHandler(_tenant, _customFormRepository, _customFieldRepository, _customFieldOptionRepsitory, _formPageComponentRepository, _customFormAnswerRepository); }
private PageNode buildNode(PageComponent component, IdGenerator idGenerator, bool inEtherealContainer, bool inJsInitElement) { nodeCount += 1; IReadOnlyCollection <PageNode> buildChildren(IEnumerable <PageComponent> children, IdGenerator g) => children.Select(i => buildNode(i, g, inEtherealContainer, inJsInitElement)).Materialize(); if (component is ElementNode elementNode) { FormState.Current.SetForNextElement(); var id = idGenerator.GenerateId(); idSetter(id); var data = elementNode.ElementDataGetter(new ElementContext(id)); ElementNodeLocalData localData = null; ElementNodeFocusDependentData focusDependentData = null; var node = new PageNode( elementNode, elementNode.FormValue, buildChildren(data.Children, idGenerator), buildChildren(data.EtherealChildren, idGenerator), () => { // Defer attribute creation for the JavaScript initialization element. if (inJsInitElement) { return(new FocusabilityCondition(false)); } localData = data.LocalDataGetter(); return(localData.FocusabilityCondition); }, (isFocused, writer) => { // Defer attribute creation for the JavaScript initialization element. if (inJsInitElement) { return; } focusDependentData = localData.FocusDependentDataGetter(isFocused); writer.Write(focusDependentData.JsInitStatements); }, () => { if (inJsInitElement) { localData = data.LocalDataGetter(); focusDependentData = localData.FocusDependentDataGetter(false); } var attributes = focusDependentData.Attributes; if (focusDependentData.IncludeIdAttribute) { attributes = attributes.Append(new ElementAttribute("id", data.ClientSideIdOverride.Any() ? data.ClientSideIdOverride : id)); } return(localData.ElementName, attributes); });
public Entities.Page GetPage(Entities.Page root, string value) { var component = new PageComponent(Context); var content = new ContentComponent(Context); var page = component.GetPage(root, value); page.Contents = content.GetPageContent(page); return(page); }
private void btnTestNetwork_Click(object sender, RoutedEventArgs e) { OCR.ShapeNet SelectedShapeNet; PageComponent PageComponent; List <Example> Examples = new List <Example>(0); bool Result; //Collect the examples SelectedShapeNet = (OCR.ShapeNet)lstNeuralNetworks.SelectedItem; List <String> Filenames = new List <string>(0); Example newExample; //collect all available examples for (int lIndex = 0; lIndex < SelectedShapeNet.ShapeList.Count; lIndex++) { Filenames.Clear(); MakeExampleList(Filenames, SelectedShapeNet.ShapeList[lIndex].SampleFolder); for (int lIndex2 = 0; lIndex2 < Filenames.Count; lIndex2++) { newExample = new Example(); newExample.Filename = Filenames[lIndex2]; newExample.ShapeId = lIndex; Examples.Add(newExample); } } //Test all examples against the network foreach (Example Example in Examples) { PageComponent = new PageComponent(); PageComponent.LoadBitmap(Example.Filename); Result = false; ExtractFeatures.ExecuteExtractFeatures(PageComponent, true); RecogniseComponent.RecogniseWithoutConnectedRepair(SelectedShapeNet, PageComponent); if (PageComponent.RecognitionResults.Count > 0 && Example.ShapeId < SelectedShapeNet.ShapeList.Count) { if (SelectedShapeNet.ShapeList[Example.ShapeId].Shape.ToLower() == PageComponent.RecognitionResults[0].Content.ToLower()) { Result = true; } } if (!Result) { lstFailedExamples.Items.Add(Example.Filename); } } }
public void Deve_Vincular_Um_Formulario_A_Um_Componente() { var pageComponent = new PageComponent("Novo componente"); Assert.IsTrue(pageComponent.Valid); Assert.AreEqual(pageComponent.EntityStatus, EntityStatus.Activated); var formPageComponent = new FormPageComponent(pageComponent.Id, _customForm.Id, _tenant.Id); Assert.IsTrue(formPageComponent.Valid); Assert.AreEqual(formPageComponent.EntityStatus, EntityStatus.Activated); Assert.AreEqual(_tenant.Id, formPageComponent.TenantId); Assert.AreEqual(pageComponent.Id, formPageComponent.PageComponentId); }
public PageTree( PageComponent rootComponent, Action <string> idSetter, Func <string, ErrorSourceSet, ImmutableDictionary <EwfValidation, IReadOnlyCollection <string> > > modificationErrorGetter, FlowComponent etherealContainer, FlowComponent jsInitElement, StringBuilder elementJsInitStatements) { this.idSetter = idSetter; this.modificationErrorGetter = modificationErrorGetter; this.etherealContainer = etherealContainer; this.jsInitElement = jsInitElement; this.elementJsInitStatements = elementJsInitStatements; rootNode = buildNode(rootComponent, new IdGenerator(), false, false); AllNodes = new List <PageNode>(nodeCount); addTreeToAllNodes(rootNode); }
public void AddItem(PageComponent_BO postedItem) { PageComponent newDbObj = new PageComponent(); newDbObj.Id = postedItem.Id; newDbObj.Code = postedItem.Code; newDbObj.Name = postedItem.Name; newDbObj.Description = postedItem.Description; newDbObj.ContentType = (int)postedItem.ContentType; newDbObj.IsActive = postedItem.IsActive; //newDbObj.CreatedOn = postedItem.CreatedOn; //newDbObj.CreatedBy = postedItem.CreatedBy; //newDbObj.ChangedOn = postedItem.ChangedOn; //newDbObj.ChangedBy = postedItem.ChangedBy; CMSContext.PageComponents.Insert(newDbObj); }
public async Task <IActionResult> Create( [Bind("Name,DisplayName,ComponentTypeId,View,ParentComponentId,Id,CreateDate,CreatedBy,UpdateDate,UpdatedBy,AppTenantId")] Component component, long?pageID) { long pageId = 0; if (pageID != null) { pageId = (long)pageID; } component.CreateDate = DateTime.Now; component.CreatedBy = "username"; if (ModelState.IsValid) { using (var transaction = _context.Database.BeginTransaction()) { try { _context.Add(component); await _context.SaveChangesAsync(); var page = _context.Pages.FirstOrDefault(x => x.Id == pageId); var pageComponent = new PageComponent { Page = page, Component = component }; _context.PageComponents.Add(pageComponent); await _context.SaveChangesAsync(); transaction.Commit(); return(RedirectToAction("Index")); } catch (Exception ex) { } } } ViewData["ComponentTypeId"] = new SelectList(_context.ComponentTypes, "Id", "DisplayName", component.ComponentTypeId); ViewData["ParentComponentId"] = new SelectList(_context.Components, "Id", "DisplayName", component.ParentComponentId); return(View(component)); }
public void DoFillFileList(string Filter, OCR.ShapeNet ShapeNet) { try { if (ShapeFiles == null) { ShapeFiles = new List <ShapeFileList>(0); } if (ShapeFiles.Count == 0) { DirectoryInfo di = new DirectoryInfo("D:\\OCR\\Images\\"); FileInfo[] Files = di.GetFiles("*_org.bmp"); foreach (FileInfo fi in Files) { if (Filter.Length > 0) { String Filename; RecognitionResult MostLikelyShape; // OCR.ShapeNet Shapenet = new OCR.ShapeNet(); PageComponent Component = new PageComponent(); //Get the selected item Filename = fi.Name.ToString(); //Load the image Component.LoadBitmap(fi.FullName.ToString()); //Extract features and recognize ExtractFeatures.ExecuteExtractFeatures(Component, true); RecogniseComponent.Recognise(ShapeNet, Component); //Fill the recognition list MostLikelyShape = new RecognitionResult(); MostLikelyShape.Probability = 0; foreach (RecognitionResult Result in Component.RecognitionResults) { if (Result.Probability > MostLikelyShape.Probability) { MostLikelyShape = Result; } } //Add ShapeFile to cache ShapeFileList ShapeFile; ShapeFile.Shape = MostLikelyShape.Content; ShapeFile.File = fi.Name.ToString(); ShapeFiles.Add(ShapeFile); //Add file to filelist if (MostLikelyShape.Content == Filter) { bwFileList.ReportProgress(0, fi.Name.ToString()); } } else { bwFileList.ReportProgress(0, fi.Name.ToString()); } } } else { foreach (ShapeFileList ShapeFile in ShapeFiles) { if (Filter.Length == 0) { bwFileList.ReportProgress(0, ShapeFile.File); } else { if (Filter == ShapeFile.Shape) { bwFileList.ReportProgress(0, ShapeFile.File); } } } } } catch (Exception e) { Console.WriteLine("Exception caught: " + e.Message); Console.WriteLine(" In: " + e.StackTrace); } }
private void btnTest_Click(object sender, RoutedEventArgs e) { OCR.ShapeNet SelectedShapeNet; OCR.PageComponent PageComponent; SelectedShapeNet = (OCR.ShapeNet)lstNeuralNetworks.SelectedItem; PageComponent.newID = 0; PageComponent = new OCR.PageComponent(); PageComponent.LoadBitmap(txtSample.Text); ExtractFeatures.ExecuteExtractFeatures(PageComponent, PageComponent, true); RecogniseComponent.Recognise(SelectedShapeNet, PageComponent); //Recognise the component lstResults.Items.Clear(); String ResultText = ""; foreach (RecognitionResult Result in PageComponent.RecognitionResults) { ResultText = Result.Content + " (" + Result.Probability + ")"; lstResults.Items.Add(ResultText); } //Build the original image PageComponent Original = new PageComponent(); Original.LoadBitmap(txtSample.Text); ExtractFeatures.CreateCompareMatrixWithoutPruning(Original, Original.Bytes); imgSample.Bytes = Original.CompareMatrix; for (int index = 0; index < 256; index++) { imgSample.GridBrushes[index] = new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)index, (byte)index, (byte)index)); } imgSample.InvalidateVisual(); ExtractFeatures.CreateCompareMatrixWithoutPruning(PageComponent); //Build the thinned and stroked image for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) { if (PageComponent.StrokeMatrix[x, y] == 0xFF && PageComponent.CompareMatrix[x, y] != 0xFF) { PageComponent.StrokeMatrix[x, y] = 0x04; } if (PageComponent.PixelTypeMatrix[x, y] == ePixelType.End) { PageComponent.StrokeMatrix[x, y] = 0xFE; } if (PageComponent.PixelTypeMatrix[x, y] == ePixelType.Junction) { PageComponent.StrokeMatrix[x, y] = 0xFD; } } } imgProjection.Bytes = PageComponent.StrokeMatrix; imgProjection.GridBrushes[0] = new SolidColorBrush(Colors.Black); imgProjection.GridBrushes[4] = new SolidColorBrush(Colors.LightGray); imgProjection.GridBrushes[11] = new SolidColorBrush(Colors.Brown); imgProjection.GridBrushes[12] = new SolidColorBrush(Colors.Maroon); imgProjection.GridBrushes[13] = new SolidColorBrush(Colors.Magenta); imgProjection.GridBrushes[14] = new SolidColorBrush(Colors.Lime); imgProjection.GridBrushes[15] = new SolidColorBrush(Colors.LightCyan); imgProjection.GridBrushes[16] = new SolidColorBrush(Colors.Purple); imgProjection.GridBrushes[32] = new SolidColorBrush(Colors.Blue); imgProjection.GridBrushes[48] = new SolidColorBrush(Colors.Green); imgProjection.GridBrushes[64] = new SolidColorBrush(Colors.Yellow); imgProjection.GridBrushes[253] = new SolidColorBrush(Colors.Red); imgProjection.GridBrushes[254] = new SolidColorBrush(Colors.Red); imgProjection.InvalidateVisual(); lblStrokes.Content = "#Strokes: " + Convert.ToString(PageComponent.Strokes); //Bitmap StrokeMatrixBitmap = OCR.DebugTrace.DebugTrace.CreateBitmapFromByteArray(PageComponent.StrokeMatrix, new System.Drawing.Size(32, 32)); //StrokeMatrixBitmap.Save("d:\\ocr\\temp.bmp"); //imgProjection.Source = new BitmapImage(new Uri("d:\\ocr\\temp.bmp")); pbHorizontal.Clear(); int ProjectionValue; for (int x = 0; x < 3; x++) { ProjectionValue = 0; for (int y = 0; y < 3; y++) { ProjectionValue += PageComponent.PixelTypeProjectionJunction[x, y]; ProjectionValue += PageComponent.PixelTypeProjectionEndpoint[x, y]; } pbHorizontal.AddValue(ProjectionValue); } pbVertical.Clear(); for (int y = 0; y < 3; y++) { ProjectionValue = 0; for (int x = 0; x < 3; x++) { ProjectionValue += PageComponent.PixelTypeProjectionJunction[x, y]; ProjectionValue += PageComponent.PixelTypeProjectionEndpoint[x, y]; } pbVertical.AddValue(ProjectionValue); } pbStrokeHorizontal.Clear(); foreach (int Value in PageComponent.lStrokeDirectionX) { pbStrokeHorizontal.AddValue(Value); } pbStrokeVertical.Clear(); foreach (int Value in PageComponent.lStrokeDirectionY) { pbStrokeVertical.AddValue(Value); } }
private void lstFailedExamples_SelectionChanged(object sender, SelectionChangedEventArgs e) { PageComponent PageComponent; String item; OCR.ShapeNet SelectedShapeNet; //Load the image item = (String)lstFailedExamples.SelectedItem; PageComponent = new PageComponent(); PageComponent.LoadBitmap(item); //Recognise the image and fill the result list SelectedShapeNet = (OCR.ShapeNet)lstNeuralNetworks.SelectedItem; ExtractFeatures.ExecuteExtractFeatures(PageComponent, true); RecogniseComponent.RecogniseWithoutConnectedRepair(SelectedShapeNet, PageComponent); lstFailedResult.Items.Clear(); String ResultText = ""; foreach (RecognitionResult Result in PageComponent.RecognitionResults) { ResultText = Result.Content + " (" + Result.Probability + ")"; lstFailedResult.Items.Add(ResultText); } //Build the image PageComponent Original = new PageComponent(); Original.LoadBitmap(item); PageComponent OriginalWithPruning = new PageComponent(); OriginalWithPruning.LoadBitmap(item); ExtractFeatures.CreateCompareMatrixWithoutPruning(Original); ExtractFeatures.CreateCompareMatrix(OriginalWithPruning); for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) { PageComponent.CompareMatrix[x, y] = Original.CompareMatrix[x, y]; if (Original.CompareMatrix[x, y] != 0xFF && PageComponent.CompareMatrix[x, y] == 0xFF) { PageComponent.CompareMatrix[x, y] = 4; } if (PageComponent.StrokeMatrix[x, y] != 0xFF) { PageComponent.CompareMatrix[x, y] = PageComponent.StrokeMatrix[x, y]; } } } imgFailed.Bytes = PageComponent.CompareMatrix; imgFailed.GridBrushes[0] = new SolidColorBrush(Colors.Gray); imgFailed.GridBrushes[4] = new SolidColorBrush(Colors.LightGray); imgFailed.GridBrushes[11] = new SolidColorBrush(Colors.Brown); imgFailed.GridBrushes[12] = new SolidColorBrush(Colors.Maroon); imgFailed.GridBrushes[13] = new SolidColorBrush(Colors.Magenta); imgFailed.GridBrushes[14] = new SolidColorBrush(Colors.Lime); imgFailed.GridBrushes[15] = new SolidColorBrush(Colors.LightCyan); imgFailed.GridBrushes[16] = new SolidColorBrush(Colors.Purple); imgFailed.GridBrushes[32] = new SolidColorBrush(Colors.Blue); imgFailed.GridBrushes[48] = new SolidColorBrush(Colors.Green); imgFailed.GridBrushes[64] = new SolidColorBrush(Colors.Yellow); imgFailed.GridBrushes[253] = new SolidColorBrush(Colors.Red); imgFailed.GridBrushes[254] = new SolidColorBrush(Colors.Red); imgFailed.GridBrushes[255] = new SolidColorBrush(Colors.White); imgFailed.InvalidateVisual(); //imgFailed.Bytes = PageComponent.StrokeMatrix; //imgFailed.InvalidateVisual(); }
public Entities.Page GetRoot() { var component = new PageComponent(Context); return(component.GetRoot().First()); }
public void Update(PageComponent entity) { Context.Entry(entity).State = EntityState.Modified; }
public void Save(PageComponent entity) { Context.PageComponents.Add(entity); }
public abstract void Remove(PageComponent page);
private void lstFiles_SelectionChanged(object sender, SelectionChangedEventArgs e) { String Filename; String ResultString; RecognitionResult MostLikelyShape; try { // OCR.ShapeNet Shapenet = new OCR.ShapeNet(); PageComponent Component = new PageComponent(); //Get the selected item Filename = "D:\\OCR\\Images\\" + (String)lstFiles.SelectedItem; if (lstFiles.SelectedItem == null) { return; } //Load the image Component.LoadBitmap(Filename); //Extract features and recognize ExtractFeatures.ExecuteExtractFeatures(Component, true); RecogniseComponent.Recognise((OCR.ShapeNet)lstNeuralNetworks.SelectedItem, Component); //Fill the imgContainer ExtractFeatures.CreateCompareMatrixWithoutPruning(Component, Component.Bytes); imgTrainingDataOriginal.Bytes = Component.CompareMatrix; for (int index = 0; index < 256; index++) { imgTrainingDataOriginal.GridBrushes[index] = new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)index, (byte)index, (byte)index)); } imgTrainingDataOriginal.InvalidateVisual(); //Fill the recognition list lstRecognitionResult.Items.Clear(); MostLikelyShape = new RecognitionResult(); MostLikelyShape.Probability = 0; foreach (RecognitionResult Result in Component.RecognitionResults) { if (Result.Probability > MostLikelyShape.Probability) { MostLikelyShape = Result; } } ShapeListEntry Shape = new ShapeListEntry();; //Select the result with the highest probability in the shape list. if (MostLikelyShape.Probability > 0) { ResultString = MostLikelyShape.Content + " (" + MostLikelyShape.Probability + ")"; lstRecognitionResult.Items.Add(ResultString); foreach (Object Item in lstShapes.Items) { Shape = (ShapeListEntry)Item; if (Shape.Shape == MostLikelyShape.Content) { lstShapes.SelectedItem = Item; lstShapes.ScrollIntoView(Item); lstShapes.Focus(); } } } } catch (Exception exp) { Console.WriteLine("Exception caught: " + exp.Message); Console.WriteLine(" In: " + exp.StackTrace); } }
public void Post(Entities.Page page) { var pageComponent = new PageComponent(Context); pageComponent.Add(page); }
public Entities.Page Get(Guid id) { var pageComponent = new PageComponent(Context); return(pageComponent.GetPage(id)); }
public IEnumerable <Entities.Page> Get() { var component = new PageComponent(Context); return(component.GetAll()); }
public void SetUp() { _component = (PageComponent <ThoughtsComponent>)Game.Player.GetComponent <PageComponent <ThoughtsComponent> >(); }
public abstract void Add(PageComponent page);