コード例 #1
0
        private void btn_Graph_Compare_Click(object sender, RoutedEventArgs e)
        {
            var data  = m_DataProcessingHelper.getData();
            var units = m_DataProcessingHelper.getUnits();

            if (data != null && data.Count() > 0 && units != null)
            {
                string title = string.IsNullOrEmpty(m_DataProcessingHelper.getType())
                    ? CompareHelper.DEFAULT_NAME
                    : m_DataProcessingHelper.getType();
                CompareSource source = new CompareSource(title, data, units);
                m_CompareHelper.AddSource(source);
            }
        }
コード例 #2
0
        public LibraryLoader(string dllName)
        {
            HModule = LoadLibrary(dllName);
            if (HModule == IntPtr.Zero)
            {
                throw new Exception("failed to load dll: " + dllName);
            }
            IntPtr proc = GetProcAddress(HModule, "CompareSource");

            if (proc == IntPtr.Zero)
            {
                throw new Exception("failed to find func: CompareSource");
            }
            Method = Marshal.GetDelegateForFunctionPointer(proc, typeof(CompareSource)) as CompareSource;
        }
コード例 #3
0
 private void btn_Compare_Add_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var openResult = m_OpenManager.OpenMultiple(_graphfileextensions);
         if (openResult != null)
         {
             foreach (var o in openResult)
             {
                 var savedState = o.Value as SavedState;
                 if (savedState != null)
                 {
                     CompareSource source = new CompareSource(string.IsNullOrEmpty(o.Key) ? CompareHelper.DEFAULT_NAME : o.Key, savedState.Data.data, savedState.Data.units);
                     m_CompareHelper.AddSource(source);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(Properties.Resources.common_error + " (" + ex.Message + ")");
     }
 }
コード例 #4
0
        /// <summary>
        /// Returns the elements with the minimum key value by using the specified comparer to compare key values.
        /// </summary>
        /// <typeparam name="TSource">Source sequence element type.</typeparam>
        /// <typeparam name="TKey">Key type.</typeparam>
        /// <param name="source">Source sequence.</param>
        /// <param name="keySelector">Key selector used to extract the key for each element in the sequence.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare keys.</param>
        public static IList <TSource> MinBy <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, Func <CompareSource <TKey>, IFullComparer <TKey> > comparerFactory)
        {
            var comparer = comparerFactory(CompareSource.For <TKey>());

            return(source.MinBy(keySelector, comparer));
        }
コード例 #5
0
        /// <summary>
        /// Returns the minimum value in the enumerable sequence by using the specified comparer to compare values.
        /// </summary>
        /// <typeparam name="TSource">Source sequence element type.</typeparam>
        /// <param name="source">Source sequence.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare elements.</param>
        public static TSource Min <TSource>(this IEnumerable <TSource> source, Func <CompareSource <TSource>, IFullComparer <TSource> > comparerFactory)
        {
            var comparer = comparerFactory(CompareSource.For <TSource>());

            return(source.Min(comparer));
        }
コード例 #6
0
        /// <summary>
        /// Performs a subsequent ordering of the elements in a sequence in descending order by using a specified comparer.
        /// </summary>
        /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
        /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
        /// <param name="source">A sequence of values to order.</param>
        /// <param name="keySelector">A function to extract a key from an element.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare keys.</param>
        public static IOrderedEnumerable <T> ThenByDescending <T, TKey>(this IOrderedEnumerable <T> source, Func <T, TKey> keySelector, Func <CompareSource <TKey>, IFullComparer <TKey> > comparerFactory)
        {
            var comparer = comparerFactory(CompareSource.For <TKey>());

            return(source.ThenByDescending(keySelector, comparer));
        }
コード例 #7
0
        /// <summary>
        /// Sorts the elements of a sequence in ascending order by using a specified comparer.
        /// </summary>
        /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
        /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
        /// <param name="source">A sequence of values to order.</param>
        /// <param name="keySelector">A function to extract a key from an element.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare keys.</param>
        public static IOrderedEnumerable <T> OrderBy <T, TKey>(this IEnumerable <T> source, Func <T, TKey> keySelector, Func <CompareSource <TKey>, IFullComparer <TKey> > comparerFactory)
        {
            var comparer = comparerFactory(CompareSource.For <TKey>());

            return(source.OrderBy(keySelector, comparer));
        }
コード例 #8
0
        /// <summary>
        /// Performs a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer.
        /// </summary>
        /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam>
        /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
        /// <param name="source">A sequence of values to order.</param>
        /// <param name="keySelector">A function to extract a key from an element.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare keys.</param>
        /// <param name="descending">A value indicating whether the sorting is done in descending order. If <c>false</c> (the default), then the sort is in ascending order.</param>
        public static IOrderedEnumerable <T> ThenBy <T, TKey>(this IOrderedEnumerable <T> source, Func <T, TKey> keySelector, Func <CompareSource <TKey>, IFullComparer <TKey> > comparerFactory, bool descending = false)
        {
            var comparer = comparerFactory(CompareSource.For <TKey>());

            return(source.ThenBy(keySelector, descending ? comparer.Reverse() : comparer));
        }
コード例 #9
0
        /// <summary>
        /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
        /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
        /// <param name="source">An observable sequence to determine the mimimum element of.</param>
        /// <param name="selector">A transform function to apply to each element.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare elements.</param>
        public static IObservable <TResult> Min <TSource, TResult>(this IObservable <TSource> source, Func <TSource, TResult> selector, Func <CompareSource <TResult>, IFullComparer <TResult> > comparerFactory)
        {
            var comparer = comparerFactory(CompareSource.For <TResult>());

            return(source.Min(selector, comparer));
        }
コード例 #10
0
        /// <summary>
        /// Returns the maximum value in an observable sequence according to the specified comparer.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
        /// <param name="source">An observable sequence to determine the maximum element of.</param>
        /// <param name="comparerFactory">The definition of a comparer to compare elements.</param>
        public static IObservable <TSource> Max <TSource>(this IObservable <TSource> source, Func <CompareSource <TSource>, IFullComparer <TSource> > comparerFactory)
        {
            var comparer = comparerFactory(CompareSource.For <TSource>());

            return(source.Max(comparer));
        }