private async Task Open(CanvasVirtualBitmapOptions options) { var filePicker = new FileOpenPicker(); filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; filePicker.FileTypeFilter.Add("*"); var file = await filePicker.PickSingleFileAsync(); if (file == null) { return; } if (imageStream != null) { imageStream.Dispose(); imageStream = null; } try { imageStream = new ByteCounterStreamProxy(await file.OpenReadAsync()); virtualBitmapOptions = options; IOGraph.Invalidate(); await LoadVirtualBitmap(); } catch { var message = string.Format("Error opening '{0}'", file.Name); var messageBox = new MessageDialog(message, "Virtual Bitmap Example").ShowAsync(); } }
private void Control_Unloaded(object sender, RoutedEventArgs e) { IOGraph.RemoveFromVisualTree(); ImageVirtualControl.RemoveFromVisualTree(); IOGraph = null; ImageVirtualControl = null; }
/// <summary> /// Refresh/update the view with the provided genome. /// </summary> public override void RefreshView(object genome) { NeatGenome neatGenome = genome as NeatGenome; if (null == neatGenome) { return; } IOGraph graph = _graphFactory.CreateGraph(neatGenome); _viewportPainter.IOGraph = graph; graphControl1.RefreshImage(); }
/// <summary> /// Refresh/update the view with the provided genome. /// </summary> public override void RefreshView(object genome) { // There doesn't seem to be any need to require the specific NeatGenome type. That is very difficult to generate from the network that // is generated from a cppn //NeatGenome neatGenome = genome as NeatGenome; //if(null == neatGenome) { // return; //} if (genome is INetworkDefinition castGenome) { IOGraph graph = _graphFactory.CreateGraph(castGenome); _viewportPainter.IOGraph = graph; graphControl1.RefreshImage(); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////// private void FilterGraphs(String dbDirecttory2, int noOfDataBase) { // TODO Auto-generated method stub if (!Directory.Exists(dbDirecttory2)) { Console.Out.WriteLine("Le répertoire n'existe pas"); return; } String trainingGraphFileName = ""; String trainingGraphClass = ""; XmlDocument objXmlDoc = new XmlDocument(); try { objXmlDoc.Load(this.readTrainingCXLFile); } catch (Exception e) { Console.WriteLine("Fichier train.cxl introuvable"); Console.WriteLine(e.ToString()); } // Récupération du noeud racine qui est la balise <GraphCollection> XmlNode objRootNode = objXmlDoc.DocumentElement; // Récupération du premier noeud enfant XmlNode objChildNode = null; objChildNode = objRootNode.FirstChild; fs = new FileStream(this.trainingFile, System.IO.FileMode.Create, System.IO.FileAccess.Write); Encoding outputEnc = new UTF8Encoding(false); monStream = new StreamWriter(fs, outputEnc); startTags(noOfDataBase); // Parcourt l'ensemble des noeuds XML while (objChildNode != null) { objChildNode = objChildNode.FirstChild; while (objChildNode != null) { if (objChildNode.Name == "print") { foreach (XmlNode item in objChildNode.Attributes) { if (item.Name == "file") { trainingGraphFileName = item.InnerText; } else if (item.Name == "class") { trainingGraphClass = item.InnerText; } } IOGraph ioGraph = new IOGraph(); Graph g2 = new Graph(); ioGraph.loadGXL(g2, this.dbDirecttory + "/" + trainingGraphFileName); if (this.Filter(g2)) { //WriteToTxt(testGraphFileName,trainingGraphFileName,testGraphClass,trainingGraphClass); monStream.WriteLine("<print file=\"" + trainingGraphFileName + "\" class=\"" + trainingGraphClass + "\"/>"); } } objChildNode = objChildNode.NextSibling; } } endTags(noOfDataBase); if (monStream != null) { monStream.Close(); } //#######################################################################################################" }