working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,083 snippets matching: converter

    public by zonaro  205457  1  7  0

    Image toBase64 String

    Extension method to convert a System.Drawing.Image to Base64 String
    public static string toBase64(this System.Drawing.Image OriginalImage)
          {
              using (MemoryStream ms = new MemoryStream())
              {
                  OriginalImage.Save(ms, OriginalImage.RawFormat);
                  byte[] imageBytes = ms.ToArray();
                  return Convert.ToBase64String(imageBytes);
              }
          }
    

    public by Geometry  1236  0  7  0

    Assign: Assign this converter to the AForge types. This method should be called before an AForge range type can be bound to controls such as the PropertyGrid.

    Assign this converter to the AForge types. This method should be called before an AForge range type can be bound to controls such as the PropertyGrid.
    /// <summary>
    ///   Assign this converter to the AForge types. This method
    ///   should be called before an AForge range type can be
    ///   bound to controls such as the PropertyGrid.
    /// </summary>
    /// 
    public static void Assign()
    {
        TypeDescriptor.AddAttributes(typeof(DoubleRange), new TypeConverterAttribute(typeof(RangeTypeConverter)));
        TypeDescriptor.AddAttributes(typeof(IntRange), new TypeConverterAttribute(typeof(RangeTypeConverter)));
    }

    public by lauhin  2038  1  6  1

    text to two dimensional array

    Here we parse a text or csv file to a two dimensional array. By adding the TextReader class to your project, you just need to initialize that class like it is done in the main class. Enjoy!
    // Converter class
    package com.laurenthinoul.main;
    
    import java.io.*;
    import java.nio.charset.Charset;
    
    public class TextReader {
    
        //Here we give the location of the text file as a String and we return a two dimensional array
        public int[][] parseFileToArray(String file) throws IOException {
            int numberOfRows = getNumberOfCols(file);
            return parseToArray(file, numberOfRows);
        }
    
        //wee need to count the cols of the text to initialize the two dimensional array
        private int getNumberOfCols(String file) throws IOException {
            InputStream is = new FileInputStream(file);
            BufferedReader br = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
    
            int count = 0;
            while (br.readLine() != null) {
                count++;
            }
    
            br.close();
            is.close();
    
            return count;
        }
    
        //we read the text and parse it to the two dimensional array
        private int[][] parseToArray(String file, int numberOfRows) throws IOException {
            InputStream is = new FileInputStream(file);
            BufferedReader br = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
            String line;
    
            int[][] myArray = new int[numberOfRows][];
            int row = 0;
    
            while ((line = br.readLine()) != null) {
                //here we say the line must be split by tab. Change it to your wanted character.
                String[] nums = line.split("\t");
                myArray[row] = new int[nums.length];
    
                for (int col = 0; col < nums.length; col++) {
                    int n = Integer.parseInt(nums[col]);
                    myArray[row][col] = n;
                }
                row++;
            }
    
    
            br.close();
            is.close();
    
            return myArray;
        }
    }
    
    
    
    
    
    
    //the main class
    package com.laurenthinoul.main;
    
    import java.io.*;
    import java.nio.charset.Charset;
    
    public class ReadText {
    
        public static void main(String args[]) throws IOException {
    
            final String file = "/Users/laurenthinoul/.../afile.txt";
    
            TextReader reader = new TextReader();
            int[][] myArray = reader.parseFileToArray(file);
    
            for(int i = 0; i < myArray.length; i++){
                for(int j = 0; j < myArray[i].length; j++){
                    System.out.println("["+i+"]["+j+"] = "+myArray[i][j]);
                }
            }
        }
    }                        

    public by miguelarror  1839  1  5  0

    pdf to excel converter for Mac Key Features

    :1.Good Preservation.It supplies 2 options for the output file:Maintain importance without format: It permits Mac customers to save all the initial text, figures in PDF tables to Shine tissues after changing PDF to Shine, without preserving the original formatting.Retain initial formatting of types: this program allows you to protect text, numbers and formatting while in the original PDF file.
    
    click here to more information ====>> https://sourceforge.net/projects/pdftoexcelconverter/

    public by paulsimmons  804  0  4  0

    WooCommerce Currency Converter Plugin

    If you want to target multiple regions with your web store you must use WooCommerce multi-currency plugin to provide the best user experience to your international clients. WooCommerce currency switcher plugin allows you to add multiple currencies which will allow your customers to view product pricing and checkout in their local currency or to whi
    // Enter here the actual content of the snippet.            

    public by qxshower  1429  0  5  0

    GetColorFromUInt

    A simple converter for turning a "uint" into a "Color".
    using EnvDTE80;
    using SteveCadwallader.CodeMaid.Helpers;
    using SteveCadwallader.CodeMaid.Properties;
    using SteveCadwallader.CodeMaid.UI.Enumerations;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Media;
    
    /// <summary>
    /// A simple converter for turning a <see cref="uint" /> into a <see cref="Color" />.
    /// </summary>
    /// <param name="number">The number to convert.</param>
    /// <returns>The color.</returns>
    private static Color GetColorFromUInt(uint number)
    {
        return Color.FromRgb((byte)(number >> 16),
                             (byte)(number >> 8),
                             (byte)(number >> 0));
    }                        

    public by msdn  87240  0  8  0

    CreateOneWayBinding: Creates a new <see cref="Binding"/> whose <see cref="Binding.Source"/> is the object in which this method is being called, whose <see cref="Binding.Path"/> property is initialized from <see cref="prope...

    Creates a new whose is the object in which this method is being called, whose property is initialized from and whose property is a one-way object whose converter is given by
    /// <summary>
    ///     Creates a new <see cref="Binding"/> whose <see cref="Binding.Source"/>
    ///     is the object in which this method is being called, whose <see cref="Binding.Path"/> 
    ///     property is initialized from <see cref="propertyPath"/> and whose <see cref="Binding.Converter"/>
    ///     property is a one-way <see cref="LambdaValueConverter"/> object whose converter
    ///     is given by <paramref name="converter"/>
    /// </summary>
    public static Binding CreateOneWayBinding(this INotifyPropertyChanged bindingSource, string propertyPath, IValueConverter converter)
    {
        Binding binding = new Binding();
    
        binding.Source = bindingSource;
        binding.Path = new PropertyPath(propertyPath);
        binding.Converter = converter;
    
        return binding;
    }

    public by msdn  1794  0  6  0

    IsVisibilityInverted: Determine whether or not visibility is inverted based on a converter parameter. When the parameter is specified as Collapsed, that means that when the boolean value is true, we should return Collapsed, which i...

    Determine whether or not visibility is inverted based on a converter parameter. When the parameter is specified as Collapsed, that means that when the boolean value is true, we should return Collapsed, which is inverted.
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    /// <summary>
    /// Determine whether or not visibility is inverted based on a converter parameter.
    /// When the parameter is specified as Collapsed, that means that when the boolean value
    /// is true, we should return Collapsed, which is inverted.
    /// </summary>
    /// <param name="parameter"></param>
    /// <returns></returns>
    private static bool IsVisibilityInverted(object parameter)
    {
        return (GetVisibilityMode(parameter) == Visibility.Collapsed);
    }

    public by msdn  1548  0  8  0

    ReplaceTextBox: Replaces a <see cref="DataField" />'s <see cref="TextBox" /> control with another control, taking care of automatically updating the bindings and overriding the existing converter with another one

    Replaces a 's control with another control, taking care of automatically updating the bindings and overriding the existing converter with another one The new control you're going to set as The control's property that will be used for data binding A function you can use to change parameters on the newly generated
    /// <summary>
    ///     Replaces a <see cref="DataField" />'s <see cref="TextBox" /> control with another control,
    ///     taking care of automatically updating the bindings and overriding the existing converter
    ///     with another one
    /// </summary>
    /// <param name="newControl">The new control you're going to set as <see cref="DataField.Content" /></param>
    /// <param name="dataBindingProperty">The control's property that will be used for data binding</param>        
    /// <param name="bindingSetupFunction">
    ///     A function you can use to change parameters on the newly generated binding before
    ///     it is applied to <paramref name="newControl"/>
    /// </param>
    public static void ReplaceTextBox(this DataField field, FrameworkElement newControl, DependencyProperty dataBindingProperty, Action<Binding> bindingSetupFunction)
    {
        if (field == null)
        {
            throw new ArgumentNullException("field");
        }
    
        if (newControl == null)
        {
            throw new ArgumentNullException("newControl");
        }
    
        // Construct new binding by copying existing one, and sending it to bindingSetupFunction
        // for any changes the caller wants to perform
        Binding newBinding = field.Content.GetBindingExpression(TextBox.TextProperty).ParentBinding.CreateCopy();
    
        if (bindingSetupFunction != null)
        {
            bindingSetupFunction(newBinding);
        }
    
        // Replace field
        newControl.SetBinding(dataBindingProperty, newBinding);
        field.Content = newControl;
    }

    public by msdn  1424  0  6  0

    GetVisibilityMode: Determine the visibility mode based on a converter parameter. This parameter is of type Visibility, and specifies what visibility value to return when the boolean value is true.

    Determine the visibility mode based on a converter parameter. This parameter is of type Visibility, and specifies what visibility value to return when the boolean value is true.
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    /// <summary>
    /// Determine the visibility mode based on a converter parameter.  This parameter is of type Visibility,
    /// and specifies what visibility value to return when the boolean value is true.
    /// </summary>
    /// <param name="parameter"></param>
    /// <returns></returns>
    private static Visibility GetVisibilityMode(object parameter)
    {
        // Default to Visible
        Visibility mode = Visibility.Visible;
    
        // If a parameter is specified, then we'll try to understand it as a Visibility value
        if (parameter != null)
        {
            // If it's already a Visibility value, then just use it
            if (parameter is Visibility)
            {
                mode = (Visibility)parameter;
            }
            else
            {
                // Let's try to parse the parameter as a Visibility value, throwing an exception when the parsing fails
                try
                {
                    mode = (Visibility)Enum.Parse(typeof(Visibility), parameter.ToString(), true);
                }
                catch (FormatException e)
                {
                    throw new FormatException("Invalid Visibility specified as the ConverterParameter.  Use Visible or Collapsed.", e);
                }
            }
        }
    
        // Return the detected mode
        return mode;
    }
    • Public Snippets
    • Channels Snippets