private void Redraw() { if (_sessions.Count == 0) { return; } var g = GraphicArea.CreateGraphics(); var fieldWidth = GraphicArea.Size.Width / BoardWidth; var fieldHeight = GraphicArea.Size.Height / BoardHeight; for (var x = 0; x < BoardWidth; x++) { for (var y = 0; y < BoardHeight; y++) { var color = GetFieldColor(_sessions[_selectedBoard].Board[x, y]); var brush = new SolidBrush(color); g.FillRectangle(brush, x * fieldWidth, y * fieldHeight, fieldWidth, fieldHeight); } } }
private static IWidget CreateWindow6_2(string path) { var window = new Window("window6_2", Path.Combine(path, @"generic/bg.raw")); var graphic = new GraphicArea("", 10, 10); var graphicSampleData = new GraphicArea.GraphicsData { Color = new Color { R = 1 } }; graphic.AddGrapics(graphicSampleData); window.AddChild(graphic); var vStartArea = new TextArea("", null, 12, 34, 100) { Size = 12, Text = "0.15 В" }; window.AddChild(vStartArea); var vEndArea = new TextArea("", null, 12, 198, 100) { Size = 12, Text = "0.35 В" }; window.AddChild(vEndArea); var timeStartArea = new TextArea("", null, 50, 12, 100) { Size = 14, Text = "Х с." }; window.AddChild(timeStartArea); var timeEndArea = new TextArea("", null, 410, 12, 100) { Size = 14, Text = "XXXX c." }; window.AddChild(timeEndArea); mMeasureController.Window62DataAction = (vStart, vEnd, timeStart, timeEnd, initialData, sampleData) => { vStartArea.Text = vStart; vEndArea.Text = vEnd; timeStartArea.Text = timeStart; timeEndArea.Text = timeEnd; graphicSampleData.Data = sampleData; window.Invalidate(); }; window.AddChild(new RawButton("", Path.Combine(path, "RawButtons/bt_to_table.raw"), Path.Combine(path, "RawButtons/bt_to_table_pr.raw"), 380, 180) { OnRelease = () => mMeasureController.CloseSampleGraphic() }); return(window); }
public static GraphicArea ClassicArea(IWidget parent) { var rv = new GraphicArea(parent, 460, 220) { Background = Palette.TextArea.Background }; #region Lines & arrows { var path = VGPath.OpenVGPath(); VG.vgLoadIdentity(); VGU.vguLine(path, 0, 0, rv.Width - 60, 0); // OX VGU.vguLine(path, 0, 0, 0, rv.Height - 40); // OY const float kXBias = 5f; const float kYBias = 12f; var yArroyBias = rv.Height - 40f; var pathData = new float[16]; pathData[0] = -kXBias; pathData[1] = yArroyBias; //0f; pathData[2] = 0f; pathData[3] = yArroyBias + kYBias; // kYBias; pathData[4] = kXBias; pathData[5] = yArroyBias; //0f; VGU.vguPolygon(path, pathData, 3, VGboolean.VG_TRUE); var xArroyBias = rv.Width - 60f; pathData[0] = xArroyBias; pathData[1] = -kXBias; pathData[2] = xArroyBias + kYBias; pathData[3] = 0f; pathData[4] = xArroyBias; pathData[5] = kXBias; VGU.vguPolygon(path, pathData, 3, VGboolean.VG_TRUE); var vgPath = new VGPath(path, new VGSolidColor(Palette.Black), new VGSolidColor(Palette.LightBlue)); vgPath.Move(35, 15); rv.Arrows = vgPath; } #endregion #region Grid { var path = VGPath.OpenVGPath(); for (var i = 1; i < 4; i++) { VGU.vguLine(path, 0, i * 60, rv.Width - 60, i * 60); // OX } for (var i = 1; i < 11; i++) { VGU.vguLine(path, i * 40, 0, i * 40, rv.Height - 40); // OY } var vgPath = new VGPath(path, null, null); vgPath.SetStroke(new VGSolidColor(Palette.DarkSlateGray), new[] { 5.0f, 10.0f, 15.0f, 10.0f }); vgPath.StrokeWidth = 0.5f; vgPath.Move(40, 20); rv.Grid = vgPath; } #endregion rv.Move(10, 10); return(rv); }
public static Window ShowWindow() { var window = new Window("show", kWidth, kHeight) { Description = "Шеф-повар \"Сибовар\"" }; var line = new TableLine(25); line.AddColumn(80); line.AddColumn(80); line.AddColumn(70); line.Text[0].Text = "HgjloGreen"; line.Text[0].SetFont(Palette.Lime, 20); line.Text[0].SetAlign(Align.Left, new GfxPoint(0, 3)); line.Text[1].Text = "HelloRed"; line.Text[1].SetFont(Palette.Red, 15); line.Text[1].SetAlign(Align.Center); line.Text[2].Text = "HgelloBlue"; line.Text[2].SetFont(Palette.PaleTurquoise, 30); line.Text[2].SetAlign(Align.Left, new GfxPoint(0, 4)); line.Name = "line"; var table = new Table(window) { Name = "table" }; table.Move(10, 50); table.AddLine(new TableLine(line)); table.AddLine(new TableLine(line)); table.AddLine(new TableLine(line)); table.SetBackground(Palette.Red, Palette.White); table.SetBorder(1, Palette.Lime); table.OnPress += caller => { var rv = table.GetLineByCell(caller); if (rv == null) { return; } table.ActiveLine = rv; window.Description = rv.Name; }; var text = new TextArea(window, 10, 180, 325, 50); text.SetFont("i260c", Palette.PaleTurquoise, 50); text.Text = "0123456789:"; text.OnPress += caller => window.Description = "Text.Pressed"; var bar = new ProgressBar(window, 40, 30, 200, 15, 15) { Percent = 10, Status = { Text = "hello" } }; bar.Status.SetAlign(Align.Center, new GfxPoint(3, 3)); bar.Status.SetFont(Palette.White, 14); bar.Rotate(70); text.OnRelease += caller => { window.Description = "Text.Released"; //mApplication.SetFocusedWindow("1"); line.Move(line.X - 3, line.Y - 3); table.ActiveLine = null; bar.Percent -= 1; }; window.OnPaint += delegate { Debug.Print(DateTime.Now.ToString("HH:mm:ss") + ":\tHome update"); }; var activePath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL); VGU.vguRoundRect(activePath, 0, 0, 60, 100, 20, 20); var normalPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL); VGU.vguRoundRect(normalPath, 0, 0, 100, 50, 20, 20); VGU.vguRoundRect(normalPath, 10, 50, 80, 70, 20, 20); var activeButton = new VGSolidColor(new Color(0xFF0000FF)); //var normalButton = new VGSolidColor(new Color(0x00FF00FF)); var normalButton = new VGLinearGradient(0, 0, 100, 120); normalButton.AddColor(0, new Color(0xFF0000FF)); normalButton.AddColor(100, new Color(0x00FF00FF)); var button = new Button(window, new VGPath(activePath, null, activeButton), new VGPath(normalPath, null, normalButton)); button.IsCached = true; button.Move(250, 50); button.OnPress += delegate { Console.WriteLine("button.OnPress"); }; var image = new Image(window, 25, 10); image.Load("splash.raw"); image.Scale(0.5f, 0.5f); image.RotateCenter = new GfxPoint(image.Width / 2, image.Height / 2); //image.Hide(); window.OnPaint += caller => { image.Rotate(mImageRotate); mImageRotate += 5; }; var graphicArea = new GraphicArea(window, 200, 200); graphicArea.Move(70, 20); graphicArea.Background = new Color(0xF0F0F0FF); graphicArea.Grid = new VGPath(activePath, activeButton, null); graphicArea.Arrows = new VGPath(normalPath, new VGSolidColor(Palette.PaleTurquoise), null); var graphicData1 = new GraphicsData { Data = new byte[] { 0, 15, 25, 50, 40, 35, 12, 10, 15, 17, 30, 32, 35, 35, 35, 35, 35, 40, 45, 57, 25, 23, 20, 18, 12, 12, 12, 30, 32, 35, 35, 35, 35, 35, 40, 45 } }; var graphicData2 = new GraphicsData(graphicData1) { Color = Palette.Lime, Position = new GfxPoint(10, 10) }; graphicArea.AddGrapic(graphicData1); graphicArea.AddGrapic(graphicData2); return(window); }
private void UpdateGraphics() { double canvasHeight = mainCanvas.ActualHeight; double canvasWidth = mainCanvas.ActualWidth; Point bottomLeft = new Point(0, mainCanvas.ActualHeight); double leftColumnWidth = Math.Min(200, canvasWidth / 4); double PlotAxisMargin = 10; AbovePlotArea = new GraphicArea(leftColumnWidth, 0, canvasWidth - leftColumnWidth, 26); AxisArea = new GraphicArea(0, AbovePlotArea.Bottom, leftColumnWidth, 7 * canvasHeight / 12); PlotArea = new GraphicArea(AxisArea.Right + PlotAxisMargin, AbovePlotArea.Bottom, canvasWidth - AxisArea.width, AxisArea.height); XLabelArea = new GraphicArea(PlotArea.Left, PlotArea.Bottom, canvasWidth - AxisArea.width, 50); TimeModeArea = new GraphicArea(0, AxisArea.Bottom, AxisArea.width, XLabelArea.height); //Bot left area WordSoupArea = new GraphicArea(XLabelArea.Left, XLabelArea.Bottom, XLabelArea.width, canvasHeight - XLabelArea.Bottom); Canvas.SetLeft(PlotAreaRect, PlotArea.Left); Canvas.SetTop(PlotAreaRect, PlotArea.Top); PlotAreaRect.Width = PlotArea.width; PlotAreaRect.Height = PlotArea.height; //Show draw zones only if (false) { mainCanvas.Children.Clear(); Rectangle a1 = new Rectangle(); a1.Fill = new SolidColorBrush(Colors.Blue); a1.Width = AxisArea.width; a1.Height = AxisArea.height; mainCanvas.Children.Add(a1); Canvas.SetTop(a1, AxisArea.Top); Canvas.SetLeft(a1, AxisArea.Left); a1 = new Rectangle(); a1.Fill = new SolidColorBrush(Colors.Red); a1.Width = PlotArea.width; a1.Height = PlotArea.height; //mainCanvas.Children.Add(a1); Canvas.SetTop(a1, PlotArea.Top); Canvas.SetLeft(a1, PlotArea.Left); a1 = new Rectangle(); a1.Fill = new SolidColorBrush(Colors.Orange); a1.Width = XLabelArea.width; a1.Height = XLabelArea.height; mainCanvas.Children.Add(a1); Canvas.SetTop(a1, XLabelArea.Top); Canvas.SetLeft(a1, XLabelArea.Left); a1 = new Rectangle(); a1.Fill = new SolidColorBrush(Colors.Purple); a1.Width = WordSoupArea.width; a1.Height = WordSoupArea.height; mainCanvas.Children.Add(a1); Canvas.SetTop(a1, WordSoupArea.Top); Canvas.SetLeft(a1, WordSoupArea.Left); a1 = new Rectangle(); a1.Fill = new SolidColorBrush(Colors.Pink); a1.Width = TimeModeArea.width; a1.Height = TimeModeArea.height; mainCanvas.Children.Add(a1); Canvas.SetTop(a1, TimeModeArea.Top); Canvas.SetLeft(a1, TimeModeArea.Left); //return; } //Plot Measure Plots //Detect graphical elements size descrepancies if (plotsGraphics.Count != binner.measures.Count) { int diff = binner.measures.Count - plotsGraphics.Count; if (diff > 0) { while (binner.measures.Count != plotsGraphics.Count) { //Create graphical object associated with measure PlotGraph measureGraph = new PlotGraph(); plotsGraphics.Add(measureGraph); //Create polygon associated with graphical object Polygon plotPoly = new Polygon(); plotPoly.Stroke = new SolidColorBrush(Colors.Black); plotPoly.Fill = new SolidColorBrush(Colors.LightBlue); plotPoly.StrokeThickness = 2; measureGraph.plotPoly = plotPoly; mainCanvas.Children.Add(plotPoly); } } else { while (binner.measures.Count != plotsGraphics.Count) { //Remove Polygons mainCanvas.Children.Remove(plotsGraphics[0].plotPoly); //Remove graphics plotsGraphics.RemoveAt(0); } } } //Detect self graphical elements size descrepancies if (binner.GetSplitMode()) { if (selfPlotsGraphics.Count != binner.measures.Count) { int diff = binner.measures.Count - selfPlotsGraphics.Count; if (diff > 0) { while (binner.measures.Count != selfPlotsGraphics.Count) { //Create graphical object associated with measure PlotGraph measureGraph = new PlotGraph(); selfPlotsGraphics.Add(measureGraph); //Create polygon associated with graphical object Polygon plotPoly = new Polygon(); plotPoly.Stroke = new SolidColorBrush(Colors.Black); plotPoly.Fill = new SolidColorBrush(Colors.Green); plotPoly.StrokeThickness = 2; measureGraph.plotPoly = plotPoly; mainCanvas.Children.Add(plotPoly); } } else { while (binner.measures.Count != selfPlotsGraphics.Count) { //Remove Polygons mainCanvas.Children.Remove(selfPlotsGraphics[0].plotPoly); //Remove graphics selfPlotsGraphics.RemoveAt(0); } } } } //Update plot graphics double pace = PlotArea.width / (binner.binCount); double multiplier; TimelineDataController.PlotData data, selfData; PlotGraph graph, selfGraph; double axisHeight; PointCollection points; for (int m = 0; m < binner.measures.Count; m++) { data = binner.plotsData[m]; selfData = null; graph = plotsGraphics[m]; if (!binner.GetSplitMode()) { axisHeight = 0; multiplier = PlotArea.height / data.max; } else { selfData = binner.selfPlotsData[m]; axisHeight = PlotArea.height * selfData.max / (data.max + selfData.max); multiplier = PlotArea.height / (data.max + selfData.max); } points = new PointCollection(); points.Add(new Point(PlotArea.Right, PlotArea.Bottom - axisHeight)); points.Add(new Point(PlotArea.Left, PlotArea.Bottom - axisHeight)); for (int b = 0; b < binner.binCount; b++) { //Bin points.Add(new Point(binner.binDefinitions[b].axisStart * PlotArea.width + PlotArea.Left, -(data.binValues[b] * multiplier) + PlotArea.Bottom - axisHeight)); points.Add(new Point(binner.binDefinitions[b].axisEnd * PlotArea.width + PlotArea.Left, -(data.binValues[b] * multiplier) + PlotArea.Bottom - axisHeight)); //Linear //points.Add(new Point(binner.binDefinitions[b].axisStart * PlotArea.width + pace/2 + PlotArea.Left, -(data.binValues[b] * multiplier) + PlotArea.Bottom)); } graph.plotPoly.Points = points; if (binner.GetSplitMode()) { selfGraph = selfPlotsGraphics[m]; points = new PointCollection(); points.Add(new Point(PlotArea.Right, PlotArea.Bottom - axisHeight)); points.Add(new Point(PlotArea.Left, PlotArea.Bottom - axisHeight)); for (int b = 0; b < binner.binCount; b++) { //Bin points.Add(new Point(binner.binDefinitions[b].axisStart * PlotArea.width + PlotArea.Left, (selfData.binValues[b] * multiplier) + PlotArea.Bottom - axisHeight)); points.Add(new Point(binner.binDefinitions[b].axisEnd * PlotArea.width + PlotArea.Left, (selfData.binValues[b] * multiplier) + PlotArea.Bottom - axisHeight)); //Linear //points.Add(new Point(binner.binDefinitions[b].axisStart * PlotArea.width + pace/2 + PlotArea.Left, -(data.binValues[b] * multiplier) + PlotArea.Bottom)); } selfGraph.plotPoly.Points = points; } } //Update Top Controls //Split Canvas.SetLeft(splitBut, 0); Canvas.SetTop(splitBut, 0); splitBut.Content = binner.GetSplitMode() ? "All" : "Split"; splitBut.Width = AbovePlotArea.Left; splitBut.Height = AxisArea.Top; //TimeOverviewer Canvas.SetLeft(timeOverviewLabel, AbovePlotArea.Left); Canvas.SetTop(timeOverviewLabel, AbovePlotArea.Top); timeOverviewLabel.Content = binner.timeOverview; //Text Finder Canvas.SetLeft(textFinderBox, AbovePlotArea.Right - 100); Canvas.SetTop(textFinderBox, AbovePlotArea.Top); Canvas.SetLeft(textFinderLabel, AbovePlotArea.Right - 100 - 40); Canvas.SetTop(textFinderLabel, AbovePlotArea.Top); //Update TimeMode Buttons Position double buttonSize = TimeModeArea.width / 4; Canvas.SetLeft(linearTimeBut, TimeModeArea.Left); Canvas.SetTop(linearTimeBut, TimeModeArea.Top); linearTimeBut.Width = buttonSize; Canvas.SetLeft(yearTimeBut, TimeModeArea.Left + buttonSize * 1); Canvas.SetTop(yearTimeBut, TimeModeArea.Top); yearTimeBut.Width = buttonSize; Canvas.SetLeft(weekTimeBut, TimeModeArea.Left + buttonSize * 2); Canvas.SetTop(weekTimeBut, TimeModeArea.Top); weekTimeBut.Width = buttonSize; Canvas.SetLeft(hourTimeBut, TimeModeArea.Left + buttonSize * 3); Canvas.SetTop(hourTimeBut, TimeModeArea.Top); hourTimeBut.Width = buttonSize; //Spread some labels around //Clear labels for (int i = 0; i < labels.Count; i++) { mainCanvas.Children.Remove(labels[i]); } labels.Clear(); for (int i = 0; i < axisMarkers.Count; i++) { mainCanvas.Children.Remove(axisMarkers[i]); } axisMarkers.Clear(); //Axis labels List <TimelineDataController.LabelDefinition> axisLabels = binner.getTimeAxisLabels(); for (int i = 0; i < axisLabels.Count; i++) { TimelineDataController.LabelDefinition labelData = axisLabels[i]; if (labelData.axisFactor >= 0 && labelData.axisFactor <= 1) { double xx = PlotArea.Left + PlotArea.width * labelData.axisFactor; Label newLabel = new Label(); newLabel.Width = 100; newLabel.Content = labelData.mainText; newLabel.HorizontalContentAlignment = HorizontalAlignment.Center; Canvas.SetTop(newLabel, PlotArea.Bottom); Canvas.SetLeft(newLabel, xx - 50); mainCanvas.Children.Add(newLabel); labels.Add(newLabel); if (labelData.subText != "") { newLabel = new Label(); newLabel.Width = 100; newLabel.Content = labelData.subText; newLabel.HorizontalContentAlignment = HorizontalAlignment.Center; Canvas.SetTop(newLabel, PlotArea.Bottom + XLabelArea.height / 4); Canvas.SetLeft(newLabel, xx - 50); mainCanvas.Children.Add(newLabel); labels.Add(newLabel); } Line newMarker = new Line(); newMarker.Stroke = new SolidColorBrush(Colors.Black); newMarker.StrokeThickness = 2; newMarker.X1 = xx; newMarker.Y1 = PlotArea.Bottom - 6; newMarker.X2 = xx; newMarker.Y2 = PlotArea.Bottom + 6; mainCanvas.Children.Add(newMarker); axisMarkers.Add(newMarker); } } //WordSoup for (int i = 0; i < wordSoupLabels.Count; i++) { mainCanvas.Children.Remove(wordSoupLabels[i]); } wordSoupLabels.Clear(); List <WordSoupMeta> wordMeta = new List <WordSoupMeta>(); int wordSoupCount = 5; double accumulated = 0; for (int i = 0; i < wordSoupCount && i < binner.lexicAnomalies.Count; i++) { TimelineDataController.LexicPresence presence = binner.lexicAnomalies[i]; WordSoupMeta meta = new WordSoupMeta(presence.word, presence.weight, presence.placement); wordMeta.Add(meta); accumulated += meta.weight; } double orderAcum = 0; for (int i = 0; i < wordMeta.Count; i++) { WordSoupMeta wmeta = wordMeta[i]; Label lbl = new Label(); lbl.Content = wmeta.word; lbl.HorizontalContentAlignment = HorizontalAlignment.Center; lbl.VerticalContentAlignment = VerticalAlignment.Center; double cS = (wmeta.weight / accumulated); lbl.Background = new SolidColorBrush(Colors.CornflowerBlue); lbl.BorderBrush = new SolidColorBrush(Colors.Blue); double hh = cS * WordSoupArea.height; lbl.Height = hh; double ww = cS * WordSoupArea.width; lbl.Width = ww; Canvas.SetTop(lbl, WordSoupArea.Top + orderAcum * WordSoupArea.height); Canvas.SetLeft(lbl, WordSoupArea.Left + wmeta.axis * WordSoupArea.width - ww / 2); orderAcum += cS; wordSoupLabels.Add(lbl); mainCanvas.Children.Add(lbl); } }
public EditorArea(State state, GraphicArea graphicArea) { this.state = state; this.graphicArea = graphicArea; }