Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

DaveyM69

@DaveyM69
About
Posts
3.7k
Topics
184
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • project Convert of Binary To Decimal
    D DaveyM69

    You will need to write the project yourself however there is a lot of code out there to help you. Here are a couple of things I wrote 8 years ago that may assist... This article[^] deals with binary/int and other conversions too. This article[^] deals with a numeric text box - you can modify to only allow 0 and 1 if in binary mode.

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp

  • float to and from frequency
    D DaveyM69

    I'll keep my eye on it for other parameters that use the logf type. For the 20-400HZ one Math.E is giving the correct result. Thanks for the heads up.

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • float to and from frequency
    D DaveyM69

    Ha ha! I don't think I'd be that brave ;) Nearly there now thanks to Kenneth's find.

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • float to and from frequency
    D DaveyM69

    Thanks for your help Sascha - I've got a solution, see my response to Kenneth below :thumbsup:

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • float to and from frequency
    D DaveyM69

    Brilliant find Kenneth! I have tweaked the C# method on that page to:

    float[] logValues = CreateLogValues(20, 400, 101);

    public static float[] CreateLogValues(float minimum, float maximum, int valuesCount)
    {
    double logarithmicBase = Math.E;
    double logMinimum = Math.Log(minimum);
    double logMaximum = Math.Log(maximum);
    double delta = (logMaximum - logMinimum) / (valuesCount - 1);
    double accumulatedDelta = 0;
    float[] values = new float[valuesCount];
    for (int i = 0; i < valuesCount; ++i)
    {
    values[i] = (float)Math.Pow(logarithmicBase, logMinimum + accumulatedDelta);
    accumulatedDelta += delta;
    }
    return values;
    }

    which is a good start. I should be able to sort the rest from here :) Thanks :thumbsup:

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • float to and from frequency
    D DaveyM69

    I've double checked the displayed results for those values and they are correct. All the spec says is:

    logf [20.000, 400.000, 101] Hz

    which means: log float with a range of 20-400Hz, 101 valid steps

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • float to and from frequency
    D DaveyM69

    Sure... .25 = approx. 42Hz and .75 = approx. 189Hz I've found a little more information. The displayed values on the end device are arranged into 101 steps so the mid value is actually 0.49 which displays 87Hz (this will be rounded though)

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • float to and from frequency
    D DaveyM69

    Mathematics is not my strong point! I'm coding against a protocol (OSC) that connects to an external device that takes a float between 0.0 and 1.0 to represent a frequency between 20Hz and 400Hz. The frequency scale is an inverse log curve so for example 0.5 represents approximately 89Hz. How on earth do I convert from the float to the frequency - and back again too?

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com tutorial question

  • Tree class recommendation
    D DaveyM69

    Well thanks again Eddy, it's done the job brilliantly with only a few minor tweaks to allow for use in my situation! Awesome :)

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com data-structures tutorial

  • Tree class recommendation
    D DaveyM69

    Thanks Eddy, I'll try this tomorrow :thumbsup: It's actually to hold and look up against OSC[^] addresses for a particular device. I don't need all the wild card stuff thankfully so with what you've given me I should be close. Thanks again :)

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com data-structures tutorial

  • Tree class recommendation
    D DaveyM69

    Hi, I need to create a data structure that is very tree like that operates similar to a directory structure. For example: /ch - will add "ch" to root /ch/01/config - will add "01" to ch from above and "config" to 01 /ch/02/insert - will add "02" to ch from first line and "insert" to 02 /ch/01/mix/01 - will add "mix" to 01 from second line and "01" to mix /config/chlink - will add "config" to root and "chlink" to config which will result in a Tree layout like:

    root->ch ->01 ->config
    ->mix ->01
    ->02 ->insert
    ->config->chlink

    I have been playing with this for a while now and just can't get anything I write to function in this way. If anyone could point me in the right direction it would be much appreciated!

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# csharp com data-structures tutorial

  • Matching two audio files in android
    D DaveyM69

    These responses[^] seems to look promising...

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    Android help android com question

  • remote sql
    D DaveyM69

    The answer is in the first line of your post: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)"

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# sysadmin database sql-server help

  • Bitmap from view with opaque/semi transparent background
    D DaveyM69

    No idea I'm afraid without seeing your code... You need to put a breakpoint at line 59 in SplashScreen.java and see what's going wrong

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    Android csharp com graphics help

  • Bitmap from view with opaque/semi transparent background
    D DaveyM69

    I'm using the code below to create a filled rounded rectangle with border of a view. The problem is: 1. If Alpha is set high, the bitmap of the view is no longer visible 2. If Alpha is medium, the bitmap of the view is also dulled I want the foreground to be as the original on top of the background that is controlled by the Alpha value

        Bitmap bitmap = getBitmapFromView(view);
        Canvas canvas = new Canvas(bitmap);
        Paint background = new Paint();
        RectF rectF = new RectF(1, 1, bitmap.getWidth() - 2, bitmap.getHeight() - 2);
        
        // draw background
        background.setStyle(Paint.Style.FILL);
        background.setColor(BACKGROUND\_COLOUR);
        background.setAlpha(ALPHA);
        canvas.drawRoundRect(rectF, ROUNDING, ROUNDING, background);
        
        // draw border
        background.setStyle(Paint.Style.STROKE);
        background.setStrokeWidth(LINE\_THICKNESS);
        background.setColor(BORDER\_COLOUR);
        canvas.drawRoundRect(rectF, ROUNDING, ROUNDING, background);
        
        // draw foreground
        Paint foreground = new Paint();
        canvas.drawBitmap(bitmap, 0, 0, foreground);
        
        return bitmap;
    

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    Android csharp com graphics help

  • UI / Model Hook Up
    D DaveyM69

    In case anyone else drops by this, extending ArrayAdapter<> and using that as the adapter for a ListView works pretty well for collections. With some work you can get it to behave as you want! For single items, it's just as easy to do it all in the activity itself, although not great separation. I am new to this Android stuff though so I'm probably missing something...

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    Android csharp design java android

  • NumericString Sort
    D DaveyM69

    This works the way you have described. It may not be very efficient so you may want to optimise it somewhat:

    public static int Compare(string first, string second)
        {
            if (object.ReferenceEquals(first, second))
                return 0;
            if (object.ReferenceEquals(null, first)) // second cannot be null
                return -1;
            // neither string can be null
            char\[\] digits = new char\[\] { '0', '1', '2', '3', '4', '5', '6', '7', '8','9' };
            int firstDigitIndex = first.IndexOfAny(digits);
            int secondDigitIndex = second.IndexOfAny(digits);
            string firstLhs = firstDigitIndex == -1 ? first : first.Substring(0, firstDigitIndex);
            string secondLhs = secondDigitIndex == -1 ? second : second.Substring(0, firstDigitIndex);
            int result = firstLhs.CompareTo(secondLhs);
            if (result == 0)
            {
                // left hand sides are equal so sort on numeric part
                int firstInteger = 0;
                int secondInteger = 0;
                if (firstDigitIndex > -1)
                    int.TryParse(first.Substring(firstDigitIndex), out firstInteger);
                if (secondDigitIndex > -1)
                    int.TryParse(second.Substring(secondDigitIndex), out secondInteger);
                result = firstInteger.CompareTo(secondInteger);
            }
            return result;
        }
    

    Test:

        SortAndWriteList(new List(new string\[\] { "ABC 1", "ABC 10", "ABC 2", "ABC 100" }));
        Console.WriteLine();
        SortAndWriteList(new List(new string\[\] { "ADBCDEF - 1", "ADBCDEF - 10", "ADBCDEF - 3" }));
        Console.WriteLine();
        Console.ReadKey();
    
        private static void SortAndWriteList(List list)
        {
            if (list != null)
            {
                list.Sort(new Comparison(Compare));
                foreach (string item in list)
                    Console.WriteLine(item);
            }
        }
    

    Result:

    ABC 1
    ABC 2
    ABC 10
    ABC 100

    ADBCDEF - 1
    ADBCDEF - 3
    ADBCDEF - 10

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (

    C# algorithms

  • UI / Model Hook Up
    D DaveyM69

    So, I'm developing my first ever Android app and my first experience of Eclipse and Java (after many years of Visual Studio and C#)! I have all my data storage and retrieval coded and working, as well as all my classes that represent that data. Now it's time to design the UI - I have an idea of how I want it to look and interact so all good to go but... What is the best or recommended way of hooking up the UI in Java to the objects behind. From the research I've done it doesn't appear that DataBinding (ala WPF) is supported which would be the obvious way. It's just straight forward class instances and collections of those classes. Thanks in advance :)

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    Android csharp design java android

  • Help needed XNA and Window Forms
    D DaveyM69

    Form1 form = new Form1();
    form.Show();
    Game1 game = new Game1(form.getDrawSurface());
    form.Game = game; //The new line
    game.GameEvent += HandleGameEvent;
    game.Run();

    // Inside Form1
    private void HandleGameEvent(object sender, EventArgs e)
    {
    //
    }

    public class Game1
    {
    public event EventHandler GameEvent;

    protected vitual void OnGameEvent(EventArgs e)
    {
    EventHandler eh = GameEvent;
    if(eh != null)
    eh(this, e);
    }
    }

    Check out Basic Event Creation in C#[^] and Events Made Simple[^]

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# question game-dev help

  • Help needed XNA and Window Forms
    D DaveyM69

    Create custom events in your Game1 class and subscribe to those events from the game instance in your form

    Dave
    Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
    BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

    C# question game-dev help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups