/** * 滴水法入口 * @param sourceImage * @return 切割完图片的数组 */ public IList <Bitmap> Execute(Bitmap sourceImage) { var imageList = new List <Bitmap>(); this.sourceImage = sourceImage; int width = sourceImage.Width; int height = sourceImage.Height; Console.WriteLine("width:" + width + " height:" + height); // if (width <= maxD) { // //如果是单个字符,则直接返回 // this.imageList.add(sourceImage); // return this.imageList; // } //在x轴的投影 int[] histData = new int[width]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { var color = sourceImage.GetPixel(x, y); if (ColorHelper.isBlack(color)) { histData[x]++; } } } List <int> extrems = Extremum.GetMinExtrem(histData); Point[] startRoute = new Point[height]; Point[] endRoute = null; for (int y = 0; y < height; y++) { startRoute[y] = new Point(0, y); } int num = (int)Math.Round((double)(width * 1.0 / meanD * 1.0)); //字符的个数 int lastP = 0; //上一次分割的位置 int curSplit = 1; //分割点的个数,小于等于 num - 1; for (int i = 0; i < extrems.Count; i++) { if (curSplit > (num - 1)) { break; } //判断两个分割点之间的距离是否合法 int curP = extrems[(i)]; int dBetween = curP - lastP + 1; if (dBetween < minD || dBetween > maxD) { continue; } // //判断当前分割点与末尾结束点的位置是否合法 // int dAll = width - curP + 1; // if (dAll < minD*(num - curSplit) || dAll > maxD*(num - curSplit)) { // continue; // } endRoute = getEndRoute(new Point(curP, 0), height, curSplit); doSplit(imageList, startRoute, endRoute); startRoute = endRoute; lastP = curP; curSplit++; Console.WriteLine(curP); } endRoute = new Point[height]; for (int y = 0; y < height; y++) { endRoute[y] = new Point(width - 1, y); } doSplit(imageList, startRoute, endRoute); Console.WriteLine("================="); Console.WriteLine(width + "," + height); return(imageList); }
public CustomizationDemo() { InitializeComponent(); customeEditor.DataContext = this; this.schedule = Schedule; Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US"; var visibleDatesBinding = new Binding { Source = this, Mode = BindingMode.TwoWay, Path = new PropertyPath("VisibleDatesCollection") }; BindingOperations.SetBinding(schedule, SfSchedule.VisibleDatesProperty, visibleDatesBinding); DateTime currentdate = DateTime.Now.Date; if (currentdate.DayOfWeek == System.DayOfWeek.Friday || currentdate.DayOfWeek == System.DayOfWeek.Saturday) { currentdate = currentdate.SubtractDays(3); } else if (currentdate.DayOfWeek == System.DayOfWeek.Sunday || currentdate.DayOfWeek == System.DayOfWeek.Monday) { currentdate = currentdate.AddDays(3); } AppointmentCollection = new ScheduleAppointmentCollection(); AppointmentCollection.Add(new Appointment() { AppointmentType = Appointment.AppointmentTypes.Health, Status = schedule.AppointmentStatusCollection[0], StartTime = currentdate.AddHours(12), AppointmentTime = currentdate.AddHours(12).ToString("hh:mm tt"), EndTime = currentdate.AddHours(15), Subject = "Checkup", Location = "Chennai", AppointmentBackground = new SolidColorBrush(ColorHelper.FromArgb(255, 236, 12, 12)) }); currentdate = currentdate.AddHours(4); AppointmentCollection.Add(new Appointment() { AppointmentType = Appointment.AppointmentTypes.Family, Status = schedule.AppointmentStatusCollection[0], StartTime = currentdate.Date.SubtractDays(2).AddHours(1), AppointmentTime = currentdate.Date.SubtractDays(2).AddHours(1).ToString("hh:mm tt"), EndTime = currentdate.Date.SubtractDays(2).AddHours(4), Subject = "My B'day", AppointmentBackground = new SolidColorBrush(ColorHelper.FromArgb(255, 180, 31, 125)) }); AppointmentCollection.Add(new Appointment() { AppointmentType = Appointment.AppointmentTypes.Office, Status = schedule.AppointmentStatusCollection[0], StartTime = currentdate.Date.AddDays(2).AddHours(9), AppointmentTime = currentdate.Date.AddDays(2).AddHours(9).ToString("hh:mm tt"), EndTime = currentdate.Date.AddDays(2).AddHours(12), Subject = "Meeting", AppointmentBackground = new SolidColorBrush(ColorHelper.FromArgb(255, 60, 181, 75)) }); schedule.Appointments = AppointmentCollection; schedule.AppointmentEditorOpening += schedule_AppointmentEditorOpening; schedule.ContextMenuOpening += Schedule_PopupMenuOpening; schedule.ScheduleTapped += schedule_ScheduleTapped; }
void MapObject(SeriesCollection seriesCollection, DocumentObjectModel.Shapes.Charts.SeriesCollection domSeriesCollection) { foreach (DocumentObjectModel.Shapes.Charts.Series domSeries in domSeriesCollection) { Series series = seriesCollection.AddSeries(); series.Name = domSeries.Name; if (domSeries.IsNull("ChartType")) { DocumentObjectModel.Shapes.Charts.Chart chart = (DocumentObjectModel.Shapes.Charts.Chart)DocumentObjectModel.DocumentRelations.GetParentOfType(domSeries, typeof(DocumentObjectModel.Shapes.Charts.Chart)); series.ChartType = (ChartType)chart.Type; } else { series.ChartType = (ChartType)domSeries.ChartType; } if (!domSeries.IsNull("DataLabel")) { DataLabelMapper.Map(series.DataLabel, domSeries.DataLabel); } if (!domSeries.IsNull("LineFormat")) { LineFormatMapper.Map(series.LineFormat, domSeries.LineFormat); } if (!domSeries.IsNull("FillFormat")) { FillFormatMapper.Map(series.FillFormat, domSeries.FillFormat); } series.HasDataLabel = domSeries.HasDataLabel; if (domSeries.MarkerBackgroundColor.IsEmpty) { series.MarkerBackgroundColor = XColor.Empty; } else { #if noCMYK series.MarkerBackgroundColor = XColor.FromArgb(domSeries.MarkerBackgroundColor.Argb); #else series.MarkerBackgroundColor = ColorHelper.ToXColor(domSeries.MarkerBackgroundColor, domSeries.Document.UseCmykColor); #endif } if (domSeries.MarkerForegroundColor.IsEmpty) { series.MarkerForegroundColor = XColor.Empty; } else { #if noCMYK series.MarkerForegroundColor = XColor.FromArgb(domSeries.MarkerForegroundColor.Argb); #else series.MarkerForegroundColor = ColorHelper.ToXColor(domSeries.MarkerForegroundColor, domSeries.Document.UseCmykColor); #endif } series.MarkerSize = domSeries.MarkerSize.Point; if (!domSeries.IsNull("MarkerStyle")) { series.MarkerStyle = (MarkerStyle)domSeries.MarkerStyle; } foreach (DocumentObjectModel.Shapes.Charts.Point domPoint in domSeries.Elements) { if (domPoint != null) { Point point = series.Add(domPoint.Value); FillFormatMapper.Map(point.FillFormat, domPoint.FillFormat); LineFormatMapper.Map(point.LineFormat, domPoint.LineFormat); } else { series.Add(double.NaN); } } } }
private void SetColor() { base.Color = ColorHelper.ColorFromHSB(Hue, 1, 1); //base.Brush = new SolidColorBrush(Color); }
/// <summary> /// Render lens flare. /// Checks the zbuffer if objects are occluding the lensflare sun. /// </summary> public void Render(Color sunColor) { ScreenFlareSize = 250 * BaseGame.Width / 1024; Vector3 relativeLensPos = lensOrigin3D + BaseGame.CameraPos; // Only show lens flare if facing in the right direction if (BaseGame.IsInFrontOfCamera(relativeLensPos) == false) { return; } // Convert 3D point to 2D! Point lensOrigin = BaseGame.Convert3DPointTo2D(relativeLensPos); // Check sun occlusion itensity and fade it in and out! float thisSunIntensity = 0.75f; /*unsupported in XNA: BaseGame.OcclusionIntensity( * flareMaterials[SunFlareType].diffuseTexture, * lensOrigin, ScreenFlareSize / 5); */ sunIntensity = thisSunIntensity * 0.1f + sunIntensity * 0.9f; // We can skip rendering the sun if the itensity is to low if (sunIntensity < 0.01f) { return; } int resWidth = BaseGame.Width, resHeight = BaseGame.Height; Point center = new Point(resWidth / 2, resHeight / 2); Point relOrigin = new Point( center.X - lensOrigin.X, center.Y - lensOrigin.Y); // Check if origin is on screen, fade out at borders float alpha = 1.0f; float distance = Math.Abs(Math.Max(relOrigin.X, relOrigin.Y)); if (distance > resHeight / 1.75f) { distance -= resHeight / 1.75f; // If distance is more than half the resolution, don't show anything! if (distance > resHeight / 1.75f) { return; } alpha = 1.0f - (distance / ((float)resHeight / 1.75f)); if (alpha > 1.0f) { alpha = 1.0f; } } // Use square of sunIntensity for lens flares because we want // them to get very weak if sun is not fully visible. alpha *= sunIntensity * sunIntensity; foreach (FlareData data in flareTypes) { int size = (int)(ScreenFlareSize * data.scale); flareTextures[data.type].RenderOnScreen( new Rectangle( (int)(center.X - relOrigin.X * data.position - size / 2), (int)(center.Y - relOrigin.Y * data.position - size / 2), size, size), flareTextures[data.type].GfxRectangle, ColorHelper.ApplyAlphaToColor(//MixAlphaToColor( ColorHelper.MultiplyColors(sunColor, data.color), ((float)data.color.A / 255.0f) * // For the sun and glow flares try always to use max. intensity (data.type == SunFlareType || data.type == GlowFlareType ? sunIntensity : alpha)), SpriteBlendMode.Additive); } }
/* * void AttachAssetObject(VuMarkIdentifier identifier, GameObject parent, string objectId, AssetInstance assetInstance, MediaElement fallbackImage, Action onOpen, Action onSelect) * { * if (fallbackImage != null) * { * AttachAssetObject(identifier, parent, objectId, assetInstance, fallbackImage.MediaUrl, fallbackImage.Layout, onOpen, onSelect); * } * else * { * AttachAssetObject(identifier, parent, objectId, assetInstance, null, null, onOpen); * } * }*/ void AttachMediaObject( MarkerMedia media, //VuMarkIdentifier identifier, GameObject parent /*, * string objectId, * string url, * MediaType mediaType, * Layout layout, * Action onOpen, * Action onSelect, * Action onComplete*/) { var activeObject = GetOrCreateActiveObject(media.ObjectId); VisualMarkerObject markerObj = null; Action onReady = null; VisualMarkerWorldObject worldObj = null; activeObject.MarkerObjects.TryGetValue(media.Marker.Identifier, out worldObj); if (worldObj != null) { markerObj = worldObj.GameObject.GetComponent <VisualMarkerObject>(); switch (media.MediaType) { case Motive.Core.Media.MediaType.Audio: onReady = () => { var player = markerObj.GetComponentInChildren <AudioSubpanel>(); player.Play(media.OnClose); }; break; case Motive.Core.Media.MediaType.Video: onReady = () => { var player = markerObj.GetComponentInChildren <VideoSubpanel>(); player.Play(media.OnClose); }; break; } worldObj.GameObject.SetActive(true); } else { switch (media.MediaType) { case Motive.Core.Media.MediaType.Audio: { markerObj = Instantiate(MarkerAudioObject); onReady = () => { var player = markerObj.GetComponentInChildren <AudioSubpanel>(); player.Play(media.MediaUrl, media.OnClose); }; break; } case Motive.Core.Media.MediaType.Image: { markerObj = Instantiate(MarkerImageObject); onReady = () => { ThreadHelper.Instance.StartCoroutine( ImageLoader.LoadImage(media.MediaUrl, markerObj.RenderObject)); }; break; } case Motive.Core.Media.MediaType.Video: { markerObj = Instantiate(MarkerVideoObject); var renderer = markerObj.RenderObject.GetComponent <Renderer>(); renderer.enabled = false; onReady = () => { var player = markerObj.GetComponentInChildren <VideoSubpanel>(); UnityAction setAspect = () => { renderer.enabled = true; if (media.MediaLayout == null) { var aspect = player.AspectRatio; if (aspect > 1) { // Wider than tall, reduce y scale player.transform.localScale = new Vector3(1, 1 / aspect, 1); } else { // Wider than tall, reduce x scale player.transform.localScale = new Vector3(aspect, 1, 1); } } }; player.ClipLoaded.AddListener(setAspect); player.Play(media.MediaUrl, media.OnClose); }; break; } } if (markerObj) { if (media.MediaLayout != null) { LayoutHelper.Apply(markerObj.LayoutObject.transform, media.MediaLayout); } if (media.Color != null) { var renderer = markerObj.RenderObject.GetComponent <Renderer>(); if (renderer) { renderer.material.color = ColorHelper.ToUnityColor(media.Color); } } worldObj = CreateWorldObject(markerObj, markerObj.RenderObject, media.ActivationContext); activeObject.MarkerObjects[media.Marker.Identifier] = worldObj; worldObj.Clicked += (sender, args) => { if (media.OnSelect != null) { media.OnSelect(); } }; } } if (markerObj) { markerObj.transform.SetParent(parent.transform, false); markerObj.transform.localScale = ItemScale; markerObj.transform.localPosition = Vector3.zero; markerObj.transform.localRotation = Quaternion.identity; if (onReady != null) { onReady(); } if (media.OnOpen != null) { media.OnOpen(); } } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var selectedColor = (HSLColor)value; return(ColorHelper.GetColorShiftedByAngle(selectedColor, 150.0f)); }
/// <summary> /// Converts a given <see cref="Color"/> to its Name /// </summary> /// <param name="value">Needed: The <see cref="Color"/>. </param> /// <param name="targetType"></param> /// <param name="parameter">Optional: A <see cref="Dictionary{TKey, TValue}"/></param> /// <param name="culture"></param> /// <returns>The name of the color or the Hex-Code if no name is available</returns> public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return(ColorHelper.GetColorName(value as Color?, parameter as Dictionary <Color?, string>)); }
/// <summary> /// OpenGLForm constructor /// </summary> /// <author>Markus Strobel</author> public OpenGLForm() { InitializeComponent(); colorHelper = new ColorHelper(); container = new System.ComponentModel.Container(); tooltip = new System.Windows.Forms.ToolTip(container); selectedRGBColor = new RGB(); selectedHSLBaseSL = new HSL(1f, 1f, 0.5f); selectedHSLColor = new HSL(1f, 1f, 0.5f); // VBO inits ellipsesVBOs = new List<VBO>(); customRGB.Checked = true; // WP, RR, GG, BB set to default (lables etc) labelWPXValue.Text = Math.Round((double)ColorHelper.WP_default.X, 3).ToString(); labelWPYValue.Text = Math.Round((double)ColorHelper.WP_default.Y, 3).ToString(); labelWPZValue.Text = Math.Round((double)ColorHelper.WP_default.Z, 3).ToString(); labelRRXValue.Text = Math.Round((double)ColorHelper.RR_default.X, 3).ToString(); labelRRYValue.Text = Math.Round((double)ColorHelper.RR_default.Y, 3).ToString(); labelRRZValue.Text = Math.Round((double)ColorHelper.RR_default.Z, 3).ToString(); labelGGXValue.Text = Math.Round((double)ColorHelper.GG_default.X, 3).ToString(); labelGGYValue.Text = Math.Round((double)ColorHelper.GG_default.Y, 3).ToString(); labelGGZValue.Text = Math.Round((double)ColorHelper.GG_default.Z, 3).ToString(); labelBBXValue.Text = Math.Round((double)ColorHelper.BB_default.X, 3).ToString(); labelBBYValue.Text = Math.Round((double)ColorHelper.BB_default.Y, 3).ToString(); labelBBZValue.Text = Math.Round((double)ColorHelper.BB_default.Z, 3).ToString(); // initializes internal color values ResetColorValues(); //set RGB Slider lables to values (between 0 and 1) labelTabRGB_R.Text = "R: " + trackBarR.Value; labelTabRGB_G.Text = "G: " + trackBarG.Value; labelTabRGB_B.Text = "B: " + trackBarB.Value; //set HSL Slider lables to values labelTabHSL_H.Text = "H: " + (trackBarH.Value) + "°"; labelTabHSL_S.Text = "S: " + trackBarS.Value + "%"; labelTabHSL_L.Text = "L: " + trackBarL.Value + "%"; }
private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e) { this.AssociatedObject.gridpanel.Children.Add(gridControl1); Brush headerBrush = ColorHelper.CreateFrozenSolidColorBrush(128, Colors.CadetBlue); gridControl1.Model.HeaderStyle.Background = headerBrush; gridControl1.Model.HeaderStyle.Borders.All = new Pen(Brushes.White, 1); gridControl1.Model.TableStyle.Borders.All = new Pen(Brushes.White, 0); gridControl1.Model.HeaderStyle.Font.FontWeight = FontWeights.Bold; gridControl1.Model.TableStyle.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; gridControl1.Model.TableStyle.VerticalAlignment = System.Windows.VerticalAlignment.Center; gridControl1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo); this.viewModel.PopulateDataTableValues(); gridControl1.Model.RowCount = this.viewModel.dt.Rows.Count + 1; gridControl1.Model.ColumnCount = this.viewModel.dt.Columns.Count + 1; gridControl1.Model.BaseStylesMap["Row Header"].StyleInfo.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; gridControl1.Model.BaseStylesMap["Row Header"].StyleInfo.VerticalAlignment = VerticalAlignment.Center; CalcEngine.ResetSheetFamilyID(); this.viewModel.engine = new CalcEngine(gridControl1); List <string> formulaNameCollection = GetFunctionNames(); var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static); var dpiYProperty = typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static); var dpiX = (int)dpiXProperty.GetValue(null, null); var dpiY = (int)dpiYProperty.GetValue(null, null); if (dpiX > 100) { this.AssociatedObject.desc.Height = 120; this.AssociatedObject.sytx.Height = 60; this.AssociatedObject.t1.Width = 150; this.AssociatedObject.desc.Width = 300; this.AssociatedObject.sytx.Width = 300; this.AssociatedObject.res.Width = 300; this.AssociatedObject.res.FontSize = 21; this.AssociatedObject.cbx1.Height = this.AssociatedObject.t1.Height = 30; gridControl1.Model.RowHeights.DefaultLineSize = 35; gridControl1.Model.ColumnWidths.DefaultLineSize = 75; } else { this.AssociatedObject.desc.Height = 150; this.AssociatedObject.sytx.Height = 90; this.AssociatedObject.t1.Width = 220; this.AssociatedObject.desc.Width = 500; this.AssociatedObject.sytx.Width = 500; this.AssociatedObject.res.Width = 500; this.AssociatedObject.cbx1.Width = 200; this.AssociatedObject.cbx1.Height = this.AssociatedObject.t1.Height = 30; this.AssociatedObject.buttonAdv.Height = 30; gridControl1.Model.RowHeights.DefaultLineSize = 45; gridControl1.Model.ColumnWidths.DefaultLineSize = 85; } this.AssociatedObject.t1.KeyDown += new KeyEventHandler(t1_KeyDown); this.AssociatedObject.tempTextBlock.Text = "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG"; this.AssociatedObject.functionCountLable.Text = "CALCULATE SUPPORTS " + formulaNameCollection.Count.ToString() + " FORMULAS."; this.AssociatedObject.cbx1.ItemsSource = formulaNameCollection; this.AssociatedObject.cbx1.CustomSource = formulaNameCollection; this.AssociatedObject.cbx1.SelectionChanged += new SelectionChangedEventHandler(cbx1_SelectionChanged); this.AssociatedObject.cbx1.SelectedIndex = 0; this.AssociatedObject.t1.TextChanged += new TextChangedEventHandler(t1_TextChanged); this.AssociatedObject.cbx1.SelectedIndex = formulaNameCollection.IndexOf("SUM"); this.AssociatedObject.t1.LostFocus += new RoutedEventHandler(t1_LostFocus); this.AssociatedObject.t1.GotFocus += new RoutedEventHandler(t1_GotFocus); }
public new void Randomize() { GoingDown = Random.NextDouble() > 0.5; Location = new Point(Random.Next(Frame.Width), Random.Next(GoingDown ? 0 : Frame.Height / 3 * 2, GoingDown ? Frame.Height / 3 : Frame.Height)); Color = ColorHelper.HsvToColor((byte)Random.Next(byte.MaxValue)); }
protected override void deserialize(BaseItem item, List <SyncPropertyNames> changedProperties) { Class c = item as Class; byte[] rawColor = ColorHelper.ToBytes(c.Color); if (changedProperties != null) { if (CourseNumber != c.CourseNumber) { changedProperties.Add(SyncPropertyNames.CourseNumber); } var gradeScales = GetGradeScales(); if ((gradeScales == null && c.GradeScales != null) || (gradeScales != null && c.GradeScales == null) || (gradeScales != null && c.GradeScales != null && !gradeScales.SequenceEqual(c.GradeScales))) { changedProperties.Add(SyncPropertyNames.GradeScales); } if (ShouldAverageGradeTotals != c.ShouldAverageGradeTotals) { changedProperties.Add(SyncPropertyNames.ShouldAverageGradeTotals); } if (Credits != c.Credits) { changedProperties.Add(SyncPropertyNames.Credits); } if (Position != c.Position) { changedProperties.Add(SyncPropertyNames.Position); } if (!RawColor.SequenceEqual(rawColor)) { changedProperties.Add(SyncPropertyNames.Color); } if (DoesRoundGradesUp != c.DoesRoundGradesUp) { changedProperties.Add(SyncPropertyNames.DoesRoundGradesUp); } if (GpaType != c.GpaType) { changedProperties.Add(SyncPropertyNames.GpaType); } if (PassingGrade != c.PassingGrade) { changedProperties.Add(SyncPropertyNames.PassingGrade); } if (OverriddenGrade != c.OverriddenGrade) { changedProperties.Add(SyncPropertyNames.OverriddenGrade); } if (OverriddenGPA != c.OverriddenGPA) { changedProperties.Add(SyncPropertyNames.OverriddenGPA); } if (StartDate != c.StartDate.ToUniversalTime()) { changedProperties.Add(SyncPropertyNames.StartDate); } if (EndDate != c.EndDate.ToUniversalTime()) { changedProperties.Add(SyncPropertyNames.EndDate); } } CourseNumber = c.CourseNumber; SetGradeScales(c.GradeScales); ShouldAverageGradeTotals = c.ShouldAverageGradeTotals; Credits = c.Credits; Position = c.Position; RawColor = rawColor; DoesRoundGradesUp = c.DoesRoundGradesUp; GpaType = c.GpaType; PassingGrade = c.PassingGrade; OverriddenGPA = c.OverriddenGPA; OverriddenGrade = c.OverriddenGrade; StartDate = c.StartDate.ToUniversalTime(); EndDate = c.EndDate.ToUniversalTime(); base.deserialize(c, changedProperties); }
public static bool Prefix(int cell, SimHashes element, BlockTileRenderer __instance, ref Color __result) { try { Color tileColor; if (State.ConfiguratorState.Enabled) { if (State.ConfiguratorState.LegacyTileColorHandling) { switch (State.ConfiguratorState.ColorMode) { case ColorMode.Json: tileColor = ColorHelper.GetCellColorJson(cell); break; case ColorMode.DebugColor: tileColor = ColorHelper.GetCellColorDebug(cell); break; default: tileColor = ColorHelper.DefaultCellColor; break; } } else { if (ColorHelper.TileColors.Length > cell && ColorHelper.TileColors[cell].HasValue) { tileColor = ColorHelper.TileColors[cell].Value; } else { //if (cell == __instance.invalidPlaceCell) if (cell == (int)GetField(__instance, "invalidPlaceCell")) { __result = ColorHelper.InvalidCellColor; return(false); } tileColor = ColorHelper.DefaultCellColor; } } } else { tileColor = ColorHelper.DefaultCellColor; } //if (cell == __instance.selectedCell) if (cell == (int)GetField(__instance, "selectedCell")) { __result = tileColor * 1.5f; return(false); } //if (cell == __instance.highlightCell) if (cell == (int)GetField(__instance, "highlightCell")) { __result = tileColor * 1.25f; return(false); } __result = tileColor; return(false); } catch (Exception e) { State.Logger.Log("EnterCell failed."); State.Logger.Log(e); } return(true); }
public FormThemeBase() { // about theme ThemeName = "Base Default Theme"; // form shape SideResizeWidth = 6; BorderWidth = 5; CaptionHeight = 36; IconLeftMargin = 2; IconSize = new Size(16, 16); TextLeftMargin = 2; ControlBoxOffset = new Point(8, 8); CloseBoxSize = new Size(37, 17); MaxBoxSize = new Size(25, 17); MinBoxSize = new Size(25, 17); ControlBoxSpace = 2; Radius = 8; RoundedStyle = RoundStyle.None; UseDefaultTopRoundingFormRegion = false; DrawCaptionIcon = true; DrawCaptionText = true; // form shadow ShowShadow = false; ShadowWidth = 6; ShadowColor = Color.Black; ShadowAValueDark = 80; ShadowAValueLight = 0; UseShadowToResize = false; // form color FormBorderInmostColor = FormBorderInnerColor = FormBorderOutterColor = ColorHelper.GetLighterColor(Color.FromArgb(75, 159, 216), 10); CaptionBackColorBottom = CaptionBackColorTop = ColorHelper.GetLighterColor(Color.FromArgb(75, 159, 216), 10); CaptionTextColor = Color.Black; FormBackColor = SystemColors.Control; // form other SetClientInset = true; CaptionTextCenter = false; // control box color CloseBoxColor = ButtonColorTable.GetDevWhiteThemeCloseBtnColor(); MaxBoxColor = ButtonColorTable.GetDevWhiteThemeMinMaxBtnColor(); MinBoxColor = MaxBoxColor; #region mdi support // bar overall Mdi_UseMsgToActivateChild = true; Mdi_BarMargin = new Padding(6, 38, 100, 0); Mdi_BarLeftPadding = 3; Mdi_BarRightPadding = 100; Mdi_BarBackColor = Color.LightSkyBlue; Mdi_BarBorderColor = Color.Red; Mdi_DrawBarBackground = false; Mdi_DrawBarBorder = false; // bar bottom region Mdi_BarBottomRegionBackColor = Color.White; Mdi_BarBottomRegionHeight = 3; // tab Mdi_TabHeight = 26; Mdi_TabHeightActive = Mdi_TabHeight; Mdi_TabSlopeWidth = 8; Mdi_TabAndTabSpace = -Mdi_TabSlopeWidth; Mdi_TabTopSpace = 2; Mdi_TabMaxWidth = 360; Mdi_TabNormalWidth = 180; Mdi_TabMinWidth = 90; Mdi_ShowTabIcon = true; Mdi_TabActiveBackColorTop = Color.White; Mdi_TabActiveBackColorBottom = Color.White; Mdi_TabDeactiveBackColorTop = Color.LightGray; Mdi_TabDeactiveBackColorBottom = Color.DarkGray; Mdi_TabOutterBorderColor = Color.Gray; Mdi_TabInnerBorderColor = Color.FromArgb(180, Color.White); // new tab btn Mdi_ShowNewTabBtn = true; Mdi_NewTabBtnBottomSpace = Mdi_BarBottomRegionHeight + 4; Mdi_NewTabBtnLeftSpace = 4; Mdi_NewTabBtnSize = new Size(25, 18); Mdi_NewTabBtnColor = ButtonColorTable.DefaultTable(); // list all btn Mdi_AlwaysShowListAllBtn = true; //Mdi_ListAllBtnAlign = BarButtonAlignmentType.Left; Mdi_ListAllBtnBottomSpace = Mdi_BarBottomRegionHeight + 4; Mdi_ListAllBtnLeftSpace = 4; Mdi_ListAllBtnSize = new Size(36, 18); Mdi_ListAllBtnColor = ButtonColorTable.DefaultTable(); #endregion }
void Start() { dataFolder = Directory.GetParent(Application.dataPath).FullName + "/VN/"; #if UNITY_EDITOR dataFolder = debugDataFolder; if (!dataFolder.EndsWith("/")) { dataFolder += "/"; } #endif Hide(); var filePath = ""; if (txt == null) { filePath = Path.Combine(dataFolder, "script.txt"); if (!File.Exists(filePath)) { Debug.LogError("Cannot find source script file : \"" + filePath + "\""); return; } } var scriptFileText = File.ReadAllText(filePath); var lines = scriptFileText.Split('\n'); var key = ""; var phrase = new StringBuilder(); foreach (var l in lines) { if (string.IsNullOrEmpty(l)) { continue; } if (l.StartsWith("//")) { continue; } switch (l[0]) { case '@': if (key.Length > 0) { scenes.Add(key); dialogs.Add(key, phrase.ToString()); phrase = new StringBuilder(); } key = l.Trim('\r', '\n'); break; case '#': string[] split = l.Trim('\r', '\n').TrimEnd(')').Split('(', ','); for (int i = 0; i < split.Length; i++) { split[i] = split[i].Trim(' ', '\t'); } if (l.StartsWith("#color")) { var newColor = ColorHelper.HexToColor(split[2]); if (!newColor.HasValue) { Debug.LogError("Cannot parse color : " + split[2] + ".\n" + "Making defult White color."); newColor = Color.white; } if (!colors.ContainsKey(split[1])) { colors.Add(split[1], newColor.Value); } else { colors[split[1]] = newColor.Value; } } else if (l.StartsWith("#folder")) { if (!charFolders.ContainsKey(split[1])) { charFolders.Add(split[1], split[2] + "/"); } else { charFolders[split[1]] = split[2] + "/"; } } break; default: if (key.Length > 0) { phrase.AppendLine(l); } break; } } scenes.Add(key); dialogs.Add(key, phrase.ToString()); StartGame(); }
/// <summary> /// Sets the background color of the writer. /// </summary> /// <param name="color">The color.</param> public void SetBackgroundColor(Color color) { lock (_builder) _builder.AppendFormat("{{{0}:{1}}}", FormatBuilder.BackgroundColorTag, ColorHelper.GetName(color)); }
private void DrawBuffer() { Array.Sort(depthBuffer, triangleBuffer, 0, polygonCount); int i = polygonCount - 1; // skipping polygons that too far while (i >= 0 && depthBuffer[i] > 1f) { i--; } for (; i >= 0; i--) { if (depthBuffer[i] < 0f) { break; } Triangle polygon = triangleBuffer[i]; polygon.A = Viewport.TranslateToScreenSize(polygon.A); polygon.B = Viewport.TranslateToScreenSize(polygon.B); polygon.C = Viewport.TranslateToScreenSize(polygon.C); polygonPoints[0] = new PointF(polygon.A.X, polygon.A.Y); polygonPoints[1] = new PointF(polygon.B.X, polygon.B.Y); polygonPoints[2] = new PointF(polygon.C.X, polygon.C.Y); if (!IsWireframe) { using (Brush brush = new SolidBrush(polygon.Color)) { bufferGraphics.FillPolygon(brush, polygonPoints); } if (ShowEdges) { unchecked { float hue = 180f + polygon.Color.GetHue(); if (hue > 360f) { hue -= 360f; } Color edgeColor = ColorHelper.FromAhsb( polygon.Color.A, hue, polygon.Color.GetSaturation(), polygon.Color.GetBrightness()); using (Pen pen = new Pen(edgeColor)) { bufferGraphics.DrawPolygon(pen, polygonPoints); } } } } else { using (Pen pen = new Pen(polygon.Color)) { bufferGraphics.DrawPolygon(pen, polygonPoints); } } } }
int AddSymbolMembers(ISymbol source, string typeCategory) { var nsOrType = source as INamespaceOrTypeSymbol; var members = nsOrType.GetMembers().RemoveAll(m => (m as IMethodSymbol)?.AssociatedSymbol != null || m.IsImplicitlyDeclared); SetupForSpecialTypes(this, source.ContainingNamespace.ToString(), source.Name); if (source.Kind == SymbolKind.NamedType && ((INamedTypeSymbol)source).TypeKind == TypeKind.Enum) { // sort enum members by value members = members.Sort(CodeAnalysisHelper.CompareByFieldIntegerConst); } else { members = members.Sort(CodeAnalysisHelper.CompareByAccessibilityKindName); } foreach (var item in members) { var i = Add(item, false); if (typeCategory != null) { i.Hint = typeCategory; } } return(members.Length); void SetupForSpecialTypes(SymbolList list, string typeNamespace, string typeName) { switch (typeNamespace) { case "System.Drawing": switch (typeName) { case nameof(GDI.SystemBrushes): SetupListForSystemColors(list); return; case nameof(GDI.Color): case nameof(GDI.Brushes): case nameof(GDI.KnownColor): SetupListForKnownColors(list); return; } return; case "System.Windows": if (typeName == nameof(SystemColors)) { SetupListForSystemColors(list); } return; case "Microsoft.VisualStudio.PlatformUI": switch (typeName) { case nameof(EnvironmentColors): SetupListForVsUIColors(list, typeof(EnvironmentColors)); return; case nameof(CommonControlsColors): SetupListForVsUIColors(list, typeof(CommonControlsColors)); return; case nameof(CommonDocumentColors): SetupListForVsUIColors(list, typeof(CommonDocumentColors)); return; case nameof(HeaderColors): SetupListForVsUIColors(list, typeof(HeaderColors)); return; case nameof(InfoBarColors): SetupListForVsUIColors(list, typeof(InfoBarColors)); return; case nameof(ProgressBarColors): SetupListForVsUIColors(list, typeof(ProgressBarColors)); return; case nameof(SearchControlColors): SetupListForVsUIColors(list, typeof(SearchControlColors)); return; case nameof(StartPageColors): SetupListForVsUIColors(list, typeof(StartPageColors)); return; case nameof(ThemedDialogColors): SetupListForVsUIColors(list, typeof(ThemedDialogColors)); return; case nameof(TreeViewColors): SetupListForVsUIColors(list, typeof(TreeViewColors)); return; } return; case "Microsoft.VisualStudio.Shell": switch (typeName) { case nameof(VsColors): SetupListForVsResourceColors(list, typeof(VsColors)); return; case nameof(VsBrushes): SetupListForVsResourceBrushes(list, typeof(VsBrushes)); return; } return; case "Microsoft.VisualStudio.Imaging": if (typeName == nameof(KnownImageIds)) { SetupListForKnownImageIds(list); } return; } } void SetupListForVsUIColors(SymbolList symbolList, Type type) { symbolList.ContainerType = SymbolListType.PredefinedColors; symbolList.IconProvider = s => ((s.Symbol as IPropertySymbol)?.IsStatic == true) ? GetColorPreviewIcon(ColorHelper.GetVsThemeBrush(type, s.Symbol.Name)) : null; } void SetupListForVsResourceColors(SymbolList symbolList, Type type) { symbolList.ContainerType = SymbolListType.PredefinedColors; symbolList.IconProvider = s => ((s.Symbol as IPropertySymbol)?.IsStatic == true) ? GetColorPreviewIcon(ColorHelper.GetVsResourceColor(type, s.Symbol.Name)) : null; } void SetupListForVsResourceBrushes(SymbolList symbolList, Type type) { symbolList.ContainerType = SymbolListType.PredefinedColors; symbolList.IconProvider = s => ((s.Symbol as IPropertySymbol)?.IsStatic == true) ? GetColorPreviewIcon(ColorHelper.GetVsResourceBrush(type, s.Symbol.Name)) : null; } void SetupListForSystemColors(SymbolList symbolList) { symbolList.ContainerType = SymbolListType.PredefinedColors; symbolList.IconProvider = s => ((s.Symbol as IPropertySymbol)?.IsStatic == true) ? GetColorPreviewIcon(ColorHelper.GetSystemBrush(s.Symbol.Name)) : null; } void SetupListForKnownColors(SymbolList symbolList) { symbolList.ContainerType = SymbolListType.PredefinedColors; symbolList.IconProvider = s => ((s.Symbol as IPropertySymbol)?.IsStatic == true) ? GetColorPreviewIcon(ColorHelper.GetBrush(s.Symbol.Name) ?? ColorHelper.GetSystemBrush(s.Symbol.Name)) : null; } void SetupListForKnownImageIds(SymbolList symbolList) { symbolList.ContainerType = SymbolListType.VsKnownImage; symbolList.IconProvider = s => { var f = s.Symbol as IFieldSymbol; return(f == null || f.HasConstantValue == false || f.Type.SpecialType != SpecialType.System_Int32 ? null : ThemeHelper.GetImage((int)f.ConstantValue)); }; } Border GetColorPreviewIcon(WPF.Brush brush) { return(new Border { BorderThickness = WpfHelper.TinyMargin, BorderBrush = ThemeHelper.MenuTextBrush, SnapsToDevicePixels = true, Background = brush, Height = ThemeHelper.DefaultIconSize, Width = ThemeHelper.DefaultIconSize, }); } }
public void Test_ColorHelper_FromHsv() { Assert.AreEqual(ColorHelper.FromHsv(0.0, 1.0, 1.0), Windows.UI.Colors.Red); }
/// <summary> /// </summary> public MultiplayerMap(MultiplayerScreen screen, MultiplayerGame game) : base(new ScalableVector2(682, 86), new ScalableVector2(682, 86)) { Screen = screen; Game = game; Size = new ScalableVector2(650, 86); Image = UserInterface.MapPanel; DownloadButton = new ImageButton(UserInterface.BlankBox, OnDownloadButtonClicked) { Parent = this, Alignment = Alignment.MidCenter, Size = new ScalableVector2(Width - 4, Height - 4), Alpha = 0 }; Background = new Sprite { Parent = this, Size = new ScalableVector2(Height * 1.70f, Height - 4), Alignment = Alignment.MidLeft, X = 2, Image = MapManager.Selected.Value == BackgroundHelper.Map && MapManager.Selected.Value.Md5Checksum == Game.MapMd5 ? BackgroundHelper.RawTexture: UserInterface.MenuBackground, Alpha = MapManager.Selected.Value == BackgroundHelper.Map && MapManager.Selected.Value.Md5Checksum == Game.MapMd5 ? 1 : 0 }; AddContainedDrawable(Background); var diffName = GetDifficultyName(); ArtistTitle = new SpriteTextBitmap(FontsBitmap.GothamRegular, game.Map.Replace($"[{diffName}]", "")) { Parent = this, X = Background.X + Background.Width + 16, Y = 12, FontSize = 16 }; AddContainedDrawable(ArtistTitle); Mode = new SpriteTextBitmap(FontsBitmap.GothamRegular, "[" + ModeHelper.ToShortHand((GameMode)game.GameMode) + "]") { Parent = this, X = ArtistTitle.X, Y = ArtistTitle.Y + ArtistTitle.Height + 8, FontSize = 14 }; AddContainedDrawable(Mode); DifficultyRating = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{game.DifficultyRating:0.00}") { Parent = this, X = Mode.X + Mode.Width + 8, Y = Mode.Y, FontSize = 14, Tint = ColorHelper.DifficultyToColor((float)game.DifficultyRating) }; AddContainedDrawable(DifficultyRating); DifficultyName = new SpriteTextBitmap(FontsBitmap.GothamRegular, " - \"" + diffName + "\"") { Parent = this, X = DifficultyRating.X + DifficultyRating.Width + 2, Y = Mode.Y, FontSize = 14, }; AddContainedDrawable(DifficultyName); Creator = new SpriteTextBitmap(FontsBitmap.GothamRegular, "Mods: None") { Parent = this, X = Mode.X, Y = DifficultyRating.Y + DifficultyRating.Height + 8, FontSize = DifficultyRating.FontSize }; AddContainedDrawable(Creator); BackgroundHelper.Loaded += OnBackgroundLoaded; OnlineManager.Client.OnGameMapChanged += OnGameMapChanged; OnlineManager.Client.OnChangedModifiers += OnChangedModifiers; OnlineManager.Client.OnGameHostSelectingMap += OnGameHostSelectingMap; ModManager.ModsChanged += OnModsChanged; BackgroundHelper.Load(MapManager.Selected.Value); UpdateContent(); }
private void SetText(ref TextMeshProUGUI textMesh, string textKey, string hex) { textMesh.text = L10nManager.Localize(textKey); textMesh.color = ColorHelper.HexToColorRGB(hex); }
/// <summary> /// </summary> public void UpdateContent() { Map map; if (MapManager.Selected.Value?.Md5Checksum == Game.MapMd5) { map = MapManager.Selected.Value; } else { map = MapManager.FindMapFromMd5(Game.MapMd5); // In the event that we don't have the correct version, try to find the // alternative one. This is commonly used for situations where one has osu! // beatmaps auto-loaded and someone downloads and converts the file to .qua format if (map == null && Game.MapMd5 != Game.AlternativeMd5) { map = MapManager.FindMapFromMd5(Game.AlternativeMd5); } MapManager.Selected.Value = map; } HasMap = map != null; if (OnlineManager.CurrentGame.HostSelectingMap) { ArtistTitle.Text = "Host is currently selecting a map!"; Mode.Text = "Please wait..."; Creator.Text = ""; DifficultyName.Text = ""; DifficultyRating.Text = ""; } else { var diffName = GetDifficultyName(); ArtistTitle.Text = Game.Map.Replace($"[{diffName}]", ""); Mode.Text = $"[{ModeHelper.ToShortHand((GameMode) Game.GameMode)}]"; Creator.Tint = Color.White; DifficultyRating.Text = map != null ? $"{map.DifficultyFromMods(ModManager.Mods):0.00}" : $"{Game.DifficultyRating:0.00}"; DifficultyRating.Tint = ColorHelper.DifficultyToColor((float)(map?.DifficultyFromMods(ModManager.Mods) ?? Game.DifficultyRating)); DifficultyRating.X = Mode.X + Mode.Width + 8; DifficultyName.X = DifficultyRating.X + DifficultyRating.Width + 2; DifficultyName.Text = " - \"" + diffName + "\""; } var game = (QuaverGame)GameBase.Game; if (map != null) { ArtistTitle.Tint = Color.White; var length = TimeSpan.FromMilliseconds(map.SongLength / ModHelper.GetRateFromMods(ModManager.Mods)); var time = length.Hours > 0 ? length.ToString(@"hh\:mm\:ss") : length.ToString(@"mm\:ss"); if (OnlineManager.CurrentGame.HostSelectingMap) { Creator.Text = ""; } else { Creator.Text = $"By: {map.Creator} | Length: {time} | BPM: {(int) (map.Bpm * ModHelper.GetRateFromMods(ModManager.Mods))} " + $"| LNs: {(int) map.LNPercentage}%"; } // Inform the server that we now have the map if we didn't before. if (OnlineManager.CurrentGame.PlayersWithoutMap.Contains(OnlineManager.Self.OnlineUser.Id)) { OnlineManager.Client.HasMultiplayerGameMap(); } if (game.CurrentScreen.Type == QuaverScreenType.Lobby || game.CurrentScreen.Type == QuaverScreenType.Multiplayer || QuaverScreenManager.QueuedScreen.Type == QuaverScreenType.Multiplayer || AudioEngine.Map != map) { if (BackgroundHelper.Map != MapManager.Selected.Value) { Background.Alpha = 0; var view = Screen.View as MultiplayerScreenView; view?.FadeBackgroundOut(); BackgroundHelper.Load(map); } ThreadScheduler.Run(() => { try { if (AudioEngine.Map != map) { if (!HasMap) { return; } AudioEngine.LoadCurrentTrack(); AudioEngine.Track.Play(); } } catch (Exception e) { // ignored } }); } } // Let the server know that we don't have the selected map else { ArtistTitle.Tint = Color.Red; Creator.Text = Game.MapId != -1 ? "You don't have this map. Click to download!" : "You don't have this map. Download not available!"; Creator.Tint = Colors.SecondaryAccent; if (!OnlineManager.CurrentGame.PlayersWithoutMap.Contains(OnlineManager.Self.OnlineUser.Id)) { OnlineManager.Client.DontHaveMultiplayerGameMap(); } if (!AudioEngine.Track.IsStopped) { AudioEngine.Track.Stop(); } MapManager.Selected.Value = MapManager.Mapsets.First().Maps.First(); } }
protected override void OnPaint(PaintEventArgs e) { int radius = 20; if (this.Width < 8 || this.Height < 8) { return; } if (this.Width < 30 || this.Height < 30) { radius = 1; } e.Graphics.Clear(Parent.BackColor); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; int width = this.Width - 2; int height = this.Height - 1; int x = this.ClientRectangle.X; int y = this.ClientRectangle.Y; Color upperColor = this.JBackColor; Color nearClor = this.JBackColor; Color borderColor = this.JBackColor; int borderWidth = 0; switch (mouseActionType) { case MouseActionType.None: nearClor = ColorHelper.GetNearColor(this.JBackColor, 0.8f); borderColor = ColorHelper.GetNearColor(this.JBackColor, -0.5f); break; case MouseActionType.Hover: nearClor = ColorHelper.GetNearColor(this.JBackColor, 1.2f); borderColor = ColorHelper.GetNearColor(this.JBackColor, -0.8f); break; case MouseActionType.Click: borderWidth = 1; upperColor = ColorHelper.GetNearColor(this.JBackColor, 0.5f); nearClor = this.JBackColor; borderColor = ColorHelper.GetNearColor(this.JBackColor, -1.2f); break; default: break; } // Draw(e.ClipRectangle, e.Graphics, 16); GraphicsPath gp = new GraphicsPath(); Pen shadowPen = new Pen(borderColor, borderWidth); LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush( ClientRectangle, upperColor, nearClor, LinearGradientMode.Vertical); gp.AddArc(x + 1, y + 1, radius, radius, 180, 90); //左上角 gp.AddArc(width - radius - 1, y + 1, radius, radius, 270, 90); //右上角 gp.AddArc(width - radius - 1, height - (radius + 1), radius, radius, 0, 90); //右下角 gp.AddArc(x + 1, height - (radius + 1), radius, radius, 90, 90); gp.CloseAllFigures(); e.Graphics.DrawPath(shadowPen, gp); e.Graphics.FillPath(myLinearGradientBrush, gp); RectangleF StringRectangle = this.ClientRectangle; int fontHeight = (int)e.Graphics.MeasureString(JText, JFont, 1000, new StringFormat(StringFormat.GenericTypographic)).Height; StringRectangle.Height = fontHeight; StringRectangle.Y = StringRectangle.Y + ((this.ClientRectangle.Height - fontHeight) / 2); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; SolidBrush solidBrush = new SolidBrush(JForeColor); e.Graphics.DrawString(JText, JFont, solidBrush, StringRectangle, stringFormat); gp.Dispose(); shadowPen.Dispose(); solidBrush.Dispose(); stringFormat.Dispose(); myLinearGradientBrush.Dispose(); base.OnPaint(e); }
public override void Initialize() { base.Initialize(); _buttonsGroup = new Control(); const int buttonWidth = 212; const int buttomHeight = 40; _continueButton = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelContinue, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _continueButton.Pressed += delegate { OnContinuePressed(); }; _singlePlayer = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelSingleplayer, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _singlePlayer.Pressed += delegate { OnSinglePlayerPressed(); }; _multiplayer = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelMultiplayer, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _multiplayer.Pressed += delegate { OnMultiplayerPressed(); }; _settingsButton = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelSettings, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _settingsButton.Pressed += delegate { OnSettingsButtonPressed(); }; _editor = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelEditor, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _editor.Pressed += delegate { OnEditorPressed(); }; _credits = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelCredits, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _credits.Pressed += delegate { OnCreditsPressed(); }; _logoutButton = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelLogOut, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _logoutButton.Pressed += delegate { OnLogoutPressed(); }; _exitButton = new ButtonControl { CustomImage = _commonResources.StButtonBackground, CustomImageDown = _commonResources.StButtonBackgroundDown, CustomImageHover = _commonResources.StButtonBackgroundHover, CusomImageLabel = _stLabelExit, Bounds = new UniRectangle(0, 0, buttonWidth, buttomHeight) }; _exitButton.Pressed += delegate { OnExitPressed(); }; _buttonsGroup.Children.Add(_singlePlayer); _buttonsGroup.Children.Add(_multiplayer); _buttonsGroup.Children.Add(_settingsButton); _buttonsGroup.Children.Add(_editor); _buttonsGroup.Children.Add(_credits); _buttonsGroup.Children.Add(_logoutButton); _buttonsGroup.Children.Add(_exitButton); _buttonsGroup.ControlsSpacing = new SharpDX.Vector2(0, 0); _helloLabel = new LabelControl { Text = "HELLO", Color = ColorHelper.ToColor4(Color.FromArgb(198, 0, 75)), CustomFont = _commonResources.FontBebasNeue25 }; _nicknameLabel = new LabelControl { Color = SharpDX.Color.White, CustomFont = _commonResources.FontBebasNeue25 }; _mainMenuLabel = new ImageControl { Image = _stMainMenuLabel }; UpdateLayout(_engine.ViewPort, _engine.BackBufferTex.Description); }
public Factory(ColorHelper colorHelper) { _colorHelper = colorHelper; }
/// <summary> /// Convert hsv to rgb color /// </summary> /// <param name="hue">hue</param> /// <param name="saturation">saturation</param> /// <param name="brightness">brightness</param> /// <returns>Color</returns> private static Color FromHsv(float hue, float saturation, float brightness) { if (saturation == 0) { var c = (byte)Math.Round(brightness * 255f, MidpointRounding.AwayFromZero); return(ColorHelper.FromArgb(0xff, c, c, c)); } var hi = ((int)(hue / 60f)) % 6; var f = hue / 60f - (int)(hue / 60d); var p = brightness * (1 - saturation); var q = brightness * (1 - f * saturation); var t = brightness * (1 - (1 - f) * saturation); float r, g, b; switch (hi) { case 0: r = brightness; g = t; b = p; break; case 1: r = q; g = brightness; b = p; break; case 2: r = p; g = brightness; b = t; break; case 3: r = p; g = q; b = brightness; break; case 4: r = t; g = p; b = brightness; break; case 5: r = brightness; g = p; b = q; break; default: throw new InvalidOperationException(); } return(ColorHelper.FromArgb( 0xff, (byte)Math.Round(r * 255d), (byte)Math.Round(g * 255d), (byte)Math.Round(b * 255d))); }
// apply system color when changed private void SystemParametersOnStaticPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) { Background = ColorHelper.SystemWindowGlassBrushOfStrength(Strength); }
/// <summary> /// Gets a reference to the <see cref="T:System.Drawing.Color" /> structure preferred for this font. /// </summary> /// <returns> /// <see cref="T:System.Drawing.Color"/> structure that represents a .NET color. /// </returns> public Color GetColor() => ColorHelper.GetColorFromString(LineColor);
public void SetEmailFontColor(Color color) { var variable = GetAll().FirstOrDefault(f => Path.GetFileName(f).ToLower() == "variables.less"); if (variable == null) { return; } var variableContent = System.IO.File.ReadAllText(variable); variableContent = Regex.Replace(variableContent, @"@taxiHailEmailFontColor:(.+?);", string.Format(@"@taxiHailEmailFontColor:#{0};", ColorHelper.HexFromColor(color))); System.IO.File.WriteAllText(variable, variableContent, Encoding.UTF8); }
void Start() { //GetComponentInChildren<Renderer>().material.SetColor("_TintColor", new Color(0.25f, 0.25f, 0.25f, 1)); GetComponentInChildren <Renderer>().material.SetColor("_TintColor", new Color(0, 0, 0, 0.5f)); originalPosition = transform.position; transform.localScale = new Vector3(1, 1, 1) * Power; transform.position = originalPosition; gameObject.FindChild("Particle System").GetComponent <ParticleSystem>().renderer.material.SetColor("_TintColor", ColorHelper.ColorFromHSV(BulletHue, 1, 1)); }
public override void Update(GameSettings settings, float elapsedSeconds) { bool advanceRay = settings.Pause == false || settings.SingleStep; base.Update(settings, elapsedSeconds); DrawString("Press 1-5 to drop stuff, m to change the mode"); DrawString(string.Format("Mode = {0}", _mode)); const float l = 11.0f; Vector2 point1 = new Vector2(0.0f, 10.0f); Vector2 d = new Vector2(l * (float)Math.Cos(_angle), l * (float)Math.Sin(_angle)); Vector2 point2 = point1 + d; Vector2 point = Vector2.Zero, normal = Vector2.Zero; switch (_mode) { case RayCastMode.Closest: bool hitClosest = false; World.RayCast((f, p, n, fr) => { Body body = f.Body; if (body.Tag != null) { int index = (int)body.Tag; if (index == 0) { // filter return(-1.0f); } } hitClosest = true; point = p; normal = n; return(fr); }, point1, point2); if (hitClosest) { DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawPoint(point, .5f, ColorHelper.FromPercentages(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, point, ColorHelper.FromPercentages(0.8f, 0.8f, 0.8f)); Vector2 head = point + 0.5f * normal; DebugView.DrawSegment(point, head, ColorHelper.FromPercentages(0.9f, 0.9f, 0.4f)); DebugView.EndCustomDraw(); } else { DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawSegment(point1, point2, ColorHelper.FromPercentages(0.8f, 0.8f, 0.8f)); DebugView.EndCustomDraw(); } break; case RayCastMode.Any: bool hitAny = false; World.RayCast((f, p, n, fr) => { Body body = f.Body; if (body.Tag != null) { int index = (int)body.Tag; if (index == 0) { // filter return(-1.0f); } } hitAny = true; point = p; normal = n; return(0); }, point1, point2); if (hitAny) { DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawPoint(point, .5f, ColorHelper.FromPercentages(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, point, ColorHelper.FromPercentages(0.8f, 0.8f, 0.8f)); Vector2 head = point + 0.5f * normal; DebugView.DrawSegment(point, head, ColorHelper.FromPercentages(0.9f, 0.9f, 0.4f)); DebugView.EndCustomDraw(); } else { DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawSegment(point1, point2, ColorHelper.FromPercentages(0.8f, 0.8f, 0.8f)); DebugView.EndCustomDraw(); } break; case RayCastMode.Multiple: List <Vector2> points = new List <Vector2>(); List <Vector2> normals = new List <Vector2>(); World.RayCast((f, p, n, fr) => { Body body = f.Body; if (body.Tag != null) { int index = (int)body.Tag; if (index == 0) { // filter return(-1.0f); } } points.Add(p); normals.Add(n); return(1.0f); }, point1, point2); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawSegment(point1, point2, ColorHelper.FromPercentages(0.8f, 0.8f, 0.8f)); for (int i = 0; i < points.Count; i++) { DebugView.DrawPoint(points[i], .5f, ColorHelper.FromPercentages(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, points[i], ColorHelper.FromPercentages(0.8f, 0.8f, 0.8f)); Vector2 head = points[i] + 0.5f * normals[i]; DebugView.DrawSegment(points[i], head, ColorHelper.FromPercentages(0.9f, 0.9f, 0.4f)); } DebugView.EndCustomDraw(); break; } if (advanceRay) { _angle += 0.25f * MathHelper.Pi / 180.0f; } }
public void testColorOrder() { var color = new TBColor(); var helper = new ColorHelper(); var result = helper.GetColor(color); }