/// <summary> /// Load color sets. /// </summary> private void LoadColorSets() { ColorSets colorSets = null; if (MyAPIGateway.Utilities.FileExistsInGlobalStorage(COLOR_SETS_FILE)) { try { using (var reader = MyAPIGateway.Utilities.ReadFileInGlobalStorage(COLOR_SETS_FILE)) { colorSets = MyAPIGateway.Utilities.SerializeFromXML <ColorSets>(reader.ReadToEnd()); } } catch (Exception exception) { // ignored } } if (colorSets != null) { if (colorSets.Version < ColorSets.VERSION) { // todo: merge old and new color sets in future versions. } } else { colorSets = new ColorSets(); } ColorSets = colorSets; }
public void UpdateGraphVm() { if (Values == null) { return; } var bins = A2dUt.ToP2V(Histos.Histogram2d( bounds: Bounds, binCount: BinCounts.Sz2Int, vals: Values)).ToArray(); var counts = bins.Select(b => b.V.V).ToArray(); var colorLeg = ColorLegger(counts); LegendVm = new LegendVm( minVal: "<" + colorLeg.minV, midVal: ColorSets.GetLegMidVal(colorLeg).ToString(), maxVal: ">" + colorLeg.maxV, minCol: colorLeg.minC, midColors: colorLeg.spanC, maxColor: colorLeg.maxC ); GraphVm.Watermark = $"Bins count: [{BinCounts.X}, {BinCounts.Y}]"; GraphVm.SetData( boundingRect: Bounds, plotPoints: Enumerable.Empty <P2V <float, Color> >(), plotLines: Enumerable.Empty <LS2V <float, Color> >(), filledRects: MakePlotRectangles(colorLeg: colorLeg, hist: bins), openRects: Enumerable.Empty <RV <float, Color> >()); }
/// <summary> /// Defines a coarse partitioning that categorizes nodes based on the degree of the node. /// </summary> private int InitializeColoring() { ColorAssignment.Clear(); ColorSets.Clear(); foreach (var node in _graph.Nodes) { int color = node.OutDegree; ColorAssignment[node] = color; } int nextColor = ColorAssignment.Values.Max() + 1; for (int i = 0; i < D.Count; i++) { ColorAssignment[D[i]] = nextColor; ColorAssignment[I[i]] = nextColor; nextColor++; } foreach (var entry in ColorAssignment) { if (!ColorSets.TryGetValue(entry.Value, out var set)) { ColorSets[entry.Value] = set = new HashSet <Node>(); } set.Add(entry.Key); } return(nextColor); }
public ColorDefinition() { ColorSet = null; ColorSetRowIndex = -1; UnitType = null; UnitTypeRowIndex = -1; Colors = null; }
public RV <float, Color> MakeRectangle(P2V <int, T> v) { return(new RV <float, Color>( minX: v.X, minY: v.Y, maxX: v.X + 1.0f, maxY: v.Y + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); }
public Properity(int price, ProperityDeed deed, ColorSets color) { this.price = price; this.deed = deed; this.color = color; onMortgage = false; HouseCount = 0; HotelCount = 0; }
private object UpDato(P2 <int> dataLoc, R <double> imagePatch, object data) { var offset = dataLoc.X + dataLoc.Y * DataSz2.X; var color = ColorSets.GetLegColor(ColorSets.RedBlueSFLeg, _testArray[offset]); return(new RV <float, Color>( minX: (float)imagePatch.MinX, maxX: (float)imagePatch.MaxX, minY: (float)imagePatch.MinY, maxY: (float)imagePatch.MaxY, v: color)); }
private List <RV <float, Color> > MakePlotRectangles( ColorLeg <int> colorLeg, IEnumerable <P2V <int, RV <float, int> > > hist) { return(hist.Select( v => new RV <float, Color>( minX: v.V.MinX, minY: v.V.MinY, maxX: v.V.MaxX, maxY: v.V.MaxY, v: ColorSets.GetLegColor(colorLeg, v.V.V) )).ToList()); }
public Grid2DVm(Sz2 <int> strides, ColorLeg <T> colorLeg, string title = "") { Strides = strides; ColorLeg = colorLeg; WbImageVm = new WbImageVm(); Title = title; LegendVm = new LegendVm( minVal: "<" + colorLeg.range.Min, midVal: ColorSets.GetLegMidVal(colorLeg).ToString(), maxVal: ">" + colorLeg.range.Max, minCol: colorLeg.minC, midColors: colorLeg.spanC, maxColor: colorLeg.maxC ); }
private void settingsCommand(object parameter) { DialogData settingsData = new DialogData(); settingsData.WindowTitle = "Settings..."; settingsData.Topmost = false; settingsData.Background = ColorSets.HexConverter("#FF1E1E1E"); DialogBaseWindowViewModel viewmodel = new SettingsViewModel(settingsData); WindowMessageResult settingsResult = DialogService.OpenDialog(viewmodel, parameter as Window, ShutdownMode.OnLastWindowClose); if (settingsResult == WindowMessageResult.Yes) { ChangeContent.Select(MainContent.Connect); } }
/// <summary> /// Load build color set with given name. /// </summary> /// <param name="name">The name of the build color set.</param> private void LoadColorSet(string name) { var set = new ColorSet { Name = name }; if (ColorSets.Contains(set)) { set = ColorSets.First(x => StringComparer.InvariantCultureIgnoreCase.Equals(x.Name, name)); MyAPIGateway.Session.LocalHumanPlayer.BuildColorSlots = set.Colors.Select(x => (Vector3)x).ToList(); } else { MyAPIGateway.Utilities.ShowMessage(NAME, string.Format(ModText.NoColorSetFound.GetString(), name)); } }
private TileVm UpDato(P2 <int> dataLoc, R <double> imagePatch) { var offset = dataLoc.X + dataLoc.Y * DataSz2.X; var vmRet = new TileVm { BoundingRect = new R <float>( minX: (float)imagePatch.MinX, maxX: (float)imagePatch.MaxX, minY: (float)imagePatch.MinY, maxY: (float)imagePatch.MaxY ), Color = ColorSets.GetLegColor(ColorSets.RedBlueSFLeg, _testArray[offset]), TextA = $"({dataLoc.X}, {dataLoc.Y})" }; return(vmRet); }
/// <summary> /// Saves or overrides a build color set with current build colors. /// </summary> /// <param name="name">The name of the build color set.</param> private void SaveColorSet(string name) { var set = new ColorSet { Name = name }; if (ColorSets.Contains(set)) { ColorSets.Remove(set); } set.Colors = MyAPIGateway.Session.LocalHumanPlayer.BuildColorSlots.Select(x => (Color)x).ToArray(); ColorSets.Add(set); SaveColorSets(); MyAPIGateway.Utilities.ShowMessage(NAME, string.Format(ModText.ColorSetSaved.GetString(), name)); }
/// <summary> /// Removes a Color Set with given name. /// </summary> /// <param name="name">The name of the color set.</param> private void RemoveColorSet(string name) { var set = new ColorSet { Name = name }; if (!ColorSets.Contains(set)) { MyAPIGateway.Utilities.ShowMessage(NAME, string.Format(ModText.NoColorSetFound.GetString(), name)); return; } ColorSets.Remove(set); SaveColorSets(); MyAPIGateway.Utilities.ShowMessage(NAME, string.Format(ModText.ColorSetRemoved.GetString(), name)); }
private void addCommand(object parameter) { DialogData modifyData = new DialogData(); modifyData.WindowTitle = "Modify Database..."; modifyData.Topmost = false; modifyData.Background = ColorSets.HexConverter("#FF1E1E1E"); DialogBaseWindowViewModel viewmodel = new AddEditViewModel(modifyData); WindowMessageResult settingsResult = DialogService.OpenDialog(viewmodel, parameter as Window, ShutdownMode.OnLastWindowClose); // Data was deleted and the view needs to reloaded. // Sloppy and could be better by updating page counts or adding to the existing page if it matches the current search pattern. if (settingsResult == WindowMessageResult.Accept) { querySQL(PageCurrent); } }
/// <summary> /// Adds data to the especified ID Set data. /// Id Set doesnt exist, will be created. /// </summary> /// <param name="ld">Line data to Add</param> public void AddData(LineData ld, string Id) { if (!data.Keys.Contains(Id)) { data.Add(Id, new List <LineData>()); ColorSets.Add(Id, new Cairo.Color( (new Random((int)(DateTime.UtcNow - DateTime.UtcNow.Subtract(new TimeSpan(24, 24, 24))).TotalMilliseconds)).NextDouble(), (new Random((int)(DateTime.UtcNow - DateTime.UtcNow.Subtract(new TimeSpan(24, 24, 24))).TotalMilliseconds)).NextDouble(), (new Random((int)(DateTime.UtcNow - DateTime.UtcNow.Subtract(new TimeSpan(24, 24, 24))).TotalMilliseconds)).NextDouble() )); } List <LineData> lista = GetDataValues(Id); lista.Add(ld); data[Id].Sort(); drawingArea.QueueDraw(); }
public Grid4DVm(P2 <int> strides, P2 <int> cursor, ColorLeg <T> colorLeg, string title = "") { X1Y1 = true; Strides = strides; Cursor = cursor; Values = new List <LS2V <int, T> >(); ColorLeg = colorLeg; WbImageVm = new WbImageVm(); Title = title; LegendVm = new LegendVm( minVal: "<" + colorLeg.range.Min, midVal: ColorSets.GetLegMidVal(colorLeg).ToString(), maxVal: ">" + colorLeg.range.Max, minCol: colorLeg.minC, midColors: colorLeg.spanC, maxColor: colorLeg.maxC ); }
private TileVm MakeTileVm(P2 <int> dataLoc, R <double> imagePatch) { var offset = dataLoc.X + dataLoc.Y * (LatticeBounds.MaxX - LatticeBounds.MinX); var gpuData = GpuArrayWrite.GetGpuData(offset)[0]; var vmRet = new TileVm { BoundingRect = new R <float>( minX: (float)imagePatch.MinX, maxX: (float)imagePatch.MaxX, minY: (float)imagePatch.MinY, maxY: (float)imagePatch.MaxY ), Color = ColorSets.GetLegColor(ColorSets.RedBlueSFLeg, gpuData.Value), TextA = $"({gpuData.Block.X}, {gpuData.Block.Y}, {gpuData.Block.Z})", TextB = $"", TextC = $"({gpuData.Thread.X}, {gpuData.Thread.Y}, {gpuData.Thread.Z})" }; return(vmRet); }
public static SortableItemVm[] ToRedBlueSortableItemVms(this int[] positions, int order, bool showLabel) { var csB = ColorSets.ColorSpan(order, Colors.Blue, Colors.Red) .Select(c => new SolidColorBrush(c)) .ToArray(); return (Enumerable.Range(0, order).Select (i => new SortableItemVm( backgroundBrush: csB[positions[i]], foregroundBrush: Brushes.White, showLabel: showLabel, stageSection: -1, stagePos: StagePos.Left, keyLinePos: i, label: positions[i], sortableValue: positions[i]) ).ToArray()); }
/// <summary> /// Adds data to the especified ID Set data. /// Id Set doesnt exist, will be created. /// </summary> /// <param name="ld">Line data to Add</param> public void AddData(BarData ld, String Id) { if (!data.Keys.Contains(Id)) { data.Add(Id, new List <BarData>()); } List <BarData> lista = GetDataValues(Id); if (!ColorSets.Keys.ToList().Contains(ld.Name)) { ColorSets.Add(ld.Name, new Cairo.Color( (new Random((int)(DateTime.UtcNow - DateTime.UtcNow.Subtract(new TimeSpan(24, 24, 24))).TotalMilliseconds)).NextDouble(), (new Random((int)(DateTime.UtcNow - DateTime.UtcNow.Subtract(new TimeSpan(24, 24, 24))).TotalMilliseconds)).NextDouble(), (new Random((int)(DateTime.UtcNow - DateTime.UtcNow.Subtract(new TimeSpan(24, 24, 24))).TotalMilliseconds)).NextDouble() )); } if (ld.Value > MaxValue) { MaxValue = ld.Value; } lista.Add(ld); lista.Sort(); }
void chart_Loaded(object sender, RoutedEventArgs e) { Chart chart = sender as Chart; chart.ColorSet = "Visifire1"; if (chart != null) { // 新建一个 ColorSet 集合 ColorSets emcs = new ColorSets(); string resourceName = "Visifire.Charts.ColorSets.xaml"; // Visifire 默认颜色集合的文件 using (System.IO.Stream s = typeof(Chart).Assembly.GetManifestResourceStream(resourceName)) { if (s != null) { System.IO.StreamReader reader = new System.IO.StreamReader(s); String xaml = reader.ReadToEnd(); emcs = System.Windows.Markup.XamlReader.Load(xaml) as ColorSets; reader.Close(); s.Close(); } } // 根据名称取得 Chart 的 ColorSet ( Chart 的 ColorSet 属性为颜色集的名称 ) ColorSet cs = emcs.GetColorSetByName(chart.ColorSet); // 显示图例的 StackPanel StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal, VerticalAlignment = System.Windows.VerticalAlignment.Top, HorizontalAlignment = System.Windows.HorizontalAlignment.Center }; // 图例文本 string[] legendText = { "离异", "已婚", "未婚" }; // 自定义图例 for (int i = 0; i < chart.Series[0].DataPoints.Count; i++) { Grid grid = new Grid(); grid.Margin = new Thickness(15, 0, 0, 0); ColumnDefinition cd1 = new ColumnDefinition(); grid.ColumnDefinitions.Add(cd1); ColumnDefinition cd2 = new ColumnDefinition(); grid.ColumnDefinitions.Add(cd2); Rectangle rect = new Rectangle() { Width = 10, Height = 10, Fill = cs.Brushes[i] }; rect.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(rect); TextBlock tb = new TextBlock() { Text = legendText[i], Margin = new Thickness(5, 0, 0, 0), Foreground = cs.Brushes[i] }; tb.SetValue(Grid.ColumnProperty, 1); grid.Children.Add(tb); sp.Children.Add(grid); } ReportChartList.Children.Add(sp); } }
public Func <LS2V <int, T>, RV <float, Color> > MakeFilledRectangle() { if (X1Y1) { return(v => new RV <float, Color>( minX: v.X2, minY: v.Y2, maxX: v.X2 + 1.0f, maxY: v.Y2 + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); } if (X1X2) { return(v => new RV <float, Color>( minX: v.Y1, minY: v.Y2, maxX: v.Y1 + 1.0f, maxY: v.Y2 + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); } if (X1Y2) { return(v => new RV <float, Color>( minX: v.Y1, minY: v.X2, maxX: v.Y1 + 1.0f, maxY: v.X2 + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); } if (Y1X2) { return(v => new RV <float, Color>( minX: v.X1, minY: v.Y2, maxX: v.X1 + 1.0f, maxY: v.Y2 + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); } if (Y1Y2) { return(v => new RV <float, Color>( minX: v.X1, minY: v.X2, maxX: v.X1 + 1.0f, maxY: v.X2 + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); } if (X2Y2) { return(v => new RV <float, Color>( minX: v.X1, minY: v.Y1, maxX: v.X1 + 1.0f, maxY: v.Y1 + 1.0f, v: ColorSets.GetLegColor(ColorLeg, v.V) )); } throw new Exception("case not handled in FilterByCursor"); }
/// <summary> /// List available build color sets. /// </summary> /// <param name="arguments"></param> private void ListColorSets(string arguments) { MyAPIGateway.Utilities.ShowMessage(NAME, ColorSets.Any() ? string.Join(", ", ColorSets.Select(x => x.Name)) : ModText.NoColorSetsAvailable.GetString()); }