示例#1
0
 /// <summary>
 /// Gets the type of the service provider given it's name.
 /// </summary>
 /// <param name="ProviderFileName">A type of the Service provider to instantiate.</param>
 /// <returns></returns>
 public static System.Type GetProviderType(string ProviderFileName)
 {
     try
     {
         System.Reflection.Assembly asmbl = System.Reflection.Assembly.LoadFrom(ProviderFileName);
         foreach (System.Reflection.Module module in asmbl.GetModules())
         {
             // Checking each module in assembly.
             foreach (System.Type type in module.GetTypes())
             {
                 if (type.IsNotPublic)
                 {
                     continue;
                 }
                 // Checking each interface in module.
                 foreach (System.Type interf in type.GetInterfaces())
                 {
                     // Checking each implemented interface in class.
                     if (interf.Equals(typeof(ISP)))
                     {
                         TraceOut.Put("Type that implements interface: " + type.ToString());
                         return(type);
                     }
                 }
             }
         }
     }
     catch (Exception x)
     {
         TraceOut.Put(x);
     }
     return(null);
 }
示例#2
0
        public static void LoadAssembly(System.Reflection.Assembly assembly, Server server)
        {
            ServiceAttribute.LoadAssembly(assembly, server);
            foreach (HosteableObjectAttribute attr in assembly.GetCustomAttributes(typeof(HosteableObjectAttribute), false))
            {
                attr.RegisterTo(server);
            }
            foreach (var module in assembly.GetModules())
            {
                foreach (HosteableObjectAttribute attr in module.GetCustomAttributes(typeof(HosteableObjectAttribute), false))
                {
                    attr.RegisterTo(server);
                }
            }

            foreach (Type type in assembly.GetTypes())
            {
                var attrs = type.GetCustomAttributes(typeof(HosteableObjectAttribute), false);
                if (attrs.Length > 0)
                {
                    var attr = attrs[0] as HosteableObjectAttribute;
                    attr.RegisterTo(server);
                }
            }
        }
示例#3
0
        private void RecursivelyAddModuleDependencies(System.Reflection.Module module, List <System.Reflection.Module> addedModules)
        {
            // if it's in the GAC, don't add it
            if (module.Assembly.GlobalAssemblyCache)
            {
                return;
            }

            // if it's already been added, don't add it
            if (addedModules.Contains(module))
            {
                return;
            }

            // if it was manually added, don't add it
            if (this.Manifest.Contains(new ModuleDependency(module)))
            {
                return;
            }

            // otherwise, add it to the manifest and to the collection
            this.Manifest.Add(new ModuleDependency(module));
            addedModules.Add(module);

            // and add all referenced modules
            foreach (System.Reflection.AssemblyName assemblyName in module.Assembly.GetReferencedAssemblies())
            {
                System.Reflection.Assembly referencedAssembly = System.Reflection.Assembly.Load(assemblyName);

                foreach (System.Reflection.Module referencedModule in referencedAssembly.GetModules())
                {
                    this.RecursivelyAddModuleDependencies(referencedModule, addedModules);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Compiles the script and attaches it the current GameObject.
        /// </summary>
        private void CompileScript()
        {
#if TIMING
            stopwatch.Reset();
            stopwatch.Start();
#endif

            string code = System.IO.File.ReadAllText(Filepath);

            // TODO: Find the namespace name, if there is one

            // Find the behaviour class name
            ////int indexOfClass = code.IndexOf("class") + 5;
            ////int indexOfColon = code.IndexOf(":");
            ////className = code.Substring(indexOfClass, indexOfColon - indexOfClass).Trim();
            ////#if DEBUG
            ////Debug.Log(string.Format("Compiling {0}", className));
            ////#endif

            // The first type is always the autogenerated <InteractiveExpressionClass>, so we must inject a "connection point" struct
            // This allows us to access the actual MonoBehaviour class
            // See here: https://csscriptsource.codeplex.com/SourceControl/latest#CSScriptLibrary/CSScriptLib.Eval.cs
            // And here: https://csscriptsource.codeplex.com/SourceControl/latest#CSScriptLibrary/AsmHelper.cs
            string connectionPointName   = "ConnectionPoint_" + id++;
            string connectionPointStruct = "\n public struct " + connectionPointName + " {}";
            evaluator.Compile(code + connectionPointStruct);

            ////scriptType = (Type)evaluator.Evaluate(string.Format("typeof({0});", className));
            ////Debug.Log(className + " = " + scriptType);

            System.Reflection.Assembly compiledAssembly = ((Type)evaluator.Evaluate(string.Format("typeof({0});", connectionPointName))).Assembly;

            foreach (Type type in compiledAssembly.GetModules()[0].GetTypes())
            {
                if (type.FullName != "<InteractiveExpressionClass>")
                {
                    ////Debug.Log("Found: " + type.FullName + " : " + type.BaseType);
                    scriptType = type;
                    break;
                }
            }

            AttachAll();

#if TIMING
            stopwatch.Stop();
            Debug.Log(string.Format("Compiling {0} took {1} ms", className, stopwatch.ElapsedMilliseconds));
#endif
        }
示例#5
0
 internal CILAssemblyImpl(
     CILReflectionContextImpl ctx,
     Int32 anID,
     System.Reflection.Assembly ass
     )
     : base(ctx, anID, CILElementKind.Assembly, () => new CustomAttributeDataEventArgs(ctx, ass))
 {
     ArgumentValidator.ValidateNotNull("Assembly", ass);
     InitFields(
         ref this.name,
         ref this.modules,
         ref this.forwardedTypes,
         ref this.mainModule,
         () =>
     {
         var result = CILAssemblyName.Parse(ass.FullName);
         var args   = new AssemblyNameEventArgs(ass);
         ctx.LaunchAssemblyNameLoadEvent(args);
         var info = args.AssemblyNameInfo;
         if (info != null)
         {
             result.HashAlgorithm = info.Item1;
             result.Flags         = info.Item2;
             if (info.Item3 != null)
             {
                 result.PublicKey = info.Item3;
                 if (result.PublicKey.IsNullOrEmpty())
                 {
                     // .NET for some reason returns PublicKey-flag set, even with no public key...
                     result.Flags = result.Flags & ~(AssemblyFlags.PublicKey);
                 }
             }
         }
         return(result);
     },
         () => ctx.CollectionsFactory.NewListProxy <CILModule>(ass
                                                               .GetModules()
                                                               .Select(module => ctx.Cache.GetOrAdd(module))
                                                               .ToList()),
         () =>
     {
         // TODO seems that getting type forward info is not really possible via C# managed reflection API?
         throw new NotImplementedException();
     },
         () => ctx.Cache.GetOrAdd(ass.ManifestModule)
         );
 }
示例#6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            System.Reflection.Assembly asb = System.Reflection.Assembly.GetExecutingAssembly();
            System.Reflection.Module[] ms  = asb.GetModules();

            string file  = "pocketpc.mobile.cs.exe";
            int    count = ms.Length;

            for (int i = 0; i < count; i++)
            {
                if (string.Compare(file, ms[i].Name, true) == 0)
                {
                    file = ms[i].FullyQualifiedName;
                    break;
                }
            }

            string path = file;
            int    pos  = path.LastIndexOf('\\');

            if (pos != -1)
            {
                path = path.Substring(0, pos);
            }

            _currentPath = path;

            webMail.Navigate(new System.Uri("about:blank"));

            lstProtocol.Items.Add("POP3");
            lstProtocol.Items.Add("IMAP4");
            lstProtocol.Items.Add("Exchange Web Service - 2007/2010");
            lstProtocol.Items.Add("Exchange WebDAV - Exchange 2000/2003");

            lstProtocol.SelectedIndex = 0;

            lstAuthType.Items.Add("USER/LOGIN");
            lstAuthType.Items.Add("APOP");
            lstAuthType.Items.Add("NTLM");
            lstAuthType.SelectedIndex = 0;

            LoadMails();
        }
示例#7
0
 private void ScanDirs()
 {
     // Check if ISP interface is somewhere implemented.
     TraceOut.Put("Getting service providers...");
     foreach (string asmblPath in files)
     {
         TraceOut.Put("Loading Assembly :" + asmblPath + " ....");
         // Checking each assembly.
         try
         {
             System.Reflection.Assembly asmbl = System.Reflection.Assembly.LoadFrom(asmblPath);
             foreach (System.Reflection.Module module in asmbl.GetModules())
             {
                 // Checking each module in assembly.
                 foreach (System.Type type in module.GetTypes())
                 {
                     if (type.IsNotPublic)
                     {
                         continue;
                     }
                     // Checking each interface in module.
                     foreach (System.Type interf in type.GetInterfaces())
                     {
                         // Checking each implemented interface in class.
                         if (interf.Equals(typeof(ISP)))
                         {
                             TraceOut.Put("Class that implements interface: " + type.ToString());
                             // ISP interface imlpemented, adding the class.
                             string SPTitle = ((System.Reflection.AssemblyTitleAttribute)(asmbl.GetCustomAttributes(typeof(System.Reflection.AssemblyTitleAttribute), true)[0])).Title;
                             types.Add(SPTitle);
                             providers[SPTitle] = asmblPath;
                             TraceOut.Put("Collecting service providers: \"" + SPTitle + "\" added...");
                         }
                     }
                 }
             }
         }
         catch (Exception x)
         {
             TraceOut.Put(x);
         }
     }
 }
示例#8
0
文件: AccCIL.cs 项目: PlumpMath/ac3il
        public static System.Reflection.MethodInfo FindReflectionMethod(MethodReference calledmethod)
        {
            string methodname   = calledmethod.DeclaringType.FullName + "::" + calledmethod.Name;
            string assemblyName = FindAssemblyName(calledmethod);

            System.Reflection.Assembly asm = System.Reflection.Assembly.Load(new System.Reflection.AssemblyName(assemblyName));
            foreach (var mod in asm.GetModules())
            {
                foreach (var type in asm.GetTypes())
                {
                    if (type.FullName == calledmethod.DeclaringType.FullName)
                    {
                        foreach (var method in type.GetMethods())
                        {
                            if (method.Name == calledmethod.Name)
                            {
                                var margs = method.GetParameters();
                                if (margs.Length == calledmethod.Parameters.Count)
                                {
                                    bool match = true;
                                    for (int i = 0; i < margs.Length; i++)
                                    {
                                        if (margs[i].ParameterType != Type.GetType(calledmethod.Parameters[i].ParameterType.FullName))
                                        {
                                            match = false;
                                            break;
                                        }
                                    }

                                    if (match)
                                    {
                                        return(method);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
示例#9
0
        public void ConnectClass(string Assembly, string Type, string ComponentAttributes, string CredentialAttributes, string ClinicalContext)
        {
            try
            {
                System.Xml.XmlDocument credDoc = new System.Xml.XmlDocument();
                credDoc.LoadXml(CredentialAttributes);
                System.Xml.XmlDocument compDoc = new System.Xml.XmlDocument();
                compDoc.LoadXml(ComponentAttributes);

                System.Reflection.Assembly asm = System.Reflection.Assembly.Load(Assembly);
                connectedType = asm.GetModules(false)[0].GetType(Type, true, false);
                System.Reflection.ConstructorInfo constructor = connectedType.GetConstructor(System.Type.EmptyTypes);
                connectedClass = constructor.Invoke(null);

                //try
                //{
                //    // Check PreferLocal
                //    if( (bool)connectedClass.GetType().InvokeMember("PreferLocal",
                //        System.Reflection.BindingFlags.InvokeMethod, null, connectedClass, null) )
                //    {
                //        System.IntPtr buffer = IntPtr.Zero;
                //        uint bytesReturned;

                //        bool isRdpSession = false;

                //        // Determine whether this code is running in an RDP session
                //        int sessionId = -1;
                //        try
                //        {
                //            WTSQuerySessionInformation((IntPtr)WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSInfoClass.WTSSessionId, out buffer, out bytesReturned);
                //            sessionId = Marshal.ReadInt32(buffer);
                //        }
                //        catch(Exception exc)
                //        {
                //            throw new Exception("Error getting SessionID", exc);
                //        }
                //        finally
                //        {
                //            WTSFreeMemory(buffer);
                //            buffer = IntPtr.Zero;
                //        }

                //        if (sessionId != WTSGetActiveConsoleSessionId())
                //            isRdpSession = true;

                //        if (isRdpSession)
                //        {
                //            string machine = null;
                //            string user = null;

                //            try
                //            {
                //                WTSQuerySessionInformation((IntPtr)WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSInfoClass.WTSClientName, out buffer, out bytesReturned);
                //                machine = Marshal.PtrToStringAnsi(buffer);
                //            }
                //            catch(Exception exc)
                //            {
                //                throw new Exception("Error getting WTSClientName.", exc);
                //            }
                //            finally
                //            {
                //                WTSFreeMemory(buffer);
                //                buffer = IntPtr.Zero;
                //            }

                //            try
                //            {
                //                WTSQuerySessionInformation((IntPtr)WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSInfoClass.WTSUserName, out buffer, out bytesReturned);
                //                user = Marshal.PtrToStringAnsi(buffer);
                //            }
                //            catch(Exception exc)
                //            {
                //                throw new Exception("Error getting WTSUserName.", exc);
                //            }
                //            finally
                //            {
                //                WTSFreeMemory(buffer);
                //                buffer = IntPtr.Zero;
                //            }

                //            try
                //            {
                //                // Create a channel for communicating w/ the remote object
                //                // Notice no port is specified on the client
                //                BinaryClientFormatterSinkProvider clientProvider =
                //                    new BinaryClientFormatterSinkProvider();
                //                BinaryServerFormatterSinkProvider serverProvider =
                //                    new BinaryServerFormatterSinkProvider();
                //                serverProvider.TypeFilterLevel =

                //                    System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

                //                IDictionary props = new Hashtable();
                //                props["port"] = 0;
                //                string s = System.Guid.NewGuid().ToString();
                //                props["name"] = s;
                //                props["typeFilterLevel"] = TypeFilterLevel.Full;
                //                TcpChannel chan = new TcpChannel(
                //                    props,clientProvider,serverProvider);

                //                ChannelServices.RegisterChannel(chan);
                //            }
                //            catch(Exception exc)
                //            {
                //                throw new Exception("Error setting up remoting channel.", exc);
                //            }

                //            try
                //            {
                //                r = (EPRemoting.RemoteService) Activator.GetObject(typeof(EPRemoting.RemoteService), "tcp://localhost:14863/RemoteService");
                //                object ret = r.RequestObject(new EPRemoting.ClientIdentity(machine, user), Assembly, Type);
                //                if(null!=ret)
                //                    connectedClass = ret;
                //                else
                //                    Log("Request for client-side object returned null.", System.Diagnostics.EventLogEntryType.Information);
                //            }
                //            catch(Exception exc)
                //            {
                //                throw new Exception("Error getting RemoteService object from Remoting service.",exc);
                //            }
                //        }
                //    }
                //}
                //catch(Exception exc)
                //{
                //    Log(exc.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                //}

                System.Type executeSqlDelegateType = null;
                System.Reflection.ConstructorInfo esConstructor = null;
                object         executeSqlDelegateObject         = null;
                System.Version baseVersion = new Version(1, 3, 0, 0);

                try
                {
                    foreach (System.Reflection.AssemblyName assembly in asm.GetReferencedAssemblies())
                    {
                        if (assembly.Name != "EncounterPRO.OS.Component")
                        {
                            continue;
                        }
                        System.Reflection.Assembly asm2 = System.Reflection.Assembly.Load(assembly);
                        baseVersion            = asm2.GetName().Version;
                        executeSqlDelegateType = asm2.GetModules(false)[0].GetType("EncounterPRO.OS.Component.ExecuteSql", true, false);
                        esConstructor          = executeSqlDelegateType.GetConstructors()[0];
                        System.IntPtr methodHandle = this.GetType().GetMethod("ExecuteSql").MethodHandle.GetFunctionPointer();
                        executeSqlDelegateObject = esConstructor.Invoke(new object[] { this, methodHandle });
                    }
                }
                catch (Exception exc)
                {
                    throw new Exception("Error getting ExecuteSql for connectedClass.", exc);
                }

                credentialAttributes = (System.Collections.Specialized.ListDictionary) new System.Collections.Specialized.ListDictionary();
                foreach (System.Xml.XmlNode node in credDoc.DocumentElement.ChildNodes)
                {
                    if (node.Name != "Attribute")
                    {
                        continue;
                    }
                    if (node.Attributes["name"] == null)
                    {
                        continue;
                    }
                    credentialAttributes.Add(node.Attributes["name"].Value, node.InnerText);
                }

                componentAttributes = (System.Collections.Specialized.ListDictionary) new System.Collections.Specialized.ListDictionary();
                foreach (System.Xml.XmlNode node in compDoc.DocumentElement.ChildNodes)
                {
                    if (node.Name != "Attribute")
                    {
                        continue;
                    }
                    if (node.Attributes["name"] == null)
                    {
                        continue;
                    }
                    componentAttributes.Add(node.Attributes["name"].Value, node.InnerText);
                }

                try
                {
                    connectedClass.GetType().InvokeMember("Initialize", System.Reflection.BindingFlags.InvokeMethod, null, connectedClass,
                                                          new object[] { executeSqlDelegateObject, componentAttributes, ClinicalContext });
                }
                catch (Exception exc)
                {
                    foreach (System.Reflection.MethodInfo mi in connectedClass.GetType().GetMethods())
                    {
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append(mi.Name + " method is supported by connectedClass." + Environment.NewLine);
                        foreach (System.Reflection.ParameterInfo pi in mi.GetParameters())
                        {
                            sb.Append(pi.ParameterType.ToString() + " " + pi.Name + Environment.NewLine);
                        }

                        Log(sb.ToString(), System.Diagnostics.EventLogEntryType.Information);
                    }
                    throw new Exception("Error calling Initialize on connectedClass.", exc);
                }

                if (null != ClassConnected)
                {
                    try
                    {
                        ClassConnected(this, new EventArgs());
                    }
                    catch (Exception exc)
                    {
                        Log("Error firing ClassConnected event." +
                            Environment.NewLine + exc.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }
                }
            }
            catch (Exception exc)
            {
                Log(exc.ToString(), System.Diagnostics.EventLogEntryType.Error);
                throw exc;
            }
        }
 private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
 {
     detailView.DataSource        = null;
     detailView.Visible           = false;
     propertyGrid1.SelectedObject = null;
     propertyGrid1.Visible        = false;
     notSupportedTextBox.Visible  = false;
     if (e.Node.Text == "All Product Info")
     {
         notSupportedTextBox.Text    = "Select category from left";
         notSupportedTextBox.Visible = true;
     }
     else if (e.Node.Text == "Basic Info")
     {
         propertyGrid1.Visible        = true;
         propertyGrid1.SelectedObject = new AssemblyAttributeInfo(m_assembly);
     }
     else if (e.Node.Text == "Assembly Info")
     {
         propertyGrid1.Visible        = true;
         propertyGrid1.SelectedObject = m_assembly;
     }
     else if (e.Node.Text == "Refrenced Assemblies")
     {
         detailView.DataSource = m_assembly.GetReferencedAssemblies();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Exported Types")
     {
         detailView.DataSource = m_assembly.GetExportedTypes();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Files")
     {
         detailView.DataSource = m_assembly.GetFiles();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Loaded Modules")
     {
         detailView.DataSource = m_assembly.GetLoadedModules();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Resource Names")
     {
         detailView.DataSource = m_assembly.GetManifestResourceNames();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Modules")
     {
         detailView.DataSource = m_assembly.GetModules();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Defined Types")
     {
         detailView.DataSource = m_assembly.GetTypes();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Executable File Info")
     {
         propertyGrid1.SelectedObject = FileVersionInfo.GetVersionInfo(m_assembly.Location);
         propertyGrid1.Visible        = true;
     }
     else if (e.Node.Text == "Environment")
     {
         propertyGrid1.SelectedObject = CommonFunctions.GetPropertyBagForStaticMembers(typeof(System.Environment));
         propertyGrid1.Visible        = true;
     }
     else if (e.Node.Text == "Task View")
     {
         detailView.DataSource = Process.GetProcesses();
         detailView.Visible    = true;
     }
     else if (e.Node.Text == "Culture Info")
     {
         propertyGrid1.SelectedObject = System.Threading.Thread.CurrentThread.CurrentCulture;
         propertyGrid1.Visible        = true;
     }
     else if (e.Node.Text == "Time Zone")
     {
         propertyGrid1.SelectedObject = System.TimeZone.CurrentTimeZone;
         propertyGrid1.Visible        = true;
     }
     else if (e.Node.Text == "Date Time Formats")
     {
         propertyGrid1.SelectedObject = System.Globalization.DateTimeFormatInfo.CurrentInfo;
         propertyGrid1.Visible        = true;
     }
     else if (e.Node.Text == "Number Formats")
     {
         propertyGrid1.SelectedObject = System.Globalization.NumberFormatInfo.CurrentInfo;
         propertyGrid1.Visible        = true;
     }
     else if (e.Node.Text == "Region Info")
     {
         propertyGrid1.SelectedObject = System.Globalization.RegionInfo.CurrentRegion;
         propertyGrid1.Visible        = true;
     }
     else
     {
         notSupportedTextBox.Text    = e.Node.Text + " is not implemented yet";
         notSupportedTextBox.Visible = true;
     }
 }
示例#11
0
        //<summary>Lock level scrolling</summary>
        //private bool bScrollLock;
        //################################################################################################################
        //Constructor
        ///<summary>Top-level contructor for SokobanCompact</summary>
        public formMain()
        {
            FunctionResult uRV;

            InitializeComponent();

            hGameSkin = null;
            uBackBuffer = null;
            bDeadlockMessage = false;
            bHaveUnfinishedPosition = false;
            Cursor.Current = Cursors.WaitCursor;//Waiting cursor - while loading levelset and skin

            //Get handle of assembly
            hExecAssem = System.Reflection.Assembly.GetExecutingAssembly();
            //Get file name of assembly
            string sAppFilePath = hExecAssem.GetModules()[0].FullyQualifiedName;
            //Get path only
            sApplicationDirectory = System.IO.Path.GetDirectoryName(sAppFilePath);
            //Add delimiter at the end
            if (!sApplicationDirectory.EndsWith(@"\"))
                sApplicationDirectory += @"\";

            //Calc paths for folders
            //sSavesDirectory = sApplicationDirectory + @"Saves\";
            sLevelsDirectory = sApplicationDirectory + @"Levels\";
            sSolutionsDirectory = sApplicationDirectory + @"Solutions\";
            sSkinsDirectory = sApplicationDirectory + @"Skins\";
            sBackgroundsDirectory = sApplicationDirectory + @"Backgrounds\";

            //Try to create all required folders, to not bother in future
            try
            {
                //System.IO.Directory.CreateDirectory(sSavesDirectory);
                System.IO.Directory.CreateDirectory(sBackgroundsDirectory);
                System.IO.Directory.CreateDirectory(sSkinsDirectory);
                System.IO.Directory.CreateDirectory(sSolutionsDirectory);
                System.IO.Directory.CreateDirectory(sLevelsDirectory);
            }
            catch (System.IO.IOException)
            {}//Dont know that to do, if creation fails

            //Calc rectangles on statusbar
            int iX = 3;

            int iStatusHeight = pictureStatus.Height;//Height of status bar
            Graphics uGr1 = CreateGraphics();//Get graphics of current form
            SizeF uCounterSizes = uGr1.MeasureString(" 0000", Font);//Measure sample string for get actual font sizes
            int iCounterWidth = (int)uCounterSizes.Width;//Width of counter - with of sample string
            int iCounterY0 = (int)(iStatusHeight-uCounterSizes.Height)/2;//Text positions - valign center
            int iSpace = iCounterWidth/10;//Space between fields - 10% if counter width
            uGr1.Dispose();//Release graphics of form

            uRectIndic = new Rectangle(iX, (iStatusHeight-16)/2, 16, 16);//for solved/not-solved indicator
            iX += uRectIndic.Width + iSpace;
            uRectMoves = new Rectangle(iX, iCounterY0, iCounterWidth, 16);//for counter of moves
            iX += uRectMoves.Width + iSpace;
            uRectPushes = new Rectangle(iX, iCounterY0, iCounterWidth, 16);//for counter of pushes
            iX += uRectPushes.Width + iSpace;
            uRectMessage = new Rectangle(iX, iCounterY0, ClientRectangle.Width - iX, 16); //all rest space - for non-modal message

            //Font f1 = this.Font;
            //f1.me
            //this.gr
            //Graphic .MeasureString

            //bScrollLock = false;
            bResize = true;
            iBottomOfForm = pictureStatus.Top;//this done here for perform recenter of level before any redraws

            //Create and load settings
            uSetting = new Settings();
            if (uSetting.Load(sApplicationDirectory + sConfigFile) != FunctionResult.OK)
            {
                //Settings not loaded - first start or failure of file
                uSetting = new Settings();//reset to default, just in case...
            }
            menuScrollLock.Checked = uSetting.bScrollLock;

            if (uSetting.bLogActions)
            {
                uLog = new LogFile();
                uLog.Start(sApplicationDirectory + sLogFile);
                uLog.LogString(ActionID.Start, "Started SokobanCompact; v" + hExecAssem.GetName().Version);
            }

            //Load level set list
            uLevelSetList = new SokobanLevelSetList(sApplicationDirectory + sLevelSetList, sLevelsDirectory, sSolutionsDirectory);
            uLevelSetList.LoadList();

            iSkinSize = 0;

            //Load skinset
            uSkinSet = new SkinSet();
            //uSkinSet.Load(sSkinsDirectory + "\\" + "oq.sks");//TODO: move skinset name into Settings
            uSkinSet.Load(sSkinsDirectory + uSetting.sSkinSet);

            if (!uSetting.bAutosize)
            {   //No autosize? Load skin now
                uRV = LoadSkin(sSkinsDirectory + uSetting.sSkin);
                if (iSkinSize == 0)
                {
                    LogSimpleLine(ActionID.ShowDialog, "Error; Failed to load skin, null skin created; " + uSetting.sSkin+"; "+uRV.ToString());
                    MessageBox.Show("Failed to load skin '" + uSetting.sSkin + "' \r\nNull skin will be loaded, " + uRV.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    GenNullSkin();
                }
            }

            UpdateBackground();//Create background according to settings

            //Create game
            uGame = new SokobanGame();

            //THREAD
            uBackgroundCalc = new BackgroundThread(BackgroundFinished);//Create thread for background

            iSelectorMode = 0;//Selector initialy in "play" mode
            SetToolBarMode();//Refresh selector

            //Load levelset
            uLevelSet = new SokobanLevelSet();
            uRV = uLevelSetList.LoadLevelSet(uLevelSet, uSetting.sLastLevelSet);
            if (uRV != FunctionResult.OK)
            {   //Something happens with levelset file
                LogSimpleLine(ActionID.ShowDialog, "Error; Failed to load levelset, random will be generated; " + uSetting.sLastLevelSet+"; "+uRV.ToString());
                MessageBox.Show("Unable to load LevelSet '" + uSetting.sLastLevelSet + "', result: " + uRV.ToString() + "\r\nRandom level will be loaded.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                uLevelSetList.GenNullLevelSet(uLevelSet);//Generate levelset with 1 random level
                uSetting.iLastLevelPlayed = 0;//Res
            }

            //Start last played level
            uRV = LoadLevel(uGame, uSetting.iLastLevelPlayed);
            if (uRV == FunctionResult.OK)
            {   //Loaded successfully
                AfterLoadLevel();
            }
            else
            {   //Level not loaded (only variant - FunctionResult.OutOfLevelSet)
                LogSimpleLine(ActionID.ShowDialog, "Error; Failed to load level, random will be choosen; " + uSetting.iLastLevelPlayed.ToString() + "; " + uRV.ToString());
                MessageBox.Show("Unable to load level " + uSetting.iLastLevelPlayed.ToString() + ", result: " + uRV.ToString() + "\r\nRandom level will be selected.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                ActionRandLevel();
            }

            if (iSkinSize < 1)
            {
                LogSimpleLine(ActionID.ShowDialog, "Error; No skin loaded, null skin created");
                MessageBox.Show("Failed to load skin\r\nNull skin will be loaded", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                GenNullSkin();
                RecenterLevel();
            }

            NonModalMessage(uLevelSet.sTitle + ", " + uGame.sTitle);

            Cursor.Current = Cursors.Default;//remove wait cursor
        }