Exemplo n.º 1
0
 private static void GenLoadLoader(IntPtr context, LoadFunction load)
 {
     vkCreateInstance_ptr = LoadCallbackThrow(context, load, "vkCreateInstance");
     vkEnumerateInstanceExtensionProperties_ptr = LoadCallbackThrow(context, load, "vkEnumerateInstanceExtensionProperties");
     vkEnumerateInstanceLayerProperties_ptr     = LoadCallbackThrow(context, load, "vkEnumerateInstanceLayerProperties");
     vkEnumerateInstanceVersion_ptr             = load(context, "vkEnumerateInstanceVersion");
 }
Exemplo n.º 2
0
        private static T LoadCallback <T>(IntPtr context, LoadFunction load, string name)
        {
            var functionPtr = load(context, name);

            if (functionPtr == IntPtr.Zero)
            {
                return(default);
Exemplo n.º 3
0
 public LoaderMgr(LoadFunction Function)
 {
     _Function = Function;
     ThreadStart Start = new ThreadStart(Load);
     Thread LoadThread = new Thread(Start);
     LoadThread.Start();
 }
Exemplo n.º 4
0
        public LoaderMgr(LoadFunction Function)
        {
            _Function = Function;
            ThreadStart Start      = new ThreadStart(Load);
            Thread      LoadThread = new Thread(Start);

            LoadThread.Start();
        }
Exemplo n.º 5
0
 public void Init(int pageSize, LoadFunction loadFunction, GameObject goLoadingNext = null, GameObject goLoadingLast = null)
 {
     _curPage    = 1;
     _maxPage    = int.MaxValue;
     _pageSize   = pageSize;
     onLoad      = loadFunction;
     LoadingNext = goLoadingNext;
     LoadingLast = goLoadingLast;
 }
Exemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="name"></param>
 /// <param name="fullscreen"></param>
 public GLWindow(int width, int height, string name, GameWindowFlags fullscreen)
     : base(width, height, GraphicsMode.Default, name, fullscreen, DisplayDevice.Default, 3, 3, GraphicsContextFlags.ForwardCompatible)
 {
     Renderables = new List<IRenderable>();
     ClearColor = new Color4();
     OnLoadFunction = null;
     OnUpdateFunction = null;
     KeyEvents = new Dictionary<Key, Action>();
     MouseEvents = new Dictionary<MouseInformation, Action>();
 }
Exemplo n.º 7
0
 public static void InitLoad(LoadFunction Func)
 {
     if (MaxThread == 0 || LoaderCount < MaxThread)
     {
         new LoaderMgr(Func);
         Thread.Sleep(50);
     }
     else
         Func.Invoke();
 }
Exemplo n.º 8
0
    private static void GenLoadLoader(IntPtr context, LoadFunction load)
    {
        vkCreateInstance_ptr = (delegate * unmanaged[Stdcall] < VkInstanceCreateInfo *, VkAllocationCallbacks *, out VkInstance, VkResult >) LoadCallbackThrow(context, load, "vkCreateInstance");

        vkEnumerateInstanceExtensionProperties_ptr = (delegate * unmanaged[Stdcall] < byte *, int *, VkExtensionProperties *, VkResult >) LoadCallbackThrow(context, load, "vkEnumerateInstanceExtensionProperties");

        vkEnumerateInstanceLayerProperties_ptr = (delegate * unmanaged[Stdcall] < int *, VkLayerProperties *, VkResult >) LoadCallbackThrow(context, load, "vkEnumerateInstanceLayerProperties");

        vkEnumerateInstanceVersion_ptr = (delegate * unmanaged[Stdcall] < uint *, VkResult >) load(context, "vkEnumerateInstanceVersion");
    }
Exemplo n.º 9
0
        private static T LoadCallbackThrow <T>(IntPtr context, LoadFunction load, string name)
        {
            var functionPtr = load(context, name);

            if (functionPtr == IntPtr.Zero)
            {
                throw new InvalidOperationException($"No function was found with the name {name}.");
            }

            return(Marshal.GetDelegateForFunctionPointer <T>(functionPtr));
        }
Exemplo n.º 10
0
        private static IntPtr LoadCallbackThrow(IntPtr context, LoadFunction load, string name)
        {
            var functionPtr = load(context, name);

            if (functionPtr == IntPtr.Zero)
            {
                throw new InvalidOperationException($"No function was found with the name {name}.");
            }

            return(functionPtr);
        }
Exemplo n.º 11
0
 static public void InitLoad(LoadFunction Func)
 {
     if (MaxThread == 0 || LoaderCount < MaxThread)
     {
         new LoaderMgr(Func);
         Thread.Sleep(50);
     }
     else
     {
         Func.Invoke();
     }
 }
Exemplo n.º 12
0
 public static void LoadFunctions(Type type, LoadFunction func)
 {
     foreach (var f in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)) {
         if (f.FieldType.BaseType == typeof(MulticastDelegate) ||
             f.FieldType.BaseType == typeof(Delegate)) {
             var ptr = func (f.Name);
             if (f.Name.Contains ("$") || f.Name.Contains ("<") || f.Name.Contains (">"))
                 continue; //For some reason this reflection stuff catches compiler-internal static variables
             var del = Marshal.GetDelegateForFunctionPointer (ptr, f.FieldType);
             f.SetValue (null, del);
         }
     }
 }
Exemplo n.º 13
0
        private static void Load(List <LoadFunction> WaitEnd, HashSet <Type> loaded, Type type)
        {
            // Pick up a class
            if (type.IsClass != true)
            {
                return;
            }

            if (loaded.Contains(type))
            {
                return; // Already loaded
            }
            object[]         attrArray   = type.GetCustomAttributes(typeof(ServiceAttribute), false);
            ServiceAttribute serviceDecl = attrArray.Length > 0 ? (ServiceAttribute)attrArray[0] : null;

            // Ensure all dependencies have been initialized
            if (serviceDecl != null)
            {
                foreach (Type dependency in serviceDecl.Dependencies)
                {
                    if (!loaded.Contains(dependency))
                    {
                        Load(WaitEnd, loaded, dependency);
                    }
                }
            }

            // Iterate over all annotated methods
            foreach (MethodInfo m in type.GetMethods())
            {
                foreach (LoadingFunctionAttribute at in m.GetCustomAttributes(typeof(LoadingFunctionAttribute), false))
                {
                    LoadFunction loadfunction = (LoadFunction)Delegate.CreateDelegate(typeof(LoadFunction), m);

                    if (at.Immediate)
                    {
                        InitLoad(loadfunction);
                    }
                    else
                    {
                        WaitEnd.Add(loadfunction);
                    }
                }
            }

            // Register the service as loaded
            if (serviceDecl != null)
            {
                loaded.Add(type);
            }
        }
Exemplo n.º 14
0
 public static void LoadFunctions(Type type, LoadFunction func)
 {
     foreach (var f in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
     {
         if (f.FieldType.BaseType == typeof(MulticastDelegate) ||
             f.FieldType.BaseType == typeof(Delegate))
         {
             var ptr = func(f.Name);
             if (f.Name.Contains("$") || f.Name.Contains("<") || f.Name.Contains(">"))
             {
                 continue;                         //For some reason this reflection stuff catches compiler-internal static variables
             }
             var del = Marshal.GetDelegateForFunctionPointer(ptr, f.FieldType);
             f.SetValue(null, del);
         }
     }
 }
Exemplo n.º 15
0
        static public void Start()
        {
            long Start = TCPManager.GetTimeStampMS();

            List <LoadFunction> WaitEnd = new List <LoadFunction>();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    // Pick up a class
                    if (type.IsClass != true)
                    {
                        continue;
                    }

                    foreach (MethodInfo m in type.GetMethods())
                    {
                        foreach (LoadingFunctionAttribute at in m.GetCustomAttributes(typeof(LoadingFunctionAttribute), false))
                        {
                            LoadFunction loadfunction = (LoadFunction)Delegate.CreateDelegate(typeof(LoadFunction), m);

                            if (at.CreateNewThread)
                            {
                                InitLoad(loadfunction);
                            }
                            else
                            {
                                WaitEnd.Add(loadfunction);
                            }
                        }
                    }
                }
            }

            Wait();

            foreach (LoadFunction Function in WaitEnd)
            {
                Function.Invoke();
            }

            long End = TCPManager.GetTimeStampMS();

            Log.Success("LoaderMgr", "Loading complete in : " + (End - Start) + "ms");
        }
Exemplo n.º 16
0
    private static delegate *unmanaged[Stdcall] < void > LoadCallbackThrow(IntPtr context, LoadFunction load, string name)
    {
        delegate * unmanaged[Stdcall] < void > functionPtr = load(context, name);
        if (functionPtr == null)
        {
            throw new InvalidOperationException($"No function was found with the name {name}.");
        }

        return(functionPtr);
    }
Exemplo n.º 17
0
        private void LoadReportToDataGrid(LoadFunction type)
        {
            SqlConnection con = Connection.getConnection();

            dgvProductDetail.Columns.Clear();
            SqlCommand cmd = null;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                int soldYear  = (cboYearDetail.SelectedIndex == -1) ? -1 : (int)cboYearDetail.SelectedValue;
                int soldMonth = (cboMonthDetail.SelectedIndex == -1) ? -1 : (int)cboMonthDetail.SelectedValue;
                int empID     = (cboSellerDetail.SelectedIndex == -1) ? -1 : (int)cboSellerDetail.SelectedValue;

                if (type == LoadFunction.YEARLY)
                {
                    cmd             = new SqlCommand("GetTableSoldByYear", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@empID", empID);
                }
                else if (type == LoadFunction.MONTHLY)
                {
                    cmd             = new SqlCommand("GetTableSoldByMonth", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@empID", empID);
                    cmd.Parameters.AddWithValue("@soldYear", soldYear);
                }
                else if (type == LoadFunction.DAILY)
                {
                    cmd             = new SqlCommand("GetTableSoldByDay", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@empID", empID);
                    cmd.Parameters.AddWithValue("@soldYear", soldYear);
                    cmd.Parameters.AddWithValue("@soldMonth", soldMonth);
                }
                else if (type == LoadFunction.SEARCH)
                {
                    cmd             = new SqlCommand("GetSoldBetweenDates", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@fromDate", dtpFromDate.Value);
                    cmd.Parameters.AddWithValue("@toDate", dtpToDate.Value);
                    cmd.Parameters.AddWithValue("@empID", empID);
                }

                SqlDataAdapter da        = new SqlDataAdapter(cmd);
                DataTable      dtProduct = new DataTable();
                da.Fill(dtProduct);

                if (dtProduct.Rows.Count != 0)
                {
                    /*Add new Column to DataTable */
                    dtProduct.Columns.Add("Total", typeof(double));

                    /*Begin Total Amount of Each Rows*/
                    foreach (DataRow row in dtProduct.Rows)
                    {
                        double rowSum = 0;
                        foreach (DataColumn col in dtProduct.Columns)
                        {
                            if (!row.IsNull(col))
                            {
                                double value;
                                if (double.TryParse(row[col].ToString().Trim(), out value))
                                {
                                    rowSum += value;
                                }
                            }
                        }
                        row.SetField("Total", rowSum);
                    }
                    /*End Total Amount of Each Rows*/


                    /*Begin Total Amount of Each Columns of Datatable*/
                    var newRow = dtProduct.NewRow();
                    for (int i = 0; i < dtProduct.Columns.Count; i++)
                    {
                        if (i == 0)
                        {
                            newRow[i] = "Total";
                        }
                        else
                        {
                            double ColumnTotal = 0;
                            foreach (DataRow dr in dtProduct.Rows)
                            {
                                double value = 0;
                                double.TryParse(dr[i].ToString(), out value);
                                ColumnTotal += value;
                            }
                            newRow[i] = ColumnTotal;
                        }
                    }
                    dtProduct.Rows.Add(newRow);
                    /*End Total Amount of Each Columns of Datatable*/
                }

                dgvProductDetail.DataSource = dtProduct;
                dgvProductDetail.DataError += dgvProductDetail_DataError;

                if (dgvProductDetail.Rows.Count > 0)
                {
                    dgvProductDetail.DefaultCellStyle.NullValue = "0.00 R";

                    foreach (DataGridViewColumn col in dgvProductDetail.Columns)
                    {
                        if (col.Index == 0)
                        {
                            continue;
                        }
                        dgvProductDetail.Columns[col.Index].DefaultCellStyle.Format    = "#,##0.00 R";
                        dgvProductDetail.Columns[col.Index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    }

                    foreach (DataGridViewColumn col in dgvProductDetail.Columns)
                    {
                        Controller.AlignHeaderTextCenter(col);
                    }

                    Controller.NonSortableDataGridView(dgvProductDetail);

                    /*Set Total ROW to BOLD Text*/
                    DataGridViewCellStyle style = new DataGridViewCellStyle();
                    style.Font = new Font(dgvProductDetail.Font, FontStyle.Bold);
                    dgvProductDetail.Rows[dgvProductDetail.Rows.Count - 1].DefaultCellStyle = style;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Load Report : " + ex.Message);
                //MessageBox.Show(ex.Message,"LOAD FUNCTION");
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 18
0
 public void SetLoadFunction(LoadFunction function)
 {
     OnLoad = function;
 }
Exemplo n.º 19
0
 public FormLoading(LoadFunction loadStuff)
 {
     this.loadStuff = loadStuff;
     this.StartPosition = FormStartPosition.CenterScreen;
     InitializeComponent();
 }
Exemplo n.º 20
0
        private void LoadSoldData(LoadFunction load)
        {
            /*
             * if searchFor = 0 : Search Sold Information
             * if searchFor = 1 : Search Sold Detail Information
             */
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                if (load == LoadFunction.LoadAllSoldData) /*Search General Sold  and  Sold Details*/
                {
                    cmd             = new SqlCommand("GetSoldInformation", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchSoldID || load == LoadFunction.SearchSoldDate || load == LoadFunction.SearchEmployeeID || load == LoadFunction.SearchEmployeeName || load == LoadFunction.SearchProductID || load == LoadFunction.SerachProductName)
                {
                    cmd             = new SqlCommand("SearchSoldInformation", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@searchType", cboSearchType.SelectedIndex);
                    cmd.Parameters.AddWithValue("@condition", searchCondition);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchBetweenDate)
                {
                    /*Search Between two Dates => for General Sold  and  Sold Details*/
                    cmd             = new SqlCommand("SearchSoldBetweenDates", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@fromDate", dtpFrom.Value.Date);
                    cmd.Parameters.AddWithValue("@toDate", dtpTo.Value.Date);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchSoldConditionWithDates)
                {
                    /*Search Between two Dates And Combine with General Search (SoldID, Product Name,...)*/
                    cmd             = new SqlCommand("SearchSoldConditionWithDates", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@searchType", cboSearchType.SelectedIndex);
                    cmd.Parameters.AddWithValue("@condition", searchCondition);
                    cmd.Parameters.AddWithValue("@fromDate", dtpFrom.Value.Date);
                    cmd.Parameters.AddWithValue("@toDate", dtpTo.Value.Date);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchSoldConditionWithYear)
                {
                    cmd             = new SqlCommand("SearchSoldConditionWithYear", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@searchType", cboSearchType.SelectedIndex);
                    cmd.Parameters.AddWithValue("@condition", searchCondition);
                    cmd.Parameters.AddWithValue("@year", selectedYear);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchSoldWithYear)
                {
                    cmd             = new SqlCommand("SearchSoldWithYear", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@year", selectedYear);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchSoldWithYearAndMonth)
                {
                    cmd             = new SqlCommand("SearchSoldWithYearAndMonth", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@year", selectedYear);
                    cmd.Parameters.AddWithValue("@month", selectedMonth);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }
                else if (load == LoadFunction.SearchSoldConditionWithYearAndMonth)
                {
                    cmd             = new SqlCommand("SearchSoldConditionWithYearAndMonth", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@searchType", cboSearchType.SelectedIndex);
                    cmd.Parameters.AddWithValue("@condition", searchCondition);
                    cmd.Parameters.AddWithValue("@year", selectedYear);
                    cmd.Parameters.AddWithValue("@month", selectedMonth);
                    cmd.Parameters.AddWithValue("@searchFor", searchFor);
                }

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                dgvSoldDetail.DataSource = dt;

                /*Align Header to Middle Center*/
                foreach (DataGridViewColumn col in dgvSoldDetail.Columns)
                {
                    Controller.AlignHeaderTextCenter(col);
                }

                /*Align Column Date to middle*/
                dgvSoldDetail.Columns[1].DefaultCellStyle.Format    = "dd/MM/yyyy";
                dgvSoldDetail.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

                dgvSoldDetail.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dgvSoldDetail.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

                /*Display And Format all Sold Detail Information Columns*/
                if (searchFor == 1)
                {
                    /*Align number colums to Middle Right*/

                    int lastCol = dgvSoldDetail.Columns.Count - 1;
                    /*Sub Amount Column*/
                    dgvSoldDetail.Columns[lastCol].DefaultCellStyle.Format    = "#,##0.00 R";
                    dgvSoldDetail.Columns[lastCol].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                    /*% Discount Column*/
                    dgvSoldDetail.Columns[lastCol - 1].DefaultCellStyle.Format    = "##0.00 %";
                    dgvSoldDetail.Columns[lastCol - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                    /*% Tax Column*/
                    dgvSoldDetail.Columns[lastCol - 2].DefaultCellStyle.Format    = "##0.00 %";
                    dgvSoldDetail.Columns[lastCol - 2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                    /*Unit Price Column*/
                    dgvSoldDetail.Columns[lastCol - 3].DefaultCellStyle.Format    = "#,##0.00 R";
                    dgvSoldDetail.Columns[lastCol - 3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                    /*Quantity Column*/
                    dgvSoldDetail.Columns[lastCol - 4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }
                else
                {
                    int lastCol = dgvSoldDetail.Columns.Count - 1;
                    dgvSoldDetail.Columns[lastCol].DefaultCellStyle.Format    = "#,##0.00 R";
                    dgvSoldDetail.Columns[lastCol].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }

                double total = 0;
                foreach (DataRow row in dt.Rows)
                {
                    total += double.Parse(row[dt.Columns.Count - 1].ToString());
                }
                lblTotalRow.Text    = dt.Rows.Count.ToString();
                lblTotalAmount.Text = string.Format("{0:N2} Riel", total);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Load Data");
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
Exemplo n.º 21
0
 public void InitializeSaveLoadFuncs(LoadFunction onSave, LoadFunction onLoad)
 {
     m_onSave += onSave;
     m_onLoad += onLoad;
 }
Exemplo n.º 22
0
 public static void InitLoad(LoadFunction Func)
 {
     Func.Invoke();
 }