logo
down
shadow

How to generate new back colour if two object's back colour match?


How to generate new back colour if two object's back colour match?

By : Ian
Date : October 21 2020, 08:10 AM
To fix the issue you can do If your code can be modified (Interface included) these are the changes that I propose:
Since you have two Properties that reference the selected Colors, you could assign default values and use these values to set the initial Colors of the Form and the Buttons.
code :
[ServiceContract]
public interface IRandomColoursService
{
    [OperationContract]
    Color GenerateRandomColour(Color UsedColor);
}

public class RandomColoursService : IRandomColoursService
{
    public Color GenerateRandomColour(Color UsedColor)
    {
        List<Color> colours = new List<Color>() { 
            Color.Red, Color.Blue, Color.Green, Color.Pink, Color.Purple, Color.Black
        };
        colours.Remove(UsedColor);
        Random rand = new Random();
        return colours[rand.Next(0, colours.Count)];
    }
}
RandomColourServiceReference.RandomColoursServiceClient ws = null;

Color BackGroundColour { get; set; } = Color.Red;
Color TextColour { get; set; } = Color.Black;

public Front_End()
{
    InitializeComponent();
    btnChangeButton.BackColor = TextColour;
    btnChangeBack.BackColor = TextColour;
    this.BackColor = BackGroundColour;
}

private void BtnChangeButton_Click(object sender, EventArgs e)
{
    TextColour = ws.GenerateRandomColour(BackGroundColour);
    btnChangeButton.BackColor = TextColour;
    btnChangeBack.BackColor = TextColour;
}

private void BtnChangeBack_Click(object sender, EventArgs e)
{
    BackGroundColour = GenerateRandomColour(TextColour);
    this.BackColor = BackGroundColour;
}
public Color GenerateRandomColour(List<Color> UsedColor)
{
    List<Color> colours = new List<Color>() { 
        Color.Red, Color.Blue, Color.Green, Color.Pink, Color.Purple, Color.Black
    };
    List<Color> AvailableColours = colours.Except(UsedColor).ToList();
    Random rand = new Random();
    return AvailableColours[rand.Next(0, AvailableColours.Count)];
}
Color BackGroundColour { get; set; } = Color.Black;
Color TextColour { get; set; } = Color.Red;
Color AnotherColour { get; set; } = Color.Green;

private void BtnChangeButton_Click(object sender, EventArgs e)
{
    List<Color> UsedColors = new List<Color>() { BackGroundColour, AnotherColour };
    TextColour = ws.GenerateRandomColour(UsedColors);
    btnChangeButton.BackColor = TextColour;
    btnChangeBack.BackColor = TextColour;
}

//(...)


Share : facebook icon twitter icon
Need to adjust jQuery color animation script to add transition from final colour back to first colour in a sequence

Need to adjust jQuery color animation script to add transition from final colour back to first colour in a sequence


By : Ivan Hernández
Date : March 29 2020, 07:55 AM
it should still fix some issue I am using the following script (which depends on jQuery UI) to animate the changing of the background colour of a DIV using the CSS below. You can see it in action on this page - it changes the colour in the doorway of the logo (you have to wait 10 secs to see a noticeable change). The transitions work fine apart from the change from the 5th colour back to the 1st which is a sudden change (i.e. no fade transition). I wonder if it would be possible to alter the script below to get this transition working too? , Here's the code that works for me:
code :
function changeColor(element, curNumber){
    curNumber++;

    if(curNumber > 5) {
        // we are back at 1, animate removeClass instead
        curNumber = 1;

        // we don't need animation here since color5 is defined AFTER color1, (cascading)
        element.addClass('color' + curNumber);

        // we animate removeClass instead
        element.removeClass('color' + 5, 2000);
    } else {
        element.addClass('color' + curNumber, 2000);
        // So previous classes get removed.
        element.attr('class', 'color' + curNumber);
    }
    console.log(curNumber);
    setTimeout(function(){changeColor(element, curNumber)}, 10000);  
}​
Highcharts: Change series colour on hover; revert back to original colour at mouseOut

Highcharts: Change series colour on hover; revert back to original colour at mouseOut


By : Srinivasan
Date : March 29 2020, 07:55 AM
help you fix your problem When returning back to original color use this.color, see: http://jsfiddle.net/3bQne/275/
Colour transition and back to original colour not working correctly

Colour transition and back to original colour not working correctly


By : user2604613
Date : March 29 2020, 07:55 AM
This might help you You're reversing the transition immediately, so the initial transition is being canceled.
code :
transitionDrawable.startTransition(2000);
linearLayoutPlatform.postDelayed(new Runnable() {
    @Override
    public void run() {
        transitionDrawable.reverseTransition(2000);
    }
}, 2000);
Javascript to set colour of html label back to default colour rather than assuming color black

Javascript to set colour of html label back to default colour rather than assuming color black


By : R.Pepe
Date : March 29 2020, 07:55 AM
Does that help Setting a style.blah property to an empty string will cause the normal stylesheet to apply again.
Alternatively, you could define your styles in CSS and add and remove a class from the element instead of twiddling its styles directly.
How to toggle button colour when it is clicked and change the colour back to its previous colour when it is clicked agai

How to toggle button colour when it is clicked and change the colour back to its previous colour when it is clicked agai


By : Riyaz Patel
Date : March 29 2020, 07:55 AM
may help you . You can use the native toggle method of the classList property. Also missing from your JavaScript is a reference to the clicked button.
code :
var button = document.querySelector('.btn-hold');

button.addEventListener('click', function() {
  this.classList.toggle('btn-alt-color');

  if (button.getAttribute("data-text-swap") == button.innerHTML) {
    button.innerHTML = button.getAttribute("data-text-original");
  } else {
    button.setAttribute("data-text-original", button.innerHTML);
    button.innerHTML = button.getAttribute("data-text-swap");
  }
}, false);
.btn-hold {
  float: right;
  text-decoration-color: white;
  background-color: ;
  font-family: Lato;
  font-size: 20px;
  cursor: pointer;
}

button {
  float: right;
}

button:focus {
  background: #FFD700;
}

.btn-hold.btn-alt-color {
  background-color: lightgreen;
}
<button class="btn-hold" data-text-swap=" Starred!">Star Message!</button>
Related Posts Related Posts :
  • How do request a correct access token in ASP.NET Core for Azure AD to access Microsoft Graph
  • How to run a .NET Core console application on Linux
  • UI not updating for bound element
  • C# Odata v4 open type raw values
  • DocumentFormat.OpenXml Modify Creator Propery of Document
  • How to SetBasePath in ConfigurationBuilder in Core 2.0
  • ASP MVC5 public readonly variable changes value when it should not
  • How to conditionally select item from hashset with queryable linq?
  • Progress Bar C# not showing the real progress
  • Correct logic to reconnect in SignalR with HubConnection
  • ComboBox with two or more sections
  • .NET listbox to SQLite DB
  • C# Ninject binding from Dictionary<Type, Type>
  • asp.net mvc -view displaying real-time progress status
  • Getting reference to dependent in service with generic type
  • Implementing EqualityCompare vs overriding GetHashCode and Equals
  • C# Linq Find all indexes of item in List<int> within another List<int>
  • XML image how to display at data grid columns in c#.net
  • How to override Equals and GetHash of HashSet
  • Creating Windows authentication and SQL Server authentication in login form
  • How to interop with Azure Service Bus topics created by MassTransit using Rebus?
  • MVC 5 Google Calendar Integration
  • C# - Use parallel arrays to calculate cost of a phone call in GUI
  • Use a int in entire code
  • How to display newly added element at the top of StackPanel in WPF?
  • T4MVC is generating T4MVC.cs and T4MVC1.cs
  • Remove blur effect on certain controls inside UserControl
  • Sql Transcation Query to Linq Query in Wcf Rest Service
  • Setting AWS S3 credentials in C# app
  • does not contain in an ObservableCollection
  • App doesn't run it crashed directly after I started it
  • Is it possible in Entity Framework MVC application to run .sql scripts on a different database
  • Type Inference with Deconstruct tuple assignment extension methods
  • Setting up mock objects for EF dbcontext to test repository methods
  • Using C# in XSLT with MSXSL 6.0
  • Absolute positioning of UIElement in FlowDocument in WPF
  • Display debuggers not showing up in Visual Studio 2017
  • Discord.NET Users playing the same game
  • Azure function output API call to 3rd party service
  • Unable to determine the relationship represented by navigation property ASP.NET core 2.0 Entity Framework
  • Regex to find group of Regex inside a word
  • When calling a method, when to reference the class, and when to reference the object?
  • AmazonCloudWatchLogsClient async methods failing with no error
  • Create FileStream in memory instead of saving a physical file on disk
  • ViewBag data coming from ActionFilter is persisting in session even after database
  • ERROR: the name 'lvSubCategories' does not exist in the current context
  • Why datetime can't recognise the string?
  • Getting 500 error while requesting to webservice using Ajax AutoCompleteExtender
  • The property 'x' is not a navigation property of entity type 'y'
  • ASP.NET MVC - How to generate empty input boxes in loop when model is empty?
  • Need help writing regular expression
  • Add/remove buttons to a panel with an arraylist c#
  • Linq .Where(type = typeof(xxx)) comparison is always false
  • Using EF6 Code First without migrations to an existing db how do I specify column names of the many to many join table?
  • C# - Using Thread.Sleep precisely in a console application
  • Add item to a List<Tuple> inside another list
  • Double[,], inversion C#
  • Counting a string to ensure the input is within a min/max boundary
  • Assign invalidValue to Enum variable (why is this not throwing an Exception?)
  • Namespace or type specified in the project-level Imports 'System.Threading.Tasks' doesn't contain any public member or c
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org