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
G

GrooverFromHolland

@GrooverFromHolland
About
Posts
47
Topics
18
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Maybe I did it again??
    G GrooverFromHolland

    Ticket: (No ticket provided - possibly an error in the error-system) Error: An error occurred in this page. The error has been recorded and the site administrator informed. Abort, Retry, Fail?_

    0200 A9 23 0202 8D 01 80 0205 00

    The Lounge help question

  • Houdini???
    G GrooverFromHolland

    Now YOU startled me!

    0200 A9 23 0202 8D 01 80 0205 00

    The Lounge database question

  • Did i do it?
    G GrooverFromHolland

    Ticket: 615594 Error: An error occurred in this page. The error has been recorded and the site administrator informed. Abort, Retry, Fail?_

    0200 A9 23 0202 8D 01 80 0205 00

    The Lounge help question

  • Houdini???
    G GrooverFromHolland

    NetworkDbconn = "\\\\\\\\computer\\Users\\DbUser\\MachineData\\MachineData.db";

    Really? :confused::confused::confused:

    0200 A9 23 0202 8D 01 80 0205 00

    The Lounge database question

  • Famous last words; Have to do it
    G GrooverFromHolland

    someone had to, so it might as well be me.

    0200 A9 23 0202 8D 01 80 0205 00

    The Lounge help

  • Famous last words; Have to do it
    G GrooverFromHolland

    I know politics are not allowed but I can't help myself, have to post. >“I don’t know Mr Libby,” Mr Trump said in a quote provided alongside a statement announcing >the pardon, “but for years I have heard that he has been treated unfairly. Hopefully this full >pardon will help rectify a very sad portion of his life.” BTW first post in the lounge.:~

    0200 A9 23 0202 8D 01 80 0205 00

    The Lounge help

  • Enter key invokes button click
    G GrooverFromHolland

    Thank You for Your reply, now it is obvious that the button automatically gets focus, but I could not see difference in appearance of the button. I'll fix that. How can I prevent any control to get keyboard focus other than with the TAB-key or mouse-click? It is a disaster when my application gets a reset when the ENTER-key is accidentally hit.

    0200 A9 23 0202 8D 01 80 0205 00

    WPF wpf csharp css database debugging

  • Enter key invokes button click
    G GrooverFromHolland

    Hi all, This is my very first WPf-project, so please have some consideration and don’t advise me on MVVM . Everything I in my project is working fine except one thing: Whenever I hit the enter key on my keyboard a button gets the click event. This button is not default button and the only event registered with this button is the click-event. This is driving me insane.:confused: If I put a breakpoint in the click event handler the routedEventsArgs e is button base click. Here is the code related to this problem:

            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="IsEnabled" Value="True" />
            <Setter Property="Width" Value="Auto" />
            <Setter Property="Height" Value="Auto" />
            <Setter Property="Margin" Value="14,5,0,5" />            
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Offset="0" Color="Black" />
                        <GradientStop Offset="1" Color="#FFC41B1B" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="MyContentPresenter"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Content="{TemplateBinding Content}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="#7d7f74" />
                    <Setter Property="Background" Value="#31302c" />
                </Trigger>
                <Trigger Property="IsKeyboardFocused" Value="true">
                    <Setter Property="Foreground" Value="Goldenrod" />
                </Trigger>
                <Trigger Property="IsMouseOver" Va</x-turndown>
    
    WPF wpf csharp css database debugging

  • Speed up code
    G GrooverFromHolland

    I followed Your advice and went for SQLite database and entity framework EF6 and the total time needed for the same same code is now 1400 ms vs 16 sec before! It took some time to learn and implement EF(hence the late reply) but it was worth the efford :) Thank You, Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# help debugging performance

  • Speed up code
    G GrooverFromHolland

    You are absolutely right, I did mention that I write crappy code. :) changed it to:

    int colNum = 0;
    for (int i = 0; i < length; i += 8)
    {
    colNum = i / 8 + 1;

    and zero divided by 8 gives zero, so no need for checking that. :doh: Thanks, Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# help debugging performance

  • Speed up code
    G GrooverFromHolland

    Thank You for your fast response. I should have done the math myself :doh:! Unfortunately there is no bulk-copy for SQL Compact Edition, so the only way I think Is to show the data first in the richTextBox and insert it in the database on a different thread and notify the user when it is successfully finished. Or is there another way? Groover,

    0200 A9 23 0202 8D 01 80 0205 00

    C# help debugging performance

  • Speed up code
    G GrooverFromHolland

    Hi all, I know that I write crappy code, but the code snippet below takes 16 seconds on my machine in debug and that is unacceptable. Please help me to speed it up.

    string valueString = string.Empty;
    //List<byte> AtronBytes First 39 bytes = header
    int length = AtronBytes.Count - 39;
    for (int i = 0; i < length; i += 8) // length = 1176
    {
    int colNum;
    if (i == 0) colNum = 1;
    else colNum = i / 8 + 1;
    string column = machineDataColumnNames[colNum];
    //tempAtronBytes = copy of AtronBytes
    byte[] valueByte = tempAtronBytes.GetRange(0, 8).ToArray();
    // last byte of valueByte = checksum
    byte chkVal = Extentions.CalculateOpdrChecksum(tempAtronBytes.GetRange(0, 7).ToArray()); // 1ms
    if (chkVal == tempAtronBytes[7])// checksum test
    {
    valueString = Encoding.ASCII.GetString(
    tempAtronBytes.GetRange(0, 7).ToArray()).Trim();
    // Remove value bytes and checksum:
    tempAtronBytes.RemoveRange(0, 8);

                  SqlCeExtentions.ZakdataDatabase\_Update(column, valueString, opdrString); // 87ms
                  // add to stringBuilder:
                  logAppend(column.PadRight(30), valueString);
                  //Show in richTextbox
                  if (colNum > 146)
                  {
                      logResult();
                  }
              }
              else
              {
                  MessageBox.Show("Checksum error");
                  return;
              }
          }
    

    Thanks, Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# help debugging performance

  • Obtaining USB HID device information
    G GrooverFromHolland

    This is how I get the friendly name of my USB serial devices. The friendly name is in the caption of the management objects. I get them like this:

    List<string> usbSerial = new List<string>();
    List<ManagementObject> listObj = new List<ManagementObject>();
    try
    {
    string query = "SELECT * FROM Win32_PnPEntity WHERE ConfigManagerErrorCode = 0";
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
    listObj = searcher.Get().Cast<ManagementObject>().ToList();
    searcher.Dispose();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.ToString());
    usbSerial = new List<string>();
    }
    foreach (ManagementObject obj in listObj)
    {
    object captionObj = obj["Caption"]; //This will get you the friendly name.
    if (captionObj != null)
    {
    string caption = captionObj.ToString();
    if (caption.Contains("(COM")) //This is where I filter on COM-ports.
    {
    usbSerial.Add(caption);
    }

               }
           }
           usbDevices = usbSerial.Distinct().OrderBy(s => s).ToArray();
    

    Hope this can help, Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# csharp c++ database question

  • How to design a keypad in C#?
    G GrooverFromHolland

    Hi If You are new to C# it wont be easy. First of all You can not use buttons, because when You click a button that button will steal focus, so your key stroke will have no notion where to go. The only (winforms)control that not steals focus is a label, but a label has not got the right properties to act as a key. The solution is to create a custom control derived from label control. to do so You must add this class to your project:

    namespace YOURPROJECTNAMESPACE
    {
    public sealed class MyControl : Label
    {
    public MyControl()
    {
    // Allow transparent background
    SetStyle(ControlStyles.SupportsTransparentBackColor, true);
    // Default to transparent background
    BackColor = Color.Transparent;
    }

        public Image ControlImage { get; set; }
    
        protected override void OnPaint(PaintEventArgs e)
        {
            // Draw image, sized to control
            if (ControlImage != null)
            {
                e.Graphics.DrawImage(ControlImage, 4, 4, Width - 8, Height - 8);
            }
            // Draw text, centered vertically and horizontally
            var rectangle = new RectangleF(2, 0, Width, Height + 5);
            var format = new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment = StringAlignment.Center
            };
            e.Graphics.DrawString(Text, Font, Brushes.Black, rectangle, format);
        }
    }
    

    }

    After you have done this You will find in the designer toolbox MyControl. Then drag a flowLayouPanel from the toolbox. Populate this panel by dragging as many MyControls as you need. in properties give them a nice picture of a key and a character as text. One more thing to do, In the designer doubleclick each key,and in the click event this:

    private void myControl1_Click(object sender, EventArgs e)
    {
    SendKeys.Send("{1}");
    }

    private void myControlEnter_Click(object sender, EventArgs e)
    {
    SendKeys.Send("{ENTER}");
    }

    Etc. If You have any more questions just ask, Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# tutorial question csharp design help

  • Local sqlce database or datatable in xml file
    G GrooverFromHolland

    Hi Gerry, With the XML datafile I will have to store the datatable in memory and overwrite or create a new XML file with new or changed data. Wit SQLCE database I will have to deal with one record only. Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# database xml help career

  • Local sqlce database or datatable in xml file
    G GrooverFromHolland

    Hi Mycroft, Having a table with 150 columns is a must, the data just has 150 parameters that can change. there is no need for reporting and no relations, just one or two tables, and distribution is to one workstation only. Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# database xml help career

  • Local sqlce database or datatable in xml file
    G GrooverFromHolland

    Hi all, I have started a new WindowsForms project and I am wondering if there is a benefit to store my project data in a local SQLCE database or just store data table(s) in a xml file. The data-tables have a maximum of 9999 records and 150 columns. The data is used for auto-complete source(job number only) and to compare just one record from stored data with new data. the data does not change for hours. The data per column is 10 characters. I hope You can help me to choose and elaborate the pro's and cons. Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# database xml help career

  • Is there a way to make "speakers" pickup 440hz?
    G GrooverFromHolland

    First thing to do is reading this: http://www.codeproject.com/Messages/1278604/How-to-get-an-answer-to-your-question.aspx[^] If you are trying to make a guitar tuner in C# program, there is no way to get audio input from your speakers, you have to use the microphone input. This Codeproject article How to implement the FFT algorithm[^] is useful to analyze audio frequency and help you with writing your program. If you want to generate reference pitch tones this is helpful: Simple Signal Generator[^]. By the way it took me less then a minute to search the Codeproject to find this! Regards, Groover.

    0200 A9 23 0202 8D 01 80 0205 00

    C# help question

  • Updating UI from Task
    G GrooverFromHolland

    Hi Eddy, Thank You for the good explanation. Regards, Groover

    0200 A9 23 0202 8D 01 80 0205 00

    C# tutorial question design performance announcement

  • Updating UI from Task
    G GrooverFromHolland

    Hi All, In a tutorial I found a a new way (new for me)of updating a control from a thread. In the example code the new way(AsyncParallel) is in button1_Click and what I am familiar with is in button2_Click. They both do the job, but what is better, regarding performance and especially when more tasks are running that might update UI-thread? Here is the example:

    namespace Task_Compare
    {
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
    
            string data = "";
            Task Tf1 = Task.Factory.StartNew(() =>
                                  {
                                      data = GetData();
                                  });
    
            Task T2 = Tf1.ContinueWith((previousTask) =>
                                   {
                                      listBox1.Items.Insert(0, data);
                                   }, TaskScheduler.FromCurrentSynchronizationContext());
    
        }
    
        private void button2\_Click(object sender, EventArgs e)
        {
            string data = "";
            Task Tf2 = Task.Factory.StartNew(() =>
                                    {
                                        data = GetData();
                                    });
            Tf2.Wait();
    
            listBox1.Invoke(new EventHandler(delegate
            {
                listBox1.Items.Insert(0, data);
            }));
        }
    
        private string GetData()
        {
            string temp = "";
            {
                temp = " Do something long running ......";
            }
    
            return temp;
        }
    }
    

    }

    Groover,

    0200 A9 23 0202 8D 01 80 0205 00

    C# tutorial question design performance announcement
  • Login

  • Don't have an account? Register

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