Posts

c# - Problems in generating random colors -

i want generate random colors in wpf , store them in array. random r; color[] colarr = new color[6]; (int = 0; < colarr.length; i++) { color c=new color(); r=new random(); r.next(); c.r = (byte)r.next(1, 255); c.g = (byte)r.next(1, 255); c.b = (byte)r.next(1, 255); c.a = (byte)r.next(1, 255); c.b = (byte)r.next(1, 255); colarr[i] = c; } but elements of array represent 1 single color. when debugged code, found random colors every element, when code executed(not in debug mode) same color generated. makes clear code correct, there problem while execution. edit : how can increase randomness of colors generated? the problem making new instance of random each run. should set once. the default seed random system time, same if repeat fast loop; time won't change lot. if set @ start, random work expected. i suggest use r.next(0, 256) , since give value ranging 0 255. also, call r.next() after definition of color c unnecess...

opengl - GLSL - Weird syntax error "<" -

i'm trying use shader keeps telling me error on both fragment , vertex shader: error(#132) syntax error: "<" parse error vertex shader varying vec4 diffuse; varying vec4 ambient; varying vec3 normal; varying vec3 halfvector;   void main() {     normal = normalize(gl_normalmatrix * gl_normal);       halfvector = gl_lightsource[0].halfvector.xyz;       diffuse = gl_frontmaterial.diffuse * gl_lightsource[0].diffuse;     ambient = gl_frontmaterial.ambient * gl_lightsource[0].ambient;     ambient += gl_lightmodel.ambient * gl_frontmaterial.ambient;     gl_position = ftransform();   } fragment shader varying vec4 diffuse,ambient; varying vec3 normal,halfvector;   void main() {     vec3 n,halfv,lightdir;     float ndotl,ndothv;       lightdir = vec3(gl_lightsource[0].position);       vec4 color = ambient;       n = normalize(normal);       ndotl = max(dot(n,lightdir),0.0);     if (ndotl > 0.0) {         color += diffuse * ndotl;         halfv = normalize(ha...

php - How do I find out that a link was seen -

i'm trying make page links , when clicks on link, score count go up. how can find out visitor has really seen page related link? not click link , close page score... really seen means: page loads completed. and links opens in new window. any solution? you cant see pages aren't in same domain. chrome puts them in separate thread. back in day have used css exploit talked here: https://developer.mozilla.org/en-us/docs/web/css/privacy_and_the_:visited_selector if want make page kind of functionality have make browser plugin/extension.

html - why their is little margin in between two red regions of the page shown? -

Image
shown in image below little gap between 2 red regions.. i have set margins , paddings 0 still giving 4px(i think) margin in between.. want know why appearing there... two red regions given floating left , displayed inline-block. <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>learning...</title> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="_body"> <div id="_header"> <img src="images/header_index.jpg"/> <br /> <h3> view of uttrakhand camera come here , explore whole beauty...</h3> </div> <div id="_navigation"> <ul> <li><a href="htmlpage.html">destinations</a></li> <li><a h...

c# - Are there any classes which can supply you with what a MethodInfo/method name would be? -

i wondering if there classes can generate methodbase/methodinfo, or generate method name, without using "magic strings". right i'm doing following: public void foo(methodinfo method) { if (string.equals("get_isbar", method.name, stringcomparison.ordinal)) { // ... } } instead, wondering if there way of getting name, "get_isbar", interface, this: public interface ibar { bool isbar { get; } } public void foo(methodinfo method) { string barmethodname = getbargettermethodname(typeof(ibar), "isbar"); if (string.equals(barmethodname, method.name, stringcomparison.ordinal)) { // ... } } i realize there still "magic string" in there, @ least it's more manageable. use getgetmethod() of propertyinfo : typeof(ibar).getproperty("isbar").getgetmethod().name

html5 - How do you center a line-wrapped <nav> menu in CSS? -

Image
i have ul centered in wide , narrow widths breaks in mid range. when wide fits nice, when browser narrow stacks nice, when using mid width, 800px wide, menu wraps next line, works now, see if possible center second row of links. here screenshot of how looks on top (red circle), , want on bottom (green circle). if @ another thread , see kind of how menu works right in example link . if shrink browser on example notice menu wraps , second row left aligned. i have second row centered under first row in picture above. possible? here html: <div id="navcontainer" <ul> <li class="menu_home"><a href="/">home</a></li> <li class="menu_gallery squished"><a href="/galleryintro.php">gallery of properties</a></li> <li class="menu_service"><a href="/service.php">service options</a></li> <li class=...

android - Launching an activity from notification -

i trying launch activity notification. have activity a. activity launched clicking on notification. once activity launched, mainactivity upon pressing phone's button. happen implement follow. code implemented in broadcastreceiver. having compilation error @ line intent resultintent = new intent(mainactivity.this, theclass); because mainactivity.this not valid in broadcastreceiver class. how can make correct? class theclass = class.forname("sg.santhit.trackme.notificationlistactivity"); intent resultintent = new intent(mainactivity.this, theclass); resultintent.putextra("mobilenumber", tel); taskstackbuilder stackbuilder = taskstackbuilder.create(mainactivity.this); // adds stack intent (but not intent itself) stackbuilder.addparentstack(theclass); // adds intent starts activity top of stack stackbuilder.addnextintent(resultintent); pendingintent resultpendingintent = stackbuilder.getpendingintent( 0, ...