Beispiel #1
0
 private void listBoxSystemFont_DoubleClick(object sender, System.EventArgs e)
 {
     _selectedfont.Clear();
     _selectedfont.Add((string)this.fontListBoxSystem.SelectedItem);
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
 public static void Save <T>(
     System.Collections.Specialized.StringCollection collection,
     ConcurrentDictionary <int, T> dictionary, Func <T, string> valueSelector)
 {
     collection.Clear();
     collection.AddRange(dictionary.Select(x => WriteMapping(x, valueSelector)).ToArray());
 }
        /// <summary>
        /// Access to a collection of parameters
        /// </summary>
        /// <param name="parameterName">name of collection</param>
        /// <param name="list">list to fill with parameters</param>
        /// <returns>parameter(s) exist</returns>
        public bool GetParam(string parameterName, System.Collections.Specialized.StringCollection list)
        {
            XmlNodeList nodeList;
            bool        parameterExists;
            long        lCount;

            parameterExists = false;
            nodeList        = m_doc.GetElementsByTagName(parameterName);

            list.Clear();

            lCount = nodeList.Count;

            if (lCount > 0)
            {
                parameterExists = true;

                for (long i = 0; i < lCount; i++)
                {
                    list.Add(nodeList.Item((int)i).InnerText);
                }
            }
            else
            {
                parameterExists = false;
            }

            return(parameterExists);
        }
Beispiel #4
0
        private static bool WriteSQLInner <T>(string db, string schema, string objType, string objName, string filePath, T o, ScriptingOptions so) where T : SqlSmoObject
        {
            if (schema == "")
            {
                schema = "dbo";
            }
            if (db == "*")
            {
                Console.WriteLine(objType + ": " + objName);
            }
            else
            {
                Console.WriteLine(objType + ": " + db + "." + schema + "." + objName + " (" + so.ToString() + ")");
            }


            System.Collections.Specialized.StringCollection cs = new System.Collections.Specialized.StringCollection();
            try {
                cs = (o as dynamic).Script(so);
            }
            catch (Exception ex) {
                if (UseDAC)
                {
                    try {
                        DB.ChangeDB(db);
                        var dt = DB.GetDecryptedObject(objName, objType);
                        cs.Clear();
                        cs.Add(dt.Rows[0]["script"].ToString());
                    }
                    catch (Exception ex2) {
                        Console.WriteLine(ex2.Message);
                        return(false);
                    }
                }
                else
                {
                    Console.WriteLine(ex.Message);
                    return(false);
                }
            }

            if (cs != null)
            {
                var ts = "";
                foreach (var s in cs)
                {
                    ts += s + Environment.NewLine;
                }
                if (!String.IsNullOrWhiteSpace(ts.Trim()))
                {
                    if (!File.Exists(filePath))
                    {
                        csFile.writeFile(filePath, sqlComments(db, schema, objType, objName), true);
                    }
                    csFile.writeFile(filePath, ts + ";" + Environment.NewLine, true);
                }
            }

            return(true);
        }
        private static System.Collections.Specialized.StringCollection LoadSetting(System.Collections.Specialized.StringCollection MSsetting, string setting)
        {
            MSsetting.Clear();

            foreach (string val in setting.Split(new string[] { "<sp>" }, StringSplitOptions.None))
            {
                MSsetting.Add(val);
            }

            return(MSsetting);
        }
Beispiel #6
0
 private void UseConfiguration()
 {
     m_skipDirs.Clear();
     foreach (XmlNode node in  m_configDocument.SelectNodes("//skipDirs/directory"))
     {
         m_skipDirs.Add(node.Attributes["path"].Value);
     }
     m_skipNameParts.Clear();
     foreach (XmlNode node in  m_configDocument.SelectNodes("//skipNameParts/part"))
     {
         m_skipNameParts.Add(node.Attributes["text"].Value);
     }
 }
Beispiel #7
0
 private static void GetStringsFromBuffer(Byte[] buffer, long bufLen, System.Collections.Specialized.StringCollection Strings)
 {
     Strings.Clear();
     if (bufLen != 0)
     {
         int start = 0;
         for (int i = 0; i < bufLen; i++)
         {
             if ((buffer[i] == 0) && ((i - start) > 0))
             {
                 String s = Encoding.GetEncoding(0).GetString(buffer, start, i - start);
                 Strings.Add(s);
                 start = i + 1;
             }
         }
     }
 }
        private void program_textbox_previous_button_Click(object sender, EventArgs e)
        {
            blocked_programs.Clear();//clear the string collection so we get only the values in the list box


            foreach (string x in listBox1.Items)
            {
                blocked_programs.Add(x);
            }

            if (Application.OpenForms["MainTimer"] != null)
            {
                (Application.OpenForms["MainTimer"] as MainTimer).create_website_textboxes();
            }

            next_previous_button_clicked = true;

            this.Close();
        }
        /// <summary>
        /// Get a string collection parameter
        /// </summary>
        /// <param name="parameterName">name of collection</param>
        /// <param name="list">collection that gets filled up with parameters</param>
        /// <param name="getInnerXml">true if we want to get at inner nodes, false if not</param>
        /// <returns>true if parameter(s) exist</returns>
        public bool GetParam(string parameterName, System.Collections.Specialized.StringCollection list, bool getInnerXml)
        {
            /// necessary for OALP objects path that is in an XML form
            if (true == getInnerXml)
            {
                XmlNodeList nodeList;
                bool        parameterExists;
                long        lCount;

                parameterExists = false;
                nodeList        = m_doc.GetElementsByTagName(parameterName);

                list.Clear();

                lCount = nodeList.Count;

                if (lCount > 0)
                {
                    parameterExists = true;

                    for (long i = 0; i < lCount; i++)
                    {
                        list.Add(nodeList.Item((int)i).InnerXml);
                    }
                }
                else
                {
                    parameterExists = false;
                }

                return(parameterExists);
            }
            else
            {
                return(GetParam(parameterName, list));
            }
        }
Beispiel #10
0
        //private static int CategoryCount = 8;

        #region public methods
        public static bool ReadKRP(Stream s)
        {
            using (BinaryReader br = new BinaryReader(s))
            {
                string versionText = new string(br.ReadChars(VERSION.Length));

                if (versionText == VERSION)    // Version Check
                {
                    // Category Booleans
                    Properties.Settings.Default.DoRandomization_Module  = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_Item    = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_Sound   = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_Model   = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_Texture = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_TwoDA   = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_Text    = br.ReadBoolean();
                    Properties.Settings.Default.DoRandomization_Other   = br.ReadBoolean();

                    // Categories
                    #region Modules
                    if (Properties.Settings.Default.DoRandomization_Module)
                    {
                        // Check that Module data is present
                        if (new string(br.ReadChars(4)) != "MODU")
                        {
                            throw new IOException("Module Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Pull the list of omitted modules from the save
                        System.Collections.Specialized.StringCollection omittedMods = Properties.Settings.Default.OmittedModules;
                        omittedMods.Clear();

                        StringBuilder sb = new StringBuilder();
                        while (br.PeekChar() != '\n')
                        {
                            sb.Clear();

                            while (br.PeekChar() != '\0')
                            {
                                sb.Append(br.ReadChar());
                            }
                            br.ReadChar();

                            omittedMods.Add(sb.ToString());
                        }
                        br.ReadChar();

                        for (int i = 0; i < Globals.BoundModules.Count; i++)
                        {
                            Globals.BoundModules[i] = new Globals.Mod_Entry(
                                Globals.BoundModules[i].Code,
                                omittedMods.Contains(Globals.BoundModules[i].Code)
                                );
                        }

                        // Load bool settings
                        Properties.Settings.Default.ModuleExtrasValue = 0;
                        if (!br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.NoSaveDelete;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.SaveMiniGames;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.SaveAllModules;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.FixDream;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.UnlockGalaxyMap;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.FixCoordinates;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.FixMindPrison;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.UnlockDanRuins;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.UnlockLevElev;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.VulkarSpiceLZ;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.UnlockManSub;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.UnlockStaBastila;
                        }
                        if (br.ReadBoolean())
                        {
                            Properties.Settings.Default.ModuleExtrasValue |= ModuleExtras.UnlockUnkSummit;
                        }

                        // Load reachability settings
                        Properties.Settings.Default.UseRandoRules      = br.ReadBoolean();
                        Properties.Settings.Default.VerifyReachability = br.ReadBoolean();
                        Properties.Settings.Default.IgnoreOnceEdges    = br.ReadBoolean();
                        Properties.Settings.Default.AllowGlitchClip    = br.ReadBoolean();
                        Properties.Settings.Default.AllowGlitchDlz     = br.ReadBoolean();
                        Properties.Settings.Default.AllowGlitchFlu     = br.ReadBoolean();
                        Properties.Settings.Default.AllowGlitchGpw     = br.ReadBoolean();
                        Properties.Settings.Default.GoalIsMalak        = br.ReadBoolean();
                        Properties.Settings.Default.GoalIsPazaak       = br.ReadBoolean();
                        Properties.Settings.Default.GoalIsStarMaps     = br.ReadBoolean();

                        Properties.Settings.Default.LastPresetComboIndex = -2;
                        Properties.Settings.Default.ModulePresetSelected = false;
                    }
                    #endregion
                    #region Items
                    if (Properties.Settings.Default.DoRandomization_Item)
                    {
                        // Check that Item data is present
                        if (new string(br.ReadChars(4)) != "ITEM")
                        {
                            throw new IOException("Item Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Load in randolevels
                        Properties.Settings.Default.RandomizeArmor       = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeStims       = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeBelts       = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeVarious     = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeHides       = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeArmbands    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeDroid       = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeGloves      = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeImplants    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeMask        = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizePaz         = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeMines       = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeUpgrade     = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeBlasters    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeCreature    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeLightsabers = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeGrenades    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeMelee       = (RandomizationLevel)br.ReadInt32();

                        // Load Omit Items
                        Globals.OmitItems.Clear();
                        while (br.PeekChar() != '\n')
                        {
                            StringBuilder sb = new StringBuilder();

                            while (br.PeekChar() != '\0')
                            {
                                sb.Append(br.ReadChar());
                            }
                            br.ReadChar();

                            Globals.OmitItems.Add(sb.ToString());
                        }
                        br.ReadChar();
                    }
                    #endregion
                    #region Sounds
                    if (Properties.Settings.Default.DoRandomization_Sound)
                    {
                        // Check that Sound data is present
                        if (new string(br.ReadChars(4)) != "SOUN")
                        {
                            throw new IOException("Sound Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Rando Levels
                        Properties.Settings.Default.RandomizeAreaMusic     = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeBattleMusic   = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeAmbientNoise  = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeCutsceneNoise = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizeNpcSounds     = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.RandomizePartySounds   = (RandomizationLevel)br.ReadInt32();

                        // Bools
                        Properties.Settings.Default.RemoveDmcaMusic      = br.ReadBoolean();
                        Properties.Settings.Default.MixNpcAndPartySounds = br.ReadBoolean();
                    }
                    #endregion
                    #region Models
                    if (Properties.Settings.Default.DoRandomization_Model)
                    {
                        // Check that Model data is present
                        if (new string(br.ReadChars(4)) != "MODE")
                        {
                            throw new IOException("Model Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Settings
                        Properties.Settings.Default.RandomizeCharModels  = br.ReadInt32();
                        Properties.Settings.Default.RandomizePlaceModels = br.ReadInt32();
                        Properties.Settings.Default.RandomizeDoorModels  = br.ReadInt32();
                    }
                    #endregion
                    #region Textures
                    if (Properties.Settings.Default.DoRandomization_Texture)
                    {
                        // Check that Texture data is present
                        if (new string(br.ReadChars(4)) != "TEXU")
                        {
                            throw new IOException("Texture Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Settings
                        Properties.Settings.Default.TextureRandomizeCubeMaps   = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeCreatures  = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeEffects    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeItems      = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizePlanetary  = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeNPC        = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizePlayHeads  = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizePlayBodies = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizePlaceables = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeParty      = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeStunt      = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeVehicles   = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeWeapons    = (RandomizationLevel)br.ReadInt32();
                        Properties.Settings.Default.TextureRandomizeOther      = (RandomizationLevel)br.ReadInt32();

                        // Texture Pack
                        Properties.Settings.Default.TexturePack = (TexturePack)br.ReadInt32();
                    }
                    #endregion
                    #region 2DAs
                    if (Properties.Settings.Default.DoRandomization_TwoDA)
                    {
                        // Check that 2DA data is present
                        if (new string(br.ReadChars(4)) != "TWDA")
                        {
                            throw new IOException("2-Dimensional Array Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        Globals.Selected2DAs.Clear();
                        while (br.PeekChar() != '\x3')
                        {
                            StringBuilder kb = new StringBuilder();
                            while (br.PeekChar() != '\r')
                            {
                                kb.Append(br.ReadChar());
                            }
                            br.ReadChar();
                            string key = kb.ToString();
                            Globals.Selected2DAs.Add(key, new List <string>());
                            while (br.PeekChar() != '\n')
                            {
                                StringBuilder vb = new StringBuilder();
                                while (br.PeekChar() != '\0')
                                {
                                    vb.Append(br.ReadChar());
                                }
                                br.ReadChar();
                                Globals.Selected2DAs[key].Add(vb.ToString());
                            }
                            br.ReadChar();
                        }
                        br.ReadChar();
                    }
                    #endregion
                    #region Text
                    if (Properties.Settings.Default.DoRandomization_Text)
                    {
                        // Check that Text data is present
                        if (new string(br.ReadChars(4)) != "TEXT")
                        {
                            throw new IOException("Text Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Text Settings
                        Properties.Settings.Default.TextSettingsValue = (TextSettings)br.ReadInt32();
                    }
                    #endregion
                    #region Other
                    if (Properties.Settings.Default.DoRandomization_Other)
                    {
                        // Check that Other data is present
                        if (new string(br.ReadChars(4)) != "OTHR")
                        {
                            throw new IOException("Other Randomization is Active, but no such preset data is found. Is the file corrupt?");
                        }

                        // Name Gen
                        Properties.Settings.Default.RandomizeNameGen = br.ReadBoolean();
                        if (Properties.Settings.Default.RandomizeNameGen)
                        {
                            Properties.Settings.Default.FirstnamesM.Clear();
                            while (br.PeekChar() != '\n')
                            {
                                StringBuilder mb = new StringBuilder();
                                while (br.PeekChar() != '\0')
                                {
                                    mb.Append(br.ReadChar());
                                }
                                br.ReadChar();
                                Properties.Settings.Default.FirstnamesM.Add(mb.ToString());
                            }
                            br.ReadChar();

                            Properties.Settings.Default.FirstnamesF.Clear();
                            while (br.PeekChar() != '\n')
                            {
                                StringBuilder mb = new StringBuilder();
                                while (br.PeekChar() != '\0')
                                {
                                    mb.Append(br.ReadChar());
                                }
                                br.ReadChar();
                                Properties.Settings.Default.FirstnamesF.Add(mb.ToString());
                            }
                            br.ReadChar();

                            Properties.Settings.Default.Lastnames.Clear();
                            while (br.PeekChar() != '\n')
                            {
                                StringBuilder mb = new StringBuilder();
                                while (br.PeekChar() != '\0')
                                {
                                    mb.Append(br.ReadChar());
                                }
                                br.ReadChar();
                                Properties.Settings.Default.Lastnames.Add(mb.ToString());
                            }
                            br.ReadChar();
                        }

                        Properties.Settings.Default.PolymorphMode           = br.ReadBoolean();
                        Properties.Settings.Default.RandomizePazaakDecks    = br.ReadBoolean();
                        Properties.Settings.Default.RandomizePartyMembers   = br.ReadBoolean();
                        Properties.Settings.Default.RandomizeSwoopBoosters  = br.ReadBoolean();
                        Properties.Settings.Default.RandomizeSwoopObstacles = br.ReadBoolean();
                    }
                    #endregion

                    return(true);
                }
            }
            return(false);
        }
                /// -----------------------------------------------------------------------------
                /// <summary>
                /// Will load all modules in given list
                /// </summary>
                /// <param name="ModFiles"></param>
                /// <remarks>
                /// Once a module is loaded it will be added the the Module list,
                /// and will then have ModLoad called and the filename property set
                /// </remarks>
                /// <history>
                /// 	[Caleb]	6/18/2005	Created
                /// </history>
                /// -----------------------------------------------------------------------------
                public void LoadModules(string[] ModFiles)
                {
                    System.Collections.Specialized.StringCollection ModuleFiles = new System.Collections.Specialized.StringCollection();
                    Assembly tObject;
                    //File tFile;
                    int tIndex;
                    short tCount = 0;
                    string tMod;
                    string tString;
                    System.Collections.Specialized.StringCollection tFound = new System.Collections.Specialized.StringCollection();
                    foreach (string xMod in ModFiles)
                    {
                        ModuleFiles.Add(xMod);
                    }
                    BlackLightModule tModule;
                    //Cycle through the modules untill they are all loaded or removed
                    while (ModuleFiles.Count > 0)
                    {
                        try
                        {
                            //Infinate loop check
                            if (tCount > 1000)
                            {
                                Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "It appears we have gotten into an infinate loop while loading modules, loading halted", "Most likely cause is two or more modules require each other and will never be able to load", "", "");
                                return;
                            }
                            tCount += Convert.ToInt16(1);

                            //Get the filename
                            tMod = ModuleFiles[0].ToString();

                            //Make sure it exists
                            if (File.Exists("modules/" + tMod))
                            {

                                //Use .NET to attempt to load the class inside the dll
                                tObject = @Assembly.LoadFrom("modules/" + tMod);

                                //Make sure everything is still hawt or remove the failed module
                                if (tObject == null)
                                {
                                    ModuleFiles.RemoveAt(0);
                                }

                                //Get a list of the classes the module contains
                                Type[] tList = tObject.GetTypes();
                                //Cycle through them all
                                foreach (Type tType in tList)
                                {

                                    //Make sure it uses our module base somewhere
                                    if (tType.IsSubclassOf(typeof(BlackLightModule)) == true)
                                    {
                                        //Alrighty it's a valid module now what?

                                        //Well lets check if its a special module, currently only datadrivers

                                        //Ooooo isn't this sexy
                                        tModule = ((BlackLightModule) tType.GetConstructor(new Type[] { typeof(ServicesDaemon) }).Invoke(new object[] {Base}));

                                        //Or not :'(
                                        if (tModule == null)
                                        {
                                            ModuleFiles.RemoveAt(0);
                                        }

                                        if (tType.IsSubclassOf(typeof(DB.DataDriver)) == true)
                                        {
                                            if (DataDriver == "")
                                            {
                                                DataDriver = tModule.Name;
                                            }
                                            else
                                            {
                                                Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "DataBase driver already loaded!", "File does not exist", "", "");
                                                ModuleFiles.RemoveAt(0);
                                            }
                                        }

                                        //Set the internal filename for the ModuleList Class
                                        tModule.FileName = tMod;

                                        //Clear the list of found modules for requirements
                                        tFound.Clear();

                                        //Malicious module coder?
                                        if (tModule.Requires.Count < 1000)
                                        {

                                            //Check if they actually have any requirements (Hope they don't)
                                            if (tModule.Requires.Count > 0)
                                            {
                                                //What kind of peice of shit coder requires other modules...oh right chanserv needs
                                                //nickserv

                                                //Check if its loaded already and work is saved
                                                foreach (string xString in tModule.Requires)
                                                {
                                                    tString = xString.ToLower();
                                                    //Make sure the dumbass didn't require themselves
                                                    if (tMod.ToLower() != tString)
                                                    {

                                                        //Make sure we havn't already found it
                                                        if (tFound.Contains(tString) == false)
                                                        {

                                                            //Now check if its loaded
                                                            if (Modules.Contains(tString) == false)
                                                            {
                                                                //Nope not loaded, does the file actually exist?
                                                                if (File.Exists("modules/" + tMod) == false)
                                                                {
                                                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Requirements for " + tMod + " not met", "File does not exist", "", "");
                                                                    ModuleFiles.RemoveAt(0);
                                                                    break;
                                                                }
                                                                else
                                                                {
                                                                    //It does, heh, so the module still could be loaded

                                                                    //Well maybe, lets see if its possible
                                                                    if (ModuleFiles.Contains(tString) == false)
                                                                    {
                                                                        //Nope? Well thats the end of that module
                                                                        Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Requirements for " + tMod + " not met", "Requirement not found in avalability list", "", "");
                                                                        ModuleFiles.RemoveAt(0);
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                //Alrighty then, so the module has already been loaded, add it to the found list
                                                                tFound.Add(tString);
                                                                // Base.Service.SendLogMessage("ModuleManagement", "LoadModules", Errors.LOG_DEBUG_AND_WARNING, "Found", "", "", "")
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        //One word: Dumbass
                                                        Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "A module cannot require itself", "", "", "");
                                                        ModuleFiles.RemoveAt(0);
                                                        break;
                                                    }
                                                }

                                                //Make sure we didn't remove our module already
                                                if (ModuleFiles.Contains(tMod))
                                                {

                                                    //Check if all the requirements are met
                                                    if (tFound.Count == tModule.Requires.Count)
                                                    {

                                                        //Verify its not already loaded
                                                        if (Modules.Contains(tMod) == false && Modules.Contains(tModule.Name) == false)
                                                        {
                                                            //Add it
                                                            Modules.Add(tModule);
                                                            // tModule.ModLoad()
                                                        }
                                                        else
                                                        {
                                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Module with duplicate name already loaded: " + tMod, "", "", "");
                                                        }
                                                        //Remove it and goto the next module
                                                        ModuleFiles.RemoveAt(0);
                                                    }
                                                    else
                                                    {
                                                        //The requirements are not met, so we
                                                        //Send it to the back?
                                                        ModuleFiles.RemoveAt(0);
                                                        ModuleFiles.Add(tMod);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                //YAY! No requirements. Now just make sure its not already loaded and add it to the list
                                                if (Modules.Contains(tMod) == false && Modules.Contains(tModule.Name) == false)
                                                {
                                                    Modules.Add(tModule);
                                                    // tModule.ModLoad()
                                                }
                                                else
                                                {
                                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Module with duplicate name already loaded: " + tMod, "", "", "");
                                                }
                                                ModuleFiles.RemoveAt(0);
                                            }
                                        }
                                        else
                                        {
                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Module contains to many requirements: " + tMod, "", "", "");
                                        }
                                    }
                                }

                            }
                            else
                            {
                                Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "File does not exist: " + tMod, "", "", "");
                                ModuleFiles.RemoveAt(0);
                            }
                        }
                        catch (Exception e)
                        {
                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Exception", "", e.Message, e.StackTrace);
                            //MessageBox.Show(e.Message + " " + e.StackTrace);
                        }
                    }
                    //Now give our user a nice pretty list of which modules f****d up
                    for (tIndex = 0; tIndex <= ModFiles.Length - 1; tIndex++)
                    {
                        if (Modules.Contains(ModFiles[tIndex]) == false)
                        {
                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "", "", "");
                        }
                        else
                        {
                            if (Modules[ModFiles[tIndex]].NeedsDBDriver == true)
                            {
                                if (DataDriver == "")
                                {
                                    Modules.Remove(Modules[ModFiles[tIndex]]);
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "No DataDriver Found", "", "");
                                }
                                else
                                {
                                    try
                                    {
                                        if (Modules[ModFiles[tIndex]].ModLoad())
                                        {
                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG, "Loaded Module: " + ModFiles[tIndex].ToString(), "", "", "");
                                        }
                                        else
                                        {
                                            Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", "", "");
                                            RemoveAllRequired(ModFiles[tIndex]);
                                            Modules.Remove(Modules[ModFiles[tIndex]]);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", ex.Message, ex.StackTrace);
                                    }

                                }
                            }
                            else
                            {
                                try
                                    {
                                if (Modules[ModFiles[tIndex]].ModLoad())
                                {
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG, "Loaded Module: " + ModFiles[tIndex].ToString(), "", "", "");
                                }
                                else
                                {
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", "", "");
                                    RemoveAllRequired(ModFiles[tIndex]);
                                    Modules.Remove(Modules[ModFiles[tIndex]]);
                                }
                                }
                                catch (Exception ex)
                                {
                                    Base.Core.SendLogMessage("ModuleManagement", "LoadModules", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.WARNING, "Failed to load: " + ModFiles[tIndex].ToString(), "ModLoad Error", ex.Message, ex.StackTrace);
                                }
                            }
                        }
                    }
                    //And we are done
                }
Beispiel #12
0
 private void ClearButtonClick(object sender, EventArgs e)
 {
     mainListBox.Items.Clear();
     collection.Clear();
 }
Beispiel #13
0
        //键盘监听回调
        public void OnKeyPress(KeyboardHookLib.HookStruct hookStruct, out bool handle)
        {
            handle = false; //预设不拦截任何键
            Keys key = (Keys)hookStruct.vkCode;

            string keyStr = key.ToString();

            System.Console.WriteLine(keyStr);
            switch (keyStr)
            {
            case "F5":
                if (IsGameAlready())
                {
                    Bitmap blankImage = DrawBlankImage();
                    GetAllHeroIcon();
                    Bitmap bitmap = MergePicture(blankImage);
                    Clipboard.SetDataObject(bitmap);
                }
                break;

            case "F6":
                if (IsGameAlready())
                {
                    GetCurrentScreenImage(ref image);
                    GetAllHeroIcon();
                    Bitmap bitmap = MergePicture(image);
                    Clipboard.SetImage(bitmap);    //保存到Clipboard中
                }
                break;

            case "F7":
                if (IsGameAlready())
                {
                    Bitmap blankImage = DrawBlankImage();
                    GetAllHeroIcon();
                    Bitmap bitmap  = MergePicture(blankImage);
                    String fileStr = System.DateTime.Now.Ticks.ToString() + ".png";
                    bitmap.Save(@fileStr);
                    System.Collections.Specialized.StringCollection files = new System.Collections.Specialized.StringCollection();
                    String path = System.AppDomain.CurrentDomain.BaseDirectory;
                    files.Add(@path + fileStr);
                    Clipboard.SetFileDropList(files);
                    files.Clear();
                    bitmap.Dispose();
                }
                break;

            case "Oemtilde":
                if (IsGameAlready())
                {
                    GetCurrentScreenImage(ref image);
                    GetAllHeroIcon();
                    Bitmap bitmap = MergePictureForViewer(image);
                    Clipboard.SetImage(bitmap);    //保存到Clipboard中
                }
                break;

            default:
                break;
            }
            return;
        }
Beispiel #14
0
        private void ReceiveFile(object stream)
        {
            byte[] buff = new byte[1024];
            int j;
            string text, user_sharing;
            System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection();

            TcpClient s = (TcpClient) stream;
            NetworkStream netStream = s.GetStream();
            StreamReader str = new StreamReader(s.GetStream());
            bool abort= false;

             while (ServRunning==true)
             {
                try
                {
                    string what = str.ReadLine();
                    user_sharing = what.Substring(4);
                    if (what.Substring(0, 4).Equals("File")) //someone is sharing a file-clopboard
                    {
                        string Reason = "Receving Clipboard...";
                        mf.Invoke(new DisableClipboardCallback(mf.disableClipboard), new object[] { Reason });
                        user_sharing = what.Substring(5);
                        paths.Clear();
                        string qta = what.Substring(4, 1);
                        for (j = 0; j < int.Parse(qta); j++)
                        {
                            string tmp = str.ReadLine();
                            if (tmp.Equals("Abort"))
                            {
                                abort = true;
                                break;
                            }
                            abort = false;
                            string fileName = tmp.Substring(6);
                            byte[] clientData = Convert.FromBase64String(str.ReadLine());
                            BinaryWriter bWrite = new BinaryWriter(File.Open(Path.GetFullPath(@".\File ricevuti\") + fileName, FileMode.Create));
                            bWrite.Write(clientData, 4 + fileName.Length, clientData.Length - 4 - fileName.Length);
                            bWrite.Close();
                            paths.Add(Path.GetFullPath(@".\File ricevuti\") + fileName);

                            //send file to others users
                            TcpClient[] tcpClients = new TcpClient[ChatServer.tcpClipboard.Count];
                            String[] users = new String[ChatServer.htUsers.Count];
                            ChatServer.tcpClipboard.Values.CopyTo(tcpClients, 0);
                            ChatServer.htUsers.Keys.CopyTo(users, 0);
                            for (int i = 0; i < tcpClients.Length; i++)
                            {
                                // Try sending a message to each
                                try
                                {
                                    // If the message is blank or the connection is null, break out
                                    if (tcpClients[i] == null || user_sharing == users[i])
                                    {
                                        continue;
                                    }
                                    StreamWriter sw = new StreamWriter(tcpClients[i].GetStream());
                                    sw.WriteLine("File");
                                    sw.Flush();
                                    // Send the message to the current user in the loop
                                    sw.WriteLine("File: " + Path.GetFileName(fileName));
                                    sw.Flush();
                                    sw.WriteLine(Convert.ToBase64String(clientData));
                                    sw.Flush();
                                    sw = null;
                                }
                                catch (Exception ex)// If there was a problem, the user is not there anymore, remove him
                                {
                                    //MessageBox.Show(ex.ToString());
                                    continue;
                                }
                            }
                        }
                        if (abort == false)
                        {
                            if (int.Parse(qta) == 1)
                                SendAdminMessage(user_sharing + " just shared his clipboard containing a file with us!");
                            else
                                SendAdminMessage(user_sharing + " just shared his clipboard containing some files with us!");
                            mf.Invoke(new UpdateClipboardCallback(UpdateClipboard), new object[] { paths });
                        }
                        Reason = "Share Clipboard";
                        mf.Invoke(new DisableClipboardCallback(mf.enableClipboard), new object[] { Reason });
                        //mf.enableClipboard();
                        //MessageBox.Show("file ricevuto!!"+paths.ToString());

                    }
                    else if (what.Substring(0, 4).Equals("Text"))
                    {
                        string Reason = "Receving Clipboard...";
                        mf.Invoke(new DisableClipboardCallback(mf.disableClipboard), new object[] { Reason });

                        byte[] bytes = new byte[s.ReceiveBufferSize];

                        // Read can return anything from 0 to numBytesToRead.
                        // This method blocks until at least one byte is read.
                        netStream.Read(bytes, 0, (int)s.ReceiveBufferSize);
                        string textcrc = Encoding.ASCII.GetString(bytes);
                        text = TrimFromZero(textcrc);
                        //text = str.ReadLine();
                        TcpClient[] tcpClients = new TcpClient[ChatServer.tcpClipboard.Count];
                        String[] users = new String[ChatServer.htUsers.Count];
                        ChatServer.tcpClipboard.Values.CopyTo(tcpClients, 0);
                        ChatServer.htUsers.Keys.CopyTo(users, 0);
                        for (int i = 0; i < tcpClients.Length; i++)
                        {
                            // Try sending a message to each
                            try
                            {
                                // If the message is blank or the connection is null, break out
                                if (tcpClients[i] == null || user_sharing == users[i])
                                {
                                    continue;
                                }
                                // Send the message to the current user in the loop

                                StreamWriter sw = new StreamWriter(tcpClients[i].GetStream());
                                sw.WriteLine("Text");
                                sw.Flush();
                                sw = null;

                                NetworkStream sendstr = tcpClients[i].GetStream();
                                Byte[] sendBytes = Encoding.ASCII.GetBytes(text);
                                sendstr.Write(sendBytes, 0, sendBytes.Length);
                            }
                            catch (Exception ex)// If there was a problem, the user is not there anymore, remove him
                            {
                                //MessageBox.Show(ex.ToString());
                                continue;
                            }
                        }

                        IDataObject ido = new DataObject();
                        ido.SetData(text);
                        Clipboard.SetDataObject(ido, true);
                        Reason = "Share Clipboard";
                        mf.Invoke(new DisableClipboardCallback(mf.enableClipboard), new object[] { Reason });
                        SendAdminMessage(user_sharing + " just shared his clipboard containing text with us!");
                    }
                    else if (what.Substring(0, 4).Equals("Imag"))
                    {
                        string Reason = "Receving Clipboard...";
                        mf.Invoke(new DisableClipboardCallback(mf.disableClipboard), new object[] { Reason });

                        Stream stm = s.GetStream();
                        IFormatter formatter = new BinaryFormatter();
                        Bitmap bitm = (Bitmap)formatter.Deserialize(stm);

                        TcpClient[] tcpClients = new TcpClient[ChatServer.tcpClipboard.Count];
                        String[] users = new String[ChatServer.htUsers.Count];
                        ChatServer.tcpClipboard.Values.CopyTo(tcpClients, 0);
                        ChatServer.htUsers.Keys.CopyTo(users, 0);
                        for (int i = 0; i < tcpClients.Length; i++)
                        {
                            // Try sending a message to each
                            try
                            {
                                // If the message is blank or the connection is null, break out
                                if (tcpClients[i] == null || user_sharing == users[i])
                                {
                                    continue;
                                }
                                // Send the message to the current user in the loop
                                NetworkStream sendstr = tcpClients[i].GetStream();

                                StreamWriter sw = new StreamWriter(tcpClients[i].GetStream());
                                sw.WriteLine("Imag");
                                sw.Flush();

                                IFormatter myformat = new BinaryFormatter();
                                myformat.Serialize(sendstr, bitm);

                            }
                            catch (Exception ex)// If there was a problem, the user is not there anymore, remove him
                            {
                                //MessageBox.Show(ex.ToString());
                                continue;
                            }
                        }
                        Clipboard.SetImage(bitm);
                        Reason = "Share Clipboard";
                        mf.Invoke(new DisableClipboardCallback(mf.enableClipboard), new object[] { Reason });
                        SendAdminMessage(user_sharing + " just shared his clipboard containing an image with us!");
                    }
                }
                catch (Exception e)
                {
                    //MessageBox.Show(e.ToString());
                    break;
                }
                //string sss = "ciao";
                //Clipboard.SetDataObject(Encoding.ASCII.GetBytes(sss));
            }
        }
 public void ClearAllowedPatterns()
 {
     _allowedPatterns.Clear();
 }
Beispiel #16
0
        private void ReceiveClip()
        {
            String text;
            System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection();
            NetworkStream netstream = tcpClip.GetStream();
            int j;
            bool abort = false;

            while (Connected==true)
            {
                try
                {
                    string what = str.ReadLine();

                    if (MessageBox.Show("E' stata condivisa una clipboard.\n Accettarla, sovrascrivendo la clipboard attuale?", "Clipboard condivisa", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        if (what.Substring(0, 4).Equals("File"))
                        {
                            string Reason = "Ricevendo Clipboard...";
                            this.Invoke(new DisableClipboardCallback(this.DisableClipboard), new object[] { Reason });
                            paths.Clear();
                            string qta = what.Substring(4, 1);
                            for (j = 0; j < int.Parse(qta); j++)
                            {
                                string tmp = str.ReadLine();
                                if (tmp.Equals("Abort"))
                                {
                                    abort = true;
                                    break;
                                }
                                abort = false;
                                string fileName = tmp.Substring(6);
                                byte[] clientData = Convert.FromBase64String(str.ReadLine());
                                BinaryWriter bWrite = new BinaryWriter(File.Open(Path.GetFullPath(@".\File ricevuti\") + fileName, FileMode.Create));
                                bWrite.Write(clientData, 4 + fileName.Length, clientData.Length - 4 - fileName.Length);
                                bWrite.Close();
                                paths.Add(Path.GetFullPath(@".\File ricevuti\") + fileName);
                                //SetClipboard(fileName);
                            }
                            Reason = "Condividi Clipboard";
                            this.Invoke(new DisableClipboardCallback(this.EnableClipboard), new object[] { Reason });
                            if (abort == false)
                                this.Invoke(new UpdateClipboardCallback(UpdateClipboard), new object[] { paths });
                        }

                        else if (what.Substring(0, 4).Equals("Text")) // text
                        {
                            string Reason = "Ricevendo Clipboard...";
                            this.Invoke(new DisableClipboardCallback(this.DisableClipboard), new object[] { Reason });
                            byte[] bytes = new byte[tcpClip.ReceiveBufferSize];

                            // Read can return anything from 0 to numBytesToRead.
                            // This method blocks until at least one byte is read.
                            netstream.Read(bytes, 0, (int)tcpClip.ReceiveBufferSize);
                            string textcrc = Encoding.ASCII.GetString(bytes);
                            text = TrimFromZero(textcrc);
                            IDataObject ido = new DataObject();
                            ido.SetData(text);
                            Clipboard.SetDataObject(ido, true);
                            Reason = "Condividi Clipboard";
                            this.Invoke(new DisableClipboardCallback(this.EnableClipboard), new object[] { Reason });
                            //MessageBox.Show(text);
                        }

                        else if (what.Substring(0, 4).Equals("Imag")) // bitmap
                        {
                            string Reason = "Ricevendo Clipboard...";
                            this.Invoke(new DisableClipboardCallback(this.DisableClipboard), new object[] { Reason });
                            Stream stm = tcpClip.GetStream();
                            IFormatter formatter = new BinaryFormatter();
                            Bitmap bitm = (Bitmap)formatter.Deserialize(stm);
                            Clipboard.SetImage(bitm);
                            Reason = "Condividi Clipboard";
                            this.Invoke(new DisableClipboardCallback(this.EnableClipboard), new object[] { Reason });
                        }

                    }
                }

                catch (Exception e)
                {
                    //MessageBox.Show(e.ToString());
                    break;
                }
            }
        }
Beispiel #17
0
 /// <summary>
 /// Возвращает коллекцию строк
 /// с именами секций в ini файле
 /// </summary>
 /// <param name="filename"><c>Путь к ini файлу</c></param>
 /// <returns><c>Коллекция строк из класса System.Collections.Specialized.StringCollection</c></returns>
 public System.Collections.Specialized.StringCollection GetSections(string filename)
 {
     System.Collections.Specialized.StringCollection items = new System.Collections.Specialized.StringCollection();
       try
       {
     byte[] buffer = new byte[32768];
     int beg=0;
     string ss="";
     int bufLen = GetBytes(null,null,DefaultValue, buffer, buffer.GetUpperBound(0), filename);
     if (bufLen > 0)
     {
       for (int i=0; i < bufLen; i++)
       {
     if (buffer[i] != 0)
     {
       ss=System.Text.UnicodeEncoding.Default.GetString (buffer, beg, i-beg+1);
     }
     else
     {
       if (ss.Length > 0)
       {
         items.Add(ss);
         ss="";
         beg=i+1;
       }
     }
       }
     }
       }
       catch
       {
     //произошла какая-то ошибка:
     items.Clear();
       }
       return items;
 }
 /// <summary>
 /// очистить
 /// </summary>
 public void Clear()
 {
     BaseClear();
     keys.Clear();
 }
Beispiel #19
0
 public void Clear()
 {
     partial.Remove(0, partial.Length);
     strings.Clear();
 }