/// <summary> /// Action when PrintObjectList change /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnPrintObjectListChanged(object sender, NotifyCollectionChangedEventArgs e) { _children.Clear(); //_children.Add( CreateObjectDrawingVisual(Barcode_Base_List)); int index = 0; foreach (PrintObject_Base b in PrintObject_List) { b._Index = index; index++; _children.Add(CreateObjectDrawingVisual(b)); } if (_children.Contains(DashRect)) { _children.Remove(DashRect); } if (e.OldItems != null) { foreach (INotifyPropertyChanged item in e.OldItems) { item.PropertyChanged -= ItemList_PropertyChanged; } } if (e.NewItems != null) { foreach (INotifyPropertyChanged item in e.NewItems) { item.PropertyChanged += ItemList_PropertyChanged; } } }
// Create a DrawingVisual that contains a rectangle. public void CreateBarChart(ICollection dt, double _maxData, double chartHeight, double chartWidth) { _children.Clear(); stopWatch.Restart(); var barWidth = SetBarWidth(dt.Count, chartWidth); var visual = new DrawingVisual(); using (var dc = visual.RenderOpen()) { // For each row in the datasource double left, right = _axis_start; foreach (var el in dt) { // Calculate bar value. var height = Convert.ToDouble(el) * (chartHeight - _axis_start) / _maxData; left = right; right = barWidth + left; dc.DrawRectangle(null, _chartPen, new Rect(left, chartHeight - height - _axis_start, barWidth, height)); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. // Format and display the TimeSpan value. var elapsedTime = String.Format("{0} - {1} - {2}", MethodBase.GetCurrentMethod().Name, dt.Count, stopWatch.ElapsedTicks); dc.DrawText(new FormattedText(elapsedTime, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 12, Brushes.LightGreen), new Point(10, 10)); } _children.Add(visual); }
public void AddLayer(int priority, Action <DrawingContext> draw, ChangeType notifyOnChange = ChangeType.Redraw) { var drawingVisual = new DrawingVisual(); var layerInfo = new WpfLayerInfo(priority, draw, drawingVisual, notifyOnChange); _layers.Add(layerInfo); _layers.Sort((x, y) => x.Priority.CompareTo(y.Priority)); _children.Clear(); _layers.ForEach(l => _children.Add(l.Visual)); }
public void DrawHexes(IEnumerable <TileViewModel> tiles) { children.Clear(); children.Add(CreateBackground()); var tileEnumerator = tiles.GetEnumerator(); for (int col = 0; col < hexCols; col++) { for (int row = 0; row < hexRows; row++) { if (HiddenHexes.Any(x => x.Item1 == col && x.Item2 == row)) { continue; } if (!tileEnumerator.MoveNext()) { break; } var offset = computeHexOffsets(col, row); var tmpHex = new TileControl(offset.Item1, offset.Item2, HEX_WIDTH, HEX_HEIGHT, tileEnumerator.Current); children.Add(tmpHex); } } }
internal static void UpdateTrackVisuals(PtsContext ptsContext, VisualCollection visualCollection, PTS.FSKUPDATE fskupdInherited, ref PTS.FSTRACKDESCRIPTION trackDesc) { PTS.FSKUPDATE fskupdate = trackDesc.fsupdinf.fskupd; if (trackDesc.fsupdinf.fskupd == PTS.FSKUPDATE.fskupdInherited) { fskupdate = fskupdInherited; } if (fskupdate == PTS.FSKUPDATE.fskupdNoChange) { return; } ErrorHandler.Assert(fskupdate != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid); bool flag = trackDesc.pfstrack == IntPtr.Zero; if (!flag) { PTS.FSTRACKDETAILS fstrackdetails; PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out fstrackdetails)); flag = (fstrackdetails.cParas == 0); if (!flag) { PTS.FSPARADESCRIPTION[] arrayParaDesc; PtsHelper.ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref fstrackdetails, out arrayParaDesc); PtsHelper.UpdateParaListVisuals(ptsContext, visualCollection, fskupdate, arrayParaDesc); } } if (flag) { visualCollection.Clear(); } }
public void DrawPoints(SortedList <double, double> points, Point[] line) { _children.Clear(); double width = ActualWidth; double height = ActualHeight; foreach (var point in line) { System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); double x = point.X * width; double y = height - point.Y * height; drawingContext.DrawEllipse(Brushes.Blue, null, new Point(x, y), 1, 1); drawingContext.Close(); _children.Add(drawingVisual); } foreach (var point in points) { System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); Pen pen = new Pen(Brushes.AntiqueWhite, 3); drawingContext.DrawEllipse(Brushes.Transparent, pen, new Point(point.Key * width, height - point.Value * height), 3, 3); drawingContext.Close(); _children.Add(drawingVisual); } }
/// <summary> /// Renders heat map content into the given canvas. The rendering is done using monochrome color (white) and need /// colorizing effect to have custom palette. /// </summary> public void Render() { // clear visuals _heatMapVisuals.Clear(); // draw heatmap points DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext dc = drawingVisual.RenderOpen()) { var heatPoints = GetPointsSource(this)?.ToList(); if (heatPoints != null) { foreach (var point in heatPoints) { var widthHeight = (double)point.Intensity; dc.DrawRectangle(_brushes[point.Intensity], null, new Rect(point.X - widthHeight / 2, point.Y - widthHeight / 2, widthHeight, widthHeight)); } } _heatMapVisuals.Add(drawingVisual); } }
// Token: 0x0600692C RID: 26924 RVA: 0x001DC364 File Offset: 0x001DA564 internal static void UpdateFloatingElementVisuals(ContainerVisual visual, List <BaseParaClient> floatingElementList) { VisualCollection children = visual.Children; int num = 0; if (floatingElementList == null || floatingElementList.Count == 0) { children.Clear(); return; } for (int i = 0; i < floatingElementList.Count; i++) { Visual visual2 = floatingElementList[i].Visual; while (num < children.Count && children[num] != visual2) { children.RemoveAt(num); } if (num == children.Count) { children.Add(visual2); } num++; } if (children.Count > floatingElementList.Count) { children.RemoveRange(floatingElementList.Count, children.Count - floatingElementList.Count); } }
void ChartHost_SizeChanged(object sender, SizeChangedEventArgs e) { //Trace.WriteLine(string.Format("{0}-{1}", e.PreviousSize.ToString(), e.NewSize.ToString())); _children.Clear(); Size newSize = new Size(e.NewSize.Width - ChartMargin.Left - ChartMargin.Right, e.NewSize.Height - ChartMargin.Top - ChartMargin.Bottom); if (_mainCollection != null) { _mainCollection.Resize(newSize); } foreach (var assistColl in _assistCollections) { assistColl.Resize(newSize); } if (_mainCollection != null) { DrawVisuals(); } _collectionRect = GetChartRect(); }
internal void UpdateVisualForScript(IScriptObject hostScript) { if (null == hostScript) { return; } // If there's no switching of active script, // then simply do a screen refresh and get out of here! if (textBuffer == hostScript.GetTextBuffer()) { highlight.Render(); lineHeading.Render(); sourceDisplay.Render(); auxiliary.Render(); return; } children.Clear(); // Clears all children before populating it again. textBuffer = hostScript.GetTextBuffer(); highlight.UpdateLayerForScript(hostScript); lineHeading.UpdateLayerForScript(hostScript); sourceDisplay.UpdateLayerForScript(hostScript); auxiliary.UpdateLayerForScript(hostScript); highlight.ResetHighlightLayer(); highlight.ResetExecutionCursor(); children.Add(auxiliary.Render()); children.Add(highlight.Render()); children.Add(lineHeading.Render()); children.Add(sourceDisplay.Render()); }
// Warning: this method is very dangerous because it does not prevent adding children // into collection populated by generator. This may cause crashes if used incorrectly. // Don't call this unless you are deriving a panel that is populating the collection // in cooperation with the generator internal void ClearInternal() { VisualCollection vc = _visualChildren; int cnt = vc.Count; if (cnt > 0) { // copy children in VisualCollection so that we can clear the visual link first, // followed by the logical link Visual[] visuals = new Visual[cnt]; for (int i = 0; i < cnt; i++) { visuals[i] = vc[i]; } vc.Clear(); //disconnect from logical tree for (int i = 0; i < cnt; i++) { UIElement e = visuals[i] as UIElement; if (e != null) { ClearLogicalParent(e); } } _visualParent.InvalidateMeasure(); } }
// ------------------------------------------------------------------ // Syncs a floating element para list with a visual collection // ------------------------------------------------------------------ internal static void UpdateFloatingElementVisuals(ContainerVisual visual, List <BaseParaClient> floatingElementList) { VisualCollection visualChildren = visual.Children; int visualIndex = 0; if (floatingElementList == null || floatingElementList.Count == 0) { visualChildren.Clear(); } else { for (int index = 0; index < floatingElementList.Count; index++) { Visual paraVisual = floatingElementList[index].Visual; while (visualIndex < visualChildren.Count && visualChildren[visualIndex] != paraVisual) { visualChildren.RemoveAt(visualIndex); } if (visualIndex == visualChildren.Count) { visualChildren.Add(paraVisual); } visualIndex++; } if (visualChildren.Count > floatingElementList.Count) { visualChildren.RemoveRange(floatingElementList.Count, visualChildren.Count - floatingElementList.Count); } } }
public void Redraw() { visualCollection.Clear(); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); GlobalVars.figures = GlobalVars.figures.OrderBy(o => o.ZIndex).ToList(); foreach (Figures.Figure figure in GlobalVars.figures) { var newFigure = figure.SetConvertedFigure(); newFigure.Draw(drawingContext); } foreach (var figure in GlobalVars.selections) { var newFigure = figure.SetConvertedFigure(); newFigure.Draw(drawingContext); } if (GlobalVars.tempFigure != null) { GlobalVars.tempFigure = GlobalVars.tempFigure.SetConvertedFigure(); GlobalVars.tempFigure.Draw(drawingContext); } drawingContext.Close(); visualCollection.Add(drawingVisual); }
// ----------------------------------------------------------------------------------------------------------------------- public void ClearAllIndicators() { ClearExclusivePointingIndicators(); Indicators.Clear(); InvalidateVisual(); }
/// <summary> /// Removes all DrawingVisuals from VisualsPanel except the Visual for the VisualsPanel's Background. /// </summary> public void Clear() { visuals.Clear(); if (backgroundDrawingVisual != null) { visuals.Add(backgroundDrawingVisual); } }
public void DrawLines(List <Line> lines, Brush brush) { children.Clear(); var visual = new DrawingVisual(); children.Add(visual); Optimize(lines); var pen = new Pen(brush, 1); using (var dc = visual.RenderOpen()) foreach (var line in lines) { dc.DrawLine(pen, line.Point1, line.Point2); } }
private void UpdateSectionVisuals(SectionVisual visual, PTS.FSKUPDATE fskupdInherited, ref PTS.FSSECTIONDESCRIPTION sectionDesc) { PTS.FSKUPDATE fskupdate = sectionDesc.fsupdinf.fskupd; if (fskupdate == PTS.FSKUPDATE.fskupdInherited) { fskupdate = fskupdInherited; } ErrorHandler.Assert(fskupdate != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid); if (fskupdate == PTS.FSKUPDATE.fskupdNoChange) { return; } PTS.FSSECTIONDETAILS fssectiondetails; PTS.Validate(PTS.FsQuerySectionDetails(this.PtsContext.Context, sectionDesc.pfssection, out fssectiondetails)); bool flag; if (PTS.ToBoolean(fssectiondetails.fFootnotesAsPagenotes)) { ErrorHandler.Assert(fssectiondetails.u.withpagenotes.cEndnoteColumns == 0, ErrorHandler.NotSupportedFootnotes); flag = (fssectiondetails.u.withpagenotes.cBasicColumns == 0); if (!flag) { PTS.FSTRACKDESCRIPTION[] array; PtsHelper.TrackListFromSection(this.PtsContext, sectionDesc.pfssection, ref fssectiondetails, out array); flag = (array.Length == 0); if (!flag) { ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(this._section.Element); visual.DrawColumnRules(ref array, TextDpi.FromTextDpi(sectionDesc.fsrc.v), TextDpi.FromTextDpi(sectionDesc.fsrc.dv), columnProperties); VisualCollection children = visual.Children; if (fskupdate == PTS.FSKUPDATE.fskupdNew) { children.Clear(); for (int i = 0; i < array.Length; i++) { children.Add(new ContainerVisual()); } } ErrorHandler.Assert(children.Count == array.Length, ErrorHandler.ColumnVisualCountMismatch); for (int j = 0; j < array.Length; j++) { ContainerVisual containerVisual = (ContainerVisual)children[j]; PtsHelper.UpdateTrackVisuals(this.PtsContext, containerVisual.Children, fskupdate, ref array[j]); } } } } else { ErrorHandler.Assert(false, ErrorHandler.NotSupportedCompositeColumns); flag = true; } if (flag) { visual.Children.Clear(); } }
public void Init(MapColorModes mapColor = MapColorModes.Provs, List <Prov> list = null) { if (list == null) { _children.Clear(); FindDict = new Dictionary <System.Windows.Media.DrawingVisual, Prov>(); //////////////////// var vm = SimpleIoc.Default.GetInstance <MainViewModel>(); this.BeginInit(); foreach (var prov in vm.Provs) { var visual = CreateDrawingVisualProvince(prov, mapColor); _children.Add(visual); FindDict.Add(visual, prov); prov.Visual = visual; } this.EndInit(); /////////////////// var query = vm.Provs.Select( v => new SimpleProv { Name = v.Name, Color = v.Color, Contours = v.Contours }); var str = JsonConvert.SerializeObject(query, Formatting.Indented); System.IO.File.WriteAllText("points.json", str); } else { var visuals = FindDict.Where(v => list.Contains(v.Value)) .Where(v => !v.Value.IsLake && !v.Value.IsSea && !v.Value.IsWaste) .Select(v => v.Key); visuals.ToList().ForEach(v => { FindDict.Remove(v); _children.Remove(v); }); this.BeginInit(); foreach (var prov in list) { var visual = CreateDrawingVisualProvince(prov, mapColor); _children.Add(visual); FindDict.Add(visual, prov); prov.Visual = visual; } this.EndInit(); } }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { _children.Clear(); if (_children.Count == 0) _children.Add(DrawTarget()); Loaded -= OnLoaded; //Redraw(); }
private void UpdateWaveform() { children.Clear(); if (Waveform != null) { children.Add(CreateWaveFormVisual()); } this.InvalidateVisual(); }
/// <summary> /// tool deactiavaion on working Canvas /// /// </summary> public virtual void Deactivate() { if (AdornerLayer.GetAdornerLayer(AdornedElement) != null) { AdornerLayer.GetAdornerLayer(AdornedElement).Remove(this); AdornerLayer.GetAdornerLayer(AdornedElement).UpdateLayout(); } ((FrameworkElement)AdornedElement).Loaded -= new RoutedEventHandler(BaseTool_Loaded); (AdornedElement as FrameworkElement).SizeChanged -= new SizeChangedEventHandler(AdornedElementSizeChanged); visualChildren.Clear(); }
public void AddValue(float maxValue, float minValue) { int xpos = maxPoints.Count; maxPoints.Add(new Point(xpos, SampleToYPosition(minValue))); minPoints.Add(new Point(xpos, SampleToYPosition(maxValue))); _children.Clear(); _children.Add(CreateWaveFormVisual()); this.InvalidateVisual(); }
public void Generate() { using (var gen = new DefaultPasswordGenerator(new CryptoRandomNumberGenerator())) { var val = gen.Generate(1, TextLength == 0 ? 6 : TextLength, true, true, true, false, null, 2, 2, 2, PasswordStrengthEnum.NotDefined); _text = val[0].Value; } _children.Clear(); _children.Add(CreateVisual()); InvalidateVisual(); }
private void RebuildChildren() { children.Clear(); if (axisVisual != null) { children.Add(axisVisual); } foreach (var graphId in graphVisuals.Keys.OrderBy(x => x)) { children.Add(graphVisuals[graphId]); } }
public void Update(Hatch hatch) { if (hatch == null) { return; } if (children == null || string.IsNullOrEmpty(hatch.Definition)) { return; } children.Clear(); children.Add(CreateDrawingVisualHatch(hatch)); }
public void Redraw() { visualcollection.Clear(); DrawingVisual drawingvisual = new DrawingVisual(); DrawingContext drawingcontext = drawingvisual.RenderOpen(); foreach (Figure f in Global.figures) { f.Draw(drawingcontext); } drawingcontext.Close(); visualcollection.Add(drawingvisual); }
internal void MeasurePoints(IPoints points, GridRange newViewport, IGrid <string> data, bool refresh) { var orgGrid = _visualGrid; _visualGrid = new Grid <TextVisual>( newViewport, (r, c) => { if (!refresh && _dataViewport.Contains(r, c)) { return(orgGrid[r, c]); } var visual = new TextVisual(); visual.Row = r; visual.Column = c; visual.Text = data[r, c]; visual.Typeface = Typeface; visual.FontSize = FontSize; // FontSize here is in device independent pixel, and Visual's FormattedText API uses the same unit visual.Foreground = Foreground; return(visual); }); _visualChildren.Clear(); foreach (int c in newViewport.Columns.GetEnumerable()) { foreach (int r in newViewport.Rows.GetEnumerable()) { var visual = _visualGrid[r, c]; visual.Draw(); points.Width[c] = visual.Size.Width + (visual.Margin * 2) + GridLineThickness; points.Height[r] = visual.Size.Height + (visual.Margin * 2) + GridLineThickness; _visualChildren.Add(_visualGrid[r, c]); } } _dataViewport = newViewport; }
internal void Render(IEnumerable <DrawableElement> drawables, ViewPort viewPort) { collection.Clear(); foreach (var drawable in drawables) { var visual = new DrawingVisual(); using (var context = visual.RenderOpen()) { drawable.Draw(context, viewPort); } collection.Add(visual); } }
void dragHandle_DragCompleted(object sender, DragCompletedEventArgs e) { Point actualPos = Mouse.GetPosition(this); if (actualPos.X < 0 || actualPos.Y < 0) { visualChildren.Clear(); InvalidateArrange(); return; } linkStroke.path.Insert(indexInPath, new Coordinates(actualPos)); linkStroke.addStylusPointsToLink(); DrawingService.UpdateLinks(new StrokeCollection { linkStroke }); canvas.RefreshChildren(); InvalidateArrange(); visualChildren.Clear(); }
/// <summary> /// Draws the providen searchResults items and focused the correct item /// </summary> /// <param name="searchResults"></param> /// <param name="focusedIndex"></param> /// <param name="focusedItem"></param> public void DrawItems(List <ResultItem> searchResults, int focusedIndex, out ResultItem focusedItem) { focusedItem = searchResults.ElementAtOrDefault(focusedIndex); _searchResults = searchResults; Dispatcher.BeginInvoke((Action)(() => { _children.Clear(); CurrentFocus = focusedIndex; for (var i = 0; i < searchResults.Count; i++) { DrawBackground(i, focusedIndex == i? FocusBackgroundBrush : Brushes.Transparent); DrawItemAtPos(searchResults[i], i); } })); }