public GetAll() { _fakeRepository = new FakeColorRepository(); ColorFactory.Create(_fakeRepository); _colorService = new ColorService(_fakeRepository); }
public EditProduct(string productId, string productName, string measurementUnit, object date) { InitializeComponent(); // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Edit button editButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); editButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); editButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Product table product.Rows[0].Cells[0].Value = productId; product.Rows[0].Cells[1].Value = productName; product.Rows[0].Cells[2].Value = measurementUnit; product.Rows[0].Cells[3].Value = date; }
void Start() { LevelColors = ColorFactory.FromTheme(Theme); var solidBlocks = GameObject.FindGameObjectsWithTag("Solid"); Colorize(solidBlocks, ColorFactory.Black); _player = GameObject.FindGameObjectWithTag("Player"); _color1Blocks = GameObject.FindGameObjectsWithTag("Color1"); _color2Blocks = GameObject.FindGameObjectsWithTag("Color2"); _colorMixedBlocks = GameObject.FindGameObjectsWithTag("ColorMixed"); _antiColor1Blocks = GameObject.FindGameObjectsWithTag("AntiColor1"); _antiColor2Blocks = GameObject.FindGameObjectsWithTag("AntiColor2"); _antiColorMixedBlocks = GameObject.FindGameObjectsWithTag("AntiColorMixed"); Colorize(_color1Blocks, LevelColors.Color1); Colorize(_color2Blocks, LevelColors.Color2); Colorize(_colorMixedBlocks, LevelColors.ColorMixed); Colorize(_antiColor1Blocks, LevelColors.Color1); Colorize(_antiColor2Blocks, LevelColors.Color2); Colorize(_antiColorMixedBlocks, LevelColors.ColorMixed); Colorize(GameObject.FindGameObjectsWithTag("Trigger"), ColorFactory.Transparent); Colorize(GameObject.FindGameObjectsWithTag("ZeroGravity"), ColorFactory.Gray); UpdateColors(ColorInput.None); }
public void RandomColorIsRounded() { Randomizer.Use(new FixedRandom(new[] { 0.1f, 0.2f, 0.3f })); Color color = new ColorFactory().Generate(0.5f, 0.1f); Assert.AreEqual(new Color(0.5f, 0.6f, 0.6f), color); }
public EditMeal(string mealCode, string mealName, string quantity, string type, string portions, string calories, string date) { InitializeComponent(); // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Edit button editButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); editButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); editButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Meal table meal.Rows[0].Cells[0].Value = mealCode; meal.Rows[0].Cells[1].Value = mealName; meal.Rows[0].Cells[2].Value = quantity; meal.Rows[0].Cells[3].Value = calories; meal.Rows[0].Cells[4].Value = type; meal.Rows[0].Cells[5].Value = portions; meal.Rows[0].Cells[6].Value = date; }
private void InitializeAll() { Camera.main.orthographicSize = ((ColumnCount + 1) / 2) + 1; _displayColors = ColorFactory.GrayScaleReversed(5); int stateLength = (ColumnCount * RowCount); _displayState = new NativeArray <byte>(stateLength, Allocator.Persistent); _myConwayState = new ConwayStateClass(ColumnCount, RowCount); ///ushort -> byte for params _myConwayDisplayState = new ConwayDisplayState(_displayState, _myConwayState._indexer); if (_mirrorDisplay) { SetMirroredDisplayState(); } else { SetSimpleDisplayState(); } GenerateDisplay(); UpdateDisplay(); }
public EditRecipeProduct(int recipeCode, int productCode) { InitializeComponent(); this.recipeCode = recipeCode; this.productCode = productCode; // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Quantity label quantityLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Delete button editRecipeProductButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); editRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); editRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); }
public IActionResult Index() { var colorFactory = new ColorFactory(); ViewData["Colors"] = colorFactory.RandomBeautiful(256).Select(c => c.ToString("HEX", null)); return(View()); }
public NewProduct() { InitializeComponent(); // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Product name label productNameLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); productNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Measurement unit label measurementUnitLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); measurementUnitLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // New product button newProductButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 20); newProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); newProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Set tool tips this.toolTip.SetToolTip(productName, Constants.ProductNameToolTip); this.toolTip.SetToolTip(measurementUnit, Constants.MeasurementToolTip); }
private void ChangeColor_Clicked(object sender, RoutedEventArgs e) { MenuItem item = sender as MenuItem; switch (item.Tag.ToString()) { case "red": ColorFactory.ChangeColors(Colors.Red); break; case "green": ColorFactory.ChangeColors(Colors.DarkGreen); break; case "blue": ColorFactory.ChangeColors(Color.FromRgb(93, 136, 230)); break; case "gray": ColorFactory.ChangeColors(Colors.Black); break; case "orange": ColorFactory.ChangeColors(Colors.DarkOrange); break; case "lime": ColorFactory.ChangeColors(Colors.Lime); break; case "magenta": ColorFactory.ChangeColors(Colors.Magenta); break; } }
public void GetNextColorTest() { ColorFactory cf = new ColorFactory(); var color = cf.GetNextColor(); Assert.IsTrue(color == Color.Red); }
/** * Declare a parameter with the specified name and value. This parameter * will be added to the currently active parameter list. * * @param name parameter name * @param value parameter value */ public void parameter(string name, string colorspace, params float[] data) { try { parameterList.addColor(name, ColorFactory.createColor(colorspace, data)); } catch (ColorFactory.ColorSpecificationException e) { UI.printError(UI.Module.API, "Unable to specify color: {0} - ignoring parameter \"{1}\"", e.Message, name); } }
public AllRecipes() { InitializeComponent(); this.recipesBindingSource = new BindingSource(); BindRecipesData(); recipeCode.DataBindings.Add(new Binding("text", recipesBindingSource, "Код")); recipeName.DataBindings.Add(new Binding("text", recipesBindingSource, "Наименование")); // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Product label productLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); productLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Quantity label quantityLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Recipe code label recipeCodeLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); recipeCodeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Recipe name label recipeNameLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); recipeNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Delete recipe button deleteRecipeButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); deleteRecipeButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); deleteRecipeButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Show add product panel button showAddProductPanelButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); showAddProductPanelButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); showAddProductPanelButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Delete recipe product button deleteRecipeProductButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); deleteRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); deleteRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Edit recipe product button editRecipeProductButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); editRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); editRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Add recipe product button addRecipeProductButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); addRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); addRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // New product panel FillProductsComboBox(); newProductPanel.Hide(); }
private string SetSecret() { try { long recent = 0, count; double best = 0, find; Parallel.ForEach(Directory.GetFiles(string.Concat(Path.Combine(Application.StartupPath, @"..\"), @"\Statistics\"), "*.csv", SearchOption.AllDirectories), new ParallelOptions { MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 1.5) }, (val) => { arr = val.Split('\\'); arr = arr[arr.Length - 1].Split('.'); count = long.Parse(arr[0]); if (count > recent) { recent = count; } }); using StreamReader sr = new StreamReader(string.Concat(Path.Combine(Application.StartupPath, @"..\"), @"\Statistics\", recent.ToString(), ".csv")); ColorFactory = new ColorFactory(); List <string> list = new List <string>(256); SendColor += ColorFactory.OnReceiveColor; int turn = 0; if (sr != null) { while (sr.EndOfStream == false) { list.Add(sr.ReadLine()); } } foreach (IMakeUp val in mp) { find = MakeUp(list, val); if (best < find && val.Turn != 2) { best = find; turn = val.Turn; } } Key = Keys[turn]; return(string.Concat(list[1].Substring(0, 8), "^", list[list.Count - 2].Substring(0, 8))); } catch (Exception ex) { new LogMessage().Record("Error", ex.ToString()); MessageBox.Show(string.Concat(ex.ToString(), "\n\nQuit the Program."), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning); Environment.Exit(0); } return(string.Empty); }
public static void Main() { Color blue = new RedColor(); Color red = new BlueColor(); var factory = new ColorFactory(); var existingColor = factory.GetColor("blue"); existingColor.Display(); var newColor = factory.GetColor("red"); newColor.Display(); }
private void cmbx_SelectedIndexChanged(object sender, EventArgs e) { Color = ColorFactory.GetColorFromNum(_colorMenu.SelectedIndex); LineWidth = _lineWidthMenu.SelectedIndex + 1; Type = TypeFactory.GetStrShapeType(_typeMenu.SelectedIndex); RedrawShape(Data.SetData(Left, Top, Width, Height, Color, LineWidth, Type, TabIndex)); var main = FindForm() as Main; main.SetData(this); }
public void StartRayTrace() { var rayTraceConfguration = new RayTraceConfigurationModel { Width = rayTraceViewModel.BitmapWidth, Height = rayTraceViewModel.BitmapHeight, Samples = rayTraceViewModel.RenderSamples, UpdateRate = rayTraceViewModel.RenderUpdateRate, }; var sceneType = Int32.Parse(rayTraceViewModel.CurrentScene.Number); var aspect = (double)rayTraceConfguration.Width / (double)rayTraceConfguration.Height; IScene scene; switch (sceneType) { default: case 0: scene = new CoverSceneRT1(aspect); break; case 1: scene = new MaterialsScene(aspect); break; case 2: scene = new DefocusBlurScene(aspect); break; case 3: scene = new TestScene1(aspect); break; case 4: scene = new TestScene2(aspect); break; case 5: scene = new CoverSceneRT1Motion(aspect); break; case 6: scene = new CheckerTextureScene(aspect); break; case 7: scene = new NoiseTextureScene(aspect); break; case 8: scene = new GlobeScene(aspect); break; case 9: scene = new SimpleLightScene(aspect); break; case 10: scene = new RoomScene(aspect); break; case 11: scene = new VolumeScene(aspect); break; case 12: scene = new CoverSceneRT2(aspect); break; } var rayTracer = new RayTracer(scene); var rayTraceTarget = new RayTraceTargetAdapter ( progress => rayTraceViewModel.Progress = progress, (x, y, c) => rayTraceViewModel.SetBitmapPixel(x, y, ColorFactory.CreateSquare(c)) ); rayTraceProcess = new RayTraceProcessHandler(rayTraceConfguration, rayTracer, rayTraceTarget); rayTraceProcess.StartAsync(); }
// Start is called before the first frame update void Start() { cells = new GameObject[rowCount * columnCount]; GenerateGrid(); this.transform.Translate(-columnCount * .5f, -rowCount * .5f, 0); colors = ColorFactory.GrayScaleReversed(5); foreach (var color in colors) { Debug.Log("color:" + color); } }
public void TheTwentiethColorShouldBeRedAgain() { ColorFactory cf = new ColorFactory(); Color color = Color.Black; for (int i = 0; i < 21; i++) { color = cf.GetNextColor(); } Assert.IsTrue(color == Color.Red); }
public MainScreen() { InitializeComponent(); // Form settings this.Width = FromWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Main menu mainMenu.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); mainMenu.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); mainMenu.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); }
public SearchMeals() { InitializeComponent(); // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Menu strip toolStrip.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); toolStrip.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); toolStrip.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Meal name label mealNameLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); mealNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Meal type label typeLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); typeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Calories label caloriesLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); caloriesLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Calories label caloriesHelpFromLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); caloriesHelpFromLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Calories label caloriesHelpToLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); caloriesHelpToLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Quantity label quantityLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); quantityHelpFromLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); quantityHelpFromLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); quantityHelpToLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); quantityHelpToLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Search button searchButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); searchButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); searchButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Clear button clearFiltersButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12); clearFiltersButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); clearFiltersButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); }
public void ToNative_AsExpected(IColor32 fc, ColorRgba32 expected) { var colorFactory = new ColorFactory(); var actual = colorFactory.ToNative(fc); Assert.Multiple(() => { Assert.AreEqual(expected.Color, actual.Color, ".Color components not equal"); Assert.AreEqual(expected.R, actual.R, "Red components not equal"); Assert.AreEqual(expected.G, actual.G, "Green components not equal"); Assert.AreEqual(expected.B, actual.B, "Blue components not equal"); Assert.AreEqual(expected.A, actual.A, "Alpha components not equal"); }); }
public void ItReturnsColorFromRepository(byte id, string name) { // Arrange var expectedColor = ColorFactory.Create(_fakeRepository, id, name); var service = new ColorService(_fakeRepository); // Act var actualColor = service.Get(expectedColor.Id); // Assert Assert.True(_fakeRepository.GetCalled); Assert.Equal(expectedColor.Id, actualColor.Id); Assert.Equal(expectedColor.Name, actualColor.Name); }
public void OnReceiveColor(ColorFactory cf) { labelShortTick.ForeColor = cf.Recent; labelShortDay.ForeColor = cf.Weekly; labelLongTick.ForeColor = cf.Biweekly; labelLongDay.ForeColor = cf.Monthly; labelReaction.ForeColor = cf.For3Months; labelHedge.ForeColor = cf.Cumulative; labelShortTick.Text = string.Concat(labelShortTick.Text, cf.StrRecent.Contains("-") ? cf.StrRecent.Replace("-", "") : cf.StrRecent); labelShortDay.Text = string.Concat(labelShortDay.Text, cf.StrWeekly.Contains("-") ? cf.StrWeekly.Replace("-", "") : cf.StrWeekly); labelLongTick.Text = string.Concat(labelLongTick.Text, cf.StrBiweekly.Contains("-") ? cf.StrBiweekly.Replace("-", "") : cf.StrBiweekly); labelLongDay.Text = string.Concat(labelLongDay.Text, cf.StrMonthly.Contains("-") ? cf.StrMonthly.Replace("-", "") : cf.StrMonthly); labelReaction.Text = string.Concat(labelReaction.Text, cf.StrFor3Months.Contains("-") ? cf.StrFor3Months.Replace("-", "") : cf.StrFor3Months); labelHedge.Text = string.Concat(labelHedge.Text, cf.StrCumulative.Contains("-") ? cf.StrCumulative.Replace("-", "") : cf.StrCumulative); }
public void draw(string text, BufferedImage canvas, FontFactory fontFactory, ColorFactory colorFactory) { Graphics2D g = (Graphics2D)canvas.getGraphics(); TextString ts = convertToCharacters(text, g, fontFactory, colorFactory); arrangeCharacters(canvas.getWidth(), canvas.getHeight(), ts); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); foreach (TextCharacter tc in ts.Characters) { g.setColor(tc.Color); g.drawString(tc.iterator(), (float)tc.X, (float)tc.Y); } }
private void InitializePlayers() { Face1.Avatar = Configuration.DefaultAvatar; Face1.Color = Configuration.DefaultColorGroup; Face1.SetPlayerName("Jorge"); Face2.Avatar = Avatars.GetRandomAvatar(); Face2.Color = ColorFactory.GetRandomColor(Face1.Color); FaceSelector3.Avatar = Avatars.GetRandomAvatar(); FaceSelector3.Color = ColorFactory.GetRandomColor(Face1.Color, Face2.Color); FaceSelector4.Avatar = Avatars.GetRandomAvatar(); FaceSelector4.Color = ColorFactory.GetRandomColor(Face1.Color, Face2.Color, FaceSelector3.Color); }
public GeometryFactory GetFactory(GeometryType geometryType) { GeometryFactory geometryFactory = null; switch (geometryType) { case GeometryType.Shape: geometryFactory = new ShapeFactory(); break; case GeometryType.Color: geometryFactory = new ColorFactory(); break; } return(geometryFactory); }
protected override void OnMouseClick(MouseEventArgs e) { Focus(); switch (e.Button) { case MouseButtons.Left: break; case MouseButtons.Right: var shapeMenu = new ContextMenuStrip(); _colorMenu = new ToolStripComboBox(); _colorMenu.Items.AddRange(new object[] { "Black", "Green", "Red" }); _colorMenu.SelectedIndex = ColorFactory.GetNumColor(Color); _colorMenu.SelectedIndexChanged += cmbx_SelectedIndexChanged; _lineWidthMenu = new ToolStripComboBox(); _lineWidthMenu.Items.AddRange(new object[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }); _lineWidthMenu.SelectedIndex = LineWidth - 1; _lineWidthMenu.SelectedIndexChanged += cmbx_SelectedIndexChanged; _typeMenu = new ToolStripComboBox(); _typeMenu.Items.AddRange(new object[] { "Rectangle", "Ellipse", "Line" }); _typeMenu.SelectedIndex = TypeFactory.GetNumShapeType(Type); _typeMenu.SelectedIndexChanged += cmbx_SelectedIndexChanged; shapeMenu.Items.AddRange(new ToolStripItem[] { _colorMenu, _lineWidthMenu, _typeMenu }); ContextMenuStrip = shapeMenu; break; case MouseButtons.None: break; case MouseButtons.Middle: break; case MouseButtons.XButton1: break; case MouseButtons.XButton2: break; default: break; } }
public AllMeals() { InitializeComponent(); // Form settings this.Width = FormWidth; this.Height = FormHeight; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = FormTitle; this.BackColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); // Content wrapper contentWrapper.BackColor = Color.White; contentWrapper.Width = (int)(FormWidth * Constants.WrapperSizeCoefficient); contentWrapper.Height = (int)(FormHeight * Constants.WrapperSizeCoefficient); // Center the wrapper within the parent form contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2; contentWrapper.Top = (this.ClientSize.Height - contentWrapper.Height) / 2; // Meal code label mealCodeLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); mealCodeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Meal name label mealNameLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); mealNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Quantity label quantityLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Calories label caloriesLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); caloriesLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Type label typeLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); typeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Portions label portionsLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); portionsLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Modifiecation date label modificationDateLabel.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); modificationDateLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Edit button editButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); editButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); editButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); // Delete button deleteButton.Font = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16); deleteButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey); deleteButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey); }
public static void Run() { var factory = new ColorFactory(); var display = new Display(1920, 1080, factory); factory.UseCache = true; var painter = new Painter(); var sizeBeforePaint = Process.GetCurrentProcess().PrivateMemorySize64; Console.WriteLine($"Usage before paint - { sizeBeforePaint }"); paint(); var sizeAfterFlyweightPaint = Process.GetCurrentProcess().PrivateMemorySize64; Console.WriteLine($"Usage after paint with Flyweight - {sizeAfterFlyweightPaint}, diff {sizeAfterFlyweightPaint - sizeBeforePaint}"); display.Clear(); GC.Collect(); factory.UseCache = false; paint(); var sizeAfterPaint = Process.GetCurrentProcess().PrivateMemorySize64; Console.WriteLine($"Usage after paint without Flyweight - { Process.GetCurrentProcess().PrivateMemorySize64}, diff {sizeAfterFlyweightPaint - sizeAfterPaint}, "); // Рисуем одно и то же для чистоты эксперемента, хотя тут все и ежу понятно) void paint() { painter.DrowSquare(display: display, startPoint: new Point { X = 0, Y = 0 }, width: 800, color: new ColorDto { Red = 124, Gray = 101, Blue = 123 }); painter.DrowRectangle(display: display, startPoint: new Point { X = 1000, Y = 0 }, width: 900, height: 1000, color: new ColorDto { Red = 121, Gray = 11, Blue = 124 }); } }
public void ToForeignColor_Converts_Correctly(ColorRgba32 nc, ColorBgr15 expected, ColorModel colorModel) { var colorFactory = new ColorFactory(); var actual = colorFactory.ToForeign(nc, colorModel); if (actual is IColor32 actual32) { Assert.Multiple(() => { Assert.AreEqual(expected.Color, actual.Color, ".Color components not equal"); Assert.AreEqual(expected.R, actual32.R, "Red components not equal"); Assert.AreEqual(expected.G, actual32.G, "Green components not equal"); Assert.AreEqual(expected.B, actual32.B, "Blue components not equal"); Assert.AreEqual(expected.A, actual32.A, "Alpha components not equal"); }); } }